From 4962252c8ff3f4f3fa77e981d48290d8fa0c109f Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Wed, 4 Sep 2024 01:02:00 +0800 Subject: [PATCH] Enable xnnpack ep works in current windows xnn ci (#21951) ### Description The EP wasn't added in session option in onnxruntime_test_all. ### Motivation and Context After this PR onnxruntime_test_all --gtest_filter=\*xnnpack\*maxpool\* can step into https://github.com/microsoft/onnxruntime/blob/8c5336449d2279c0394cc4a742d336d7f3bd4124/onnxruntime/core/providers/xnnpack/nn/max_pool.cc#L209 --------- Co-authored-by: Yi Zhang --- onnxruntime/test/providers/cpu/model_tests.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/onnxruntime/test/providers/cpu/model_tests.cc b/onnxruntime/test/providers/cpu/model_tests.cc index 23867f2c7c..a5015c18ce 100644 --- a/onnxruntime/test/providers/cpu/model_tests.cc +++ b/onnxruntime/test/providers/cpu/model_tests.cc @@ -261,6 +261,11 @@ TEST_P(ModelTest, Run) { else if (provider_name == "armnn") { ASSERT_ORT_STATUS_OK(OrtSessionOptionsAppendExecutionProvider_ArmNN(ortso)); } +#endif +#ifdef USE_XNNPACK + else if (provider_name == "xnnpack") { + ortso.AppendExecutionProvider("XNNPACK"); + } #endif OrtSession* ort_session; OrtStatus* ort_st = OrtApis::CreateSession(*ort_env, model_path.c_str(), ortso, &ort_session); @@ -425,6 +430,9 @@ static constexpr ORT_STRING_VIEW provider_name_acl = ORT_TSTR("acl"); #ifdef USE_ARMNN static constexpr ORT_STRING_VIEW provider_name_armnn = ORT_TSTR("armnn"); #endif +#ifdef USE_XNNPACK +static constexpr ORT_STRING_VIEW provider_name_xnnpack = ORT_TSTR("xnnpack"); +#endif static constexpr ORT_STRING_VIEW provider_name_dml = ORT_TSTR("dml"); ::std::vector<::std::basic_string> GetParameterStrings() { @@ -472,6 +480,9 @@ static constexpr ORT_STRING_VIEW provider_name_dml = ORT_TSTR("dml"); #ifdef USE_DML provider_names[provider_name_dml] = {opset7, opset8, opset9, opset10, opset11, opset12, opset13, opset14, opset15, opset16, opset17, opset18}; #endif +#ifdef USE_XNNPACK + provider_names[provider_name_xnnpack] = {opset12, opset13, opset14, opset15, opset16, opset17, opset18}; +#endif #if defined(ENABLE_TRAINING_CORE) && defined(USE_CUDA) // Removing the CPU EP tests from CUDA build for training as these tests are already run in the CPU pipelines.