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

Always try to lower standalone lmhlo.transpose to custom call for better performance #1282

Merged
merged 3 commits into from
Feb 26, 2024
Merged
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
5 changes: 2 additions & 3 deletions tao_compiler/mlir/disc/transforms/disc_lower_to_library_call.cc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ struct TransposeConverter : public OpRewritePattern<lmhlo::TransposeOp> {
if (rank != 2 && rank != 3) return failure();
// only rewriter custom library when switch 1 and 2 dimensions of
// a 3d tensor, that means permute = [0, 2, 1]
if (rank == 3 && permutation[1] != 2 && permutation[2] != 1)
if (rank == 3 && (permutation[1] != 2 || permutation[2] != 1))
return failure();
bool on_gpu = placement_utils::isGpuMemRef(op->getOperand(0));
// TODO: support other device
Expand Down Expand Up @@ -914,8 +914,7 @@ struct DiscLowerToLibraryCallPass
SendOutputOpConvertor
>(context);
// clang-format on
if (enableTransposeLibraryCall())
patterns.insert<TransposeConverter>(context);
patterns.insert<TransposeConverter>(context);

// GPU copy related ops
patterns.insert<GpuCopyOpConvertor<H2DOp>>(context, "h2d");
Expand Down
Loading