Skip to content

Commit

Permalink
[WebNN EP] Update triangular_op_builder.cc (microsoft#20994)
Browse files Browse the repository at this point in the history
As a follow-up of microsoft#20730
  • Loading branch information
peishenyan authored Jun 19, 2024
1 parent 40879a2 commit 50b4964
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t> unpacked_tensor;
ORT_RETURN_IF_ERROR(onnxruntime::utils::UnpackInitializerData(diagonal_tensor, unpacked_tensor));
Expand All @@ -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)) {
Expand Down

0 comments on commit 50b4964

Please sign in to comment.