Thanks for all the feedback! I want to highlight that this approach is not intending to leave any project behind or concern unaddressed, of course. My previous comment was about ensuring that not only 0-D tensors but also 0-D vectors outside the Vector dialect can be efficiently lowered to the Vector dialect.
This is actually the churn we need to introduce today to handle 0-D vectors and it spreads all over the Vector dialect, unfortunately. I see a difference between a precise (though perhaps less flexible) representation and an ambiguous one. The former can lead to slightly suboptimal (~canonicalization) IR but concrete and mechanical transformations. The latter requires making a call to resolve every ambiguous point in the representation in one way or the other and managing the combinatorial explosion of the fact that every ambiguous point can have a different resolution. As showcased, examples of this are vector.extract and vector.insert, with multiple ambiguous points within the same operation.
Thanks for elaborating on this. It’s great to better understand different mental models. IMO, only Category 1 should exist since it’s a super-set of the others. Progressive lowering allows us to refine and constraint the IR to incrementally align with the next level of abstraction/egress dialect. We also can’t exclude multi-dimensional Vectors at any vector level, as some architectures natively support them already.
A bit of history that may help understand the current state: operations in Category 3 were introduced out of necessity when there was a gap in the representation and we used LLVM as a reference to quickly fill that gap. Later, when generalization was needed, we introduced new ops for pathfinding and building expertise without disrupting the “stable” operations. This was the case with vector.insertelement/extractelement / vector.insert/extract, but there are others. We have been working on improving this situation and we should continue to do so.
A quick comment here: I think this needs to be revisited. We can’t drop 0-D support from the operations that allow transitions into and out of 0-D vectors. This should be the final step, as we need them to proceed incrementally while preserving stability. We should first strengthen the scalar/vector support in “boundary” operations to ensure they properly cover all the necessary cases. Then, we can start with simple elementwise operations and build the support that frameworks need for them. Next, we can tackle more involved operations like reductions. And, finally, we can remove 0-D support from the “boundary” operations.