Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 94ef51b

Browse files
committedAug 6, 2024·
fix comment
1 parent 1731525 commit 94ef51b

File tree

2 files changed

+27
-50
lines changed

2 files changed

+27
-50
lines changed
 

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

+2
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ void populateLLVMPasses(mlir::OpPassManager &pm) {
133133
}
134134

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

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

+25-50
Original file line numberDiff line numberDiff line change
@@ -27,68 +27,43 @@ static LogicalResult verifyCPUTargetDescription(RewriterBase &rewriter,
2727
Location loc = op->getLoc();
2828

2929
// Check if the num_threads is existed and greater than 0
30-
std::optional<Attribute> numThreadsAttr =
31-
cpuTargetDesc.getPropertyValue(CPUTargetDescriptionAnalysis::kNumThreads);
32-
if (numThreadsAttr) {
33-
if (!isa<IntegerAttr>(*numThreadsAttr) ||
34-
cpuTargetDesc.getNumThreads() < 1) {
35-
mlir::emitError(loc)
36-
<< "num_threads must be a greater than 0 integer, but get "
37-
<< *numThreadsAttr;
38-
return failure();
39-
}
30+
if (cpuTargetDesc.getNumThreads() < 1) {
31+
mlir::emitError(loc)
32+
<< "num_threads must be a greater than 0 integer, but get "
33+
<< cpuTargetDesc.getNumThreads();
34+
return failure();
4035
}
4136

4237
// Check if the L1 cache size is existed and greater than 0
43-
std::optional<Attribute> l1CacheSizeAttr = cpuTargetDesc.getPropertyValue(
44-
CPUTargetDescriptionAnalysis::kL1CacheSize);
45-
if (l1CacheSizeAttr) {
46-
if (!isa<IntegerAttr>(*l1CacheSizeAttr) ||
47-
cpuTargetDesc.getCacheSize(1) < 1) {
48-
mlir::emitError(loc)
49-
<< "L1_cache_size_in_bytes must be a greater than 0 integer, but get "
50-
<< *l1CacheSizeAttr;
51-
return failure();
52-
}
38+
if (cpuTargetDesc.getCacheSize(1) < 1) {
39+
mlir::emitError(loc)
40+
<< "L1_cache_size_in_bytes must be a greater than 0 integer, but get "
41+
<< cpuTargetDesc.getCacheSize(1);
42+
return failure();
5343
}
5444

5545
// Check if the L2 cache size is existed and greater than 0
56-
std::optional<Attribute> l2CacheSizeAttr = cpuTargetDesc.getPropertyValue(
57-
CPUTargetDescriptionAnalysis::kL2CacheSize);
58-
if (l2CacheSizeAttr) {
59-
if (!isa<IntegerAttr>(*l2CacheSizeAttr) ||
60-
cpuTargetDesc.getCacheSize(2) < 1) {
61-
mlir::emitError(loc)
62-
<< "L2_cache_size_in_bytes must be a greater than 0 integer, but get "
63-
<< *l2CacheSizeAttr;
64-
return failure();
65-
}
46+
if (cpuTargetDesc.getCacheSize(2) < 1) {
47+
mlir::emitError(loc)
48+
<< "L2_cache_size_in_bytes must be a greater than 0 integer, but get "
49+
<< cpuTargetDesc.getCacheSize(2);
50+
return failure();
6651
}
6752

6853
// Check if the L3 cache size is existed and greater than 0
69-
std::optional<Attribute> l3CacheSizeAttr = cpuTargetDesc.getPropertyValue(
70-
CPUTargetDescriptionAnalysis::kL3CacheSize);
71-
if (l3CacheSizeAttr) {
72-
if (!isa<IntegerAttr>(*l3CacheSizeAttr) ||
73-
cpuTargetDesc.getCacheSize(3) < 1) {
74-
mlir::emitError(loc)
75-
<< "L3_cache_size_in_bytes must be a greater than 0 integer, but get "
76-
<< *l3CacheSizeAttr;
77-
return failure();
78-
}
54+
if (cpuTargetDesc.getCacheSize(3) < 1) {
55+
mlir::emitError(loc)
56+
<< "L3_cache_size_in_bytes must be a greater than 0 integer, but get "
57+
<< cpuTargetDesc.getCacheSize(3);
58+
return failure();
7959
}
8060

8161
// Check if the max_vector_width is existed and greater than 0
82-
std::optional<Attribute> maxVectorWidthAttr = cpuTargetDesc.getPropertyValue(
83-
CPUTargetDescriptionAnalysis::kMaxVectorWidth);
84-
if (maxVectorWidthAttr) {
85-
if (!isa<IntegerAttr>(*maxVectorWidthAttr) ||
86-
cpuTargetDesc.getMaxVectorWidth() < 1) {
87-
mlir::emitError(loc)
88-
<< "max_vector_width must be a greater than 0 integer, but get "
89-
<< *maxVectorWidthAttr;
90-
return failure();
91-
}
62+
if (cpuTargetDesc.getMaxVectorWidth() < 1) {
63+
mlir::emitError(loc)
64+
<< "max_vector_width must be a greater than 0 integer, but get "
65+
<< cpuTargetDesc.getMaxVectorWidth();
66+
return failure();
9267
}
9368
return success();
9469
}

0 commit comments

Comments
 (0)
Please sign in to comment.