Skip to content

Commit

Permalink
[WebNN EP] Use identity for one input of Max/Min (microsoft#21974)
Browse files Browse the repository at this point in the history
Now WebNN supports `identity` op, use it for `Max` and `Min` ops with
only one input.
  • Loading branch information
Honry authored Sep 5, 2024
1 parent 20c802a commit 23f6604
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,8 @@ Status MaxMinOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder,
options.set("label", node.Name());

if (input_count == 1) {
// For 1 input, just concat the single input as workaround.
// TODO: use identity instead once it's available in WebNN.
emscripten::val inputs = emscripten::val::array();
inputs.call<void>("push", input0);
output = model_builder.GetBuilder().call<emscripten::val>("concat", inputs, 0, options);
// For 1 input, use identity instead.
output = model_builder.GetBuilder().call<emscripten::val>("identity", input0, options);
} else {
std::string webnn_op_name = op_type == "Max" ? "max" : "min";

Expand Down

0 comments on commit 23f6604

Please sign in to comment.