Skip to content
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

[mlir][vector] Add tests for scalable vectors in one-shot-bufferize.mlir #102361

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions mlir/test/Dialect/Vector/bufferize-invalid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ func.func @mask(%t0: tensor<?xf32>, %val: vector<16xf32>, %idx: index, %m0: vect
%0 = vector.mask %m0 { vector.transfer_write %val, %t0[%idx] : vector<16xf32>, tensor<?xf32> } : vector<16xi1> -> tensor<?xf32>
return %0 : tensor<?xf32>
}

// -----

// CHECK-LABEL: func @mask_scalable(
func.func @mask_scalable(%t0: tensor<?xf32>, %val: vector<[16]xf32>, %idx: index, %m0: vector<[16]xi1>) -> tensor<?xf32> {
// expected-error @+1 {{'vector.mask' op body must bufferize in-place}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this error doesn't consider scalability so the test above covers both fixed and scalable vectors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there isn't anything specific about scalable vectors here. However, we want to avoid a situation where scalable vectors are "missed" when implementing this at some later point in time (we wouldn't know without a test).

I guess we can achieve this by simply updating the existing example to use scalable vectors. WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just looking at the pattern I see it's bufferizing mask ops so tensors are converted to memrefs and it creates a new mask op. Given the vector type is simply forwarded during bufferization (for both one-shot and out of place) I struggle to see where this could go wrong for scalable vectors.

I'm not particularly concerned about this one tbh and think it would be fine to leave it, but I did notice there's a TODO in https://github.com/llvm/llvm-project/blob/main/mlir/test/Dialect/Vector/bufferize.mlir#L47-L48

which refers to a positive test for this pattern for one shot https://github.com/llvm/llvm-project/blob/main/mlir/test/Dialect/Vector/one-shot-bufferize.mlir#L6-L13

so could add a positive test there for scalable vectors that should be noticed when this is addressed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking that and for the suggestion!

so could add a positive test there for scalable vectors that should be noticed when this is addressed?

Yeah, lets go with that. I've just updated this PR.

%0 = vector.mask %m0 { vector.transfer_write %val, %t0[%idx] : vector<[16]xf32>, tensor<?xf32> } : vector<[16]xi1> -> tensor<?xf32>
return %0 : tensor<?xf32>
}
Loading