From 0c6a300383928f76870f34730183900a23147170 Mon Sep 17 00:00:00 2001 From: samskalicky Date: Thu, 2 Jan 2020 21:53:18 +0000 Subject: [PATCH 01/11] initial commit --- include/mxnet/lib_api.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/mxnet/lib_api.h b/include/mxnet/lib_api.h index 290a63518373..9f50f80fa285 100644 --- a/include/mxnet/lib_api.h +++ b/include/mxnet/lib_api.h @@ -37,7 +37,7 @@ #include #include -#define MX_LIBRARY_VERSION 1 +#define MX_LIBRARY_VERSION 2 /* * Import from DLPack https://github.com/dmlc/dlpack/blob/master/include/dlpack/dlpack.h @@ -211,8 +211,10 @@ enum MXReturnValue { struct MXTensor { MXTensor() : data_ptr(NULL) {} - MXTensor(void *data_ptr, const std::vector &shape, MXDType dtype) - : data_ptr(data_ptr), shape(shape), dtype(dtype) {} + MXTensor(void *data_ptr, const std::vector &shape, MXDType dtype, + size_t ID, bool param) + : data_ptr(data_ptr), shape(shape), dtype(dtype), version(ID), + isParam(param) {} /*! \brief populate DLTensor fields */ void setDLTensor() { @@ -287,6 +289,13 @@ struct MXTensor { // type can only be MXDType enum types MXDType dtype; + // version number updated if the tensor has changed since the last use by custom op + size_t version; + + // true if this tensor is a fixed paramter of the model, false if it is an output + // of some other operator + bool isParam; + // corresponding DLTensor repr of MXTensor // easy way to reuse functions taking DLTensor DLTensor dltensor; From bfe1195dd40a683ddfe5774f5e7e717effc67025 Mon Sep 17 00:00:00 2001 From: samskalicky Date: Thu, 2 Jan 2020 22:49:50 +0000 Subject: [PATCH 02/11] added version initialization in c_api --- include/mxnet/lib_api.h | 54 +++++++++++++++++------------------------ src/c_api/c_api.cc | 21 ++++++++++------ 2 files changed, 36 insertions(+), 39 deletions(-) diff --git a/include/mxnet/lib_api.h b/include/mxnet/lib_api.h index 9f50f80fa285..6e0cea451fdb 100644 --- a/include/mxnet/lib_api.h +++ b/include/mxnet/lib_api.h @@ -198,6 +198,7 @@ enum MXDType { kInt32 = 4, kInt8 = 5, kInt64 = 6, + kUNSET = 100, }; enum MXReturnValue { @@ -209,13 +210,16 @@ enum MXReturnValue { * \brief Tensor data structure used by custom operator */ struct MXTensor { - MXTensor() : data_ptr(NULL) {} +MXTensor() : data_ptr(NULL), dtype(kUNSET), version(0) {} MXTensor(void *data_ptr, const std::vector &shape, MXDType dtype, - size_t ID, bool param) - : data_ptr(data_ptr), shape(shape), dtype(dtype), version(ID), - isParam(param) {} + size_t ID) + : data_ptr(data_ptr), shape(shape), dtype(dtype), version(ID) {} + void update(void *data_ptr, MXDType dtype, size_t ID) { + data_ptr = data_ptr; dtype = dtype; version = ID; + } + /*! \brief populate DLTensor fields */ void setDLTensor() { dltensor.data = data_ptr; @@ -292,10 +296,6 @@ struct MXTensor { // version number updated if the tensor has changed since the last use by custom op size_t version; - // true if this tensor is a fixed paramter of the model, false if it is an output - // of some other operator - bool isParam; - // corresponding DLTensor repr of MXTensor // easy way to reuse functions taking DLTensor DLTensor dltensor; @@ -687,15 +687,9 @@ typedef int (*opCallInferType_t)(inferType_t, const char* const*, const char* co #define MXLIB_OPCALLFCOMP_STR "_opCallFCompute" typedef int (*opCallFComp_t)(fcomp_t, const char* const*, const char* const*, int, - const int64_t**, int*, void**, int*, int, - const int64_t**, int*, void**, int*, int, - xpu_malloc_t, void*); - -#define MXLIB_OPCALLBKWD_STR "_opCallBackward" -typedef int (*opCallBkwd_t)(fcomp_t, const char* const*, const char* const*, int, - const int64_t**, int*, void**, int*, int, - const int64_t**, int*, void**, int*, int, - xpu_malloc_t, void*); + const int64_t**, int*, void**, int*, size_t*, int, + const int64_t**, int*, void**, int*, size_t*, int, + xpu_malloc_t, void*); #define MXLIB_OPCALLMUTATEINPUTS_STR "_opCallMutateInputs" typedef int (*opCallMutateInputs_t)(mutateInputs_t, const char* const*, const char* const*, int, @@ -706,9 +700,9 @@ typedef int (*opCallCreateOpState_t)(createOpState_t, const char* const*, const void**); #define MXLIB_OPCALLFSTATEFULCOMP_STR "_opCallFStatefulCompute" -typedef int (*opCallFStatefulComp_t)(bool, void*, const int64_t**, int*, void**, int*, int, - const int64_t**, int*, void**, int*, int, - xpu_malloc_t, void*); +typedef int (*opCallFStatefulComp_t)(bool, void*, const int64_t**, int*, void**, int*, size_t*, + int, const int64_t**, int*, void**, int*, size_t*, + int, xpu_malloc_t, void*); #define MXLIB_INITIALIZE_STR "initialize" typedef int (*initialize_t)(int); @@ -878,9 +872,9 @@ extern "C" { _opCallFCompute(fcomp_t fcomp, const char* const* keys, const char* const* vals, int num, const int64_t** inshapes, int* indims, - void** indata, int* intypes, int num_in, + void** indata, int* intypes, size_t* inIDs, int num_in, const int64_t** outshapes, int* outdims, - void** outdata, int* outtypes, int num_out, + void** outdata, int* outtypes, size_t* outIDs, int num_out, xpu_malloc_t cpu_malloc, void* cpu_alloc) { // create map of attributes from list std::map attrs; @@ -891,8 +885,7 @@ extern "C" { // create a vector of tensors for inputs std::vector inputs(num_in); for (int i = 0; i < num_in; i++) { - inputs[i].data_ptr = indata[i]; - inputs[i].dtype = (MXDType)intypes[i]; + inputs[i].update(indata[i], (MXDType)intypes[i], inIDs[i]); for (int j = 0; j < indims[i]; j++) { inputs[i].shape.push_back(inshapes[i][j]); } @@ -902,8 +895,7 @@ extern "C" { // create a vector of tensors for outputs std::vector outputs(num_out); for (int i = 0; i < num_out; i++) { - outputs[i].data_ptr = outdata[i]; - outputs[i].dtype = (MXDType) outtypes[i]; + outputs[i].update(outdata[i], (MXDType)outtypes[i], outIDs[i]); for (int j = 0; j < outdims[i]; j++) { outputs[i].shape.push_back(outshapes[i][j]); } @@ -975,15 +967,14 @@ extern "C" { #endif _opCallFStatefulCompute(bool is_forward, void* state_op, const int64_t** inshapes, int* indims, - void** indata, int* intypes, int num_in, + void** indata, int* intypes, size_t* inIDs, int num_in, const int64_t** outshapes, int* outdims, - void** outdata, int* outtypes, int num_out, + void** outdata, int* outtypes, size_t* outIDs, int num_out, xpu_malloc_t cpu_malloc, void* cpu_alloc) { // create a vector of tensors for inputs std::vector inputs(num_in); for (int i = 0; i < num_in; i++) { - inputs[i].data_ptr = indata[i]; - inputs[i].dtype = (MXDType)intypes[i]; + inputs[i].update(indata[i], (MXDType)intypes[i], inIDs[i]); for (int j = 0; j < indims[i]; j++) { inputs[i].shape.push_back(inshapes[i][j]); } @@ -993,8 +984,7 @@ extern "C" { // create a vector of tensors for outputs std::vector outputs(num_out); for (int i = 0; i < num_out; i++) { - outputs[i].data_ptr = outdata[i]; - outputs[i].dtype = (MXDType) outtypes[i]; + outputs[i].update(outdata[i], (MXDType)outtypes[i], outIDs[i]); for (int j = 0; j < outdims[i]; j++) { outputs[i].shape.push_back(outshapes[i][j]); } diff --git a/src/c_api/c_api.cc b/src/c_api/c_api.cc index f8db501d46f0..de956bd93ba5 100644 --- a/src/c_api/c_api.cc +++ b/src/c_api/c_api.cc @@ -387,13 +387,15 @@ int MXLoadLib(const char *path) { std::vector in_shapes, out_shapes; std::vector in_dims, out_dims; std::vector in_types, out_types; - + std::vector in_versions, out_versions; + // convert input tensors to constituent parts for (size_t i = 0; i < inputs.size(); i++) { in_data.push_back(inputs[i].data().dptr_); in_shapes.push_back(inputs[i].shape().data()); in_dims.push_back(inputs[i].shape().ndim()); in_types.push_back(inputs[i].dtype()); + in_versions.push_back(inputs[i].version()); } // convert output tensors to constituent parts @@ -402,6 +404,7 @@ int MXLoadLib(const char *path) { out_shapes.push_back(outputs[i].shape().data()); out_dims.push_back(outputs[i].shape().ndim()); out_types.push_back(outputs[i].dtype()); + out_versions.push_back(outputs[i].version()); } // get memory resource @@ -430,9 +433,10 @@ int MXLoadLib(const char *path) { // call fcompute function CHECK(callFComp(fcomp_fp, attr_keys.data(), attr_vals.data(), attr_keys.size(), in_shapes.data(), in_dims.data(), in_data.data(), - in_types.data(), in_data.size(), + in_types.data(), in_versions.data(), in_data.size(), out_shapes.data(), out_dims.data(), out_data.data(), - out_types.data(), out_data.size(), cpu_malloc, &cpu_alloc)) + out_types.data(), out_versions.data(), out_data.size(), + cpu_malloc, &cpu_alloc)) << "Error calling FCompute for custom operator '" << name_str << "'"; // return type void @@ -562,13 +566,15 @@ int MXLoadLib(const char *path) { std::vector in_shapes, out_shapes; std::vector in_dims, out_dims; std::vector in_types, out_types; - + std::vector in_versions, out_versions; + // convert input tensors to constituent parts for (size_t i = 0; i < inputs.size(); i++) { in_data.push_back(inputs[i].data().dptr_); in_shapes.push_back(inputs[i].shape().data()); in_dims.push_back(inputs[i].shape().ndim()); in_types.push_back(inputs[i].dtype()); + in_versions.push_back(inputs[i].version()); } // convert output tensors to constituent parts @@ -577,6 +583,7 @@ int MXLoadLib(const char *path) { out_shapes.push_back(outputs[i].shape().data()); out_dims.push_back(outputs[i].shape().ndim()); out_types.push_back(outputs[i].dtype()); + out_versions.push_back(outputs[i].version()); } // get memory resource @@ -610,9 +617,9 @@ int MXLoadLib(const char *path) { // call fcompute function CHECK(callFStatefulComp(is_forward, state_op_inst, in_shapes.data(), in_dims.data(), - in_data.data(), in_types.data(), in_data.size(), - out_shapes.data(), out_dims.data(), out_data.data(), - out_types.data(), out_data.size(), cpu_malloc, &cpu_alloc)) + in_data.data(), in_types.data(), in_versions.data(), in_data.size(), + out_shapes.data(), out_dims.data(), out_data.data(), out_types.data(), + out_versions.data(), out_data.size(), cpu_malloc, &cpu_alloc)) << "Error calling FStatefulCompute for custom operator '" << name_str << "'"; }; From fa8037280a24a6126020c68847ab11e70f63ff73 Mon Sep 17 00:00:00 2001 From: samskalicky Date: Thu, 2 Jan 2020 23:05:46 +0000 Subject: [PATCH 03/11] added isSame helper function --- include/mxnet/lib_api.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/mxnet/lib_api.h b/include/mxnet/lib_api.h index 6e0cea451fdb..026ea837448e 100644 --- a/include/mxnet/lib_api.h +++ b/include/mxnet/lib_api.h @@ -283,6 +283,14 @@ MXTensor() : data_ptr(NULL), dtype(kUNSET), version(0) {} return size; } + /*! \brief helper function to compare two MXTensors */ + inline bool isSame(MXTensor &oth) { + return data_ptr == oth.data_ptr && + dtype == oth.dtype && + version == oth.version && + shape == oth.shape; + } + // data is flatten 1D repr of tensor, elements are in continuous memory // user can access each element using the shape of tensor void *data_ptr; From f8b30353d76227c7167ea9aabbcffdad65bea091 Mon Sep 17 00:00:00 2001 From: samskalicky Date: Fri, 3 Jan 2020 05:53:13 +0000 Subject: [PATCH 04/11] fixed whitespace and isSame function --- include/mxnet/lib_api.h | 10 +++++----- src/c_api/c_api.cc | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/mxnet/lib_api.h b/include/mxnet/lib_api.h index 506b8b17e595..f7714bcec5bb 100644 --- a/include/mxnet/lib_api.h +++ b/include/mxnet/lib_api.h @@ -216,10 +216,10 @@ MXTensor() : data_ptr(NULL), dtype(kUNSET), version(0) {} size_t ID) : data_ptr(data_ptr), shape(shape), dtype(dtype), version(ID) {} - void update(void *data_ptr, MXDType dtype, size_t ID) { - data_ptr = data_ptr; dtype = dtype; version = ID; + void update(void *dptr, MXDType type, size_t ver) { + data_ptr = dptr; dtype = type; version = ver; } - + /*! \brief populate DLTensor fields */ void setDLTensor() { dltensor.data = data_ptr; @@ -284,13 +284,13 @@ MXTensor() : data_ptr(NULL), dtype(kUNSET), version(0) {} } /*! \brief helper function to compare two MXTensors */ - inline bool isSame(MXTensor &oth) { + inline bool isSame(const MXTensor &oth) { return data_ptr == oth.data_ptr && dtype == oth.dtype && version == oth.version && shape == oth.shape; } - + // data is flatten 1D repr of tensor, elements are in continuous memory // user can access each element using the shape of tensor void *data_ptr; diff --git a/src/c_api/c_api.cc b/src/c_api/c_api.cc index acbd6661b85e..c3e91611bde7 100644 --- a/src/c_api/c_api.cc +++ b/src/c_api/c_api.cc @@ -396,7 +396,7 @@ int MXLoadLib(const char *path) { std::vector in_dims, out_dims; std::vector in_types, out_types; std::vector in_versions, out_versions; - + // convert input tensors to constituent parts for (size_t i = 0; i < inputs.size(); i++) { in_data.push_back(inputs[i].data().dptr_); @@ -575,7 +575,7 @@ int MXLoadLib(const char *path) { std::vector in_dims, out_dims; std::vector in_types, out_types; std::vector in_versions, out_versions; - + // convert input tensors to constituent parts for (size_t i = 0; i < inputs.size(); i++) { in_data.push_back(inputs[i].data().dptr_); From 15679f6abae579ba7af77cf499546b88c1523a83 Mon Sep 17 00:00:00 2001 From: samskalicky Date: Fri, 3 Jan 2020 20:31:19 +0000 Subject: [PATCH 05/11] changed version to verID --- include/mxnet/lib_api.h | 12 ++++++------ src/c_api/c_api.cc | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/mxnet/lib_api.h b/include/mxnet/lib_api.h index f7714bcec5bb..d5f35a30e8b2 100644 --- a/include/mxnet/lib_api.h +++ b/include/mxnet/lib_api.h @@ -210,14 +210,14 @@ enum MXReturnValue { * \brief Tensor data structure used by custom operator */ struct MXTensor { -MXTensor() : data_ptr(NULL), dtype(kUNSET), version(0) {} +MXTensor() : data_ptr(NULL), dtype(kUNSET), verID(0) {} MXTensor(void *data_ptr, const std::vector &shape, MXDType dtype, size_t ID) - : data_ptr(data_ptr), shape(shape), dtype(dtype), version(ID) {} + : data_ptr(data_ptr), shape(shape), dtype(dtype), verID(vID) {} - void update(void *dptr, MXDType type, size_t ver) { - data_ptr = dptr; dtype = type; version = ver; + void setTensor(void *dptr, MXDType type, size_t vID) { + data_ptr = dptr; dtype = type; verID = vID; } /*! \brief populate DLTensor fields */ @@ -287,7 +287,7 @@ MXTensor() : data_ptr(NULL), dtype(kUNSET), version(0) {} inline bool isSame(const MXTensor &oth) { return data_ptr == oth.data_ptr && dtype == oth.dtype && - version == oth.version && + verID == oth.verID && shape == oth.shape; } @@ -302,7 +302,7 @@ MXTensor() : data_ptr(NULL), dtype(kUNSET), version(0) {} MXDType dtype; // version number updated if the tensor has changed since the last use by custom op - size_t version; + size_t verID; // corresponding DLTensor repr of MXTensor // easy way to reuse functions taking DLTensor diff --git a/src/c_api/c_api.cc b/src/c_api/c_api.cc index c3e91611bde7..bb98d96f733a 100644 --- a/src/c_api/c_api.cc +++ b/src/c_api/c_api.cc @@ -395,7 +395,7 @@ int MXLoadLib(const char *path) { std::vector in_shapes, out_shapes; std::vector in_dims, out_dims; std::vector in_types, out_types; - std::vector in_versions, out_versions; + std::vector in_verIDs, out_verIDs; // convert input tensors to constituent parts for (size_t i = 0; i < inputs.size(); i++) { @@ -403,7 +403,7 @@ int MXLoadLib(const char *path) { in_shapes.push_back(inputs[i].shape().data()); in_dims.push_back(inputs[i].shape().ndim()); in_types.push_back(inputs[i].dtype()); - in_versions.push_back(inputs[i].version()); + in_verIDs.push_back(inputs[i].version()); } // convert output tensors to constituent parts @@ -412,7 +412,7 @@ int MXLoadLib(const char *path) { out_shapes.push_back(outputs[i].shape().data()); out_dims.push_back(outputs[i].shape().ndim()); out_types.push_back(outputs[i].dtype()); - out_versions.push_back(outputs[i].version()); + out_verIDs.push_back(outputs[i].version()); } // get memory resource @@ -441,9 +441,9 @@ int MXLoadLib(const char *path) { // call fcompute function CHECK(callFComp(fcomp_fp, attr_keys.data(), attr_vals.data(), attr_keys.size(), in_shapes.data(), in_dims.data(), in_data.data(), - in_types.data(), in_versions.data(), in_data.size(), + in_types.data(), in_verIDs.data(), in_data.size(), out_shapes.data(), out_dims.data(), out_data.data(), - out_types.data(), out_versions.data(), out_data.size(), + out_types.data(), out_verIDs.data(), out_data.size(), cpu_malloc, &cpu_alloc)) << "Error calling FCompute for custom operator '" << name_str << "'"; @@ -574,7 +574,7 @@ int MXLoadLib(const char *path) { std::vector in_shapes, out_shapes; std::vector in_dims, out_dims; std::vector in_types, out_types; - std::vector in_versions, out_versions; + std::vector in_verIDs, out_verIDs; // convert input tensors to constituent parts for (size_t i = 0; i < inputs.size(); i++) { @@ -582,7 +582,7 @@ int MXLoadLib(const char *path) { in_shapes.push_back(inputs[i].shape().data()); in_dims.push_back(inputs[i].shape().ndim()); in_types.push_back(inputs[i].dtype()); - in_versions.push_back(inputs[i].version()); + in_verIDs.push_back(inputs[i].version()); } // convert output tensors to constituent parts @@ -591,7 +591,7 @@ int MXLoadLib(const char *path) { out_shapes.push_back(outputs[i].shape().data()); out_dims.push_back(outputs[i].shape().ndim()); out_types.push_back(outputs[i].dtype()); - out_versions.push_back(outputs[i].version()); + out_verIDs.push_back(outputs[i].version()); } // get memory resource @@ -625,9 +625,9 @@ int MXLoadLib(const char *path) { // call fcompute function CHECK(callFStatefulComp(is_forward, state_op_inst, in_shapes.data(), in_dims.data(), - in_data.data(), in_types.data(), in_versions.data(), in_data.size(), + in_data.data(), in_types.data(), in_verIDs.data(), in_data.size(), out_shapes.data(), out_dims.data(), out_data.data(), out_types.data(), - out_versions.data(), out_data.size(), cpu_malloc, &cpu_alloc)) + out_verIDs.data(), out_data.size(), cpu_malloc, &cpu_alloc)) << "Error calling FStatefulCompute for custom operator '" << name_str << "'"; }; From bbf8e63a3c5a081e0a0e3f4974bc97a47ae11de3 Mon Sep 17 00:00:00 2001 From: samskalicky Date: Fri, 3 Jan 2020 20:39:13 +0000 Subject: [PATCH 06/11] changed update to setTensor --- include/mxnet/lib_api.h | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/include/mxnet/lib_api.h b/include/mxnet/lib_api.h index d5f35a30e8b2..56fe9eb8602f 100644 --- a/include/mxnet/lib_api.h +++ b/include/mxnet/lib_api.h @@ -216,8 +216,14 @@ MXTensor() : data_ptr(NULL), dtype(kUNSET), verID(0) {} size_t ID) : data_ptr(data_ptr), shape(shape), dtype(dtype), verID(vID) {} - void setTensor(void *dptr, MXDType type, size_t vID) { + void setTensor(void *dptr, MXDType type, const int64_t* dims, + int ndims, size_t vID) { data_ptr = dptr; dtype = type; verID = vID; + shape.clear(); + for (int j = 0; j < ndims; j++) { + shape.push_back(dims[j]); + } + setDLTensor(); } /*! \brief populate DLTensor fields */ @@ -900,21 +906,14 @@ extern "C" { // create a vector of tensors for inputs std::vector inputs(num_in); for (int i = 0; i < num_in; i++) { - inputs[i].update(indata[i], (MXDType)intypes[i], inIDs[i]); - for (int j = 0; j < indims[i]; j++) { - inputs[i].shape.push_back(inshapes[i][j]); - } - inputs[i].setDLTensor(); + inputs[i].setTensor(indata[i], (MXDType)intypes[i], inshapes[i], indims[i], inIDs[i]); } // create a vector of tensors for outputs std::vector outputs(num_out); for (int i = 0; i < num_out; i++) { - outputs[i].update(outdata[i], (MXDType)outtypes[i], outIDs[i]); - for (int j = 0; j < outdims[i]; j++) { - outputs[i].shape.push_back(outshapes[i][j]); - } - outputs[i].setDLTensor(); + outputs[i].setTensor(outdata[i], (MXDType)outtypes[i], outshapes[i], outdims[i], + outIDs[i]); } OpResource res(cpu_malloc, cpu_alloc); @@ -989,21 +988,14 @@ extern "C" { // create a vector of tensors for inputs std::vector inputs(num_in); for (int i = 0; i < num_in; i++) { - inputs[i].update(indata[i], (MXDType)intypes[i], inIDs[i]); - for (int j = 0; j < indims[i]; j++) { - inputs[i].shape.push_back(inshapes[i][j]); - } - inputs[i].setDLTensor(); + inputs[i].setTensor(indata[i], (MXDType)intypes[i], inshapes[i], indims[i], inIDs[i]); } // create a vector of tensors for outputs std::vector outputs(num_out); for (int i = 0; i < num_out; i++) { - outputs[i].update(outdata[i], (MXDType)outtypes[i], outIDs[i]); - for (int j = 0; j < outdims[i]; j++) { - outputs[i].shape.push_back(outshapes[i][j]); - } - outputs[i].setDLTensor(); + outputs[i].setTensor(outdata[i], (MXDType)outtypes[i], outshapes[i], outdims[i], + outIDs[i]); } OpResource res(cpu_malloc, cpu_alloc); CustomStatefulOp* op_ptr = reinterpret_cast(state_op); From 989b3948aeb25065ddf199c811e270e921fd154b Mon Sep 17 00:00:00 2001 From: samskalicky Date: Fri, 3 Jan 2020 20:42:05 +0000 Subject: [PATCH 07/11] changed isSame to operator== --- include/mxnet/lib_api.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mxnet/lib_api.h b/include/mxnet/lib_api.h index 56fe9eb8602f..f903674d9695 100644 --- a/include/mxnet/lib_api.h +++ b/include/mxnet/lib_api.h @@ -213,7 +213,7 @@ struct MXTensor { MXTensor() : data_ptr(NULL), dtype(kUNSET), verID(0) {} MXTensor(void *data_ptr, const std::vector &shape, MXDType dtype, - size_t ID) + size_t vID) : data_ptr(data_ptr), shape(shape), dtype(dtype), verID(vID) {} void setTensor(void *dptr, MXDType type, const int64_t* dims, @@ -290,7 +290,7 @@ MXTensor() : data_ptr(NULL), dtype(kUNSET), verID(0) {} } /*! \brief helper function to compare two MXTensors */ - inline bool isSame(const MXTensor &oth) { + inline bool operator==(const MXTensor &oth) { return data_ptr == oth.data_ptr && dtype == oth.dtype && verID == oth.verID && From 789302a94a063a03806b71f95b0efd3fe5bee29c Mon Sep 17 00:00:00 2001 From: samskalicky Date: Mon, 6 Jan 2020 21:14:18 +0000 Subject: [PATCH 08/11] changed operator== back to isSame --- include/mxnet/lib_api.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/mxnet/lib_api.h b/include/mxnet/lib_api.h index f903674d9695..c7887aad378f 100644 --- a/include/mxnet/lib_api.h +++ b/include/mxnet/lib_api.h @@ -210,12 +210,13 @@ enum MXReturnValue { * \brief Tensor data structure used by custom operator */ struct MXTensor { -MXTensor() : data_ptr(NULL), dtype(kUNSET), verID(0) {} + MXTensor() : data_ptr(NULL), dtype(kUNSET), verID(0) {} MXTensor(void *data_ptr, const std::vector &shape, MXDType dtype, size_t vID) : data_ptr(data_ptr), shape(shape), dtype(dtype), verID(vID) {} + /*! \brief populate internal tensor fields */ void setTensor(void *dptr, MXDType type, const int64_t* dims, int ndims, size_t vID) { data_ptr = dptr; dtype = type; verID = vID; @@ -290,7 +291,7 @@ MXTensor() : data_ptr(NULL), dtype(kUNSET), verID(0) {} } /*! \brief helper function to compare two MXTensors */ - inline bool operator==(const MXTensor &oth) { + inline bool isSame(const MXTensor &oth) const { return data_ptr == oth.data_ptr && dtype == oth.dtype && verID == oth.verID && From e6cd9ac3a9c3980b6e5e770b6b489683a3d21a62 Mon Sep 17 00:00:00 2001 From: samskalicky Date: Tue, 7 Jan 2020 01:27:04 +0000 Subject: [PATCH 09/11] retrigger CI From c310281bc47c275709945e39785171f7a98a0b7b Mon Sep 17 00:00:00 2001 From: samskalicky Date: Tue, 7 Jan 2020 04:42:50 +0000 Subject: [PATCH 10/11] retrigger CI From d1396866ed4f738a4cf7603f8f3e09acf9a8fc45 Mon Sep 17 00:00:00 2001 From: samskalicky Date: Tue, 7 Jan 2020 05:29:53 +0000 Subject: [PATCH 11/11] retrigger ci