-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir][affine] Define affine.linearize_index
#114480
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 all commits
e640096
0b396e5
b6f5cba
7f621e3
dddd987
c00a220
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 |
---|---|---|
|
@@ -41,3 +41,29 @@ func.func @dynamic_basis(%linear_index: index, %src: memref<?x?x?xf32>) -> (inde | |
%1:3 = affine.delinearize_index %linear_index into (%b0, %b1, %b2) : index, index, index | ||
return %1#0, %1#1, %1#2 : index, index, index | ||
} | ||
|
||
// ----- | ||
|
||
// CHECK-DAG: #[[$map0:.+]] = affine_map<()[s0, s1, s2] -> (s0 * 15 + s1 * 5 + s2)> | ||
|
||
// CHECK-LABEL: @linearize_static | ||
// CHECK-SAME: (%[[arg0:.+]]: index, %[[arg1:.+]]: index, %[[arg2:.+]]: index) | ||
// CHECK: %[[val_0:.+]] = affine.apply #[[$map0]]()[%[[arg0]], %[[arg1]], %[[arg2]]] | ||
// CHECK: return %[[val_0]] | ||
func.func @linearize_static(%arg0: index, %arg1: index, %arg2: index) -> index { | ||
%0 = affine.linearize_index [%arg0, %arg1, %arg2] by (2, 3, 5) : index | ||
func.return %0 : index | ||
} | ||
|
||
// ----- | ||
|
||
// CHECK-DAG: #[[$map0:.+]] = affine_map<()[s0, s1, s2, s3, s4] -> (s1 * s2 + s3 + s0 * (s2 * s4))> | ||
|
||
// CHECK-LABEL: @linearize_dynamic | ||
// CHECK-SAME: (%[[arg0:.+]]: index, %[[arg1:.+]]: index, %[[arg2:.+]]: index, %[[arg3:.+]]: index, %[[arg4:.+]]: index, %[[arg5:.+]]: index) | ||
// CHECK: %[[val_0:.+]] = affine.apply #[[$map0]]()[%[[arg0]], %[[arg1]], %[[arg5]], %[[arg2]], %[[arg4]]] | ||
// CHECK: return %[[val_0]] | ||
func.func @linearize_dynamic(%arg0: index, %arg1: index, %arg2: index, %arg3: index, %arg4: index, %arg5: index) -> index { | ||
%0 = affine.linearize_index [%arg0, %arg1, %arg2] by (%arg3, %arg4, %arg5) : index | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am just curious if we even need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need it - but we also don't need the first basis element on This is kept for symmetry with |
||
func.return %0 : index | ||
} |
Uh oh!
There was an error while loading. Please reload this page.