mirror of
https://github.com/intel/llvm.git
synced 2026-01-24 00:20:25 +08:00
[mlir][arith] Refine the verifier for arith.constant (#86178)
Disallows initialization of scalable vectors with an attribute of arbitrary values, e.g.: ```mlir %c = arith.constant dense<[0, 1]> : vector<[2] x i32> ``` Initialization using vector splats remains allowed (i.e. when all the init values are identical): ```mlir %c = arith.constant dense<[1, 1]> : vector<[2] x i32> ```
This commit is contained in:
committed by
GitHub
parent
eb07600f8e
commit
662c62609e
@@ -213,6 +213,12 @@ LogicalResult arith::ConstantOp::verify() {
|
||||
return emitOpError(
|
||||
"value must be an integer, float, or elements attribute");
|
||||
}
|
||||
|
||||
auto vecType = dyn_cast<VectorType>(type);
|
||||
if (vecType && vecType.isScalable() && !isa<SplatElementsAttr>(getValue()))
|
||||
return emitOpError(
|
||||
"intializing scalable vectors with elements attribute is not supported"
|
||||
" unless it's a vector splat");
|
||||
return success();
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,15 @@ func.func @constant_out_of_range() {
|
||||
|
||||
// -----
|
||||
|
||||
func.func @constant_invalid_scalable_vec_initialization() {
|
||||
^bb0:
|
||||
// expected-error@+1 {{'arith.constant' op intializing scalable vectors with elements attribute is not supported unless it's a vector splat}}
|
||||
%c = arith.constant dense<[0, 1]> : vector<[2] x i32>
|
||||
return
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
func.func @constant_wrong_type() {
|
||||
^bb:
|
||||
%x = "arith.constant"(){value = 10.} : () -> f32 // expected-error {{'arith.constant' op failed to verify that all of {value, result} have same type}}
|
||||
|
||||
Reference in New Issue
Block a user