[QNN EP] Update QNN to v2.13 (#17079)

### Description
Update QNN SDK to v2.13, update some UTs accordingly
This commit is contained in:
Hector Li 2023-08-10 20:47:55 -07:00 committed by GitHub
parent 3e7f70bf88
commit 344c41fdb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 63 additions and 48 deletions

View file

@ -175,6 +175,12 @@ static void RunBatchNormQDQTest(const TestInputDef<float>& input_def,
// TODO: FIX TRANSLATION!!!
// Check that QNN compiles DQ -> BatchNormalization -> Q as a single unit.
// Use an input of rank 3.
// QNN v2.13
// Inaccuracy detected for output 'output', element 4.
// Output quant params: scale=0.019084848463535309, zero_point=9.
// Expected val: 1.7755576372146606
// QNN QDQ val: 2.9963212013244629 (err 1.2207635641098022)
// CPU QDQ val: 0.82064849138259888 (err 0.95490914583206177)
TEST_F(QnnHTPBackendTests, DISABLED_BatchNorm1D) {
constexpr int64_t num_channels = 2;
@ -187,6 +193,12 @@ TEST_F(QnnHTPBackendTests, DISABLED_BatchNorm1D) {
// TODO: FIX TRANSLATION!!!
// Check that QNN compiles DQ -> BatchNormalization -> Q as a single unit.
// Use an input of rank 4.
// QNN v2.13
// Inaccuracy detected for output 'output', element 14.
// Output quant params: scale=0.023071292787790298, zero_point=19.
// Expected val: 2.8554618358612061
// QNN QDQ val: 5.3294687271118164 (err 2.4740068912506104)
// CPU QDQ val: 1.6611330509185791 (err 1.194328784942627)
TEST_F(QnnHTPBackendTests, DISABLED_BatchNorm2D) {
constexpr int64_t num_channels = 2;
std::vector<float> input_data = {-8.0f, -6.0f, -4.0f, -2.0f, 0.0f, 1.1f, 3.3f, 8.0f,

View file

@ -225,7 +225,7 @@ static void RunHTPConvOpTest(const std::string& conv_op_type, const TestInputDef
// Check that QNN compiles DQ -> Conv -> Q as a single unit.
// Tests bias as a dynamic input.
// TODO: Segfaults when calling graphFinalize().
// TODO: Segfaults when calling graphFinalize(). v2.13
TEST_F(QnnCPUBackendTests, DISABLED_Convf32_dynamic_bias) {
RunCPUConvOpTest("Conv",
TestInputDef<float>({1, 1, 3, 3}, false, 0.0f, 10.0f), // Random dynamic input
@ -575,8 +575,7 @@ TEST_F(QnnHTPBackendTests, ConvTranspose1DU8U8S32_AutoPadLower) {
13);
}
// TODO: re-enable tests once HTP issues are resolved
TEST_F(QnnHTPBackendTests, DISABLED_ConvU8U8S32_large_input1_padding_bias_initializer) {
TEST_F(QnnHTPBackendTests, ConvU8U8S32_large_input1_padding_bias_initializer) {
RunHTPConvOpTest<uint8_t>("Conv",
TestInputDef<float>({1, 3, 60, 452}, false, 0.f, 10.f), // Dynamic input
TestInputDef<float>({16, 3, 3, 3}, true, -1.f, 1.f), // Static weights
@ -588,7 +587,7 @@ TEST_F(QnnHTPBackendTests, DISABLED_ConvU8U8S32_large_input1_padding_bias_initia
ExpectedEPNodeAssignment::All);
}
TEST_F(QnnHTPBackendTests, DISABLED_ConvU8S32_large_input2_bias_initializer) {
TEST_F(QnnHTPBackendTests, ConvU8S32_large_input2_bias_initializer) {
RunHTPConvOpTest<uint8_t>("Conv",
TestInputDef<float>({1, 128, 8, 56}, false, 0.f, 10.f), // Dynamic input
TestInputDef<float>({32, 128, 1, 1}, true, -1.f, 1.f), // Random static weights
@ -600,8 +599,7 @@ TEST_F(QnnHTPBackendTests, DISABLED_ConvU8S32_large_input2_bias_initializer) {
ExpectedEPNodeAssignment::All);
}
// TODO: Certain large input sizes cause the QNN graph to fail to finalize with error 1002 (QNN_COMMON_ERROR_MEM_ALLOC).
TEST_F(QnnHTPBackendTests, DISABLED_ConvU8U8S32_LargeInput_Dilations_Pads) {
TEST_F(QnnHTPBackendTests, ConvU8U8S32_LargeInput_Dilations_Pads) {
RunHTPConvOpTest<uint8_t>("Conv",
TestInputDef<float>({1, 3, 768, 1152}, false, 0.f, 10.f), // Dynamic input
TestInputDef<float>({64, 3, 7, 7}, true, -1.f, 1.f), // Random static weights

View file

@ -122,13 +122,13 @@ static void RunLayerNormQDQTest(const std::vector<int64_t>& input_shape,
// Check that QNN compiles DQ -> LayerNormalization -> Q as a single unit.
// Use an input of rank 3.
// Failed QNN op validation: QnnDsp <E> Param[0] has incorrect Value 3
// QNN HTP only supports axis = -1
// TODO: Use new QDQ accuracy testing approach (see TestQDQModelAccuracy)
TEST_F(QnnHTPBackendTests, TestQDQLayerNorm1DAxis0) {
RunLayerNormQDQTest({1, 2, 3}, {1, 2, 3}, ExpectedEPNodeAssignment::None);
}
// Failed QNN FinalizeGraphs: QnnDsp <E> Failed to finalize graph (id: 1) with err 1002
// QNN v2.13: Failed QNN FinalizeGraphs: QnnDsp <E> Failed to finalize graph (id: 1) with err 1002
//
// TODO: Use new QDQ accuracy testing approach (see TestQDQModelAccuracy)
TEST_F(QnnHTPBackendTests, DISABLED_TestQDQLayerNorm1DAxis2) {

View file

@ -128,7 +128,7 @@ TEST_F(QnnCPUBackendTests, MaxPool_Large_Input) {
ExpectedEPNodeAssignment::All);
}
// TODO: Certain large input sizes cause the QNN graph to fail to finalize with error 1002 (QNN_COMMON_ERROR_MEM_ALLOC).
// QNN v2.13, backendValidateOpConfig() failed for node `MaxPool` of type `PoolMax2d` with error code 4003
TEST_F(QnnCPUBackendTests, DISABLED_MaxPool_Ceil) {
RunMaxPoolOpTest(TestInputDef<float>({1, 2, 3, 3}, false, -10.0f, 10.0f), // Dynamic input with range [-10, 10]
{utils::MakeAttribute("kernel_shape", std::vector<int64_t>{3, 3}),
@ -141,7 +141,7 @@ TEST_F(QnnCPUBackendTests, DISABLED_MaxPool_Ceil) {
ExpectedEPNodeAssignment::All);
}
// TODO: Certain large input sizes cause the QNN graph to fail to finalize with error 1002 (QNN_COMMON_ERROR_MEM_ALLOC).
// QNN v2.13, backendValidateOpConfig() failed for node `MaxPool` of type `PoolMax2d` with error code 4003
TEST_F(QnnCPUBackendTests, DISABLED_MaxPool_Large_Input2_Ceil) {
RunMaxPoolOpTest(TestInputDef<float>({1, 128, 16, 113}, false, -10.0f, 10.0f), // Dynamic input with range [-10, 10]
{utils::MakeAttribute("kernel_shape", std::vector<int64_t>{2, 2}),
@ -171,8 +171,7 @@ TEST_F(QnnHTPBackendTests, MaxPool_Global_HTP_u8) {
ExpectedEPNodeAssignment::All);
}
// TODO: Certain large input sizes cause the QNN graph to fail to finalize with error 1002 (QNN_COMMON_ERROR_MEM_ALLOC).
TEST_F(QnnHTPBackendTests, DISABLED_MaxPool_Large_Input_HTP_u8) {
TEST_F(QnnHTPBackendTests, MaxPool_Large_Input_HTP_u8) {
RunQDQMaxPoolOpTest<uint8_t>(TestInputDef<float>({1, 125, 8, 56}, false, -10.0f, 10.0f), // Dynamic input with range [-10, 10]
{utils::MakeAttribute("kernel_shape", std::vector<int64_t>{2, 2}),
utils::MakeAttribute("strides", std::vector<int64_t>{2, 2}),
@ -196,7 +195,11 @@ TEST_F(QnnHTPBackendTests, MaxPool_Ceil_HTP_u8) {
ExpectedEPNodeAssignment::All);
}
// TODO: Certain large input sizes cause the QNN graph to fail to finalize with error 1002 (QNN_COMMON_ERROR_MEM_ALLOC).
// QNN v2.13: Inaccuracy detected for output 'output', element 58367.
// Output quant params: scale=0.078431375324726105, zero_point=127.
// Expected val: 5.6846914291381836
// QNN QDQ val: -5.3333334922790527 (err 11.018024444580078)
// CPU QDQ val: 5.6470589637756348 (err 0.037632465362548828)
TEST_F(QnnHTPBackendTests, DISABLED_MaxPool_Large_Input2_Ceil_HTP_u8) {
RunQDQMaxPoolOpTest<uint8_t>(TestInputDef<float>({1, 128, 16, 113}, false, -10.0f, 10.0f), // Dynamic input with range [-10, 10]
{utils::MakeAttribute("kernel_shape", std::vector<int64_t>{2, 2}),
@ -209,7 +212,7 @@ TEST_F(QnnHTPBackendTests, DISABLED_MaxPool_Large_Input2_Ceil_HTP_u8) {
ExpectedEPNodeAssignment::All);
}
// TODO: Certain large input sizes cause the QNN graph to fail to finalize with error 1002 (QNN_COMMON_ERROR_MEM_ALLOC).
// QNN v2.13: Certain large input sizes cause the QNN graph to fail to finalize with error 1002 (QNN_COMMON_ERROR_MEM_ALLOC).
TEST_F(QnnHTPBackendTests, DISABLED_MaxPool_LargeInput_1Pads) {
RunQDQMaxPoolOpTest<uint8_t>(TestInputDef<float>({1, 64, 384, 576}, false, -10.0f, 10.0f), // Dynamic input with range [-10, 10]
{utils::MakeAttribute("kernel_shape", std::vector<int64_t>{3, 3}),

View file

@ -178,8 +178,6 @@ static void RunQDQResizeOpTest(const TestInputDef<float>& input_def,
// CPU tests:
//
// TODO: Enable QnnCPU tests that use "nearest" mode.
//
// Our non-quantized implementation of Resize uses QNN's ResizeNearestNeighbor operator,
// which is __not__ equivalent to ONNX's Resize operator with a single specific "nearest_mode".
// The following disabled unit tests would pass if we removed the check in QNN EP that expects the
@ -197,9 +195,11 @@ TEST_F(QnnCPUBackendTests, DISABLED_ResizeUpsampleNearestHalfPixel_rpf) {
ExpectedEPNodeAssignment::All);
}
// QNN v2.13 Failed for Linux
#if defined(_WIN32)
// Upsample that uses "round_prefer_ceil" as the "nearest_mode".
// coordinate_transformation_mode: "half_pixel"
TEST_F(QnnCPUBackendTests, DISABLED_ResizeUpsampleNearestHalfPixel_rpc) {
TEST_F(QnnCPUBackendTests, ResizeUpsampleNearestHalfPixel_rpc) {
RunCPUResizeOpTest(TestInputDef<float>({1, 1, 2, 4}, false, -10.0f, 10.0f),
{1, 1, 7, 5}, "nearest", "half_pixel", "round_prefer_ceil",
ExpectedEPNodeAssignment::All);
@ -207,7 +207,7 @@ TEST_F(QnnCPUBackendTests, DISABLED_ResizeUpsampleNearestHalfPixel_rpc) {
// Downsample that uses "round_prefer_ceil" as the "nearest_mode".
// coordinate_transformation_mode: "half_pixel"
TEST_F(QnnCPUBackendTests, DISABLED_ResizeDownsampleNearestHalfPixel_rpc) {
TEST_F(QnnCPUBackendTests, ResizeDownsampleNearestHalfPixel_rpc) {
RunCPUResizeOpTest(TestInputDef<float>({1, 1, 2, 4}, false, -10.0f, 10.0f),
{1, 1, 1, 3}, "nearest", "half_pixel", "round_prefer_ceil",
ExpectedEPNodeAssignment::All);
@ -215,23 +215,27 @@ TEST_F(QnnCPUBackendTests, DISABLED_ResizeDownsampleNearestHalfPixel_rpc) {
// Downsample that uses "round_prefer_floor" as the "nearest_mode".
// coordinate_transformation_mode: "half_pixel"
TEST_F(QnnCPUBackendTests, DISABLED_ResizeDownsampleNearestHalfPixel_rpf) {
TEST_F(QnnCPUBackendTests, ResizeDownsampleNearestHalfPixel_rpf) {
RunCPUResizeOpTest(TestInputDef<float>({1, 1, 2, 4}, false, -10.0f, 10.0f),
{1, 1, 1, 2}, "nearest", "half_pixel", "round_prefer_ceil",
ExpectedEPNodeAssignment::All);
}
#endif
// Upsample that uses "round_prefer_floor" as the "nearest_mode".
// coordinate_transformation_mode: "align_corners"
// QNN v2.13: index #50 don't match, which is 4.67152 from -1.93515
TEST_F(QnnCPUBackendTests, DISABLED_ResizeUpsampleNearestAlignCorners_rpf) {
RunCPUResizeOpTest(TestInputDef<float>({1, 2, 7, 5}, false, -10.0f, 10.0f),
{1, 2, 21, 10}, "nearest", "align_corners", "round_prefer_floor",
ExpectedEPNodeAssignment::All);
}
// QNN v2.13 Failed for Linux
#if defined(_WIN32)
// Upsample that uses "round_prefer_ceil" as the "nearest_mode".
// coordinate_transformation_mode: "align_corners"
TEST_F(QnnCPUBackendTests, DISABLED_ResizeUpsampleNearestAlignCorners_rpc) {
TEST_F(QnnCPUBackendTests, ResizeUpsampleNearestAlignCorners_rpc) {
RunCPUResizeOpTest(TestInputDef<float>({1, 1, 2, 4}, false, -10.0f, 10.0f),
{1, 1, 7, 5}, "nearest", "align_corners", "round_prefer_ceil",
ExpectedEPNodeAssignment::All);
@ -239,7 +243,7 @@ TEST_F(QnnCPUBackendTests, DISABLED_ResizeUpsampleNearestAlignCorners_rpc) {
// Downsample that uses "round_prefer_ceil" as the "nearest_mode".
// coordinate_transformation_mode: "align_corners"
TEST_F(QnnCPUBackendTests, DISABLED_ResizeDownsampleNearestAlignCorners_rpc) {
TEST_F(QnnCPUBackendTests, ResizeDownsampleNearestAlignCorners_rpc) {
RunCPUResizeOpTest(TestInputDef<float>({1, 1, 2, 4}, false, -10.0f, 10.0f),
{1, 1, 1, 3}, "nearest", "align_corners", "round_prefer_ceil",
ExpectedEPNodeAssignment::All);
@ -247,11 +251,12 @@ TEST_F(QnnCPUBackendTests, DISABLED_ResizeDownsampleNearestAlignCorners_rpc) {
// Downsample that uses "round_prefer_floor" as the "nearest_mode".
// coordinate_transformation_mode: "align_corners"
TEST_F(QnnCPUBackendTests, DISABLED_ResizeDownsampleNearestAlignCorners_rpf) {
TEST_F(QnnCPUBackendTests, ResizeDownsampleNearestAlignCorners_rpf) {
RunCPUResizeOpTest(TestInputDef<float>({1, 1, 2, 4}, false, -10.0f, 10.0f),
{1, 1, 1, 2}, "nearest", "align_corners", "round_prefer_floor",
ExpectedEPNodeAssignment::All);
}
#endif
//
// Cpu tests that use the "linear" mode.
@ -309,10 +314,11 @@ TEST_F(QnnHTPBackendTests, ResizeU8_2xNearestAsymmetricFloor) {
// QNN's own Resize operator (instead of ResizeNearestNeighbor), but it doesn't support the "asymmetric" coordinate
// transform mode.
//
// Expected: contains 192 values, where each value and its corresponding value in 16-byte object
// <C0-00 00-00 00-00 00-00 40-05 D6-27 BB-01 00-00> are an almost-equal pair
// Actual : 16 - byte object<C0 - 00 00 - 00 00 - 00 00 - 00 40 - 04 E9 - 1B BB - 01 00 - 00>,
// where the value pair(0.15, 0.501) at index #1 don't match, which is 0.351 from 0.15
// QNN v2.13: Inaccuracy detected for output 'output', element 189.
// Output quant params: scale=0.078431375324726105, zero_point=127.
// Expected val: -2.663428783416748
// QNN QDQ val: 7.4509806632995605 (err 10.114409446716309)
// CPU QDQ val: -2.6666667461395264 (err 0.0032379627227783203)
TEST_F(QnnHTPBackendTests, DISABLED_ResizeU8_2xNearestAsymmetricCeil) {
RunQDQResizeOpTest<uint8_t>(TestInputDef<float>({1, 3, 4, 4}, false, -10.0f, 10.0f),
{1, 3, 8, 8}, "nearest", "asymmetric", "ceil",

View file

@ -244,17 +244,9 @@ TEST_F(QnnHTPBackendTests, UnaryOp_Cos) {
11, ExpectedEPNodeAssignment::All);
}
// TODO: Inaccuracy when computing cos(-1.88436)
//
// cos(-1.88436f) fp32 cpu ep = -0.308450460
// cos(-1.88436f) qdq cpu ep = -0.298039228
// cos(-1.88436f) qdq QNN ep = -0.321568638
//
// QNN error: 0.013118177652359009, CPU error: 0.010411232709884644
//
// input quant params: scale=0.0246399231, zero_point=127
// output quant params: scale=0.00784313772, zero_point=127
TEST_F(QnnHTPBackendTests, DISABLED_UnaryOp_Cos_Inaccurate) {
// Check that QNN compiles DQ -> Cos -> Q as a single unit.
// Use an input of rank 3.
TEST_F(QnnHTPBackendTests, UnaryOp_Cos_Inaccurate) {
RunQDQUnaryOpTest(TestInputDef<float>({1, 2, 3}, false, {-3.14159f, -1.88436f, -0.542863f, 0.0f, 1.05622f, 3.14159f}),
"Cos", {},
11, ExpectedEPNodeAssignment::All);
@ -449,7 +441,7 @@ TEST_F(QnnHTPBackendTests, BinaryOp_Sub4D) {
// TODO: Certain large input sizes cause the QNN graph to fail to finalize with error 1002 (QNN_COMMON_ERROR_MEM_ALLOC).
// Enable when this is fixed.
TEST_F(QnnHTPBackendTests, DISABLED_BinaryOp_Sub4D_LargeInputs) {
TEST_F(QnnHTPBackendTests, BinaryOp_Sub4D_LargeInputs) {
RunQDQBinaryOpTest<uint8_t>("Sub", TestInputDef<float>({1, 3, 768, 1152}, false, -1.0f, 1.0f),
TestInputDef<float>({1, 3, 768, 1152}, false, -1.0f, 1.0f),
17, ExpectedEPNodeAssignment::All);
@ -457,7 +449,7 @@ TEST_F(QnnHTPBackendTests, DISABLED_BinaryOp_Sub4D_LargeInputs) {
// TODO: Certain large input sizes cause the QNN graph to fail to finalize with error 1002 (QNN_COMMON_ERROR_MEM_ALLOC).
// Enable when this is fixed.
TEST_F(QnnHTPBackendTests, DISABLED_BinaryOp_Sub4D_Broadcast) {
TEST_F(QnnHTPBackendTests, BinaryOp_Sub4D_Broadcast) {
RunQDQBinaryOpTest<uint8_t>("Sub", TestInputDef<float>({1, 3, 768, 1152}, false, -1.0f, 1.0f),
TestInputDef<float>({3, 1, 1}, true, {1.0f, 0.5f, -0.3f}),
17, ExpectedEPNodeAssignment::All);
@ -470,8 +462,12 @@ TEST_F(QnnHTPBackendTests, BinaryOp_Div4D_SmallInputs) {
17, ExpectedEPNodeAssignment::All);
}
// TODO: Certain large input sizes cause the QNN graph to fail to finalize with error 1002 (QNN_COMMON_ERROR_MEM_ALLOC).
// Enable when this is fixed.
// TODO: Enable when this is fixed.
// QNN v2.13: Inaccuracy detected for output 'output', element 2551923.
// Output quant params: scale=4100.92626953125, zero_point=126.
// Expected val: -277957.3125
// QNN QDQ val: 0 (err 277957.3125)
// CPU QDQ val: -516716.71875 (err 238759.40625)
TEST_F(QnnHTPBackendTests, DISABLED_BinaryOp_Div4D_LargeInputs) {
RunQDQBinaryOpTest<uint8_t>("Div", TestInputDef<float>({1, 3, 768, 1152}, false, -1.0f, 1.0f),
TestInputDef<float>({1, 3, 768, 1152}, false, -1.0f, 1.0f),
@ -481,7 +477,7 @@ TEST_F(QnnHTPBackendTests, DISABLED_BinaryOp_Div4D_LargeInputs) {
// TODO: Certain large input sizes cause the QNN graph to fail to finalize with error 1002 (QNN_COMMON_ERROR_MEM_ALLOC).
// Enable when this is fixed.
// Fails accuracy when input0 has dims [1,3,768,768]
TEST_F(QnnHTPBackendTests, DISABLED_BinaryOp_Div4D_Broadcast) {
TEST_F(QnnHTPBackendTests, BinaryOp_Div4D_Broadcast) {
RunQDQBinaryOpTest<uint8_t>("Div", TestInputDef<float>({1, 3, 768, 1152}, false, -1.0f, 1.0f),
TestInputDef<float>({3, 1, 1}, true, {1.0f, 0.5f, -0.3f}),
17, ExpectedEPNodeAssignment::All);

View file

@ -3,7 +3,7 @@ parameters:
- name: QnnSdk
displayName: QNN SDK version
type: string
default: qnn-v2.12.0.230626
default: qnn-v2.13.1.230730
jobs:
- job: Build_QNN_EP

View file

@ -3,7 +3,7 @@ parameters:
- name: QnnSdk
displayName: QNN SDK version
type: string
default: qnn-v2.12.0.230626
default: qnn-v2.13.1.230730
jobs:
- job: Build_QNN_EP

View file

@ -2,12 +2,12 @@ parameters:
- name: qnn_sdk_path_win
displayName: QNN Windows SDK path
type: string
default: C:\data\qnnsdk\qnn-v2.12.1.230626_win
default: C:\data\qnnsdk\qnn-v2.13.1.230730_win
- name: qnn_sdk_info
displayName: QNN SDK Version Information
type: string
default: qnn-v2.12.1.230626_win
default: qnn-v2.13.1.230730_win
- name: ort_package_version
displayName: OnnxRuntime Nuget package version

View file

@ -3,7 +3,7 @@ parameters:
- name: QnnSdk
displayName: QNN SDK version
type: string
default: qnn-v2.12.1.230626_win
default: qnn-v2.13.1.230730_win
jobs:
- job: 'build'

View file

@ -3,7 +3,7 @@ parameters:
- name: QnnSdk
displayName: QNN SDK version
type: string
default: qnn-v2.12.1.230626_win
default: qnn-v2.13.1.230730_win
jobs:
- job: 'build'