kevinthesun commented on a change in pull request #6449:
URL: https://github.com/apache/incubator-tvm/pull/6449#discussion_r487322957
##########
File path: python/tvm/relay/frontend/pytorch.py
##########
@@ -274,38 +295,91 @@ def _impl(inputs, input_types):
def _slice():
def _impl(inputs, input_types):
+ index_size_limit = 2**63 - 1
data = inputs[0]
- strides = []
+ dshape = _infer_shape(data)
+ ndim = len(dshape)
+ end = []
+ for dim in dshape:
+ if isinstance(dim, tvm.tir.Any):
+ end = _op.shape_of(data)
+ break
+ end.append(int(dim))
- if isinstance(data, _expr.Expr):
- inferred_shape = _infer_shape(data)
- end = []
- for infer in inferred_shape:
- end.append(int(infer))
- if isinstance(data, _expr.Var):
- end = inferred_shape
- end = list(end)
- else:
- end = data.shape
-
- begin = [0] * len(end)
+ begin = [0] * ndim
dim = int(inputs[1])
+ stride = int(inputs[4])
if isinstance(inputs[2], _expr.Call):
- begin[dim] = np.asscalar(_infer_value(inputs[2],
{}).asnumpy().astype(np.int))
+ try:
+ begin[dim] = np.asscalar(_infer_value(inputs[2],
{}).asnumpy().astype(np.int))
+ except Exception:
+ begin[dim] = inputs[2]
else:
begin[dim] = int(inputs[2])
+ # Process begin
+ if not isinstance(begin[dim], int):
+ tmp = []
+ for b in begin:
+ if isinstance(b, int):
+ tmp.append(_op.expand_dims(_expr.const(b, "int64"),
axis=0))
+ else:
+ tmp.append(_op.cast(_op.expand_dims(b, axis=0), "int64"))
+ begin = _op.concatenate(tmp, axis=0)
+ btype = _infer_type(begin).checked_type.dtype
+ if str(btype) != "int32":
+ begin = _op.cast(begin, "int32")
Review comment:
Use int64 now.
----------------------------------------------------------------
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]