From 1a4832a5d8d4d4a3ad0388b6d9b8f7fcc98afe7d Mon Sep 17 00:00:00 2001 From: Bruce Date: Mon, 25 Aug 2025 11:12:43 -0700 Subject: [PATCH 1/2] Add util runAndValidate() --- tests/cpp/utils.cpp | 12 ++++++++++++ tests/cpp/utils.h | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/tests/cpp/utils.cpp b/tests/cpp/utils.cpp index 8fd2fefcbda..3bac08d2559 100644 --- a/tests/cpp/utils.cpp +++ b/tests/cpp/utils.cpp @@ -18,6 +18,7 @@ #include #include #include +#include namespace nvfuser { @@ -119,6 +120,17 @@ CGResultsPackage scheduleAndRun( return results; } +void runAndValidate( + Fusion* fusion, + SchedulerType scheduler_type, + const KernelArgumentHolder& runtime_inputs, + int line_number, + const char* file_name) { + auto cg_outputs = + scheduleAndRun(fusion, scheduler_type, runtime_inputs).outputs; + testValidate(fusion, cg_outputs, runtime_inputs, line_number, file_name); +} + int64_t prime_number(int64_t i) { static std::vector p{ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, diff --git a/tests/cpp/utils.h b/tests/cpp/utils.h index 3da180ab664..86b5be3091c 100644 --- a/tests/cpp/utils.h +++ b/tests/cpp/utils.h @@ -66,6 +66,13 @@ inline torch::jit::Stack createStack(std::vector&& list) { std::make_move_iterator(list.end())); } +void runAndValidate( + Fusion* fusion, + SchedulerType scheduler_type, + const KernelArgumentHolder& runtime_inputs, + int line_number, + const char* file_name); + // Make a tensor that is known to be fully contiguous of dimensionality=ndims, // but unknown sizes inline TensorView* makeContigTensor( From 3b53e4d643fe551b46454665a7b0b748e2d72ae6 Mon Sep 17 00:00:00 2001 From: Bruce Date: Mon, 25 Aug 2025 11:13:17 -0700 Subject: [PATCH 2/2] Start using runAndValidate --- tests/cpp/test_gpu2.cpp | 36 ++++++++---------- tests/cpp/test_gpu3.cpp | 10 ++--- tests/cpp/test_indexing_advanced.cpp | 10 ++--- tests/cpp/test_pointwise.cpp | 26 ++++++------- tests/cpp/test_reshape.cpp | 55 +++++++++++---------------- tests/cpp/test_resize.cpp | 26 +++++-------- tests/cpp/test_transpose.cpp | 57 +++++++++++++--------------- 7 files changed, 93 insertions(+), 127 deletions(-) diff --git a/tests/cpp/test_gpu2.cpp b/tests/cpp/test_gpu2.cpp index ac38788b3ab..0ce0c5917e0 100644 --- a/tests/cpp/test_gpu2.cpp +++ b/tests/cpp/test_gpu2.cpp @@ -684,8 +684,8 @@ TEST_F(NVFuserTest, FusionLSTMCell_CUDA) { auto at_cx = at::randn({batch_size, hidden_features}, options); inputs.push(at_cx); - auto cg_outputs = scheduleAndRun(&fusion, SchedulerType::PointWise, inputs); - testValidate(&fusion, cg_outputs.outputs, inputs, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {inputs}, __LINE__, __FILE__); } TEST_F(NVFuserTest, FusionReductionHalf_CUDA) { @@ -896,8 +896,8 @@ TEST_F(NVFuserTest, FusionTrivialReduction2_CUDA) { at::Tensor t0 = at::randn({y, z}, options); at::Tensor t1 = at::randn({w, x, y, z}, options); - auto cg_outputs = scheduleAndRun(&fusion, SchedulerType::PointWise, {t0, t1}); - testValidate(&fusion, cg_outputs.outputs, {t0, t1}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {t0, t1}, __LINE__, __FILE__); } TEST_F(NVFuserTest, FusionTrivialReduction3_CUDA) { @@ -920,8 +920,8 @@ TEST_F(NVFuserTest, FusionTrivialReduction3_CUDA) { at::Tensor t0 = at::randn({y, z}, options); at::Tensor t1 = at::randn({v, w, x, y, z}, options); - auto cg_outputs = scheduleAndRun(&fusion, SchedulerType::PointWise, {t0, t1}); - testValidate(&fusion, cg_outputs.outputs, {t0, t1}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {t0, t1}, __LINE__, __FILE__); } TEST_F(NVFuserTest, FusionInputsIdLookup_CUDA) { @@ -1146,10 +1146,12 @@ TEST_F(NVFuserTest, FusionBiasGeluFwd_CUDA) { auto at_input = at::randn(input_shape, options); auto at_bias = at::randn(bias_shape, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {at_bias, at_input}); - testValidate( - &fusion, cg_outputs.outputs, {at_bias, at_input}, __LINE__, __FILE__); + runAndValidate( + &fusion, + SchedulerType::PointWise, + {at_bias, at_input}, + __LINE__, + __FILE__); } TEST_F(NVFuserTest, FusionBiasGeluBwd_CUDA) { @@ -3699,9 +3701,7 @@ TEST_F(NVFuserTest, FusionSBAR_CUDA) { // inputs KernelArgumentHolder inputs = {at_x, at_y, at_weight, at_bias}; - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, inputs).outputs; - testValidate(&fusion, cg_outputs, inputs, __LINE__, __FILE__); + runAndValidate(&fusion, SchedulerType::PointWise, inputs, __LINE__, __FILE__); } TEST_F(NVFuserTest, FusionSingleElement_CUDA) { @@ -3718,9 +3718,7 @@ TEST_F(NVFuserTest, FusionSingleElement_CUDA) { auto options = at::TensorOptions().dtype(at::kFloat).device(at::kCUDA, 0); at::Tensor t0 = at::randn({}, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {t0}).outputs; - testValidate(&fusion, cg_outputs, {t0}, __LINE__, __FILE__); + runAndValidate(&fusion, SchedulerType::PointWise, {t0}, __LINE__, __FILE__); } TEST_F(NVFuserTest, FusionBNBackwardRepro_CUDA) { @@ -5630,10 +5628,8 @@ TEST_F(NVFuserTest, FusionPointwiseBroadcast_CUDA) { at::Tensor at_x = at::randn(input_shape, options); at::Tensor at_bias = at::randn(input_shape, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {at_x, at_bias}); - testValidate( - &fusion, cg_outputs.outputs, {at_x, at_bias}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {at_x, at_bias}, __LINE__, __FILE__); } TEST_F(NVFuserTest, FusionPointwiseVectorize_CUDA) { diff --git a/tests/cpp/test_gpu3.cpp b/tests/cpp/test_gpu3.cpp index 82554df6ff6..31af668c18e 100644 --- a/tests/cpp/test_gpu3.cpp +++ b/tests/cpp/test_gpu3.cpp @@ -3583,9 +3583,8 @@ TEST_F( at::Tensor t0 = at::randn({100, 100, 10}, options); at::Tensor t1 = at::randn({10, 20}, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {t0, t1}).outputs; - testValidate(&fusion, cg_outputs, {t0, t1}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {t0, t1}, __LINE__, __FILE__); } TEST_F(NVFuserTest, FusionPrint_CUDA) { @@ -8350,9 +8349,8 @@ TEST_F(NVFuserTest, MoveNonConcretizedBroadcastInPointwise) { at::Tensor input0 = at::randn({1024}, options); at::Tensor t1 = at::randn({1024}, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {input0, t1}).outputs; - testValidate(&fusion, cg_outputs, {input0, t1}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {input0, t1}, __LINE__, __FILE__); // tv2 and tv3 have non-concretized broadcasts. Make sure they are // moved to the innermost position of the loop domain diff --git a/tests/cpp/test_indexing_advanced.cpp b/tests/cpp/test_indexing_advanced.cpp index 610844ffc96..8c5620c8144 100644 --- a/tests/cpp/test_indexing_advanced.cpp +++ b/tests/cpp/test_indexing_advanced.cpp @@ -191,9 +191,8 @@ TEST_P(AdvancedIndexingTest, 3) { at::Tensor t0 = at::randn({x, y, z}, options); at::Tensor t1 = at::randn({w, x, y, z}, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {t0, t1}).outputs; - testValidate(&fusion, cg_outputs, {t0, t1}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {t0, t1}, __LINE__, __FILE__); } // Same as 3 but use 3 dimensions and concrete sizes @@ -410,9 +409,8 @@ TEST_P(AdvancedIndexingTest, 9) { auto t0 = at::randn({numel_y}, options); auto t3 = at::randn({numel_x, numel_y, numel_z}, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {t0, t3}).outputs; - testValidate(&fusion, cg_outputs, {t0, t3}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {t0, t3}, __LINE__, __FILE__); } TEST_P(AdvancedIndexingTest, 10) { diff --git a/tests/cpp/test_pointwise.cpp b/tests/cpp/test_pointwise.cpp index c0c7b6d0cb1..6773f9ce427 100644 --- a/tests/cpp/test_pointwise.cpp +++ b/tests/cpp/test_pointwise.cpp @@ -935,8 +935,7 @@ TEST_F(PointwiseTest, DomainMapTestEg0) { auto options = at::TensorOptions().dtype(at::kFloat).device(at::kCUDA, 0); at::Tensor t0 = at::randn({4, 7}, options); // NOTE force pointwise scheduler here for unit test - auto cg_results = scheduleAndRun(fusion, SchedulerType::PointWise, {t0}); - testValidate(fusion, cg_results.outputs, {t0}, __LINE__, __FILE__); + runAndValidate(fusion, SchedulerType::PointWise, {t0}, __LINE__, __FILE__); } TEST_F(PointwiseTest, DomainMapTestEg1) { @@ -978,8 +977,8 @@ TEST_F(PointwiseTest, DomainMapTestEg1) { at::Tensor t0 = at::randn({2, 4}, options); at::Tensor t1 = at::randn({3, 2, 4}, options); // NOTE force pointwise scheduler here for unit test - auto cg_results = scheduleAndRun(fusion, SchedulerType::PointWise, {t0, t1}); - testValidate(fusion, cg_results.outputs, {t0, t1}, __LINE__, __FILE__); + runAndValidate( + fusion, SchedulerType::PointWise, {t0, t1}, __LINE__, __FILE__); } TEST_F(PointwiseTest, DomainMapTestEg2) { @@ -1021,8 +1020,7 @@ TEST_F(PointwiseTest, DomainMapTestEg2) { auto options = at::TensorOptions().dtype(at::kFloat).device(at::kCUDA, 0); at::Tensor t0 = at::randn({4, 7}, options); // NOTE force pointwise scheduler here for unit test - auto cg_results = scheduleAndRun(fusion, SchedulerType::PointWise, {t0}); - testValidate(fusion, cg_results.outputs, {t0}, __LINE__, __FILE__); + runAndValidate(fusion, SchedulerType::PointWise, {t0}, __LINE__, __FILE__); } TEST_F(PointwiseTest, DomainMapFactory) { @@ -1185,8 +1183,8 @@ TEST_F(PointwiseTest, DomainMapPad0) { at::Tensor t0 = at::empty_strided({1, 5}, {5, 1}, options); at::Tensor t1 = at::empty_strided({7, 1, 5}, {5, 5, 1}, options); // NOTE force pointwise scheduler here for unit test - auto cg_results = scheduleAndRun(fusion, SchedulerType::PointWise, {t0, t1}); - testValidate(fusion, cg_results.outputs, {t0, t1}, __LINE__, __FILE__); + runAndValidate( + fusion, SchedulerType::PointWise, {t0, t1}, __LINE__, __FILE__); } TEST_F(PointwiseTest, DomainMapPad1) { @@ -1234,8 +1232,8 @@ TEST_F(PointwiseTest, DomainMapPad1) { at::Tensor t0 = at::empty_strided({1, 5}, {5, 1}, options); at::Tensor t1 = at::empty_strided({2, 3, 4, 1}, {12, 4, 1, 1}, options); // NOTE force pointwise scheduler here for unit test - auto cg_results = scheduleAndRun(fusion, SchedulerType::PointWise, {t0, t1}); - testValidate(fusion, cg_results.outputs, {t0, t1}, __LINE__, __FILE__); + runAndValidate( + fusion, SchedulerType::PointWise, {t0, t1}, __LINE__, __FILE__); } TEST_F(PointwiseTest, DomainMapSlice0) { @@ -1281,8 +1279,8 @@ TEST_F(PointwiseTest, DomainMapSlice0) { at::Tensor t0 = at::randn({2, 4}, options); at::Tensor t1 = at::randn({2, 4}, options); // NOTE force pointwise scheduler here for unit test - auto cg_results = scheduleAndRun(fusion, SchedulerType::PointWise, {t0, t1}); - testValidate(fusion, cg_results.outputs, {t0, t1}, __LINE__, __FILE__); + runAndValidate( + fusion, SchedulerType::PointWise, {t0, t1}, __LINE__, __FILE__); } TEST_F(PointwiseTest, DomainMapSlice1) { @@ -1328,8 +1326,8 @@ TEST_F(PointwiseTest, DomainMapSlice1) { at::Tensor t0 = at::randn({2, 2, 4}, options); at::Tensor t1 = at::randn({2, 4}, options); // NOTE force pointwise scheduler here for unit test - auto cg_results = scheduleAndRun(fusion, SchedulerType::PointWise, {t0, t1}); - testValidate(fusion, cg_results.outputs, {t0, t1}, __LINE__, __FILE__); + runAndValidate( + fusion, SchedulerType::PointWise, {t0, t1}, __LINE__, __FILE__); } TEST_F(NVFuserTest, DomainMapBroadcastIssue3653) { diff --git a/tests/cpp/test_reshape.cpp b/tests/cpp/test_reshape.cpp index 7418e4b6ae0..aa4461baffe 100644 --- a/tests/cpp/test_reshape.cpp +++ b/tests/cpp/test_reshape.cpp @@ -79,10 +79,8 @@ TEST_F(ReshapeTest, ViewDtypeSameSizeOutput) { at::Tensor at_x = at::randn(input_shape, options); at::Tensor at_bias = at::randn(input_shape, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {at_x, at_bias}) - .outputs; - testValidate(&fusion, cg_outputs, {at_x, at_bias}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {at_x, at_bias}, __LINE__, __FILE__); } TEST_F(ReshapeTest, ViewDtypeFailMismatchSize) { @@ -193,10 +191,8 @@ TEST_F(ReshapeTest, ReshapeOutput) { at::Tensor at_x = at::randn(input_shape, options); at::Tensor at_bias = at::randn(input_shape, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {at_x, at_bias}) - .outputs; - testValidate(&fusion, cg_outputs, {at_x, at_bias}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {at_x, at_bias}, __LINE__, __FILE__); } TEST_F(ReshapeTest, ReshapeFailMismatchSize) { @@ -506,10 +502,8 @@ void addViewGeluFusion( at::Tensor at_x = at::randn(input_shape, options); at::Tensor at_bias = at::randn(input_shape, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {at_x, at_bias}) - .outputs; - testValidate(&fusion, cg_outputs, {at_x, at_bias}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {at_x, at_bias}, __LINE__, __FILE__); } } @@ -572,10 +566,8 @@ void geluViewAddFusion( at::Tensor at_x = at::randn(inferred_input, options); at::Tensor at_bias = at::randn(inferred_output, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {at_x, at_bias}) - .outputs; - testValidate(&fusion, cg_outputs, {at_x, at_bias}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {at_x, at_bias}, __LINE__, __FILE__); } } @@ -612,10 +604,8 @@ void geluViewBinaryAddFusion( at::Tensor at_x = at::randn(input_shape1, options); at::Tensor at_bias = at::randn(input_shape2, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {at_x, at_bias}) - .outputs; - testValidate(&fusion, cg_outputs, {at_x, at_bias}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {at_x, at_bias}, __LINE__, __FILE__); } } @@ -1213,9 +1203,8 @@ TEST_F(ReshapeTest, ReshapeVectorize) { at::Tensor input = at::randn({256, 256, 256}, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {input}).outputs; - testValidate(&fusion, cg_outputs, {input}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {input}, __LINE__, __FILE__); auto hasVectorization = [](TensorView* tv) -> bool { for (auto i : tv->getLoopDomain()) { @@ -2203,9 +2192,8 @@ TEST_F(ReshapeTest, ReshapeZeroDimInput) { at::Tensor at_y = at::randn({2, 3, 4}).to(options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {at_x, at_y}).outputs; - testValidate(&fusion, cg_outputs, {at_x, at_y}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {at_x, at_y}, __LINE__, __FILE__); } TEST_F(ReshapeTest, ReshapeZeroDimOutput) { @@ -2236,10 +2224,12 @@ TEST_F(ReshapeTest, ReshapeZeroDimOutput) { at::randn({1}).to(options)[0]; // indexing to get zero-dim tensor NVF_ERROR(at_z.ndimension() == 0); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {at_x, at_y, at_z}) - .outputs; - testValidate(&fusion, cg_outputs, {at_x, at_y, at_z}, __LINE__, __FILE__); + runAndValidate( + &fusion, + SchedulerType::PointWise, + {at_x, at_y, at_z}, + __LINE__, + __FILE__); } TEST_F(ReshapeTest, ReshapeZeroDimInputOutput) { @@ -2266,9 +2256,8 @@ TEST_F(ReshapeTest, ReshapeZeroDimInputOutput) { at::Tensor at_y = at::randn({1}).to(options)[0]; NVF_ERROR(at_x.ndimension() == 0 && at_y.ndimension() == 0); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {at_x, at_y}).outputs; - testValidate(&fusion, cg_outputs, {at_x, at_y}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {at_x, at_y}, __LINE__, __FILE__); } TEST_F(ReshapeTest, ReshapeOfReshape) { diff --git a/tests/cpp/test_resize.cpp b/tests/cpp/test_resize.cpp index b879a7f6345..28b0f21e2d8 100644 --- a/tests/cpp/test_resize.cpp +++ b/tests/cpp/test_resize.cpp @@ -5824,8 +5824,7 @@ TEST_F(ResizeTest, VectorizeInnermostWithReshapeSplit) { auto options = at::TensorOptions().dtype(at::kFloat).device(at::kCUDA, 0); auto t0 = at::randn(shape1, options); - auto outputs = scheduleAndRun(&fusion, SchedulerType::Resize, {t0}); - testValidate(&fusion, outputs.outputs, {t0}, __LINE__, __FILE__); + runAndValidate(&fusion, SchedulerType::Resize, {t0}, __LINE__, __FILE__); // Should be vector by a factor of 2 because the resize scheduler // only uses the innermost logical ID, and the extent of the output @@ -5866,8 +5865,7 @@ TEST_F(ResizeTest, VectorizeInnermostWithReshapeMerge) { auto options = at::TensorOptions().dtype(at::kFloat).device(at::kCUDA, 0); auto t0 = at::randn(shape1, options); - auto outputs = scheduleAndRun(&fusion, SchedulerType::Resize, {t0}); - testValidate(&fusion, outputs.outputs, {t0}, __LINE__, __FILE__); + runAndValidate(&fusion, SchedulerType::Resize, {t0}, __LINE__, __FILE__); // Should be vector by a factor of 4. If the reshape were canceled, // it should have been 2, but in this case since it involves the @@ -5981,8 +5979,7 @@ TEST_F(ResizeTest, VectorizeInnerSliceMultiplePaths) { auto options = at::TensorOptions().dtype(at::kFloat).device(at::kCUDA, 0); auto t0 = at::randn({size}, options); - auto outputs = scheduleAndRun(&fusion, SchedulerType::Resize, {t0}); - testValidate(&fusion, outputs.outputs, {t0}, __LINE__, __FILE__); + runAndValidate(&fusion, SchedulerType::Resize, {t0}, __LINE__, __FILE__); // Should be vector by a factor of 2 because of the tv3 slice. The // spanning tree based vectorization analysis may return 4 as only @@ -6021,8 +6018,7 @@ TEST_F(ResizeTest, DISABLED_VectorizeOuterSliceMultiplePaths) { auto options = at::TensorOptions().dtype(at::kFloat).device(at::kCUDA, 0); auto t0 = at::randn(shape, options); - auto outputs = scheduleAndRun(&fusion, SchedulerType::PointWise, {t0}); - testValidate(&fusion, outputs.outputs, {t0}, __LINE__, __FILE__); + runAndValidate(&fusion, SchedulerType::PointWise, {t0}, __LINE__, __FILE__); // While there's a pad with factor of 2, it shouldn't matter as the // inner ID is large enough. @@ -6067,8 +6063,7 @@ TEST_F(ResizeTest, PropagateResizeThroughMultiplePaths) { auto t0 = at::randn({size}, options); auto t1 = at::randn({size}, options); - auto outputs = scheduleAndRun(&fusion, SchedulerType::Resize, {t0, t1}); - testValidate(&fusion, outputs.outputs, {t0, t1}, __LINE__, __FILE__); + runAndValidate(&fusion, SchedulerType::Resize, {t0, t1}, __LINE__, __FILE__); } // Check if vectorization is properly applied even when a resized ID @@ -6100,9 +6095,8 @@ TEST_F(ResizeTest, VectorizeOuterPad) { auto t1 = at::randn(shape2, options); auto t2 = at::randn(shape2, options); - auto outputs = - scheduleAndRun(&fusion, SchedulerType::PointWise, {t0, t1, t2}); - testValidate(&fusion, outputs.outputs, {t0, t1, t2}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::PointWise, {t0, t1, t2}, __LINE__, __FILE__); auto out_tv = tv5; // While there's a pad with factor of 2, it shouldn't matter as the @@ -6158,8 +6152,7 @@ TEST_F(ResizeTest, ReshapeAfterRef) { auto options = at::TensorOptions().dtype(at::kFloat).device(at::kCUDA, 0); auto t0 = at::randn(shape, options); - auto outputs = scheduleAndRun(&fusion, SchedulerType::Resize, {t0}); - testValidate(&fusion, outputs.outputs, {t0}, __LINE__, __FILE__); + runAndValidate(&fusion, SchedulerType::Resize, {t0}, __LINE__, __FILE__); } // Repro of an issue fixed by PR #4356. @@ -6193,8 +6186,7 @@ TEST_F(ResizeTest, ReorderLikeInputShouldNotMoveInnermostID) { auto options = at::TensorOptions().dtype(at::kFloat).device(at::kCUDA, 0); auto t0 = at::randn(shape1, options); - auto outputs = scheduleAndRun(&fusion, SchedulerType::Resize, {t0}); - testValidate(&fusion, outputs.outputs, {t0}, __LINE__, __FILE__); + runAndValidate(&fusion, SchedulerType::Resize, {t0}, __LINE__, __FILE__); } } // namespace nvfuser diff --git a/tests/cpp/test_transpose.cpp b/tests/cpp/test_transpose.cpp index 394f890090e..e14391312bc 100644 --- a/tests/cpp/test_transpose.cpp +++ b/tests/cpp/test_transpose.cpp @@ -133,10 +133,8 @@ TEST_F(TransposeTest, FusionScheduleTransposeMultipleInput) { at::Tensor input0 = at::randn({256, 1024, 1024}, options); at::Tensor input1 = at::randn({256, 1024, 1024}, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::Transpose, {input0, input1}) - .outputs; - testValidate(&fusion, cg_outputs, {input0, input1}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::Transpose, {input0, input1}, __LINE__, __FILE__); } // t0->sin->transpose->t5 @@ -193,10 +191,8 @@ TEST_F(TransposeTest, FusionScheduleTransposeMultipleInputOutput) { at::Tensor input0 = at::randn({32, 1024, 1024}, options); at::Tensor input1 = at::randn({32, 1024, 1024}, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::Transpose, {input0, input1}) - .outputs; - testValidate(&fusion, cg_outputs, {input0, input1}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::Transpose, {input0, input1}, __LINE__, __FILE__); } /* @@ -220,9 +216,8 @@ TEST_F(TransposeTest, FusionScheduleTransposeMatchingSkipConnection) { auto options = at::TensorOptions().dtype(at::kFloat).device(at::kCUDA, 0); at::Tensor input = at::randn({32, 1024, 1024}, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::Transpose, {input}).outputs; - testValidate(&fusion, cg_outputs, {input}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::Transpose, {input}, __LINE__, __FILE__); } // x->transpose--add->z @@ -244,10 +239,8 @@ TEST_F(TransposeTest, FusionScheduleTransposeBroadcast) { at::Tensor input0 = at::randn({1024, 256, 1024}, options); at::Tensor input1 = at::randn({1024, 1024}, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::Transpose, {input0, input1}) - .outputs; - testValidate(&fusion, cg_outputs, {input0, input1}, __LINE__, __FILE__); + runAndValidate( + &fusion, SchedulerType::Transpose, {input0, input1}, __LINE__, __FILE__); } // x->broadcast--add->z @@ -298,10 +291,12 @@ TEST_F(TransposeTest, FusionScheduleBroadcastOnly) { at::Tensor input0 = at::randn({1024, 1, 256}, options); at::Tensor input1 = at::randn({1024, 1024, 1}, options); - auto cg_outputs = - scheduleAndRun(&fusion, SchedulerType::Transpose, {input0, input1}) - .outputs; - testValidate(&fusion, cg_outputs, {input0, input1}, __LINE__, __FILE__); + runAndValidate( + &fusion, + SchedulerType::Transpose, + {input0, input1}, + __LINE__, + __FILE__); } } } @@ -365,12 +360,12 @@ TEST_F(TransposeTest, FusionScheduleTransposeComplexDAG1) { at::Tensor input1 = at::randn({1024, 512, 256}, options); at::Tensor input2 = at::randn({512, 256, 1024}, options); - auto cg_outputs = - scheduleAndRun( - &fusion, SchedulerType::Transpose, {input0, input1, input2}) - .outputs; - testValidate( - &fusion, cg_outputs, {input0, input1, input2}, __LINE__, __FILE__); + runAndValidate( + &fusion, + SchedulerType::Transpose, + {input0, input1, input2}, + __LINE__, + __FILE__); } // mermaid graph: @@ -643,12 +638,12 @@ TEST_F(TransposeTest, FusionScheduleTransposeMissingDim) { at::Tensor input1 = at::randn({1, 512, 1}, options); at::Tensor input2 = at::randn({512}, options); - auto cg_outputs = - scheduleAndRun( - &fusion, SchedulerType::Transpose, {input0, input1, input2}) - .outputs; - testValidate( - &fusion, cg_outputs, {input0, input1, input2}, __LINE__, __FILE__); + runAndValidate( + &fusion, + SchedulerType::Transpose, + {input0, input1, input2}, + __LINE__, + __FILE__); } // x->sin->transpose->cos->y