Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 16 additions & 20 deletions tests/cpp/test_gpu2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 4 additions & 6 deletions tests/cpp/test_gpu3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions tests/cpp/test_indexing_advanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
26 changes: 12 additions & 14 deletions tests/cpp/test_pointwise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
55 changes: 22 additions & 33 deletions tests/cpp/test_reshape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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__);
}
}

Expand Down Expand Up @@ -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__);
}
}

Expand Down Expand Up @@ -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__);
}
}

Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
Loading