[Mlir-commits] [mlir] [mlir][Vector] Add `vector.to_elements` op (PR #141457)

James Newling llvmlistbot at llvm.org
Tue May 27 08:24:26 PDT 2025


================
@@ -789,6 +789,57 @@ def Vector_FMAOp :
   }];
 }
 
+def Vector_ToElementsOp : Vector_Op<"to_elements", [
+    Pure,
+    TypesMatchWith<"operand element type matches result types",
+                   "input", "elements", "SmallVector<Type>("
+                   "::llvm::cast<VectorType>($_self).getNumElements(), "
+                   "::llvm::cast<VectorType>($_self).getElementType())">]> {
+  let summary = "operation that decomposes a vector into all its scalar elements";
+  let description = [{
+    This operation decomposes all the scalar elements from a vector. The
+    decomposed scalar elements are returned in row-major order. The number of
+    scalar results must match the number of elements in the input vector type.
+    All the result elements have the same result type, which must match the
+    element type of the input vector. Scalable vectors are not supported.
----------------
newling wrote:

I think that keeping the symmetry with `from_elements` is valuable. I'm not sure I follow the suggestion, but is it doing something that chaining `extract` / `extract_strided_slice` / `shape_cast` / `to_elements` cannot achieve? 


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


More information about the Mlir-commits mailing list