From 50b49642d5da34a419f9068c0684d3c0ae4c1c3e Mon Sep 17 00:00:00 2001 From: Peishen Yan Date: Wed, 19 Jun 2024 18:28:34 +0800 Subject: [PATCH] [WebNN EP] Update triangular_op_builder.cc (#20994) As a follow-up of https://github.com/microsoft/onnxruntime/pull/20730 --- .../webnn/builders/impl/triangular_op_builder.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/onnxruntime/core/providers/webnn/builders/impl/triangular_op_builder.cc b/onnxruntime/core/providers/webnn/builders/impl/triangular_op_builder.cc index caf3979d611d9..e4b7021d49b30 100644 --- a/onnxruntime/core/providers/webnn/builders/impl/triangular_op_builder.cc +++ b/onnxruntime/core/providers/webnn/builders/impl/triangular_op_builder.cc @@ -50,9 +50,10 @@ Status TriangularOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder, const bool upper = helper.Get("upper", 1); options.set("upper", upper); - if (!GetTensorName(input_defs, 1).empty()) { + const std::string diagonal_name = GetTensorName(input_defs, 1); + if (!diagonal_name.empty()) { // Optional input diagonal is provided, use diagonal initializer data. - const auto diagonal_tensor = *initializers.at(input_defs[1]->Name()); + const auto diagonal_tensor = *initializers.at(diagonal_name); std::vector unpacked_tensor; ORT_RETURN_IF_ERROR(onnxruntime::utils::UnpackInitializerData(diagonal_tensor, unpacked_tensor)); @@ -77,13 +78,12 @@ bool TriangularOpBuilder::IsOpSupportedImpl(const InitializedTensorSet& initiali return false; const auto input_size = input_shape.size(); if (input_size < 2) { - LOGS(logger, VERBOSE) << "Triangular only support input size >= 2d shape, input is " + LOGS(logger, VERBOSE) << "Triangular only supports input size >= 2D shape, input is " << input_size << "d shape"; return false; } const std::string diagonal_name = GetTensorName(input_defs, 1); - emscripten::val diagonal = emscripten::val::object(); // Inputs contain optional 'diagonal' input. if (!diagonal_name.empty()) { if (!Contains(initializers, diagonal_name)) {