mbrookhart commented on a change in pull request #5983:
URL: https://github.com/apache/incubator-tvm/pull/5983#discussion_r450402665
##########
File path: python/tvm/relay/op/dyn/_transform.py
##########
@@ -81,3 +84,23 @@ def _reshape_shape_func_input_data(data, newshape, ndim):
@_reg.register_shape_func("dyn.reshape", True)
def dynamic_reshape_shape_func(attrs, inputs, out_ndims):
return [_reshape_shape_func_input_data(*inputs, out_ndims[0])]
+
+
+@script
+def _tile_shape_func(data, reps, ndim):
+ out = output_tensor((ndim,), "int64")
+
+ for i in const_range(ndim):
+ out[i] = data.shape[i] * int64(reps[i])
+ return out
+
+
+@_reg.register_shape_func("dyn.tile", True)
+def tile_shape_func(attrs, inputs, _):
+ """
+ Shape function for tile op.
+ """
+ ndim = len(inputs[0].shape)
+ rdim = inputs[1].shape[0].value
+ assert ndim == rdim, "tile data and reps ranks don't match"
Review comment:
Yes, to prevent dynamic rank behavior, I matched the TF/ONNX APIs and
only allow dynamic tile where the rank of the input and the size of the reps
match. This is slightly different than the standard TOPI op which implicitly
pads either the input shape or the reps with ones.
----------------------------------------------------------------
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]