reminisce commented on a change in pull request #11406: [MXNET-599] Partial
shape infer for Slice
URL: https://github.com/apache/incubator-mxnet/pull/11406#discussion_r198698555
##########
File path: src/operator/tensor/matrix_op-inl.h
##########
@@ -674,13 +675,23 @@ inline void SetSliceOpOutputDimSize(const index_t i,
const int b,
const int e, const int s,
TShape* oshape) {
if (s > 0) {
- CHECK_LT(b, e) << "slicing with begin=[" << i << "]=" << b << ", end[" <<
i << "]="
+ CHECK_LE(b, e) << "slicing with begin=[" << i << "]=" << b << ", end[" <<
i << "]="
<< e << ", and step[" << i << "]=" << s << " is invalid";
- (*oshape)[i] = (e - b - 1) / s + 1;
+ if (e == b) {
+ // for partial shape infer
+ (*oshape)[i] = 0;
+ } else {
+ (*oshape)[i] = (e - b - 1) / s + 1;
Review comment:
I think we should only fill in output shape dim size when the corresponding
input shape dim size is non-zero.
That is if input shape is (0, 20), begin=(0, 0), end=(5, 10), it should
return (0, 10), instead of (5, 10) as inferred output shape.
@sandeep-krishnamurthy Could you confirm?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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