Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into snnn/webgpu_initial…
Browse files Browse the repository at this point in the history
…_get_capability
  • Loading branch information
snnn committed Oct 6, 2023
2 parents 26f25f2 + 7417fd4 commit 18535a3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,6 @@ Status ReduceOpBuilder::IsOpSupported(QnnModelWrapper& qnn_model_wrapper,
return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "QNN EP: ReduceProd operator not supported by HTP backend.");
}

if (is_npu_backend) {
std::vector<uint32_t> input_shape;
ORT_RETURN_IF_NOT(qnn_model_wrapper.GetOnnxShape(node_unit.Inputs()[0].node_arg, input_shape),
"QNN EP: Cannot get input shape for");
ORT_RETURN_IF(input_shape.size() > 4, "QNN EP: HTP backend does not support Reduce ops with rank > 4.");
}

return AddToModelBuilder(qnn_model_wrapper, node_unit, logger, true);
}

Expand Down
38 changes: 34 additions & 4 deletions onnxruntime/test/providers/qnn/reduce_op_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,44 @@ TEST_F(QnnHTPBackendTests, ReduceSumS8Opset13_NoKeepDims) {
ExpectedEPNodeAssignment::All);
}

// Test that we don't support rank 5 Reduce ops.
TEST_F(QnnHTPBackendTests, ReduceSumS8Opset13_Rank5Unsupported) {
// Test rank 5 ReduceSum (s8 quant) with axes = [0, 1, 2, 3, 4], keep_dims = true
// TODO: QNN 2.15.1 Graph finalization error:
// graph_prepare.cc:234:ERROR:could not create op: q::Sum
// graph_prepare.cc:1093:ERROR:Op 0x102500000011 preparation failed with err:-1
// Completed stage: Graph Transformations and Optimizations (17163 us)
// QnnDsp <E> "node_token_3" generated: could not create op
// QnnDsp <E> RouterWindows graph prepare failed 12
// QnnDsp <E> Failed to finalize graph (id: 1) with err 1002{}
TEST_F(QnnHTPBackendTests, DISABLED_ReduceSumS8Opset13_Rank5) {
RunReduceOpQDQTest<int8_t>("ReduceSum",
TestInputDef<float>({1, 3, 4, 4, 2}, false, -10.0f, 10.0f),
TestInputDef<float>({1, 3, 4, 4, 2}, false, GetFloatDataInRange(-10.0f, 10.0f, 96)),
{0, 1, 2, 3, 4}, // axes
true, // keepdims
13, // opset
ExpectedEPNodeAssignment::None);
ExpectedEPNodeAssignment::All);
}

// Test that QNN validation APIs reject inputs of unsupported ranks.
TEST_F(QnnHTPBackendTests, ReduceSumS8Opset13_Rank6_Unsupported) {
RunReduceOpQDQTest<int8_t>("ReduceSum",
TestInputDef<float>({1, 3, 4, 4, 2, 1}, false, GetFloatDataInRange(-10.0f, 10.0f, 96)),
{-1}, // axes
false, // keepdims
13, // opset
ExpectedEPNodeAssignment::None); // Not assigned to QNN EP
}

// Test rank 5 ReduceSum (u8 quant) with axes = [-1], keep_dims = false
// TODO: Enable on QNN 2.15.1 (works fine)
TEST_F(QnnHTPBackendTests, DISABLED_ReduceSumU8Opset13_Rank5_LastAxis) {
constexpr size_t num_elems = 2ULL * 12 * 124 * 2 * 4;
std::vector<float> input_data = GetFloatDataInRange(-100.0f, 100.0f, num_elems);
RunReduceOpQDQTest<uint8_t>("ReduceSum",
TestInputDef<float>({2, 12, 124, 2, 4}, false, input_data),
{-1}, // axes
false, // keepdims
13, // opset
ExpectedEPNodeAssignment::All);
}

//
Expand Down

0 comments on commit 18535a3

Please sign in to comment.