[PATCH] D72933: Adds CastSliceOp to the vector ops dialect.

Andy Davis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 21 07:16:47 PST 2020


andydavis1 marked an inline comment as done.
andydavis1 added inline comments.


================
Comment at: mlir/include/mlir/Dialect/VectorOps/VectorOps.td:964
+    ```mlir
+     // Cast slices of 'vector<4x1x3x12xf32>' from shape 1x1x3x12 to 3x12
+     %1 = vector.cast_slices %0, [1, 1, 3, 12], [3, 12]
----------------
nicolasvasilache wrote:
> I find the semantics harder to grasp than it could, I think.
> I think the issue is that the **usage** you have for "cast_slices" leaks into the semantics of the op and I don't think it is warranted.
> ```
>  %1 = vector.cast_slices %0, [1, 1, 3, 12], [3, 12]
>        : vector<4x1x3x12xf32> to vector<12x12xf32>
> ```
> 
> I can think of different ways of specifying this that I would find more natural but first I'd like to understand why you need these attributes in this form and where ambiguity appears that makes it impossible to derive them automatically.
> 
> In particular I view this as conflating 2 unrelated things: (1) a reshape that does not move and (2) a multiplicity.
> See how (1) is represented in linalg.reshape with [affine maps](https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td#L92).
> 
> It would be great if we could uniformize things (if is makes sense).
> Note that this may be an indication that you need 2 ops to express what you want.
> 
> Marking as "request changes" until the discussion is resolved. 
> 
This operation specifies a cast from one vector type to another.  I intentionally did not use affine maps (or even the less expressive permutation of dimensions to reshape), so that this operation was even more restricted to its purpose.  Its purpose is express a trivial cast between slices of the source/result vectors. Because these aggegate vectors will eventually need to be decomposed to hardware vectors, whats important is that the slices of these vectors have trivial casts that can be canonicalized away.

As an analogy. Think of a reshape operation which starts with the linear address, and de-linearizes this into the source (resp result) vector shape, by using the source (resp result) strides. Instead of source/result permutation of dims, the cast_slices operation specifies the source/result decomposition of slices and further restricts the operation in the following simple ways:

1) source/result must generate the same number slices so there is a 1-to-1 relationship between a source slice and its associated result slice.
2) each source/result slice pair must be trivial castable to each other


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72933/new/

https://reviews.llvm.org/D72933





More information about the llvm-commits mailing list