giuseros commented on a change in pull request #6851: URL: https://github.com/apache/incubator-tvm/pull/6851#discussion_r517953448
########## File path: python/tvm/relay/op/transform.py ########## @@ -308,7 +308,7 @@ def scatter_add(data, indices, updates, axis): return _make.scatter_add(data, indices, updates, axis) -def reshape_like(data, shape_like): +def reshape_like(data, shape_like, lhs_begin=0, lhs_end=None, rhs_begin=0, rhs_end=None): Review comment: Could you add the additional parameters (lhs_begin, lhs_end, rhs_begin, rhs_end) in the docstring description? ########## File path: src/relay/op/make_op.h ########## @@ -62,6 +62,9 @@ Expr MakeRepeat(Expr data, int repeats, int axis); Expr MakeReshape(Expr data, Array<Integer> newshape); +Expr MakeReshapeLike(Expr lhs, Expr rhs, int64_t lhs_begin, Integer lhs_end, int64_t rhs_begin, Review comment: Why {lhs,rhs}_begin is int64_t and {lhs,rhs}_end is Integer? ########## File path: tests/python/relay/test_op_level3.py ########## @@ -316,17 +316,36 @@ def test_reshape_like_infer_type(): zz = run_infer_type(z) assert zz.checked_type == relay.TensorType((1, 8, 8), "float32") + # partial reshaping + x = relay.var("x", relay.TensorType((1, 2, 3, 4), "float32")) + y = relay.var("y", relay.TensorType((1, 6, 5), "float32")) + z = relay.reshape_like(x, y, lhs_begin=1, lhs_end=3, rhs_begin=1, rhs_end=2) + zz = run_infer_type(z) + assert zz.checked_type == relay.TensorType((1, 6, 4), "float32") + + # symbolic partial reshaping + n, c, h, w = te.size_var("n"), 2, 3, te.size_var("w") + x = relay.var("x", relay.TensorType((n, c, h, w), "float32")) + y = relay.var("y", relay.TensorType((5, 6), "float32")) + z = relay.var("z", relay.TensorType((4,), "float32")) + w = relay.reshape_like(x, y, lhs_end=3) + w = relay.reshape_like(w, z, lhs_begin=2) Review comment: Could you also add a test with only rhs_end/rhs_begin? ---------------------------------------------------------------- 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: us...@infra.apache.org