-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Relay, TOPI] Support dynamic slicing on first few axes, keeping the rest static #8068
Conversation
@@ -25,16 +25,19 @@ | |||
|
|||
@tvm.testing.uses_gpu | |||
def test_dynamic_strided_slice(): | |||
def verify(dshape, begin, end, strides, output, slice_mode="end", test_ref=True, dtype="int32"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
output
is not used in the test, so I removed it.
0784e59
to
4f1742a
Compare
This looks good to me. Do we need to do anything to support this behavior in the standard strided slice op? |
No, I believe it is already supported, although the static version doesn't have a constraint that (No idea why CI is running another job, it already passed). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
thanks @mbrookhart |
…rest static (apache#8068) * Supporting dynamic slice on first few axes * fix index normalization * update dynamic slice tests * pylint fix * fix loop index dtype * fix more dtype issue
…rest static (apache#8068) * Supporting dynamic slice on first few axes * fix index normalization * update dynamic slice tests * pylint fix * fix loop index dtype * fix more dtype issue
This PR relaxes the constraint that
begin
,end
andstrides
params of dynamic strided slice to have the same length as input rank, and enable slicing on only first few axes (in particular, slicing along batch dim only).For example, the output shape of ONNX NMS is
(num_detection, 3)
. However, when translated to relay, it becomes(?, ?)
, since current dynamic stride slice always slices on all axes, even if some axes are conceptually static. This posed a problem whenGatherND
is applied to the output of ONNX NMS, since it requires the second dimension to be static:tvm/src/relay/op/tensor/transform.cc
Lines 3348 to 3349 in c999a84
ready for review @mbrookhart @jwfromm @kevinthesun @yongwww