TL;DR: I’m thinking about making a few cleanup changes to the Vector dialect and thought that removing the legacy
vector.insertelement operations in favor of their bigger siblings
vector.insert would be a good start. If we agree on this, this post will serve as an initial PSA of the change. Please let me know what you think! Collaboration on this work is more than welcome!
Currently, we have two operations for extracting elements from a vector value:
vector.extractelement was introduced in early stages of MLIR as a carbon copy of the LLVM
extractelement instruction. This operation can only extract scalar elements from a 1-D or 0-D vector. Some time later, the Vector dialect evolved towards n-D vectors and
vector.extractelement was introduced to model scalar and sub-vector extractions from an n-D vector. To some extent,
vector.extract is a superset of
vector.extractelement, although the former currently does not support extractions from 0-D vectors. The same applies to the
I propose that we add support for 0-D vectors to
vector.insert and remove
vector.insertelement. The replacement of
vector.extractelement/insertelement’s uses would be mechanical once
vector.extract/insert support 0-D vectors.
This change will improve the Vector dialect by:
- Removing ambiguity from the vector representation when it comes to extracting elements from a vector value.
- Removing redundant patterns/transformations currently implemented for both
- Filling implementation gaps in patterns/transformations where only one of the operation flavors is supported.
- Introduce 0-D support in
- Fill any implementation gap in
vector.extract/insertops. Make sure that all the
vector.extractelement/insertelementpatterns and transformations are also supported for
vector.extractelement/insertelementfrom upstream except for the ops themselves. Send another PSA with the imminent removal of the ops. We can add warnings to the ops’ builders for downstream users, if necessary.
Please let me know if you have any concerns or feedback! This is also a call for collaboration on this work. I’ll definitely need help!