Skip to content

only emit target description warning in verify phase and correct the target op #216

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

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions include/gc/Analysis/TargetDescriptionAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ class TargetDescriptionAnalysisBase {
// the map from device type to device string
static llvm::DenseMap<DeviceType, std::string> DeviceKeyMap;

// set the emit warning flag
void setEmitWarning(bool emit) { emitWarning = emit; }

private:
MLIRContext *ctx;
DeviceType device;
DataLayout layout;
Location loc;
bool emitWarning = false;
};

class CPUTargetDescriptionAnalysis : public TargetDescriptionAnalysisBase {
Expand Down
4 changes: 3 additions & 1 deletion lib/gc/Analysis/TargetDescriptionAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ template <typename T>
void TargetDescriptionAnalysisBase::emitNotFoundWarning(Location loc,
StringRef key,
T value) {
mlir::emitWarning(loc) << key << " not found, using default value " << value;
if (emitWarning)
mlir::emitWarning(loc) << key << " not found, using default value "
<< value;
}

static bool isIntegerNumber(const std::string &token) {
Expand Down
2 changes: 1 addition & 1 deletion lib/gc/Transforms/Pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void populateLLVMPasses(mlir::OpPassManager &pm) {

void populateCPUPipeline(mlir::OpPassManager &pm) {
// verify the target description attribute
pm.addNestedPass<func::FuncOp>(createVerifyTargetDescription());
pm.addPass(createVerifyTargetDescription());
// front-end, oneDNN graph dialect
populateFrontendPasses(pm);
// middle-end, LinalgX/Linalg/tensor dialects
Expand Down
1 change: 1 addition & 0 deletions lib/gc/Transforms/VerifyTargetDescription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace {
static LogicalResult verifyCPUTargetDescription(RewriterBase &rewriter,
Operation *op) {
CPUTargetDescriptionAnalysis cpuTargetDesc(op);
cpuTargetDesc.setEmitWarning(true);
Location loc = op->getLoc();

// Check if the num_threads is existed and greater than 0
Expand Down