Skip to content

Commit 00e6000

Browse files
committed
[QNN-EP] Add support for Sum operator with two inputs
1 parent fe7634e commit 00e6000

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

onnxruntime/core/providers/qnn/builder/op_builder_factory.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ OpBuilderRegistrations::OpBuilderRegistrations() {
4747
CreateSimpleOpBuilder("Sin", *this);
4848
CreateSimpleOpBuilder("Sqrt", *this);
4949
CreateSimpleOpBuilder("Sub", *this);
50+
CreateSimpleOpBuilder("Sum", *this);
5051
CreateSimpleOpBuilder("Tanh", *this);
5152

5253
CreateSimpleOpBuilder("Concat", *this);

onnxruntime/core/providers/qnn/builder/opbuilder/base_op_builder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ class BaseOpBuilder : public IOpBuilder {
158158
{"Softmax", QNN_OP_SOFTMAX},
159159
{"Sqrt", QNN_OP_ELEMENT_WISE_SQUARE_ROOT},
160160
{"Sub", QNN_OP_ELEMENT_WISE_SUBTRACT},
161+
{"Sum", QNN_OP_ELEMENT_WISE_ADD},
161162
{"Tanh", QNN_OP_TANH},
162163
{"Transpose", QNN_OP_TRANSPOSE},
163164
{"GridSample", QNN_OP_GRID_SAMPLE},

onnxruntime/core/providers/qnn/builder/opbuilder/simple_op_builder.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,18 @@ Status SimpleOpBuilder::ExplicitOpCheck(QnnModelWrapper& qnn_model_wrapper,
5656
padding_mode.c_str());
5757
}
5858

59-
// ONNX's Min and Max operators accept a variable number of inputs (i.e., variadic).
60-
// However, QNN's Min and Max operators must take in exactly two inputs.
59+
// ONNX's Min, Max, and Sum operators accept a variable number of inputs (i.e., variadic).
60+
// However, QNN's Min, Max, and Add operators must take in exactly two inputs.
6161
if (op_type == "Min" || op_type == "Max") {
6262
ORT_RETURN_IF_NOT(node_unit.Inputs().size() == 2,
63-
"QNN EP only supports Min and Max operators with exactly 2 inputs.");
63+
"QNN EP only supports ", op_type.c_str(), " operator with exactly 2 inputs.");
64+
}
65+
66+
if (op_type == "Sum") {
67+
size_t inputs_num = node_unit.Inputs().size();
68+
ORT_RETURN_IF_NOT(inputs_num == 2,
69+
"QNN EP supports Sum operator with QNN_OP_ELEMENT_WISE_ADD, which takes exactly 2 inputs. Got ONNX's Sum operator with ",
70+
std::to_string(inputs_num).c_str(), " inputs.");
6471
}
6572

6673
if (op_type == "DequantizeLinear") {

0 commit comments

Comments
 (0)