Simplify common pattern of shape.get_extent depending on shape_of.
The successive operations can be replaces with the standard dim operation.
This rewrite later avoids unnecessary shape materialization in memory.
Depends On D81834
Differential D81871
[MLIR][Shape] Simplify `get_extent` when dependent on `shape_of` frgossen on Jun 15 2020, 12:56 PM. Authored by
Details
Diff Detail
Event Timeline
Comment Actions As per discussion today, this pattern is going to "fight" with what we are doing with IREE (and also npcomp). Can we reserve this pattern for the shape to std-with-descriptors lowering? Does this pattern actually have much value outside lowering? The dim op + casts doesn't seem much more analyzable than get_extent(shape_of(x)) Comment Actions I don't think it fights with it. You will get dim operations in the code anyway that you have to resolve during lowering for IREE. dim(%val) is the canonical way in mlir to get the dimension of a tensor and is understood by most analyses, while get_extend(shape_of(...)) is not. In any case, I am also ok with this to be a lowering. It just felt more like a canonicalization to me.
Comment Actions Just names, but we can bikeshed on names some more later.
Comment Actions It's slightly embarrassing but it seems to work now. |
Give this a name that reflects the purpose more. createSimplifyShapeToStandardPass or something? These are in the global mlir namespace, so they need to be somewhat unique.