@@ -334,35 +334,44 @@ TEST(GatherNDOpTest, GatherND_slice_int64_t) {
334334TEST(GatherNDOpTest, GatherND_batch_dims_mismatch_error) {
335335 OpTester test("GatherND", 12, kOnnxDomain);
336336 test.AddAttribute<int64_t>("batch_dims", 1);
337+
337338 // Input has 3 batches, but indices has 2 slices (indices batch size 2), which is not divisible by 3 - mismatch!
338339 test.AddInput<float>("data", {3, 3}, {0.f, 1.f, 2.f, 10.f, 11.f, 12.f, 20.f, 21.f, 22.f});
339340 test.AddInput<int64_t>("indices", {2, 1}, {1, 2});
340341 test.AddOutput<float>("output", {2}, {0.f, 0.f}); // dummy output, won't be used
341- // Run only on CPU provider since validation logic is CPU-specific
342+
343+ // Force execution only on CPU
344+ std::vector<std::unique_ptr<onnxruntime::IExecutionProvider>> cpu_only_ep;
345+ cpu_only_ep.push_back(DefaultCpuExecutionProvider());
346+
342347 test.Run(OpTester::ExpectResult::kExpectFailure,
343348 "GatherND: indices batch size (2) is not divisible by input batch size (3)",
344- std::unordered_set<std::string>({kCudaExecutionProvider, kDnnlExecutionProvider,
345- kOpenVINOExecutionProvider, kTensorrtExecutionProvider,
346- kQnnExecutionProvider, kDmlExecutionProvider,
347- kWebGpuExecutionProvider}));
349+ {}, // no excluded providers needed
350+ nullptr, // no RunOptions
351+ &cpu_only_ep); // force CPU
348352}
349353
350354// Test for issue #23828: GatherND should return error when input batch dimension is zero
351355TEST(GatherNDOpTest, GatherND_zero_batch_dims_error) {
352356 OpTester test("GatherND", 12, kOnnxDomain);
353357 test.AddAttribute<int64_t>("batch_dims", 1);
358+
354359 // Input has 0 batches - should fail with clear error instead of division by zero
355360 test.AddInput<float>("data", {0, 3}, {});
356361 test.AddInput<int64_t>("indices", {2, 1}, {1, 2});
357362 test.AddOutput<float>("output", {2}, {0.f, 0.f}); // dummy output, won't be used
358- // Run only on CPU provider since validation logic is CPU-specific
363+
364+ // Force execution only on CPU
365+ std::vector<std::unique_ptr<onnxruntime::IExecutionProvider>> cpu_only_ep;
366+ cpu_only_ep.push_back(DefaultCpuExecutionProvider());
367+
359368 test.Run(OpTester::ExpectResult::kExpectFailure,
360369 "GatherND: input tensor batch dimensions cannot be zero",
361- std::unordered_set<std::string>({kCudaExecutionProvider, kDnnlExecutionProvider,
362- kOpenVINOExecutionProvider, kTensorrtExecutionProvider,
363- kQnnExecutionProvider, kDmlExecutionProvider,
364- kWebGpuExecutionProvider}));
370+ {},
371+ nullptr,
372+ &cpu_only_ep); // force CPU
365373}
366374
375+
367376} // namespace test
368377} // namespace onnxruntime
0 commit comments