Skip to content

[mlir][vector] Restrict vector.insert/vector.extract #121458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

banach-space
Copy link
Contributor

This patch restricts the use of vector.insert and vector.extract Ops in
the Vector dialect. Specifically:

  • The non-indexed operands for vector.insert and vector.extract
    must now be non-0-D vectors.

The following are now illegal. Note that the source and result types
(i.e. non-indexed args) are rank-0 vectors:

  %0 = vector.insert %v, %dst[0, 0] : vector<f32> into vector<2x2xf32>
  %1 = vector.extract %arg0[0, 0] : vector<f32> from vector<2x2xf32>

Instead, use scalars as the source and result types:

  %0 = vector.insert %v, %dst[0, 0] : f32 into vector<2x2xf32>
  %1 = vector.extract %src[0, 0] : f32 from vector<2x2xf32>

Put differently, this PR removes the ambiguity when it comes to
non-indexed operands of vector.insert and vector.extract. By
requiring that only one form is used, it eliminates the flexibility of
allowing both, thereby simplifying the semantics.

For more context, see the related RFC:

@banach-space
Copy link
Contributor Author

While the discussion is ongoing, I am posting this as draft. Please comment either here or on Discourse.

@banach-space banach-space force-pushed the andrzej/restrict_vec_insert_extract branch from 0962edb to 473bd0f Compare January 6, 2025 09:01
Copy link

github-actions bot commented Jan 6, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@banach-space banach-space force-pushed the andrzej/restrict_vec_insert_extract branch from 473bd0f to 9434337 Compare January 6, 2025 09:08
@banach-space banach-space force-pushed the andrzej/restrict_vec_insert_extract branch from 9434337 to eb62bf0 Compare February 8, 2025 15:24
@banach-space banach-space force-pushed the andrzej/restrict_vec_insert_extract branch from eb62bf0 to 4084038 Compare April 29, 2025 10:39
@banach-space banach-space force-pushed the andrzej/restrict_vec_insert_extract branch from 4084038 to c214bbf Compare May 28, 2025 20:25
This patch restricts the use of vector.insert and vector.extract Ops in
the Vector dialect. Specifically:
  * The non-indexed operands for `vector.insert` and `vector.extract`
    must now be non-0-D vectors.

The following are now illegal. Note that the source and result types
(i.e. non-indexed args) are rank-0 vectors:

```mlir
  %0 = vector.insert %v, %dst[0, 0] : vector<f32> into vector<2x2xf32>
  %1 = vector.extract %arg0[0, 0] : vector<f32> from vector<2x2xf32>
```
Instead, use scalars as the source and result types:

```mlir
  %0 = vector.insert %v, %dst[0, 0] : f32 into vector<2x2xf32>
  %1 = vector.extract %src[0, 0] : f32 from vector<2x2xf32>
```

Put differently, this PR removes the ambiguity when it comes to
non-indexed operands of `vector.insert` and `vector.extract`. By
requiring that only one form is used, it eliminates the flexibility of
allowing both, thereby simplifying the semantics.

For more context, see the related RFC:
  * https://discourse.llvm.org/t/rfc-should-we-restrict-the-usage-of-0-d-vectors-in-the-vector-dialect
@banach-space banach-space force-pushed the andrzej/restrict_vec_insert_extract branch from c214bbf to 29e7bb6 Compare May 30, 2025 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant