apeforest commented on a change in pull request #15170: [MXNET-1413] Adding
Large Tensor support for sort operators
URL: https://github.com/apache/incubator-mxnet/pull/15170#discussion_r295975014
##########
File path: src/operator/tensor/ordering_op-inl.h
##########
@@ -605,30 +633,32 @@ void TopKBackwardImpl(const OpContext &ctx,
using namespace mshadow::expr;
Stream<xpu> *s = ctx.run_ctx.get_stream<xpu>();
CHECK(param.ret_typ == topk_enum::kReturnValue || param.ret_typ ==
topk_enum::kReturnBoth);
- int batch_size, element_num; // number of batches + the size of each batch
+ size_t batch_size;
+ index_t element_num; // number of batches + the size of each batch
int axis = 0;
bool do_transpose = false;
bool is_ascend = false;
- int k = 0;
+ index_t k = 0;
mxnet::TShape target_shape;
ParseTopKParam(outputs[0].shape_, param,
&target_shape, &batch_size, &element_num, &axis, &k,
&do_transpose, &is_ascend);
CHECK_LE(element_num, mxnet::common::MaxIntegerValue<IDType>())
- << "'IDType' does not have a sufficient precision to represent the indices
of the input array. "
- << "The total element_num is " << element_num << ", but the selected
IDType can only represent "
+ << "'IDType' does not have a sufficient precision to represent "
+ << "the indices of the input array. The total element_num is " <<
element_num
+ << ", but the selected index_t can only represent "
<< mxnet::common::MaxIntegerValue<IDType>() << " elements";
- Tensor<xpu, 1, int> workspace =
- ctx.requested[0].get_space_typed<xpu, 1, int>(Shape1(batch_size * k +
batch_size), s);
- Tensor<xpu, 1, int> sel_indices =
- Tensor<xpu, 1, int>(workspace.dptr_, Shape1(batch_size * k), s);
- Tensor<xpu, 1, int> batch_shift =
- Tensor<xpu, 1, int>(workspace.dptr_ + batch_size * k, Shape1(batch_size),
s);
+ Tensor<xpu, 1, index_t> workspace =
+ ctx.requested[0].get_space_typed<xpu, 1, index_t>(Shape1(batch_size * k +
batch_size), s);
+ Tensor<xpu, 1, index_t> sel_indices =
+ Tensor<xpu, 1, index_t>((workspace.dptr_), Shape1(batch_size * k), s);
Review comment:
nit: parenthesis around workspace.dptr_ seems redundant
----------------------------------------------------------------
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