Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhanW authored Feb 6, 2025
1 parent f3bef2d commit 86b845b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -964,14 +964,6 @@ DiagnosedSilenceableFailure transform_dialect::IREEBufferizeOp::apply(
return listener.checkAndResetError();
}

// 3. Post-bufferization passes are fine.
PassManager pm(getContext());
addIREEPostBufferizationPasses(pm);
if (failed(pm.run(target))) {
return mlir::emitDefiniteFailure(target)
<< "post-bufferization passes failed";
}

results.set(getOperation()->getOpResult(0), {target});
return listener.checkAndResetError();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ module attributes {transform.with_named_sequence} {
transform.print %8 : !transform.any_op
transform.iree.eliminate_empty_tensors %8 : (!transform.any_op) -> ()
%9 = transform.iree.bufferize %8 : (!transform.any_op) -> !transform.any_op
// %9 = transform.structured.match ops{["func.func"]} in %8 : (!transform.any_op) -> !transform.any_op
%10 = transform.structured.match ops{["func.func"]} in %9 : (!transform.any_op) -> !transform.op<"func.func">
transform.apply_patterns to %10 {
transform.apply_patterns.canonicalization
} : !transform.op<"func.func">
transform.yield
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ module attributes { transform.with_named_sequence } {
%tensor_func = transform.structured.match ops{["func.func"]} in %variant_op : (!transform.any_op) -> !transform.any_op
transform.iree.eliminate_empty_tensors %tensor_func : (!transform.any_op) -> ()
%memref_func = transform.iree.bufferize %tensor_func : (!transform.any_op) -> !transform.any_op
%func_op_bufferized = transform.structured.match ops{["func.func"]} in %memref_func : (!transform.any_op) -> !transform.op<"func.func">
transform.apply_patterns to %func_op_bufferized {
transform.apply_patterns.canonicalization
} : !transform.op<"func.func">

// Annotate the exported function as already translated.
%none = transform.param.constant #iree_codegen.translation_info<pipeline = None> -> !transform.any_param
transform.annotate %memref_func "translation_info" = %none : !transform.any_op, !transform.any_param
transform.annotate %func_op_bufferized "translation_info" = %none : !transform.op<"func.func">, !transform.any_param
transform.yield
}
} // module
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/ToolOutputFile.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/IR/Dominance.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
#include "mlir/Support/FileUtilities.h"
#include "mlir/Transforms/CSE.h"
#include "mlir/Transforms/Passes.h"

// NOTE: redundant bindings will result in unique buffer locations during the
Expand Down Expand Up @@ -447,14 +449,9 @@ buildBenchmarkModule(IREE::HAL::ExecutableOp sourceExecutableOp,
if (!hasAnyBenchmarks)
return {};

// Run CSE and the canonicalizer to pretty up the output.
PassManager passManager(moduleOp->getContext());
passManager.addPass(mlir::createCanonicalizerPass());
passManager.addPass(mlir::createCSEPass());
if (failed(passManager.run(*moduleOp))) {
moduleOp->emitError("failed to run canonicalizer; malformed output");
return {};
}
IRRewriter rewriter(moduleOp->getContext());
DominanceInfo domInfo;
mlir::eliminateCommonSubExpressions(rewriter, domInfo, moduleOp.get());

return moduleOp;
}
Expand Down
2 changes: 1 addition & 1 deletion third_party/llvm-project
Submodule llvm-project updated 2870 files

0 comments on commit 86b845b

Please sign in to comment.