The tensor_reshape op was only fusible only if it is a collapsing case. Now we
propagate the op to all the operands so there is a further chance to fuse it
with generic op. The pre-conditions are:
- The producer is not an indexed_generic op.
- All the shapes of the operands are the same.
- All the indexing maps are identity.
- All the loops are parallel loops.
It is possible to fuse the ops if the producer is an indexed_generic op. We
still can compute the original indices. E.g., if the reshape op collapses the d0
and d1, we can use DimOp to get the width of d1, and calculate the index
d0 * width + d1. Then replace all the uses with it. However, this pattern is
not implemented in the patch.
Nit: I was hoping you would be able to pick a better name than isFusibleCase1 (I used it cause I couldnt think of one). Same for isFusibleCase2
Maybe make *Case1 -> *WhenCollapsing and *Case2 -> *WhenExpanding?