Skip to content

Commit b0fc907

Browse files
Copilotfs-eire
andcommitted
Fix ConfigEps execution provider ordering in test files
When BaseTester::ConfigEps() is called with multiple EPs, it runs the first available EP for the given operator. CPU EP should be added last to ensure other EPs get tested first. Files fixed: - matmul_2bits_test.cc: Move CPU EP after WebGPU EP - skiplayernorm_op_test.cc: Move CPU EP after WebGPU EP - gather_op_test.cc: Move CPU EP after CUDA EP (4 test cases) Co-authored-by: fs-eire <7679871+fs-eire@users.noreply.github.com>
1 parent 8aed61e commit b0fc907

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

onnxruntime/test/contrib_ops/matmul_2bits_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,11 @@ void RunTest2Bits(const TestOptions2Bits& opts) {
197197

198198
std::vector<std::unique_ptr<IExecutionProvider>> execution_providers;
199199
if constexpr (std::is_same<T1, float>::value) {
200-
execution_providers.emplace_back(DefaultCpuExecutionProvider());
201200
#ifdef USE_WEBGPU
202201
execution_providers.push_back(DefaultWebGpuExecutionProvider());
203202
#endif
203+
// CPU EP should be added last so that other EPs get tested first
204+
execution_providers.emplace_back(DefaultCpuExecutionProvider());
204205
test.ConfigEps(std::move(execution_providers));
205206
test.RunWithConfig();
206207
}

onnxruntime/test/contrib_ops/skiplayernorm_op_test.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,14 @@ static void RunOneTest(
9494
sum_output_data);
9595
}
9696

97-
if (cpu_ep != nullptr) {
98-
execution_providers.push_back(DefaultCpuExecutionProvider());
99-
}
97+
// Add WebGPU EP first so it gets tested before CPU EP
98+
// (ConfigEps runs the first available EP for the operator)
10099
if (webgpu_ep != nullptr) {
101100
execution_providers.push_back(DefaultWebGpuExecutionProvider());
102101
}
102+
if (cpu_ep != nullptr) {
103+
execution_providers.push_back(DefaultCpuExecutionProvider());
104+
}
103105

104106
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {}, nullptr, &execution_providers);
105107
} else if (CudaHasBF16Support() && use_bfloat16) {

onnxruntime/test/providers/cpu/tensor/gather_op_test.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,12 @@ TEST(GatherOpTest, Gather_axis1_scalar_indices) {
434434

435435
TEST(ShrunkenGatherOpTest, ShrunkenGather_PositiveAxis) {
436436
std::vector<std::unique_ptr<IExecutionProvider>> execution_providers;
437-
execution_providers.emplace_back(DefaultCpuExecutionProvider());
437+
// Add CUDA EP first so it gets tested before CPU EP
438+
// (ConfigEps runs the first available EP for the operator)
438439
#ifdef USE_CUDA
439440
execution_providers.emplace_back(DefaultCudaExecutionProvider());
440441
#endif
442+
execution_providers.emplace_back(DefaultCpuExecutionProvider());
441443

442444
OpTester test("ShrunkenGather", 1, onnxruntime::kMSDomain);
443445
test.AddAttribute<int64_t>("axis", 0LL);
@@ -455,10 +457,12 @@ TEST(ShrunkenGatherOpTest, ShrunkenGather_PositiveAxis) {
455457

456458
TEST(ShrunkenGatherOpTest, ShrunkenGather_NegativeAxis) {
457459
std::vector<std::unique_ptr<IExecutionProvider>> execution_providers;
458-
execution_providers.emplace_back(DefaultCpuExecutionProvider());
460+
// Add CUDA EP first so it gets tested before CPU EP
461+
// (ConfigEps runs the first available EP for the operator)
459462
#ifdef USE_CUDA
460463
execution_providers.emplace_back(DefaultCudaExecutionProvider());
461464
#endif
465+
execution_providers.emplace_back(DefaultCpuExecutionProvider());
462466

463467
OpTester test("ShrunkenGather", 1, onnxruntime::kMSDomain);
464468
test.AddAttribute<int64_t>("axis", -1LL);
@@ -476,10 +480,12 @@ TEST(ShrunkenGatherOpTest, ShrunkenGather_NegativeAxis) {
476480

477481
TEST(ShrunkenGatherOpTest, ShrunkenGather_InvalidIndicesRank) {
478482
std::vector<std::unique_ptr<IExecutionProvider>> execution_providers;
479-
execution_providers.emplace_back(DefaultCpuExecutionProvider());
483+
// Add CUDA EP first so it gets tested before CPU EP
484+
// (ConfigEps runs the first available EP for the operator)
480485
#ifdef USE_CUDA
481486
execution_providers.emplace_back(DefaultCudaExecutionProvider());
482487
#endif
488+
execution_providers.emplace_back(DefaultCpuExecutionProvider());
483489

484490
OpTester test("ShrunkenGather", 1, onnxruntime::kMSDomain);
485491
test.AddAttribute<int64_t>("axis", 0LL);
@@ -497,10 +503,12 @@ TEST(ShrunkenGatherOpTest, ShrunkenGather_InvalidIndicesRank) {
497503

498504
TEST(ShrunkenGatherOpTest, ShrunkenGather_InvalidInputRank) {
499505
std::vector<std::unique_ptr<IExecutionProvider>> execution_providers;
500-
execution_providers.emplace_back(DefaultCpuExecutionProvider());
506+
// Add CUDA EP first so it gets tested before CPU EP
507+
// (ConfigEps runs the first available EP for the operator)
501508
#ifdef USE_CUDA
502509
execution_providers.emplace_back(DefaultCudaExecutionProvider());
503510
#endif
511+
execution_providers.emplace_back(DefaultCpuExecutionProvider());
504512

505513
OpTester test("ShrunkenGather", 1, onnxruntime::kMSDomain);
506514
test.AddAttribute<int64_t>("axis", 0LL);

0 commit comments

Comments
 (0)