masahi commented on code in PR #14548:
URL: https://github.com/apache/tvm/pull/14548#discussion_r1161654039
##########
python/tvm/relax/transform/legalize_ops/index.py:
##########
@@ -59,3 +60,39 @@ def _strided_slice(bb: BlockBuilder, call: Call) -> Expr:
call.attrs.axes,
slice_mode="end",
)
+
+
+@register_legalize("relax.dynamic_strided_slice")
+def _dynamic_strided_slice(bb: BlockBuilder, call: Call) -> Expr:
+ # 1. Insert shape function
+ output_shape = bb.normalize(
+ bb.call_te(
+ topi.shape_func_dynamic_strided_slice,
+ call.args[0],
+ call.args[1],
+ call.args[2],
+ call.args[3],
Review Comment:
Three questions:
* Why `shape_func_dynamic_strided_slice` needs to be implemented in topi /
c++? This seems like a one-off function, why not just create `te.compute` here
in python?
* Are we introducing a standard API for shape func (like Relay), or is each
op going to pick any API as it sees fit (like this example)? In the latter case
I don't see any reason shape funcs need to belong to topi.
* If a shape func needs the actual runtime shape to compute the
corresponding output shape, would legalization-based approach still work? In
relay shape func, that is the first input to the shape func.
--
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]