[Mlir-commits] [mlir] [mlir][llvm dialect] Verify element type of nested types (PR #148975)

Tobias Gysi llvmlistbot at llvm.org
Tue Jul 15 23:31:33 PDT 2025


================
@@ -3112,6 +3113,18 @@ static int64_t getNumElements(Type t) {
   return 1;
 }
 
+/// Determine the element type of `type`. Supported types are `VectorType`,
+/// `TensorType`, and `LLVMArrayType`. Everything else is treated as a scalar.
+static Type getElementType(Type type) {
+  while (auto arrayType = dyn_cast<LLVM::LLVMArrayType>(type))
+    type = arrayType.getElementType();
+  if (auto vecType = dyn_cast<VectorType>(type))
+    return vecType.getElementType();
+  if (auto tenType = dyn_cast<TensorType>(type))
----------------
gysit wrote:

nit: the TensorType can be dropped. It is not a compatible LLVM type (see `isCompatibleOuterType`) and since ConstantOp returns an LLVM type there should be no tensors here.

https://github.com/llvm/llvm-project/pull/148975


More information about the Mlir-commits mailing list