-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[WebNN] Support negative steps for slice #22871
base: main
Are you sure you want to change the base?
Conversation
It suddenly occurred to me that maybe other negative steps can also be supported with reverse+slice... I'll figure it out tomorrow |
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.
Thanks @shiyi9801, LGTM % a nit.
@@ -50,9 +49,6 @@ Status SliceOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder, | |||
NodeAttrHelper helper(node); | |||
|
|||
emscripten::val inputs = model_builder.GetOperand(input_defs[0]->Name()); |
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.
Please help rename this 'inputs' as 'input', legacy issue.
emscripten::val reverse_options = emscripten::val::object(); | ||
reverse_options.set("axes", emscripten::val::array(reverse_axes)); | ||
reverse_options.set("label", node.Name() + "_reverse"); | ||
reverse_output = model_builder.GetBuilder().call<emscripten::val>("reverse", inputs, reverse_options); |
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.
It'd be better to add data type check for reverse
and split
separately in a HasSupportedInputsImpl
, in case it fails in old versions of Chrome which doesn't support reverse
. You can do it in a follow-up. :)
Slice with negative steps can be emulated by reverse+slice.