[Mlir-commits] [mlir] [mlir][vector] Update syntax and representation of insert/extract_strided_slice (PR #101850)
Mehdi Amini
llvmlistbot at llvm.org
Mon Aug 5 13:48:36 PDT 2024
================
@@ -82,4 +87,63 @@ def Vector_PrintPunctuation : EnumAttr<Vector_Dialect, PrintPunctuation, "punctu
let assemblyFormat = "`<` $value `>`";
}
+def Vector_StridedSliceAttr : Vector_Attr<"StridedSlice", "strided_slice">
+{
+ let summary = "strided vector slice";
+
+ let description = [{
+ An attribute that represents a strided slice of a vector.
+
+ *Syntax:*
+
+ ```
+ offset = integer-literal
+ stride = integer-literal
+ size = integer-literal
+ offset-list = offset (`,` offset)*
+
+ // Without sizes (used for insert_strided_slice)
+ strided-slice-without-sizes = offset-list? (`[` offset `:` stride `]`)+
+
+ // With sizes (used for extract_strided_slice)
+ strided-slice-with-sizes = (`[` offset `:` size `:` stride `]`)+
+ ```
+
+ *Examples:*
+
+ Without sizes:
+
+ `[0:1][4:2]`
+
+ - The first dimension starts at offset 0 and is strided by 1
+ - The second dimension starts at offset 4 and is strided by 2
+
+ `[0, 1, 2][3:1][4:8]`
----------------
joker-eph wrote:
I find this quite hard to read: why are some dimensions separated in their own `[` `]` group but not the non-strided ones?
In general the implicit size seems also hard to read. I'm not sure how to make it better though right now.
Looking at some examples that go from `{offsets = [1, 1], sizes = [2, 2], strides = [1, 1]}` to `[1:2:1][1:2:1]`, I appreciate the compact aspect but I'm not looking forward to need to keep the doc open always to be able to read it...
https://github.com/llvm/llvm-project/pull/101850
More information about the Mlir-commits
mailing list