Skip to content

Commit 67ff56b

Browse files
qti-yuduoJaswanth51
authored andcommitted
[QNN EP] Minor fix weight name missing when not valid QDQ node group (microsoft#25887)
### Description Minor fix weight name missing when not valid QDQ node group ### Motivation and Context Some quantized model failed QDQ node group validation, the weights then won't be folded as initializer. QNN EP failed to handle the dynamic weights here due to the transpose op input name look up. This change make sure we process the weights tensor before adding transposes.
1 parent 69cd867 commit 67ff56b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@ Status ConvOpBuilder::ProcessConv2D3DInputs(QnnModelWrapper& qnn_model_wrapper,
245245
bool is_graph_input = qnn_model_wrapper.IsGraphInput(input1_name);
246246
LOGS(logger, VERBOSE) << "Add HWCN Transpose node after input: " << input1_name;
247247

248+
if (!qnn_model_wrapper.IsQnnTensorWrapperExist(input1_name)) {
249+
QnnTensorWrapper weight_tensor_wrapper;
250+
ORT_RETURN_IF_ERROR(qnn_model_wrapper.MakeTensorWrapper(inputs[1], weight_tensor_wrapper));
251+
ORT_RETURN_IF_NOT(qnn_model_wrapper.AddTensorWrapper(std::move(weight_tensor_wrapper)), "Failed to add weight tensor.");
252+
}
253+
248254
if (conv_type == OnnxConvType::kConv) {
249255
ORT_RETURN_IF_ERROR(qnn_model_wrapper.AddNchwToHwcnTranspose(node_unit.Index(),
250256
input1_name,
@@ -425,7 +431,7 @@ Status ConvOpBuilder::ProcessConv1DInputs(QnnModelWrapper& qnn_model_wrapper,
425431

426432
//
427433
// Input 1: weight
428-
// We need to first reshape the weight inorder to handle 1D convolutions with the Conv2d operator.
434+
// We need to first reshape the weight in order to handle 1D convolutions with the Conv2d operator.
429435
// Next, we have to transpose the weight because ORT layout transformations do not change the weight layout.
430436
//
431437
{
@@ -511,6 +517,12 @@ Status ConvOpBuilder::ProcessConv1DInputs(QnnModelWrapper& qnn_model_wrapper,
511517
ORT_RETURN_IF(input_info.quant_param.IsPerChannel(),
512518
"Non-constant Conv inputs only support per-tensor quantization");
513519

520+
if (!qnn_model_wrapper.IsQnnTensorWrapperExist(input1_name)) {
521+
QnnTensorWrapper weight_tensor_wrapper;
522+
ORT_RETURN_IF_ERROR(qnn_model_wrapper.MakeTensorWrapper(inputs[1], weight_tensor_wrapper));
523+
ORT_RETURN_IF_NOT(qnn_model_wrapper.AddTensorWrapper(std::move(weight_tensor_wrapper)), "Failed to add weight tensor.");
524+
}
525+
514526
bool is_graph_input = qnn_model_wrapper.IsGraphInput(input1_name);
515527
LOGS(logger, VERBOSE) << "Adding Reshape (to 2D) and HWCN Transpose node after input: " << input1_name;
516528
ORT_RETURN_IF_ERROR(qnn_model_wrapper.AddReshapeNode(input1_name,

0 commit comments

Comments
 (0)