vvchernov commented on code in PR #16131:
URL: https://github.com/apache/tvm/pull/16131#discussion_r1395953719
##########
python/tvm/relay/frontend/pytorch.py:
##########
@@ -1546,6 +1546,16 @@ def flatten(self, inputs, input_types):
out = _op.squeeze(out, axis=squeeze_axes)
return out
+ def unflatten(self, inputs, input_types):
+ data = inputs[0]
+ dim = int(inputs[1])
+ unflattened_size = tuple(inputs[2])
+ dshape = get_const_tuple(self.infer_shape_with_prelude(data))
+ assert len(dshape) > dim
+ new_shape = dshape[:dim] + unflattened_size + dshape[dim + 1 :]
Review Comment:
I've checked that _op.reshape does not check size correctness by it-self.
Nevertheless I found that dim can be not only -1, but from list {0, -1, -2, -3,
-4} See
https://github.com/apache/tvm/blob/748882aae7be1435f042e22b0fc67cb236705b6c/python/tvm/relay/op/transform.py#L243
I suggest to check -1 case only. It looks like torch does not have other
options
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]