Skip to content

Commit

Permalink
Fix an issue with isPureMatmulProblem
Browse files Browse the repository at this point in the history
There are two issues with this function:
1. It returns true when there is no for loop
2. It cannot detect for loop when there is any.

The 2nd bullet is because "getOps<OpTy>() is useful to iterate on some
Operations immediately listed inside a single block (or a single
region)", therefore, moduleOp.getOps<scf::ForOp> will always return
nothing. Instead, we use walker here to find scf.forOp in a nested
fashion.
  • Loading branch information
zhanglx13 committed Oct 29, 2024
1 parent 4af7fde commit d0485f1
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ namespace ttg = mlir::triton::gpu;
// Return true if the given moduleOp contains a pure matmul problem; i.e.,
// single dot in the main loop.
static bool isPureMatmulProblem(ModuleOp moduleOp) {
for (auto forOp : moduleOp.getOps<scf::ForOp>()) {
bool isMatmul = true;
bool foundLoop = false;
moduleOp.walk([&](scf::ForOp forOp) -> void {
int counter = 0;
forOp.walk([&counter](triton::DotOp dotOp) { ++counter; });
if (counter != 1)
return false;
}
return true;
isMatmul = (isMatmul && (counter == 1));
foundLoop = true;
});
return foundLoop && isMatmul;
}

// Search through block to find earliest insertion point for move op. This can
Expand Down

0 comments on commit d0485f1

Please sign in to comment.