1414#include " test/common/tensor_op_test_utils.h"
1515#include " test/framework/test_utils.h"
1616#include " test/util/include/asserts.h"
17+ #include " test/util/include/current_test_name.h"
1718#include " test/util/include/default_providers.h"
1819#include " test/util/include/inference_session_wrapper.h"
1920#include " test/util/include/test/test_environment.h"
@@ -36,10 +37,6 @@ using namespace ::onnxruntime::logging;
3637namespace onnxruntime {
3738namespace test {
3839
39- #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD)
40-
41- #endif // !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD)
42-
4340#if !defined(ORT_MINIMAL_BUILD)
4441
4542// Since NNAPI EP handles Reshape and Flatten differently,
@@ -65,7 +62,8 @@ TEST(NnapiExecutionProviderTest, ReshapeFlattenTest) {
6562 feeds.insert (std::make_pair (" X" , ml_value_x));
6663 feeds.insert (std::make_pair (" Y" , ml_value_y));
6764
68- RunAndVerifyOutputsWithEP (model_file_name, " NnapiExecutionProviderTest.ReshapeFlattenTest" ,
65+ RunAndVerifyOutputsWithEP (model_file_name,
66+ CurrentTestName (),
6967 std::make_unique<NnapiExecutionProvider>(0 ),
7068 feeds);
7169#else
@@ -88,7 +86,8 @@ TEST(NnapiExecutionProviderTest, SigmoidSupportedInputRankTest) {
8886 NameMLValMap feeds;
8987 feeds.insert (std::make_pair (" X" , ml_value_x));
9088
91- RunAndVerifyOutputsWithEP (model_file_name, " NnapiExecutionProviderTest.SigmoidSupportedInputRankTest" ,
89+ RunAndVerifyOutputsWithEP (model_file_name,
90+ CurrentTestName (),
9291 std::make_unique<NnapiExecutionProvider>(0 ),
9392 feeds, {ExpectedEPNodeAssignment::None} /* params */ );
9493#else
@@ -115,7 +114,8 @@ TEST(NnapiExecutionProviderTest, DynamicGraphInputTest) {
115114 NameMLValMap feeds;
116115 feeds.insert (std::make_pair (" X" , ml_value_x));
117116
118- RunAndVerifyOutputsWithEP (model_file_name, " NnapiExecutionProviderTest.DynamicGraphInputTest" ,
117+ RunAndVerifyOutputsWithEP (model_file_name,
118+ CurrentTestName (),
119119 std::make_unique<NnapiExecutionProvider>(0 ),
120120 feeds);
121121#else
@@ -144,7 +144,8 @@ TEST(NnapiExecutionProviderTest, InternalUint8SupportTest) {
144144 NameMLValMap feeds;
145145 feeds.insert (std::make_pair (" X" , ml_value_x));
146146
147- RunAndVerifyOutputsWithEP (model_file_name, " NnapiExecutionProviderTest.InternalUint8SupportTest" ,
147+ RunAndVerifyOutputsWithEP (model_file_name,
148+ CurrentTestName (),
148149 std::make_unique<NnapiExecutionProvider>(0 ),
149150 feeds);
150151#else
@@ -208,7 +209,8 @@ TEST(NnapiExecutionProviderTest, FunctionTest) {
208209 feeds.insert (std::make_pair (" Y" , ml_value_y));
209210 feeds.insert (std::make_pair (" Z" , ml_value_z));
210211
211- RunAndVerifyOutputsWithEP (model_file_name, " NnapiExecutionProviderTest.FunctionTest" ,
212+ RunAndVerifyOutputsWithEP (model_file_name,
213+ CurrentTestName (),
212214 std::make_unique<NnapiExecutionProvider>(0 ),
213215 feeds);
214216#else
@@ -273,7 +275,8 @@ static void RunQDQModelTest(
273275 const auto model_data_span = AsByteSpan (model_data.data (), model_data.size ());
274276
275277#if defined(__ANDROID__)
276- RunAndVerifyOutputsWithEP (model_data_span, " NnapiExecutionProviderTest.TestQDQModel" ,
278+ RunAndVerifyOutputsWithEP (model_data_span,
279+ CurrentTestName (),
277280 std::make_unique<NnapiExecutionProvider>(0 ),
278281 helper.feeds_ , params);
279282#else
@@ -513,6 +516,31 @@ TEST(NnapiExecutionProviderTest, TestGather) {
513516 {ExpectedEPNodeAssignment::All});
514517}
515518
519+ TEST (NnapiExecutionProviderTest, SharedInitializersDoNotGetSkipped) {
520+ // NNAPI EP's Clip op builder will mark the max initializer as skipped but it is also used by the Div op.
521+ // Test that the shared initializer is still present in the NNAPI model for the Div op.
522+ constexpr auto * model_file_name = ORT_TSTR (" testdata/clip_div_shared_initializer.onnx" );
523+
524+ #if defined(__ANDROID__)
525+ AllocatorPtr cpu_allocator = std::make_shared<CPUAllocator>();
526+
527+ std::vector<int64_t > x_dims{3 , 2 };
528+ std::vector<float > x_values (3 .0f , 3 * 2 );
529+ OrtValue ml_value_x;
530+ CreateMLValue<float >(cpu_allocator, x_dims, x_values, &ml_value_x);
531+
532+ NameMLValMap feeds{{" input_0" , ml_value_x}};
533+
534+ RunAndVerifyOutputsWithEP (model_file_name,
535+ CurrentTestName (),
536+ std::make_unique<NnapiExecutionProvider>(0 ),
537+ feeds,
538+ {ExpectedEPNodeAssignment::All});
539+ #else
540+ TestModelLoad (model_file_name, std::make_unique<NnapiExecutionProvider>(0 ), ExpectedEPNodeAssignment::All);
541+ #endif
542+ }
543+
516544#endif // !(ORT_MINIMAL_BUILD)
517545
518546TEST (NnapiExecutionProviderTest, NNAPIFlagsTest) {
@@ -541,7 +569,8 @@ TEST(NnapiExecutionProviderTest, TestOrtFormatModel) {
541569 NameMLValMap feeds;
542570 feeds.insert (std::make_pair (" Input3" , ml_value));
543571
544- RunAndVerifyOutputsWithEP (model_file_name, " NnapiExecutionProviderTest.TestOrtFormatModel" ,
572+ RunAndVerifyOutputsWithEP (model_file_name,
573+ CurrentTestName (),
545574 std::make_unique<NnapiExecutionProvider>(0 ),
546575 feeds);
547576#else
0 commit comments