[RFC] Should We Restrict the Usage of 0-D Vectors in the Vector Dialect?

Thank you for reviewing and providing detailed feedback, @MaheshRavishankar!

Agreed. This RFC is intentionally limited to the first point.

My overarching goal is to improve the Vector dialect. Whether we ultimately decide to support or restrict 0-D vectors, there’s significant work needed to clarify semantics and reduce complexity. There’s already been great progress, so thanks to @Groverkss for these contributions:

And @dcaballe has been tackling the unfortunate vector.extract/vector.insert verifier (thank you!):

Despite this progress, the sheer number of edge cases remains a maintenance burden. To my knowledge, 0-D vector support does not address any compelling practical needs to justify this overhead.

To clarify, my proposal only restricts the non-indexed argument case. For instance, this remains valid:

%0 = vector.extract %src[] : f32 from vector<f32>
%1 = vector.insert %v, %dst[] : f32 into vector<f32>
  1. Does the Tensor dialect’s support for 0-D tensors mean we must support 0-D vectors universally in Vector?
  2. This RFC does not propose removing 0-D vector support entirely. The scope is far more limited.

I disagree :slight_smile: My experience suggests that supporting 0-D vectors introduces more complexity than not supporting them.

That said, I recognize this is a nuanced topic. 0-D vectors address some challenges but create others, such as the ambiguity described in my original post. The goal here is to start defining and enforcing semantics around 0-D vectors to better understand their role.

True, but conversely, there’s also substantial code checking:

if (vectorType.getRank() == 0)

This wouldn’t be there without 0-D vectors :wink:

Now, I do agree with you and your concerns. But I just have a feeling that we will discover that in practice this isn’t such an issue. The whole point of labelling this as an experiment is check and understand the impact. Right now I feel that this is my gut feeling versus yours :slight_smile:

Indeed, and I referenced the relevant LLVM code in my post (and provided an e2e example lowering to assembly). However, the point stands: Introducing 0-D vectors in one place necessitates their elimination elsewhere.

Note that vector.extractelement and vector.insertelement are being removed:

As mentioned in my RFC:


Final thoughts:

  1. This RFC is not about removing 0-D vectors.
    • It’s about understanding where they solve problems and assessing whether their complexity is justified.
    • The patchy current support makes it hard to evaluate their role properly.
  2. Ubiquitous support for 0-D vectors is neither good nor necessary, IMO.
    • However, to explore the problem space, we need to experiment.

Thank you :slight_smile:
-Andrzej