-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[mlir] -test-vector-unrolling-patterns
pass failed with assertion error "cast<Ty>() argument of incompatible type!"
#64075
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
Comments
@llvm/issue-subscribers-mlir |
I have found the root cause, but I give up on fixing this for now because I cannot figure it what to change. Maybe later. The root cause is that A minimum example that also crashes: func.func @multi_reduction(%0: vector<4x2xf32>, %acc1: f32) -> f32 {
%2 = vector.multi_reduction <add>, %0, %acc1 [0, 1] : vector<4x2xf32> to f32
return %2 : f32
} To see that these return types make sense, take the following Julia example: julia> A = reshape(1:(3*3), 3, 3)
3×3 reshape(::UnitRange{Int64}, 3, 3) with eltype Int64:
1 4 7
2 5 8
3 6 9
julia> A[2:2, 2:2] # extract strided slice with offset = [0, 0], sizes = [1, 1], stride = [1, 1]
1×1 Matrix{Int64}:
5 So, indeed, it makes sense that a strided slice returns a n-dimensional vector even for a single scalar result. Next, reduce doesn't necessarily have to return a vector: julia> reduce(min, A[2:2, 2:2])
5 This problem with mismatching types most likely lies somewhere in the llvm-project/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp Lines 348 to 415 in c6f0f88
|
I was looking forward to working on this issue. Can this issue be assigned to me? |
@Prakhar-Dixit yea sure - good luck and god speed 😄 |
After investigating this issue, I discovered that the Minimal Example of the Crashing IR:
The IR appears valid because it lowers correctly and shows no signs of being invalid. Therefore, I believe the proper fix is to bail out instead of handling scalars, as I assume it was never intended to do so when the operation is asked to reduce a vector to a scalar. For example:
Would love to hear your thoughts on this, |
…29694) Fixes issue #64075 Referencing this comment for more detailed view -> #64075 (comment) **Minimal example crashing :** ``` func.func @multi_reduction(%0: vector<4x2xf32>, %acc1: f32) -> f32 { %2 = vector.multi_reduction <add>, %0, %acc1 [0, 1] : vector<4x2xf32> to f32 return %2 : f32 } ```
… scalar (#129694) Fixes issue #64075 Referencing this comment for more detailed view -> llvm/llvm-project#64075 (comment) **Minimal example crashing :** ``` func.func @multi_reduction(%0: vector<4x2xf32>, %acc1: f32) -> f32 { %2 = vector.multi_reduction <add>, %0, %acc1 [0, 1] : vector<4x2xf32> to f32 return %2 : f32 } ```
MLIR built at commit 585cbe3
Reproduced with:
mlir-opt -test-vector-unrolling-patterns=unroll-based-on-type temp.mlir
temp.mlir:
trace:
The text was updated successfully, but these errors were encountered: