access2rohit commented on a change in pull request #19015:
URL: https://github.com/apache/incubator-mxnet/pull/19015#discussion_r478477723
##########
File path: src/operator/numpy/np_nonzero_op.cc
##########
@@ -88,17 +88,16 @@ void NonzeroForwardCPU(const nnvm::NodeAttrs& attrs,
const_cast<NDArray &>(out).Init(s);
return;
}
- std::vector<int32_t> prefix_sum(in_size, 0);
+ std::vector<index_t> prefix_sum(in_size, 0);
size_t valid_num = 0;
// Calculate prefix sum
MSHADOW_TYPE_SWITCH_WITH_BOOL(in.dtype(), DType, {
DType* in_dptr = in.data().dptr<DType>();
for (size_t i = 0; i < in_size; i++) {
- prefix_sum[i] = (i == 0) ? 0 : prefix_sum[i - 1];
- prefix_sum[i] += (in_dptr[i]) ? 1 : 0;
+ valid_num += (in_dptr[i] != 0);
Review comment:
Nice work ! its actually correct :
https://stackoverflow.com/questions/2725044/can-i-assume-booltrue-int1-for-any-c-compiler
But for the sake of readability can you still keep it
```
(in_dptr[i]) ? 1 : 0;
```
----------------------------------------------------------------
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]