Skip to content

Commit

Permalink
Remove VerifyInvariantsBeforeBackendLowering
Browse files Browse the repository at this point in the history
LowerToBackendContract now checks all this consistently.
  • Loading branch information
silvasean committed Aug 26, 2022
1 parent b1fa7a2 commit 0e3ddba
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 161 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ void createTorchBackendToMhloBackendPipeline(
const torch::Torch::TorchLoweringPipelineOptions &options);
#endif

std::unique_ptr<OperationPass<ModuleOp>>
createVerifyInvariantsBeforeBackendLoweringPass();

std::unique_ptr<OperationPass<ModuleOp>> createFuncBackendTypeConversionPass();

std::unique_ptr<OperationPass<func::FuncOp>>
Expand Down
21 changes: 0 additions & 21 deletions include/torch-mlir/Dialect/TorchConversion/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,6 @@

include "mlir/Pass/PassBase.td"

def VerifyInvariantsBeforeBackendLowering
: Pass<"torch-verify-invariants-before-backend-lowering", "ModuleOp"> {
let summary = "Verify invariants required by backend lowering";
let constructor =
"mlir::torch::TorchConversion::createVerifyInvariantsBeforeBackendLoweringPass()";
let description = [{
This pass checks any invariants needed by the process of lowering the
`torch` dialect to the linalg-on-tensors backend contract.

The most important invariant is that all tensors should be ranked and have
a known dtype. It is useful to catch this early because it usually
represents a simple bug in RefineTypes, but can manifest as many different
kinds of obscure symptoms during lowering.

TODO: This pass should probably be phrased as checking the
"torch backend contract" and moved to that dialect once we have more
substantial definition definition around what that layer is from an
"allowlist" perspective.
}];
}

def FuncBackendTypeConversion : Pass<"torch-func-backend-type-conversion", "ModuleOp"> {
let summary = "Convert functions to operate on builtin tensors";
let constructor = "mlir::torch::TorchConversion::createFuncBackendTypeConversionPass()";
Expand Down
3 changes: 1 addition & 2 deletions lib/Dialect/TorchConversion/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ add_mlir_library(TorchMLIRTorchConversionPasses
BackendTypeConversion.cpp
BackendTypeConversionPasses.cpp
Passes.cpp
VerifyInvariantsBeforeBackendLowering.cpp
VerifyLinalgOnTensorsBackendContract.cpp
VerifyTosaBackendContract.cpp

Expand All @@ -34,4 +33,4 @@ add_mlir_library(TorchMLIRTorchConversionPasses

LINK_LIBS PUBLIC
${LinkedLibs}
)
)
12 changes: 0 additions & 12 deletions lib/Dialect/TorchConversion/Transforms/Passes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ void mlir::torch::registerTorchConversionPasses() {

void TorchConversion::createTorchBackendToLinalgOnTensorsBackendPipeline(
OpPassManager &pm, const Torch::TorchLoweringPipelineOptions &options) {
// Check some invariants to catch errors in a clear way.
pm.addPass(
TorchConversion::createVerifyInvariantsBeforeBackendLoweringPass());

// Lower to linalg + guards which is the input to codegen backends.
// We do this first as it tends to involve pattern-matching against constants,
// (e.g. dimensions which must be constant in a ranked programming model)
Expand Down Expand Up @@ -101,10 +97,6 @@ void TorchConversion::createTorchBackendToLinalgOnTensorsBackendPipeline(

void TorchConversion::createTorchBackendToTosaBackendPipeline(
OpPassManager &pm, const Torch::TorchLoweringPipelineOptions &options) {
// Check some invariants to catch errors in a clear way.
pm.addPass(
TorchConversion::createVerifyInvariantsBeforeBackendLoweringPass());

pm.addNestedPass<func::FuncOp>(createConvertTorchToTosaPass());
// Perform rank broadcasting so TosaToLinalg pass works
pm.addNestedPass<func::FuncOp>(createTosaMakeBroadcastablePass());
Expand All @@ -130,10 +122,6 @@ void TorchConversion::createTorchBackendToTosaBackendPipeline(
#ifdef TORCH_MLIR_ENABLE_MHLO
void TorchConversion::createTorchBackendToMhloBackendPipeline(
OpPassManager &pm, const Torch::TorchLoweringPipelineOptions &options) {
// Check some invariants to catch errors in a clear way.
pm.addPass(
TorchConversion::createVerifyInvariantsBeforeBackendLoweringPass());

pm.addNestedPass<func::FuncOp>(createConvertTorchToMhloPass());

// Clean up any non-canonical code introduced above..
Expand Down

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion utils/bazel/torch-mlir-overlay/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ cc_library(
"lib/Dialect/TorchConversion/Transforms/BackendTypeConversionPasses.cpp",
"lib/Dialect/TorchConversion/Transforms/PassDetail.h",
"lib/Dialect/TorchConversion/Transforms/Passes.cpp",
"lib/Dialect/TorchConversion/Transforms/VerifyInvariantsBeforeBackendLowering.cpp",
"lib/Dialect/TorchConversion/Transforms/VerifyLinalgOnTensorsBackendContract.cpp",
"lib/Dialect/TorchConversion/Transforms/VerifyTosaBackendContract.cpp",
],
Expand Down

0 comments on commit 0e3ddba

Please sign in to comment.