- 
                Notifications
    
You must be signed in to change notification settings  - Fork 15.1k
 
          [mlir][Vector] Add vector.to_elements op
          #141457
        
          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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -1175,6 +1175,25 @@ func.func @deinterleave_nd_scalable(%arg:vector<2x3x4x[6]xf32>) -> (vector<2x3x4 | |
| return %0, %1 : vector<2x3x4x[3]xf32>, vector<2x3x4x[3]xf32> | ||
| } | ||
| 
     | 
||
| // CHECK-LABEL: func @to_elements( | ||
| // CHECK-SAME: %[[A_VEC:.*]]: vector<f32>, %[[B_VEC:.*]]: vector<4xf32>, | ||
| // CHECK-SAME: %[[C_VEC:.*]]: vector<1xf32>, %[[D_VEC:.*]]: vector<2x2xf32>) | ||
| func.func @to_elements(%a_vec : vector<f32>, %b_vec : vector<4xf32>, %c_vec : vector<1xf32>, %d_vec : vector<2x2xf32>) | ||
| -> (f32, f32, f32, f32, f32, f32, f32, f32, f32, f32) { | ||
| // CHECK: %[[A_ELEMS:.*]] = vector.to_elements %[[A_VEC]] : vector<f32> | ||
| %0 = vector.to_elements %a_vec : vector<f32> | ||
| // CHECK: %[[B_ELEMS:.*]]:4 = vector.to_elements %[[B_VEC]] : vector<4xf32> | ||
| %1:4 = vector.to_elements %b_vec : vector<4xf32> | ||
| // CHECK: %[[C_ELEMS:.*]] = vector.to_elements %[[C_VEC]] : vector<1xf32> | ||
| %2 = vector.to_elements %c_vec : vector<1xf32> | ||
| // CHECK: %[[D_ELEMS:.*]]:4 = vector.to_elements %[[D_VEC]] : vector<2x2xf32> | ||
| %3:4 = vector.to_elements %d_vec : vector<2x2xf32> | ||
| // CHECK: return %[[A_ELEMS]], %[[B_ELEMS]]#0, %[[B_ELEMS]]#1, %[[B_ELEMS]]#2, | ||
| // CHECK-SAME: %[[B_ELEMS]]#3, %[[C_ELEMS]], %[[D_ELEMS]]#0, %[[D_ELEMS]]#1, | ||
| // CHECK-SAME: %[[D_ELEMS]]#2, %[[D_ELEMS]]#3 | ||
| return %0, %1#0, %1#1, %1#2, %1#3, %2, %3#0, %3#1, %3#2, %3#3 : f32, f32, f32, f32, f32, f32, f32, f32, f32, f32 | ||
| } | ||
                
       | 
||
| 
     | 
||
| // CHECK-LABEL: func @from_elements( | ||
| // CHECK-SAME: %[[a:.*]]: f32, %[[b:.*]]: f32) | ||
| func.func @from_elements(%a: f32, %b: f32) -> (vector<f32>, vector<1xf32>, vector<1x2xf32>, vector<2x2xf32>) { | ||
| 
          
            
          
           | 
    ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it important that it decomposes into all elements? This op could be really useful for unrolling a dimension if we could do it dimwise. Something like:
This should have the exact same semantics as vector.extract, just doing multiple extracts at once.
I would much rather have this form of the operation, it is much closer to vector.extract and works for N-D vectors much better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that keeping the symmetry with
from_elementsis valuable. I'm not sure I follow the suggestion, but is it doing something that chainingextract/extract_strided_slice/shape_cast/to_elementscannot achieve?