Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge all dims in pointwise scheduler #1872

Merged
merged 2 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 0 additions & 8 deletions torch/csrc/jit/codegen/cuda/scheduler/pointwise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,6 @@ void schedulePointwise(Fusion* fusion, const PointwiseParams& params) {
int rhs_i = -1;
for (int i = (int)reference_tv->nDims(); i > (int)params.break_point; i--) {
auto axis_i = i - 1;
if (reference_tv->axis(axis_i)->isBroadcast() ||
reference_tv->axis(axis_i)->isReduction()) {
continue;
}
if (rhs_i == -1) {
rhs_i = axis_i;
} else {
Expand All @@ -548,10 +544,6 @@ void schedulePointwise(Fusion* fusion, const PointwiseParams& params) {
int lhs_i = -1;
for (int i = (int)params.break_point; i > 0; i--) {
auto axis_i = i - 1;
if (reference_tv->axis(axis_i)->isBroadcast() ||
reference_tv->axis(axis_i)->isReduction()) {
continue;
}
if (lhs_i == -1) {
lhs_i = axis_i;
} else {
Expand Down
34 changes: 34 additions & 0 deletions torch/csrc/jit/codegen/cuda/test/test_gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24846,6 +24846,40 @@ TEST_F(NVFuserTest, FusionInsertMagicZero1_CUDA) {
tv2->toString());
}

TEST_F(
NVFuserTest,
FusionPointwiseScheduleWithBroadcastAndTrivialReduction_CUDA) {
Fusion fusion;
FusionGuard fg(&fusion);

auto tv0 = makeContigTensor(3);
auto tv1 = makeContigTensor(2);
fusion.addInput(tv0);
fusion.addInput(tv1);
auto tv2 = broadcast(tv0, {false, true, false, true, false, true});
auto tv3 = sin(tv2);
auto tv4 = add(tv3, tv1);
auto tv5 = sum(tv4, {1});
fusion.addOutput(tv5);

auto options = at::TensorOptions().dtype(at::kFloat).device(at::kCUDA, 0);
at::Tensor t0 = at::randn({100, 100, 10}, options);
at::Tensor t1 = at::randn({10, 20}, options);

auto aten_output = (t0.view({100, 1, 100, 1, 10, 1}).sin() + t1).squeeze(1);

std::vector<IValue> aten_inputs = {t0, t1};

auto lparams = schedulePointwise(&fusion, aten_inputs);

FusionExecutor fe;
fe.compileFusion(&fusion, aten_inputs, lparams);
auto cg_outputs = fe.runFusion(aten_inputs, lparams);

testValidate(
&fusion, cg_outputs, aten_inputs, {aten_output}, __LINE__, __FILE__);
}

} // namespace jit
} // namespace torch
#endif // #if defined(USE_CUDA)