[Mlir-commits] [mlir] [mlir][vector] Add `vector.from_elements` op (PR #95938)
Diego Caballero
llvmlistbot at llvm.org
Tue Jun 18 09:54:57 PDT 2024
================
@@ -769,6 +768,35 @@ def Vector_FMAOp :
}];
}
+def Vector_FromElementsOp : Vector_Op<"from_elements", [
+ Pure,
+ TypesMatchWith<"operand types match result element type",
+ "result", "elements", "SmallVector<Type>("
+ "::llvm::cast<VectorType>($_self).getNumElements(), "
+ "::llvm::cast<VectorType>($_self).getElementType())">]> {
+ let summary = "operation that defines a vector from scalar elements";
+ let description = [{
+ This operation defines a vector from one or multiple scalar elements. The
+ number of elements must match the number of elements in the result type.
+ All elements must have the same type, which must match the element type of
+ the result vector type.
+
+ Example:
+
+ ```mlir
+ // [%f1, %f2]
+ %0 = vector.from_elements %f1, %f2 : vector<2xf32>
+ // [[%f1, %f2, %f3], [%f4, %f5, %f6]]
+ %1 = vector.from_elements %f1, %f2, %f3, %f4, %f5, %f6 : vector<2x3xf32>
----------------
dcaballe wrote:
I think explaining how each input element maps to the shape elements (both, in the doc and being more explicit in the example) would help understanding, esp. for the multi-dim case.
https://github.com/llvm/llvm-project/pull/95938
More information about the Mlir-commits
mailing list