From 23f6604c394716a364e9b4e73b0e7efbc4e56842 Mon Sep 17 00:00:00 2001 From: Wanming Lin Date: Fri, 6 Sep 2024 07:47:40 +0800 Subject: [PATCH] [WebNN EP] Use identity for one input of Max/Min (#21974) Now WebNN supports `identity` op, use it for `Max` and `Min` ops with only one input. --- .../providers/webnn/builders/impl/max_min_op_builder.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/onnxruntime/core/providers/webnn/builders/impl/max_min_op_builder.cc b/onnxruntime/core/providers/webnn/builders/impl/max_min_op_builder.cc index 1080fd0a3f943..5d88afda7b6a7 100644 --- a/onnxruntime/core/providers/webnn/builders/impl/max_min_op_builder.cc +++ b/onnxruntime/core/providers/webnn/builders/impl/max_min_op_builder.cc @@ -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("push", input0); - output = model_builder.GetBuilder().call("concat", inputs, 0, options); + // For 1 input, use identity instead. + output = model_builder.GetBuilder().call("identity", input0, options); } else { std::string webnn_op_name = op_type == "Max" ? "max" : "min";