Skip to content

Commit f426be1

Browse files
authored
Revert "[mlir][linalg] Add runtime verification for linalg ops" (#89780)
Reverts #89342 due to build failure
1 parent c793f4a commit f426be1

File tree

9 files changed

+33
-549
lines changed

9 files changed

+33
-549
lines changed

mlir/include/mlir/Dialect/Linalg/Transforms/RuntimeOpVerification.h

Lines changed: 0 additions & 21 deletions
This file was deleted.

mlir/include/mlir/InitAllDialects.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#include "mlir/Dialect/LLVMIR/ROCDLDialect.h"
4646
#include "mlir/Dialect/Linalg/IR/Linalg.h"
4747
#include "mlir/Dialect/Linalg/Transforms/AllInterfaces.h"
48-
#include "mlir/Dialect/Linalg/Transforms/RuntimeOpVerification.h"
4948
#include "mlir/Dialect/MLProgram/IR/MLProgram.h"
5049
#include "mlir/Dialect/MLProgram/Transforms/BufferizableOpInterfaceImpl.h"
5150
#include "mlir/Dialect/MPI/IR/MPI.h"
@@ -162,7 +161,6 @@ inline void registerAllDialects(DialectRegistry &registry) {
162161
cf::registerBufferDeallocationOpInterfaceExternalModels(registry);
163162
gpu::registerBufferDeallocationOpInterfaceExternalModels(registry);
164163
linalg::registerAllDialectInterfaceImplementations(registry);
165-
linalg::registerRuntimeVerifiableOpInterfaceExternalModels(registry);
166164
memref::registerAllocationOpInterfaceExternalModels(registry);
167165
memref::registerBufferViewFlowOpInterfaceExternalModels(registry);
168166
memref::registerRuntimeVerifiableOpInterfaceExternalModels(registry);

mlir/include/mlir/Interfaces/RuntimeVerifiableOpInterface.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ def RuntimeVerifiableOpInterface : OpInterface<"RuntimeVerifiableOpInterface"> {
3535
"::mlir::Location":$loc)
3636
>,
3737
];
38-
39-
let extraClassDeclaration = [{
40-
/// Generate the error message that will be printed to the user when
41-
/// verification fails.
42-
static std::string generateErrorMessage(Operation *op, const std::string &msg);
43-
}];
4438
}
4539

4640
#endif // MLIR_INTERFACES_RUNTIMEVERIFIABLEOPINTERFACE

mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ add_mlir_dialect_library(MLIRLinalgTransforms
2727
NamedOpConversions.cpp
2828
Padding.cpp
2929
Promotion.cpp
30-
RuntimeOpVerification.cpp
3130
Specialize.cpp
3231
Split.cpp
3332
SplitReduction.cpp

mlir/lib/Dialect/Linalg/Transforms/RuntimeOpVerification.cpp

Lines changed: 0 additions & 135 deletions
This file was deleted.

mlir/lib/Dialect/MemRef/Transforms/RuntimeOpVerification.cpp

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@
2020

2121
using namespace mlir;
2222

23+
/// Generate an error message string for the given op and the specified error.
24+
static std::string generateErrorMessage(Operation *op, const std::string &msg) {
25+
std::string buffer;
26+
llvm::raw_string_ostream stream(buffer);
27+
OpPrintingFlags flags;
28+
// We may generate a lot of error messages and so we need to ensure the
29+
// printing is fast.
30+
flags.elideLargeElementsAttrs();
31+
flags.printGenericOpForm();
32+
flags.skipRegions();
33+
flags.useLocalScope();
34+
stream << "ERROR: Runtime op verification failed\n";
35+
op->print(stream, flags);
36+
stream << "\n^ " << msg;
37+
stream << "\nLocation: ";
38+
op->getLoc().print(stream);
39+
return stream.str();
40+
}
41+
2342
namespace mlir {
2443
namespace memref {
2544
namespace {
@@ -43,10 +62,8 @@ struct CastOpInterface
4362
builder.create<arith::ConstantIndexOp>(loc, resultType.getRank());
4463
Value isSameRank = builder.create<arith::CmpIOp>(
4564
loc, arith::CmpIPredicate::eq, srcRank, resultRank);
46-
builder.create<cf::AssertOp>(
47-
loc, isSameRank,
48-
RuntimeVerifiableOpInterface::generateErrorMessage(op,
49-
"rank mismatch"));
65+
builder.create<cf::AssertOp>(loc, isSameRank,
66+
generateErrorMessage(op, "rank mismatch"));
5067
}
5168

5269
// Get source offset and strides. We do not have an op to get offsets and
@@ -84,8 +101,8 @@ struct CastOpInterface
84101
loc, arith::CmpIPredicate::eq, srcDimSz, resultDimSz);
85102
builder.create<cf::AssertOp>(
86103
loc, isSameSz,
87-
RuntimeVerifiableOpInterface::generateErrorMessage(
88-
op, "size mismatch of dim " + std::to_string(it.index())));
104+
generateErrorMessage(op, "size mismatch of dim " +
105+
std::to_string(it.index())));
89106
}
90107

91108
// Get result offset and strides.
@@ -102,10 +119,8 @@ struct CastOpInterface
102119
builder.create<arith::ConstantIndexOp>(loc, resultOffset);
103120
Value isSameOffset = builder.create<arith::CmpIOp>(
104121
loc, arith::CmpIPredicate::eq, srcOffset, resultOffsetVal);
105-
builder.create<cf::AssertOp>(
106-
loc, isSameOffset,
107-
RuntimeVerifiableOpInterface::generateErrorMessage(
108-
op, "offset mismatch"));
122+
builder.create<cf::AssertOp>(loc, isSameOffset,
123+
generateErrorMessage(op, "offset mismatch"));
109124
}
110125

111126
// Check strides.
@@ -122,8 +137,8 @@ struct CastOpInterface
122137
loc, arith::CmpIPredicate::eq, srcStride, resultStrideVal);
123138
builder.create<cf::AssertOp>(
124139
loc, isSameStride,
125-
RuntimeVerifiableOpInterface::generateErrorMessage(
126-
op, "stride mismatch of dim " + std::to_string(it.index())));
140+
generateErrorMessage(op, "stride mismatch of dim " +
141+
std::to_string(it.index())));
127142
}
128143
}
129144
};
@@ -163,9 +178,7 @@ struct LoadStoreOpInterface
163178
: andOp;
164179
}
165180
builder.create<cf::AssertOp>(
166-
loc, assertCond,
167-
RuntimeVerifiableOpInterface::generateErrorMessage(
168-
op, "out-of-bounds access"));
181+
loc, assertCond, generateErrorMessage(op, "out-of-bounds access"));
169182
}
170183
};
171184

@@ -235,7 +248,7 @@ struct ReinterpretCastOpInterface
235248

236249
builder.create<cf::AssertOp>(
237250
loc, assertCond,
238-
RuntimeVerifiableOpInterface::generateErrorMessage(
251+
generateErrorMessage(
239252
op,
240253
"result of reinterpret_cast is out-of-bounds of the base memref"));
241254
}
@@ -280,8 +293,8 @@ struct SubViewOpInterface
280293

281294
builder.create<cf::AssertOp>(
282295
loc, assertCond,
283-
RuntimeVerifiableOpInterface::generateErrorMessage(
284-
op, "subview is out-of-bounds of the base memref"));
296+
generateErrorMessage(op,
297+
"subview is out-of-bounds of the base memref"));
285298
}
286299
};
287300

@@ -321,9 +334,8 @@ struct ExpandShapeOpInterface
321334
builder.create<arith::ConstantIndexOp>(loc, 0));
322335
builder.create<cf::AssertOp>(
323336
loc, isModZero,
324-
RuntimeVerifiableOpInterface::generateErrorMessage(
325-
op, "static result dims in reassoc group do not "
326-
"divide src dim evenly"));
337+
generateErrorMessage(op, "static result dims in reassoc group do not "
338+
"divide src dim evenly"));
327339
}
328340
}
329341
};

mlir/lib/Interfaces/RuntimeVerifiableOpInterface.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,6 @@
1111
namespace mlir {
1212
class Location;
1313
class OpBuilder;
14-
15-
/// Generate an error message string for the given op and the specified error.
16-
std::string
17-
RuntimeVerifiableOpInterface::generateErrorMessage(Operation *op,
18-
const std::string &msg) {
19-
std::string buffer;
20-
llvm::raw_string_ostream stream(buffer);
21-
OpPrintingFlags flags;
22-
// We may generate a lot of error messages and so we need to ensure the
23-
// printing is fast.
24-
flags.elideLargeElementsAttrs();
25-
flags.printGenericOpForm();
26-
flags.skipRegions();
27-
flags.useLocalScope();
28-
stream << "ERROR: Runtime op verification failed\n";
29-
op->print(stream, flags);
30-
stream << "\n^ " << msg;
31-
stream << "\nLocation: ";
32-
op->getLoc().print(stream);
33-
return stream.str();
34-
}
35-
3614
} // namespace mlir
3715

3816
/// Include the definitions of the interface.

mlir/test/Dialect/Linalg/runtime-verification.mlir

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)