@@ -27,68 +27,43 @@ static LogicalResult verifyCPUTargetDescription(RewriterBase &rewriter,
27
27
Location loc = op->getLoc ();
28
28
29
29
// 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 ();
40
35
}
41
36
42
37
// 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 ();
53
43
}
54
44
55
45
// 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 ();
66
51
}
67
52
68
53
// 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 ();
79
59
}
80
60
81
61
// 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 ();
92
67
}
93
68
return success ();
94
69
}
0 commit comments