The operation shape.const_shape was used for constants of type shape only.
We can now also use it to create constant extent tensors.
Depends On D84156
Paths
| Differential D84157
[MLIR][Shape] Generalize `shape.const_shape` to extent tensors ClosedPublic Authored by frgossen on Jul 20 2020, 5:30 AM.
Details
Diff Detail
Unit TestsFailed Event Timelinefrgossen added a child revision: D84158: [MLIR][Shape] Allow `shape.get_extent` to operate on extent tensors.Jul 20 2020, 5:31 AM Comment Actions Shouldn't shape.const_shape always return a tensor? It cannot return an error currently, right? Comment Actions Not at the moment but I think eventually it should also be possible to create constant error shapes. Comment Actions What do you think about %1 = shape.const_shape [1, 2, 3] %2 = shape.const_extent_tensor [4, 5, 6] instead of %1 = shape.const_shape [1, 2, 3] : !shape.shape %2 = shape.const_shape [4, 5, 6] : tensor<?xindex> ? That seems more succinct. Also, the right thing here, given our current rationale, is to always return an extent tensor from this op since it cannot be an error. Are you planning on doing that migration as well? It seems that this patch puts us in an awkward intermediate state. stellaraccident added inline comments.
Comment Actions This is indeed an intermediate state. We would like to update all operations so that they accept extent tensors. At that point, the operation const_shape could be split in two operations: const_shape for extent tensors and const_error. Eventually, we would like to replace const_shape with std.constant. However, that requires type refinement as we can only create statically shaped extent tensors this way. When fed into a return operation, e.g., that causes problems otherwise.
This revision is now accepted and ready to land.Jul 21 2020, 9:21 AM Closed by commit rG14d3cef01264: [MLIR][Shape] Generalze `shape.const_shape` to extent tensors (authored by frgossen). · Explain WhyJul 24 2020, 1:07 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 279257 mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
mlir/lib/Dialect/Shape/IR/Shape.cpp
mlir/test/Dialect/Shape/canonicalize.mlir
mlir/test/Dialect/Shape/ops.mlir
|
What is the rationale for having a shape-specific constant op for this? Since tensor<?xindex> is a standard type, [std.]constant is the right way to be constructing constants for it, no?