In IREE we use shapex.tie_shape
to tie together a tensor value and its shape.
This is an integral part of how we handle dynamic shapes, which can be summarized as:
- before dispatch region formation, we
- create
shapex.get_ranked_shape
(similar to upstreamshape.shape_of
) on every tensor in the program, creating !shapex.ranked_shape values for every tensor. - create
shapex.tie_shape
ops tieing each tensor to its corresponding shape - Have a series of patterns that replace shapex.get_ranked_shape with some computation on the operands of the op that defines the operand of shapex.get_ranked_shape
- Apply these patterns iteratively to "bypass" all the get_ranked_shape ops using shape transfer functions so that all shapes (or as many as possible) in the program can be eliminated and replaced with computations on the shapes of the function inputs (which ideally is just sim