Skip to content

Commit 65e694e

Browse files
authored
[QNN-EP] Apply Softmax layout transformation for GPU (microsoft#26233)
### Description - Transposes are inserted for Softmax with axis != output_rank-1 for the HTP backend. - The GPU backend also has this requirement on the axis param, so this change enables the layout transformation for the GPU as well. ### Motivation and Context - Enables more models with GPU backend.
1 parent 15efe1c commit 65e694e

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Status SoftmaxOpBuilder::ProcessInputs(QnnModelWrapper& qnn_model_wrapper,
6161
const logging::Logger& logger,
6262
std::vector<std::string>& input_names,
6363
bool do_op_validation) const {
64-
const bool is_npu_backend = IsNpuBackend(qnn_model_wrapper.GetQnnBackendType());
64+
const bool is_qpu_backend = IsQpuBackend(qnn_model_wrapper.GetQnnBackendType());
6565
const auto& inputs = node_unit.Inputs();
6666
const std::string& input_name = inputs[0].node_arg.Name();
6767
assert(inputs.size() == 1);
@@ -108,9 +108,9 @@ Status SoftmaxOpBuilder::ProcessInputs(QnnModelWrapper& qnn_model_wrapper,
108108
is_graph_input,
109109
false));
110110
input_names.push_back(reshape_output_name);
111-
} else if (is_npu_backend && axis != static_cast<int32_t>(input_rank) - 1) {
111+
} else if (is_qpu_backend && axis != static_cast<int32_t>(input_rank) - 1) {
112112
/*
113-
For Onnx Softmax with opset >= 13, the QNN HTP backend only supports the axis attribute that refers to the last
113+
For Onnx Softmax with opset >= 13, the QNN HTP and GPU backends only supports the axis attribute that refers to the last
114114
input dimension.
115115
QNN EP is able to support arbitrary axis attribute by wrapping transposes around the operator.
116116
*/
@@ -152,7 +152,7 @@ Status SoftmaxOpBuilder::ProcessAttributesAndOutputs(QnnModelWrapper& qnn_model_
152152
std::vector<std::string>&& input_names,
153153
const logging::Logger& logger,
154154
bool do_op_validation) const {
155-
const bool is_npu_backend = IsNpuBackend(qnn_model_wrapper.GetQnnBackendType());
155+
const bool is_qpu_backend = IsQpuBackend(qnn_model_wrapper.GetQnnBackendType());
156156
const std::string& op_type = node_unit.OpType();
157157
const auto& outputs = node_unit.Outputs();
158158
const std::string& orig_output_name = outputs[0].node_arg.Name();
@@ -202,7 +202,7 @@ Status SoftmaxOpBuilder::ProcessAttributesAndOutputs(QnnModelWrapper& qnn_model_
202202
do_op_validation,
203203
false,
204204
is_graph_output));
205-
} else if (is_npu_backend && axis != static_cast<int32_t>(output_rank) - 1) {
205+
} else if (is_qpu_backend && axis != static_cast<int32_t>(output_rank) - 1) {
206206
std::string transpose_input_name = utils::GetUniqueName(orig_output_name, "_transpose");
207207

208208
std::vector<uint32_t> transpose_input_shape = output_info.shape;

0 commit comments

Comments
 (0)