From 034ab4fa04789af9f989975ba6515fc72941b95b Mon Sep 17 00:00:00 2001 From: Wanming Lin Date: Wed, 23 Oct 2024 11:03:09 +0800 Subject: [PATCH] [WebNN EP] Fixed a minor bug in ConvTranspose (#22384) For ConvTranspose, the filter should be transposed from iohw -> ohwi if it is NHWC preferred layout. --- .../core/providers/webnn/builders/impl/conv_op_builder.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onnxruntime/core/providers/webnn/builders/impl/conv_op_builder.cc b/onnxruntime/core/providers/webnn/builders/impl/conv_op_builder.cc index f03e5b90ff..329db75316 100644 --- a/onnxruntime/core/providers/webnn/builders/impl/conv_op_builder.cc +++ b/onnxruntime/core/providers/webnn/builders/impl/conv_op_builder.cc @@ -133,7 +133,7 @@ Status AddInitializerInNewLayout(ModelBuilder& model_builder, const auto out_t = dims[0], in_t = dims[1], h_t = dims[2], w_t = dims[3]; std::vector dest_shape; - if (is_conv == 1) + if (is_conv) dest_shape = {out_t, h_t, w_t, in_t}; // L_0231 else dest_shape = {in_t, h_t, w_t, out_t}; // L_1230 for depthwise conv and convTranspose weight @@ -265,7 +265,7 @@ Status ConvOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder, const N options.set("inputLayout", emscripten::val("nhwc")); options.set("filterLayout", emscripten::val("ohwi")); if (is_constant_weight) { - ORT_RETURN_IF_ERROR(AddInitializerInNewLayout(model_builder, weight_name, true, is_conv1d)); + ORT_RETURN_IF_ERROR(AddInitializerInNewLayout(model_builder, weight_name, false, is_conv1d)); } } }