wkcn commented on a change in pull request #14409: [Numpy] Change semantics of
ndim for operators in `src/operator/contrib`
URL: https://github.com/apache/incubator-mxnet/pull/14409#discussion_r265526200
##########
File path: include/mxnet/tuple.h
##########
@@ -316,48 +335,75 @@ class Tuple {
protected:
// stack cache size
- static const uint32_t kStackCache = 4;
+ static const int kStackCache = 4;
/*! \brief number of dimension of the tuple */
- uint32_t ndim_{0};
+ int ndim_{0};
/*! \brief number of cells allocated in data_heap_ */
- uint32_t num_heap_allocated_{0};
+ int num_heap_allocated_{0};
/*! \brief in stack space used to store shape when it is small */
ValueType data_stack_[kStackCache];
/*! \brief space to store shape when dimension is big*/
ValueType* data_heap_{nullptr};
// internal function to change the dimension
- inline void SetDim(uint32_t ndim) {
+ inline void SetDim(int ndim) {
+ CHECK_GE(ndim, -1) << "ndim cannot be less than -1, received " << ndim;
if (ndim > kStackCache &&
ndim > num_heap_allocated_) {
delete [] data_heap_;
data_heap_ = new ValueType[ndim];
num_heap_allocated_ = ndim;
+ } else if (ndim == -1 && data_heap_ != nullptr) {
Review comment:
ndim <= 0 may be better.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services