diff --git a/onnxruntime/test/framework/inference_session_test.cc b/onnxruntime/test/framework/inference_session_test.cc index 3083c0ccfd..715a122de7 100644 --- a/onnxruntime/test/framework/inference_session_test.cc +++ b/onnxruntime/test/framework/inference_session_test.cc @@ -1553,7 +1553,7 @@ TEST(InferenceSessionTests, Test3LayerNestedSubgraph) { so.session_logid = "InferenceSessionTests.Test3LayerNestedSubgraph"; InferenceSession session_object{so, GetEnvironment()}; -#if USE_TENSORRT +#if defined(_WIN32) && defined(USE_TENSORRT) ASSERT_STATUS_OK(session_object.RegisterExecutionProvider(DefaultTensorrtExecutionProvider())); #elif USE_CUDA ASSERT_STATUS_OK(session_object.RegisterExecutionProvider(DefaultCudaExecutionProvider())); @@ -1591,7 +1591,7 @@ TEST(InferenceSessionTests, Test3LayerNestedSubgraph) { ASSERT_TRUE(status.IsOK()); VerifyOutputs(fetches, expected_dims, expected_values); -#if USE_TENSORRT +#if defined(_WIN32) && defined(USE_TENSORRT) // previous run with graph being optimized, one of If node’s both subgraphs become empty, so TRT EP won’t assign this If node to TRT and later ORT assign it to CUDA. // we also want to test graph not being optimized and TRT EP should also be able to run it and make the whole graph run on TRT. so.graph_optimization_level = TransformerLevel::Default; @@ -1705,7 +1705,7 @@ TEST(InferenceSessionTests, Test2LayerNestedSubgraph) { so.session_logid = "InferenceSessionTests.Test2LayerNestedSubgraph"; InferenceSession session_object{so, GetEnvironment()}; -#if USE_TENSORRT +#if defined(_WIN32) && defined(USE_TENSORRT) ASSERT_STATUS_OK(session_object.RegisterExecutionProvider(DefaultTensorrtExecutionProvider())); #elif USE_CUDA ASSERT_STATUS_OK(session_object.RegisterExecutionProvider(DefaultCudaExecutionProvider()));