Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Typedef cleanup in C API #15899

Merged
merged 5 commits into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
427 changes: 213 additions & 214 deletions include/mxnet/c_api.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions include/mxnet/c_api_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extern "C" {
*/
MXNET_DLL int MXBuildSubgraphByOpNames(SymbolHandle sym_handle,
const char* prop_name,
const mx_uint num_ops,
const uint32_t num_ops,
const char** op_names,
SymbolHandle* ret_sym_handle);

Expand All @@ -50,7 +50,7 @@ MXNET_DLL int MXBuildSubgraphByOpNames(SymbolHandle sym_handle,
* the predefined one. This is only for the purpose of testing.
*/
MXNET_DLL int MXSetSubgraphPropertyOpNames(const char* prop_name,
const mx_uint num_ops,
const uint32_t num_ops,
const char** op_names);

/*!
Expand Down
64 changes: 31 additions & 33 deletions include/mxnet/c_predict_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ extern "C" {

/*! \brief manually define unsigned int */
typedef uint32_t mx_uint;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we still need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we do other language bindings use this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which language bindings use this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

java, C++, R, Scala

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you point me to the line in this bindings? It looks weird if this typedef is not used in this file while still keeping it.

Copy link
Contributor Author

@access2rohit access2rohit Aug 31, 2019

/*! \brief manually define 64-bit int */
typedef int64_t mx_int64;
/*! \brief manually define float */
typedef float mx_float;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we still need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we do other language bindings use this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which language bindings use this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

java, C++, R, Scala

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a search in MXNet codebase and could not find any. Could you point me to the line?

/*! \brief handle to Predictor */
Expand Down Expand Up @@ -87,10 +85,10 @@ MXNET_DLL int MXPredCreate(const char* symbol_json_str,
const void* param_bytes,
int param_size,
int dev_type, int dev_id,
mx_uint num_input_nodes,
uint32_t num_input_nodes,
const char** input_keys,
const mx_uint* input_shape_indptr,
const mx_uint* input_shape_data,
const uint32_t* input_shape_indptr,
const uint32_t* input_shape_data,
PredictorHandle* out);

/*!
Expand Down Expand Up @@ -122,11 +120,11 @@ MXNET_DLL int MXPredCreateEx(const char* symbol_json_str,
const void* param_bytes,
int param_size,
int dev_type, int dev_id,
const mx_uint num_input_nodes,
const uint32_t num_input_nodes,
const char** input_keys,
const mx_uint* input_shape_indptr,
const mx_uint* input_shape_data,
const mx_uint num_provided_arg_dtypes,
const uint32_t* input_shape_indptr,
const uint32_t* input_shape_data,
const uint32_t num_provided_arg_dtypes,
const char** provided_arg_dtype_names,
const int* provided_arg_dtypes,
PredictorHandle* out);
Expand Down Expand Up @@ -158,11 +156,11 @@ MXNET_DLL int MXPredCreatePartialOut(const char* symbol_json_str,
const void* param_bytes,
int param_size,
int dev_type, int dev_id,
mx_uint num_input_nodes,
uint32_t num_input_nodes,
const char** input_keys,
const mx_uint* input_shape_indptr,
const mx_uint* input_shape_data,
mx_uint num_output_nodes,
const uint32_t* input_shape_indptr,
const uint32_t* input_shape_data,
uint32_t num_output_nodes,
const char** output_keys,
PredictorHandle* out);

Expand Down Expand Up @@ -191,10 +189,10 @@ MXNET_DLL int MXPredCreateMultiThread(const char* symbol_json_str,
const void* param_bytes,
int param_size,
int dev_type, int dev_id,
mx_uint num_input_nodes,
uint32_t num_input_nodes,
const char** input_keys,
const mx_uint* input_shape_indptr,
const mx_uint* input_shape_data,
const uint32_t* input_shape_indptr,
const uint32_t* input_shape_data,
int num_threads,
PredictorHandle* out);

Expand All @@ -213,10 +211,10 @@ MXNET_DLL int MXPredCreateMultiThread(const char* symbol_json_str,
* \param out The reshaped predictor handle.
* \return 0 when success, -1 when failure.
*/
MXNET_DLL int MXPredReshape(mx_uint num_input_nodes,
MXNET_DLL int MXPredReshape(uint32_t num_input_nodes,
const char** input_keys,
const mx_uint* input_shape_indptr,
const mx_uint* input_shape_data,
const uint32_t* input_shape_indptr,
const uint32_t* input_shape_data,
PredictorHandle handle,
PredictorHandle* out);
/*!
Expand All @@ -229,9 +227,9 @@ MXNET_DLL int MXPredReshape(mx_uint num_input_nodes,
* \return 0 when success, -1 when failure.
*/
MXNET_DLL int MXPredGetOutputShape(PredictorHandle handle,
mx_uint index,
mx_uint** shape_data,
mx_uint* shape_ndim);
uint32_t index,
uint32_t** shape_data,
uint32_t* shape_ndim);

/*!
* \brief Get the dtype of output node.
Expand All @@ -241,7 +239,7 @@ MXNET_DLL int MXPredGetOutputShape(PredictorHandle handle,
* \param out_dtype The dtype of the output node
*/
MXNET_DLL int MXPredGetOutputType(PredictorHandle handle,
mx_uint out_index,
uint32_t out_index,
int* out_dtype);

/*!
Expand All @@ -255,8 +253,8 @@ MXNET_DLL int MXPredGetOutputType(PredictorHandle handle,
*/
MXNET_DLL int MXPredSetInput(PredictorHandle handle,
const char* key,
const mx_float* data,
mx_uint size);
const float* data,
uint32_t size);
/*!
* \brief Run a forward pass to get the output.
* \param handle The handle of the predictor.
Expand Down Expand Up @@ -289,9 +287,9 @@ MXNET_DLL int MXPredPartialForward(PredictorHandle handle, int step, int* step_l
* \return 0 when success, -1 when failure.
*/
MXNET_DLL int MXPredGetOutput(PredictorHandle handle,
mx_uint index,
mx_float* data,
mx_uint size);
uint32_t index,
float* data,
uint32_t size);
/*!
* \brief Free a predictor handle.
* \param handle The handle of the predictor.
Expand All @@ -310,7 +308,7 @@ MXNET_DLL int MXPredFree(PredictorHandle handle);
MXNET_DLL int MXNDListCreate(const char* nd_file_bytes,
int nd_file_size,
NDListHandle *out,
mx_uint* out_length);
uint32_t* out_length);
/*!
* \brief Get an element from list
* \param handle The handle to the NDArray
Expand All @@ -322,11 +320,11 @@ MXNET_DLL int MXNDListCreate(const char* nd_file_bytes,
* \return 0 when success, -1 when failure.
*/
MXNET_DLL int MXNDListGet(NDListHandle handle,
mx_uint index,
uint32_t index,
const char** out_key,
const mx_float** out_data,
const mx_uint** out_shape,
mx_uint* out_ndim);
const float** out_data,
const uint32_t** out_shape,
uint32_t* out_ndim);

/*!
* \brief set a call back to notify the completion of operation and allow for
Expand Down
2 changes: 1 addition & 1 deletion include/mxnet/imperative.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Imperative {
OpStatePtr state = OpStatePtr());
/*! \brief mark variables for computing gradients. */
void MarkVariables(const std::vector<NDArray*>& variables,
const std::vector<mx_uint>& grad_reqs,
const std::vector<uint32_t>& grad_reqs,
const std::vector<NDArray*>& gradients);
/*! \brief compute the gradient of outputs w.r.t variables. */
std::vector<NDArray*> Backward(const std::vector<NDArray*>& outputs,
Expand Down
Loading