-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir][arith] Refine the verifier for arith.constant #86178
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
[mlir][arith] Refine the verifier for arith.constant #86178
Conversation
@llvm/pr-subscribers-mlir-arith @llvm/pr-subscribers-libc Author: Andrzej Warzyński (banach-space) Changes
Full diff: https://github.com/llvm/llvm-project/pull/86178.diff 7 Files Affected:
diff --git a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
index 9f64a07f31e3af..b600f9cea78784 100644
--- a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
@@ -190,6 +190,12 @@ LogicalResult arith::ConstantOp::verify() {
return emitOpError(
"value must be an integer, float, or elements attribute");
}
+ // Intializing scalable vectors with elements attribute is not supported
+ // unless it's a vector splot.
+ auto vecType = dyn_cast<VectorType>(type);
+ auto val = dyn_cast<DenseElementsAttr>(getValue());
+ if ((vecType && val) && vecType.isScalable() && !val.isSplat())
+ return emitOpError("using elements attribute to initialize a scalable vector");
return success();
}
diff --git a/mlir/test/Dialect/Arith/invalid.mlir b/mlir/test/Dialect/Arith/invalid.mlir
index 6d8ac0ada52be3..ac28075df33e9b 100644
--- a/mlir/test/Dialect/Arith/invalid.mlir
+++ b/mlir/test/Dialect/Arith/invalid.mlir
@@ -215,6 +215,14 @@ func.func @func_with_ops() {
// -----
+func.func @func_with_ops() {
+^bb0:
+ // expected-error@+1 {{op failed to verify that result type has i1 element type and same shape as operands}}
+ %c = arith.constant dense<[0, 1]> : vector<[2] x i32>
+}
+
+// -----
+
func.func @invalid_cmp_shape(%idx : () -> ()) {
// expected-error@+1 {{'lhs' must be signless-integer-like, but got '() -> ()'}}
%cmp = arith.cmpi eq, %idx, %idx : () -> ()
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 4766e168daadbd..1d98b986f4818e 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -65,11 +65,35 @@ config_setting(
################################# Include Files ################################
libc_support_library(
- name = "internal_includes",
- textual_hdrs = glob([
- "include/llvm-libc-macros/*.h",
- "include/llvm-libc-types/*",
- ]),
+ name = "llvm_libc_macros_math_macros",
+ hdrs = ["include/llvm-libc-macros/math-macros.h"],
+)
+
+libc_support_library(
+ name = "llvm_libc_macros_limits_macros",
+ hdrs = ["include/llvm-libc-macros/limits-macros.h"],
+)
+
+libc_support_library(
+ name = "llvm_libc_macros_float_macros",
+ hdrs = ["include/llvm-libc-macros/float-macros.h"],
+)
+
+libc_support_library(
+ name = "llvm_libc_macros_stdint_macros",
+ hdrs = ["include/llvm-libc-macros/stdint-macros.h"],
+)
+
+libc_support_library(
+ name = "llvm_libc_macros_stdfix_macros",
+ hdrs = ["include/llvm-libc-macros/stdfix-macros.h"],
+ deps = [":llvm_libc_macros_float_macros"],
+)
+
+libc_support_library(
+ name = "llvm_libc_types_float128",
+ hdrs = ["include/llvm-libc-types/float128.h"],
+ deps = [":llvm_libc_macros_float_macros"],
)
############################### Support libraries ##############################
@@ -691,7 +715,7 @@ libc_support_library(
":__support_macros_properties_architectures",
":__support_macros_sanitizer",
":errno",
- ":internal_includes",
+ ":llvm_libc_macros_math_macros",
],
)
@@ -764,7 +788,7 @@ libc_support_library(
":__support_fputil_normal_float",
":__support_macros_optimization",
":__support_uint128",
- ":internal_includes",
+ ":llvm_libc_macros_math_macros",
],
)
@@ -778,7 +802,7 @@ libc_support_library(
":__support_fputil_fp_bits",
":__support_fputil_rounding_mode",
":__support_macros_attributes",
- ":internal_includes",
+ ":llvm_libc_macros_math_macros",
],
)
@@ -1007,33 +1031,6 @@ libc_support_library(
],
)
-libc_support_library(
- name = "llvm_libc_macros_limits_macros",
- hdrs = ["include/llvm-libc-macros/limits-macros.h"],
-)
-
-libc_support_library(
- name = "llvm_libc_macros_float_macros",
- hdrs = ["include/llvm-libc-macros/float-macros.h"],
-)
-
-libc_support_library(
- name = "llvm_libc_macros_stdint_macros",
- hdrs = ["include/llvm-libc-macros/stdint-macros.h"],
-)
-
-libc_support_library(
- name = "llvm_libc_macros_stdfix_macros",
- hdrs = ["include/llvm-libc-macros/stdfix-macros.h"],
- deps = [":llvm_libc_macros_float_macros"],
-)
-
-libc_support_library(
- name = "llvm_libc_types_float128",
- hdrs = ["include/llvm-libc-types/float128.h"],
- deps = [":llvm_libc_macros_float_macros"],
-)
-
############################### errno targets ################################
libc_function(
@@ -1200,7 +1197,7 @@ libc_support_library(
"__support_cpp_type_traits",
":__support_common",
":errno",
- ":internal_includes",
+ ":llvm_libc_macros_math_macros",
],
)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel
index 509a89b43f178a..2a0c071f228683 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel
@@ -84,7 +84,7 @@ libc_support_library(
"//libc:__support_fputil_fp_bits",
"//libc:__support_fputil_fpbits_str",
"//libc:__support_fputil_rounding_mode",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
],
)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel
index 15f66281860554..4f976122967c4d 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel
@@ -89,7 +89,7 @@ libc_test(
"//libc:__support_cpp_optional",
"//libc:__support_macros_properties_types",
"//libc:__support_uint",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
],
)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
index 632f55a08a24b6..15e367f0aca2dc 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
@@ -178,7 +178,7 @@ libc_support_library(
deps = [
"//libc:__support_fputil_basic_operations",
"//libc:__support_fputil_fp_bits",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
"//libc/test/UnitTest:LibcUnitTest",
"//libc/test/UnitTest:fp_test_helpers",
"//libc/utils/MPFRWrapper:mpfr_wrapper",
@@ -297,7 +297,7 @@ libc_support_library(
"//libc:__support_cpp_limits",
"//libc:__support_fputil_fp_bits",
"//libc:__support_fputil_manipulation_functions",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
"//libc/test/UnitTest:LibcUnitTest",
],
)
@@ -324,7 +324,7 @@ libc_support_library(
"//libc:__support_fputil_basic_operations",
"//libc:__support_fputil_fenv_impl",
"//libc:__support_fputil_fp_bits",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
"//libc/test/UnitTest:LibcUnitTest",
"//libc/test/UnitTest:fp_test_helpers",
],
@@ -352,7 +352,7 @@ libc_support_library(
"//libc:__support_cpp_limits",
"//libc:__support_fputil_fp_bits",
"//libc:__support_fputil_normal_float",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
"//libc/test/UnitTest:LibcUnitTest",
"//libc/test/UnitTest:fp_test_helpers",
],
@@ -379,7 +379,7 @@ libc_support_library(
deps = [
"//libc:__support_fputil_fenv_impl",
"//libc:__support_fputil_fp_bits",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
"//libc/test/UnitTest:LibcUnitTest",
"//libc/test/UnitTest:fp_test_helpers",
"//libc/utils/MPFRWrapper:mpfr_wrapper",
@@ -416,7 +416,7 @@ libc_support_library(
deps = [
"//libc:__support_fputil_fenv_impl",
"//libc:__support_fputil_fp_bits",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
"//libc/test/UnitTest:LibcUnitTest",
"//libc/test/UnitTest:fp_test_helpers",
"//libc/utils/MPFRWrapper:mpfr_wrapper",
@@ -528,7 +528,7 @@ libc_support_library(
"//libc:__support_cpp_type_traits",
"//libc:__support_fputil_basic_operations",
"//libc:__support_fputil_fp_bits",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
"//libc/test/UnitTest:LibcUnitTest",
"//libc/test/UnitTest:fp_test_helpers",
],
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl b/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl
index faab18a95095f1..1a5868d242e80a 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl
@@ -34,7 +34,7 @@ def math_test(name, hdrs = [], deps = [], **kwargs):
"//libc:__support_math_extras",
"//libc:__support_uint128",
"//libc/test/UnitTest:fp_test_helpers",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
] + deps,
**kwargs
)
|
@llvm/pr-subscribers-mlir Author: Andrzej Warzyński (banach-space) Changes
Full diff: https://github.com/llvm/llvm-project/pull/86178.diff 7 Files Affected:
diff --git a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
index 9f64a07f31e3af..b600f9cea78784 100644
--- a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
@@ -190,6 +190,12 @@ LogicalResult arith::ConstantOp::verify() {
return emitOpError(
"value must be an integer, float, or elements attribute");
}
+ // Intializing scalable vectors with elements attribute is not supported
+ // unless it's a vector splot.
+ auto vecType = dyn_cast<VectorType>(type);
+ auto val = dyn_cast<DenseElementsAttr>(getValue());
+ if ((vecType && val) && vecType.isScalable() && !val.isSplat())
+ return emitOpError("using elements attribute to initialize a scalable vector");
return success();
}
diff --git a/mlir/test/Dialect/Arith/invalid.mlir b/mlir/test/Dialect/Arith/invalid.mlir
index 6d8ac0ada52be3..ac28075df33e9b 100644
--- a/mlir/test/Dialect/Arith/invalid.mlir
+++ b/mlir/test/Dialect/Arith/invalid.mlir
@@ -215,6 +215,14 @@ func.func @func_with_ops() {
// -----
+func.func @func_with_ops() {
+^bb0:
+ // expected-error@+1 {{op failed to verify that result type has i1 element type and same shape as operands}}
+ %c = arith.constant dense<[0, 1]> : vector<[2] x i32>
+}
+
+// -----
+
func.func @invalid_cmp_shape(%idx : () -> ()) {
// expected-error@+1 {{'lhs' must be signless-integer-like, but got '() -> ()'}}
%cmp = arith.cmpi eq, %idx, %idx : () -> ()
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 4766e168daadbd..1d98b986f4818e 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -65,11 +65,35 @@ config_setting(
################################# Include Files ################################
libc_support_library(
- name = "internal_includes",
- textual_hdrs = glob([
- "include/llvm-libc-macros/*.h",
- "include/llvm-libc-types/*",
- ]),
+ name = "llvm_libc_macros_math_macros",
+ hdrs = ["include/llvm-libc-macros/math-macros.h"],
+)
+
+libc_support_library(
+ name = "llvm_libc_macros_limits_macros",
+ hdrs = ["include/llvm-libc-macros/limits-macros.h"],
+)
+
+libc_support_library(
+ name = "llvm_libc_macros_float_macros",
+ hdrs = ["include/llvm-libc-macros/float-macros.h"],
+)
+
+libc_support_library(
+ name = "llvm_libc_macros_stdint_macros",
+ hdrs = ["include/llvm-libc-macros/stdint-macros.h"],
+)
+
+libc_support_library(
+ name = "llvm_libc_macros_stdfix_macros",
+ hdrs = ["include/llvm-libc-macros/stdfix-macros.h"],
+ deps = [":llvm_libc_macros_float_macros"],
+)
+
+libc_support_library(
+ name = "llvm_libc_types_float128",
+ hdrs = ["include/llvm-libc-types/float128.h"],
+ deps = [":llvm_libc_macros_float_macros"],
)
############################### Support libraries ##############################
@@ -691,7 +715,7 @@ libc_support_library(
":__support_macros_properties_architectures",
":__support_macros_sanitizer",
":errno",
- ":internal_includes",
+ ":llvm_libc_macros_math_macros",
],
)
@@ -764,7 +788,7 @@ libc_support_library(
":__support_fputil_normal_float",
":__support_macros_optimization",
":__support_uint128",
- ":internal_includes",
+ ":llvm_libc_macros_math_macros",
],
)
@@ -778,7 +802,7 @@ libc_support_library(
":__support_fputil_fp_bits",
":__support_fputil_rounding_mode",
":__support_macros_attributes",
- ":internal_includes",
+ ":llvm_libc_macros_math_macros",
],
)
@@ -1007,33 +1031,6 @@ libc_support_library(
],
)
-libc_support_library(
- name = "llvm_libc_macros_limits_macros",
- hdrs = ["include/llvm-libc-macros/limits-macros.h"],
-)
-
-libc_support_library(
- name = "llvm_libc_macros_float_macros",
- hdrs = ["include/llvm-libc-macros/float-macros.h"],
-)
-
-libc_support_library(
- name = "llvm_libc_macros_stdint_macros",
- hdrs = ["include/llvm-libc-macros/stdint-macros.h"],
-)
-
-libc_support_library(
- name = "llvm_libc_macros_stdfix_macros",
- hdrs = ["include/llvm-libc-macros/stdfix-macros.h"],
- deps = [":llvm_libc_macros_float_macros"],
-)
-
-libc_support_library(
- name = "llvm_libc_types_float128",
- hdrs = ["include/llvm-libc-types/float128.h"],
- deps = [":llvm_libc_macros_float_macros"],
-)
-
############################### errno targets ################################
libc_function(
@@ -1200,7 +1197,7 @@ libc_support_library(
"__support_cpp_type_traits",
":__support_common",
":errno",
- ":internal_includes",
+ ":llvm_libc_macros_math_macros",
],
)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel
index 509a89b43f178a..2a0c071f228683 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel
@@ -84,7 +84,7 @@ libc_support_library(
"//libc:__support_fputil_fp_bits",
"//libc:__support_fputil_fpbits_str",
"//libc:__support_fputil_rounding_mode",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
],
)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel
index 15f66281860554..4f976122967c4d 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel
@@ -89,7 +89,7 @@ libc_test(
"//libc:__support_cpp_optional",
"//libc:__support_macros_properties_types",
"//libc:__support_uint",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
],
)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
index 632f55a08a24b6..15e367f0aca2dc 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
@@ -178,7 +178,7 @@ libc_support_library(
deps = [
"//libc:__support_fputil_basic_operations",
"//libc:__support_fputil_fp_bits",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
"//libc/test/UnitTest:LibcUnitTest",
"//libc/test/UnitTest:fp_test_helpers",
"//libc/utils/MPFRWrapper:mpfr_wrapper",
@@ -297,7 +297,7 @@ libc_support_library(
"//libc:__support_cpp_limits",
"//libc:__support_fputil_fp_bits",
"//libc:__support_fputil_manipulation_functions",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
"//libc/test/UnitTest:LibcUnitTest",
],
)
@@ -324,7 +324,7 @@ libc_support_library(
"//libc:__support_fputil_basic_operations",
"//libc:__support_fputil_fenv_impl",
"//libc:__support_fputil_fp_bits",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
"//libc/test/UnitTest:LibcUnitTest",
"//libc/test/UnitTest:fp_test_helpers",
],
@@ -352,7 +352,7 @@ libc_support_library(
"//libc:__support_cpp_limits",
"//libc:__support_fputil_fp_bits",
"//libc:__support_fputil_normal_float",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
"//libc/test/UnitTest:LibcUnitTest",
"//libc/test/UnitTest:fp_test_helpers",
],
@@ -379,7 +379,7 @@ libc_support_library(
deps = [
"//libc:__support_fputil_fenv_impl",
"//libc:__support_fputil_fp_bits",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
"//libc/test/UnitTest:LibcUnitTest",
"//libc/test/UnitTest:fp_test_helpers",
"//libc/utils/MPFRWrapper:mpfr_wrapper",
@@ -416,7 +416,7 @@ libc_support_library(
deps = [
"//libc:__support_fputil_fenv_impl",
"//libc:__support_fputil_fp_bits",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
"//libc/test/UnitTest:LibcUnitTest",
"//libc/test/UnitTest:fp_test_helpers",
"//libc/utils/MPFRWrapper:mpfr_wrapper",
@@ -528,7 +528,7 @@ libc_support_library(
"//libc:__support_cpp_type_traits",
"//libc:__support_fputil_basic_operations",
"//libc:__support_fputil_fp_bits",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
"//libc/test/UnitTest:LibcUnitTest",
"//libc/test/UnitTest:fp_test_helpers",
],
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl b/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl
index faab18a95095f1..1a5868d242e80a 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl
@@ -34,7 +34,7 @@ def math_test(name, hdrs = [], deps = [], **kwargs):
"//libc:__support_math_extras",
"//libc:__support_uint128",
"//libc/test/UnitTest:fp_test_helpers",
- "//libc:internal_includes",
+ "//libc:llvm_libc_macros_math_macros",
] + deps,
**kwargs
)
|
0fac9f0
to
5f37e9b
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
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> ```
5f37e9b
to
ed1eb3a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a drive by nit
auto val = dyn_cast<DenseElementsAttr>(getValue()); | ||
if ((vecType && val) && vecType.isScalable() && !val.isSplat()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you can simplify this a bit
auto val = dyn_cast<DenseElementsAttr>(getValue()); | |
if ((vecType && val) && vecType.isScalable() && !val.isSplat()) | |
if (vecType && vecType.isScalable() && !isa<SplatElementsAttr>(getValue())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, have you thought of having a convenience type for scalable vectors? I mean ScalableVectorType
that is VectorType
with a classoff function that checks for the scalable bit, similar to how we have spirv::ScalarType
that allows ints and floats. Then you could use that for isa<ScalableVectorType>(...)
checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting idea - I've not thought about it, no. Thanks for the suggestion! Though isa<ScalableVectorType>(...)
would be longer than vecType.isScalable()
🤷🏻
In general, we've been discussing how to better represent "scalable" vectors in MLIR for a while now. There was also a long discussion on "dynamic" vector type too:
I know that @dcaballe has been working on an updated class hierarchy for vectors. IIRC, that's not at the top of the priority list ATM, but it would be good to revisit it soon 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting idea - I've not thought about it, no. Thanks for the suggestion! Though isa(...) would be longer than vecType.isScalable() 🤷🏻
only if you have a vector type already. if the starting point is just Type
, you could do auto scalableTy = dyn_cast<ScalableVectorType>(myType):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, we've been discussing how to better represent "scalable" vectors in MLIR for a while now. There was also a long discussion on "dynamic" vector type too:
What I suggested above is just a convenience type that doesn't affect the hierarchy in any way, similar to spirv::ScalarType
or SplatElementsAttr
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've not tried it yet, but intend to do so this week.
One worry that I have is naming - we may want to keep ScalableVectorType
for when we do update the hierarchy. This is worth trying nonetheless!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be a good stepping stone but let's discuss further to make sure we don't make the potential big change more complicated. Revisiting VectorType
is something I would like to do hopefully this month.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kuhar I went ahead and landed this to unblock myself elsewhere. I've also tried your suggestion and was positively surprised how straightforward that was:
@dcaballe I've prepared #87986 as one point in the discussion on VectorType
refactor. Mainly so that we have a reference. However, having implemented it I feel that it would indeed be a good stepping stone 😅
Address PR comments
Seems like this broke a test: https://lab.llvm.org/buildbot/#/builders/61/builds/56565 I guess you haven't rebased for a while before merging so pre-merge didn't catch it? |
This reverts commit 662c626. Broken both: * https://lab.llvm.org/buildbot/#/builders/61/builds/56565
Thanks and sorry for the disruption! I've just reverted this. I'll upload a fixed version in a few mins and the let the pre-commit double-check it. |
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> ``` Note: This is a re-upload of llvm#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> ``` Note: This is a re-upload of #86178
Disallows initialization of scalable vectors with an attribute of
arbitrary values, e.g.:
Initialization using vector splats remains allowed (i.e. when all the
init values are identical):