Skip to content

Commit

Permalink
[WebNN EP] Support Greater and Less ops (microsoft#16782)
Browse files Browse the repository at this point in the history
  • Loading branch information
Honry committed Jul 24, 2023
1 parent 8ede2f1 commit 5d17bcd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions onnxruntime/core/providers/webnn/builders/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,15 @@ static const InlinedHashMap<std::string, std::string> op_map = {
{"Gemm", "gemm"},
{"GlobalAveragePool", "averagePool2d"},
{"GlobalMaxPool", "maxPool2d"},
{"Greater", "greater"},
{"GroupNormalization", "meanVarianceNormalization"},
{"HardSigmoid", "hardSigmoid"},
{"HardSwish", "hardSwish"},
{"Identity", "identity"},
{"InstanceNormalization", "meanVarianceNormalization"},
{"LayerNormalization", "meanVarianceNormalization"},
{"LeakyRelu", "leakyRelu"},
{"Less", "lesser"},
{"MatMul", "matmul"},
{"MaxPool", "maxPool2d"},
{"Mul", "mul"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ Status LogicalOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder, cons
emscripten::val output = emscripten::val::object();
if (op_type == "Equal") {
output = model_builder.GetBuilder().call<emscripten::val>("equal", input0, input1);
} else if (op_type == "Greater") {
output = model_builder.GetBuilder().call<emscripten::val>("greater", input0, input1);
} else if (op_type == "Less") {
output = model_builder.GetBuilder().call<emscripten::val>("lesser", input0, input1);
} else {
return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT,
"LogicalOpBuilder::AddToModelBuilderImpl, unknown op: ", op_type);
Expand All @@ -49,6 +53,8 @@ void CreateLogicalOpBuilder(const std::string& op_type, OpBuilderRegistrations&
static std::vector<std::string> op_types =
{
"Equal",
"Greater",
"Less",
};

op_registrations.builders.push_back(std::make_unique<LogicalOpBuilder>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ static OpBuilderRegistrations CreateOpBuilderRegistrations() {

{ // Logical
CreateLogicalOpBuilder("Equal", op_registrations);
CreateLogicalOpBuilder("Greater", op_registrations);
CreateLogicalOpBuilder("Less", op_registrations);
}

{ // Normalization
Expand Down

0 comments on commit 5d17bcd

Please sign in to comment.