yongwww commented on a change in pull request #6316:
URL: https://github.com/apache/incubator-tvm/pull/6316#discussion_r475359181
##########
File path: python/tvm/relay/op/transform.py
##########
@@ -827,13 +828,17 @@ def strided_slice(data, begin, end, strides=None,
slice_mode="end"):
ret : relay.Expr
The computed result.
"""
- strides = strides or const([1], dtype="int32")
- if isinstance(begin, (tuple, list)):
- begin = const(list(begin))
- if isinstance(end, (tuple, list)):
- end = const(list(end))
- if isinstance(strides, (tuple, list)):
- strides = const(list(strides))
+ strides = strides or [1]
+ if (isinstance(begin, Expr) or isinstance(end, Expr) or
isinstance(strides, Expr)):
+ if isinstance(begin, (tuple, list)):
+ begin = const(list(begin))
+ if isinstance(end, (tuple, list)):
+ end = const(list(end))
+ if isinstance(strides, (tuple, list)):
+ strides = const(list(strides))
+ normalized_begin = _make.where(begin < cast_like(const(0), begin),
Review comment:
we could consider moving the normalization step into strided_slice
##########
File path: python/tvm/relay/op/_transform.py
##########
@@ -165,6 +138,8 @@ def _strided_slice_shape_func_input_shape(data_shape,
begin, end, strides, slice
cstride = int64(strides[i])
if len(begin) > i:
cbegin = int64(begin[i])
+ if cbegin < 0:
+ cbegin += int64(data_shape[i])
Review comment:
how about cbegin is still less than 0 after adding data_shape[i]?
probably raise error for invalid data input.
##########
File path: src/relay/op/tensor/transform.cc
##########
@@ -2069,12 +2070,11 @@ bool StridedSliceRel(const Array<Type>& types, int
num_inputs, const Attrs& attr
oshape[i] = tir::make_const(dshape[i].dtype(), (slice_range + step - 1)
/ step);
}
} else {
- for (int64_t i = 0; i < num_axis; ++i) {
- oshape[i] = Any();
- }
+ CHECK(param->begin) << "strided_slice recieved invalid begin";
Review comment:
print the received begin value in the message?
----------------------------------------------------------------
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]