@@ -98,18 +98,33 @@ static void RunPadOpTest(const TestInputDef<float>& data_def,
9898 const std::vector<ONNX_NAMESPACE::AttributeProto>& attrs,
9999 ExpectedEPNodeAssignment expected_ep_assignment,
100100 bool has_constant_value = true ,
101- int opset = 18 ) {
101+ int opset = 18 ,
102+ bool use_htp = false ,
103+ bool enable_fp16_precision = false ,
104+ float f32_abs_err = 1e-5f ) {
102105 ProviderOptions provider_options;
106+ if (use_htp) {
103107#if defined(_WIN32)
104- provider_options[" backend_path" ] = " QnnCpu .dll" ;
108+ provider_options[" backend_path" ] = " QnnHtp .dll" ;
105109#else
106- provider_options[" backend_path" ] = " libQnnCpu .so" ;
110+ provider_options[" backend_path" ] = " libQnnHtp .so" ;
107111#endif
112+ } else {
113+ #if defined(_WIN32)
114+ provider_options[" backend_path" ] = " QnnCpu.dll" ;
115+ #else
116+ provider_options[" backend_path" ] = " libQnnCpu.so" ;
117+ #endif
118+ }
119+
120+ if (enable_fp16_precision) {
121+ provider_options[" enable_htp_fp16_precision" ] = " 1" ;
122+ }
108123
109124 RunQnnModelTest (BuildPadTestCase (data_def, pads_def, constant_value_def, attrs, has_constant_value),
110125 provider_options,
111126 opset,
112- expected_ep_assignment);
127+ expected_ep_assignment, f32_abs_err );
113128}
114129
115130// Runs a QDQ Pad model on the QNN HTP backend. Checks the graph node assignment, and that inference
@@ -229,6 +244,60 @@ TEST_F(QnnCPUBackendTests, Pad6d) {
229244#if defined(__aarch64__) || defined(_M_ARM64) || defined(__linux__)
230245//
231246// HTP tests:
247+ TEST_F (QnnHTPBackendTests, PadNoConstantValue_fp16_test) {
248+ bool has_constant_value_input = false ;
249+ bool use_htp = true ;
250+ bool enable_fp16_precision = true ;
251+ RunPadOpTest (TestInputDef<float >({3 , 2 }, false , {1 .0f , 1 .2f , 2 .3f , 3 .4f , 4 .5f , 5 .6f }),
252+ TestInputDef<int64_t >({4 }, true , {0 , 2 , 0 , 0 }),
253+ TestInputDef<float >({1 }, true , {0 .0f }),
254+ {utils::MakeAttribute (" mode" , " constant" )},
255+ ExpectedEPNodeAssignment::All,
256+ has_constant_value_input,
257+ 18 , // opset
258+ use_htp,
259+ enable_fp16_precision,
260+ 2e-3f );
261+ }
262+
263+ TEST_F (QnnHTPBackendTests, PadReflectMode_fp16) {
264+ bool has_constant_value_input = false ;
265+ bool use_htp = true ;
266+ bool enable_fp16_precision = true ;
267+ RunPadOpTest (TestInputDef<float >({3 , 2 }, false , {1 .0f , 1 .2f , 2 .3f , 3 .4f , 4 .5f , 5 .6f }),
268+ TestInputDef<int64_t >({4 }, true , {0 , 1 , 0 , 0 }),
269+ TestInputDef<float >({1 }, true , {0 .0f }),
270+ {utils::MakeAttribute (" mode" , " reflect" )},
271+ ExpectedEPNodeAssignment::All,
272+ has_constant_value_input,
273+ 18 , // opset
274+ use_htp,
275+ enable_fp16_precision,
276+ 2e-3f );
277+ }
278+
279+ // HTP\HTP\src\hexagon\prepare\graph_prepare.cc:203:ERROR:could not create op: q::flat_from_vtcm
280+ // HTP\HTP\src\hexagon\prepare\graph_prepare.cc:1238:ERROR:Op 0x104100000011 preparation failed with err:-1
281+ // Completed stage: Graph Transformations and Optimizations (13372 us)
282+ // QnnDsp <E> "node" generated: could not create op
283+ // QnnDsp <E> RouterWindows graph prepare failed 12
284+ // QnnDsp <E> Failed to finalize graph (id: 1) with err 1002
285+ TEST_F (QnnHTPBackendTests, DISABLED_PadReflectMode_FP16_big_data) {
286+ bool has_constant_value_input = false ;
287+ bool use_htp = true ;
288+ bool enable_fp16_precision = true ;
289+ RunPadOpTest (TestInputDef<float >({1 , 4 , 512 , 512 }, false , GetFloatDataInRange (1 .0f , 10 .0f , 4 * 512 * 512 )),
290+ TestInputDef<int64_t >({8 }, true , {0 , 0 , 3 , 3 , 0 , 0 , 3 , 3 }),
291+ TestInputDef<float >({1 }, true , {0 .0f }),
292+ {utils::MakeAttribute (" mode" , " reflect" )},
293+ ExpectedEPNodeAssignment::All,
294+ has_constant_value_input,
295+ 18 , // opset
296+ use_htp,
297+ enable_fp16_precision,
298+ 2e-3f );
299+ }
300+
232301//
233302// QDQ Pad
234303TEST_F (QnnHTPBackendTests, PadNoConstantValue) {
0 commit comments