-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[NFC][mlir][linalg] Make conv_3d_ncdhw_fcdhw consistent with 2D variant #129547
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
Conversation
|
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-linalg Author: Nirvedh Meshram (nirvedhmeshram) ChangesOther convolutions such as conv_2d_nchw_fchw have a output affine map with no permutations and the input and the filter map are adjusted accordingly. This makes conv_3d_ncdhw_fcdhw a stand out so this PR changes the affine map to be consistent with other variants. Full diff: https://github.com/llvm/llvm-project/pull/129547.diff 1 Files Affected:
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml b/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
index 496a323249e85..2bae43f887b04 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
@@ -4072,12 +4072,12 @@ structured_op: !LinalgStructuredOpConfig
indexing_maps: !LinalgIndexingMapsConfig
static_indexing_maps:
- affine_map<(d0, d1, d2, d3, d4, d5, d6, d7, d8)[s0, s1, s2, s3, s4, s5, s6,
- s7, s8, s9, s10, s11, s12, s13, s14] -> (d0, d8, d1 * s3 + d5 * s5, d2 * s7
- + d6 * s9, d3 * s11 + d7 * s13)>
+ s7, s8, s9, s10, s11, s12, s13, s14] -> (d0, d8, d2 * s3 + d5 * s5, d3 * s7
+ + d6 * s9, d4 * s11 + d7 * s13)>
- affine_map<(d0, d1, d2, d3, d4, d5, d6, d7, d8)[s0, s1, s2, s3, s4, s5, s6,
- s7, s8, s9, s10, s11, s12, s13, s14] -> (d4, d8, d5, d6, d7)>
+ s7, s8, s9, s10, s11, s12, s13, s14] -> (d1, d8, d5, d6, d7)>
- affine_map<(d0, d1, d2, d3, d4, d5, d6, d7, d8)[s0, s1, s2, s3, s4, s5, s6,
- s7, s8, s9, s10, s11, s12, s13, s14] -> (d0, d4, d1, d2, d3)>
+ s7, s8, s9, s10, s11, s12, s13, s14] -> (d0, d1, d2, d3, d4)>
iterator_types:
- parallel
- parallel
|
|
So effectively, for (d0, d1, d2, d3, d4, d5, d6, d7, d8) the interpretation:
For 2d nchw_fchw convolution's interpretations is (N, F, H, W, C, Hf, Wf), per llvm-project/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml Lines 3163 to 3170 in 84a7697
To be aligned in both cases I assume you also need to make 3d conv's C dimension |
84a7697 to
c92ba10
Compare
Good catch, fixed that as well! |
…20150) The orginal generic im2col implementation assumed that the filter and output affine map would not have permutations. While this is true in most named ops, it is not necessarily required. See for example llvm/llvm-project#129547 where it was not the case for `conv_3d_ncdhw_fcdhw` . While in this case we just "normalized" the map upstream, this PR adds support for such maps directly. Fixes : #20139 --------- Signed-off-by: Nirvedh Meshram <[email protected]>
|
When I update |
#129547 changed the IR directly without updating the auto generate script. Signed-off-by: Nirvedh <[email protected]>
… (#133927) llvm/llvm-project#129547 changed the IR directly without updating the auto generate script. Signed-off-by: Nirvedh <[email protected]>
llvm/llvm-project#129547 changed the IR directly without updating the auto generate script. Signed-off-by: Nirvedh <[email protected]>
llvm/llvm-project#129547 changed the IR directly without updating the auto generate script. Signed-off-by: Nirvedh <[email protected]>
llvm/llvm-project#129547 changed the IR directly without updating the auto generate script. Signed-off-by: Nirvedh <[email protected]>
llvm/llvm-project#129547 changed the IR directly without updating the auto generate script. Signed-off-by: Nirvedh <[email protected]>
Other convolutions such as conv_2d_nchw_fchw have a output affine map with no permutations and the input and the filter map are adjusted accordingly. This makes conv_3d_ncdhw_fcdhw a stand out so this PR changes the affine map to be consistent with other variants.