Skip to content

Commit ca1373e

Browse files
authored
only emit target description warning in verify phase and correct the target op (#216)
only emit warning in verify phase and correct the pass target op
1 parent 6cadff8 commit ca1373e

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

Diff for: include/gc/Analysis/TargetDescriptionAnalysis.h

+4
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,15 @@ class TargetDescriptionAnalysisBase {
5555
// the map from device type to device string
5656
static llvm::DenseMap<DeviceType, std::string> DeviceKeyMap;
5757

58+
// set the emit warning flag
59+
void setEmitWarning(bool emit) { emitWarning = emit; }
60+
5861
private:
5962
MLIRContext *ctx;
6063
DeviceType device;
6164
DataLayout layout;
6265
Location loc;
66+
bool emitWarning = false;
6367
};
6468

6569
class CPUTargetDescriptionAnalysis : public TargetDescriptionAnalysisBase {

Diff for: lib/gc/Analysis/TargetDescriptionAnalysis.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ template <typename T>
2525
void TargetDescriptionAnalysisBase::emitNotFoundWarning(Location loc,
2626
StringRef key,
2727
T value) {
28-
mlir::emitWarning(loc) << key << " not found, using default value " << value;
28+
if (emitWarning)
29+
mlir::emitWarning(loc) << key << " not found, using default value "
30+
<< value;
2931
}
3032

3133
static bool isIntegerNumber(const std::string &token) {

Diff for: lib/gc/Transforms/Pipeline.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void populateLLVMPasses(mlir::OpPassManager &pm) {
134134

135135
void populateCPUPipeline(mlir::OpPassManager &pm) {
136136
// verify the target description attribute
137-
pm.addNestedPass<func::FuncOp>(createVerifyTargetDescription());
137+
pm.addPass(createVerifyTargetDescription());
138138
// front-end, oneDNN graph dialect
139139
populateFrontendPasses(pm);
140140
// middle-end, LinalgX/Linalg/tensor dialects

Diff for: lib/gc/Transforms/VerifyTargetDescription.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace {
2424
static LogicalResult verifyCPUTargetDescription(RewriterBase &rewriter,
2525
Operation *op) {
2626
CPUTargetDescriptionAnalysis cpuTargetDesc(op);
27+
cpuTargetDesc.setEmitWarning(true);
2728
Location loc = op->getLoc();
2829

2930
// Check if the num_threads is existed and greater than 0

0 commit comments

Comments
 (0)