The collapsing dimensions transformation is limited to only those
cases where the sequence of dimensions are contiguous in all the
ranges of the indexing maps of the operation. Add this check before
applying the transformation.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
I might be missing something but why do we disable collapsing for this case? For the example your provided we can still collapse d0, d1, d2. I put the collapsed version below. Do you think that is it wrong?
#map = affine_map<(d0, d1) -> (d1, d0)> #map1 = affine_map<(d0, d1) -> (d0, d1)> module { func.func @uncollapsable(%arg0: tensor<41x3x1x57xf32>, %arg1: tensor<3x1x57x41xf32>) -> tensor<3x1x57x41xf32> { %collapsed = tensor.collapse_shape %arg0 [[0], [1, 2, 3]] : tensor<41x3x1x57xf32> into tensor<41x171xf32> %collapsed_0 = tensor.collapse_shape %arg1 [[0, 1, 2], [3]] : tensor<3x1x57x41xf32> into tensor<171x41xf32> %1 = linalg.generic {indexing_maps = [#map, #map1], iterator_types = ["parallel", "parallel"]} ins(%collapsed : tensor<41x171xf32>) outs(%collapsed_0 : tensor<171x41xf32>) { ^bb0(%in: f32, %out: f32): linalg.yield %in : f32 } -> tensor<171x41xf32> %expanded = tensor.expand_shape %1 [[0, 1, 2], [3]] : tensor<171x41xf32> into tensor<3x1x57x41xf32> return %expanded : tensor<3x1x57x41xf32> } }
Comment Actions
The test is trying to fold dimensions 2 and 3 (-test-linalg-elementwise-fusion-patterns=collapse-dimensions-control=2,3 -split-input-file) . Those cant be folded. This is just adding a check and bailing on illegal collapse dimensions list .