Repository navigation
Closed
Description
Note this is an issue on the WIP fusion_heuristic branch.
With the change in #10354, some generic ops are not in the flow.dispatch.workgroups.
%23 = flow.dispatch.workgroups[%c512, %c384, %c1](%22, %cst_30) : (tensor<512x384xf32>, tensor<384x384xf32>) -> tensor<512x384xf32> =
(%arg3: !flow.dispatch.tensor<readonly:512x384xf32>, %arg4: !flow.dispatch.tensor<readonly:384x384xf32>, %arg5: !flow.dispatch.tensor<writeonly:512x384xf32>) {
%cst_181 = arith.constant 0.000000e+00 : f32
%291 = flow.dispatch.tensor.load %arg3, offsets = [0, 0], sizes = [512, 384], strides = [1, 1] : !flow.dispatch.tensor<readonly:512x384xf32> -> tensor<512x384xf32>
%292 = flow.dispatch.tensor.load %arg4, offsets = [0, 0], sizes = [384, 384], strides = [1, 1] : !flow.dispatch.tensor<readonly:384x384xf32> -> tensor<384x384xf32>
%293 = linalg.init_tensor [512, 384] : tensor<512x384xf32>
%294 = linalg.fill ins(%cst_181 : f32) outs(%293 : tensor<512x384xf32>) -> tensor<512x384xf32>
%295 = linalg.matmul ins(%291, %292 : tensor<512x384xf32>, tensor<384x384xf32>) outs(%294 : tensor<512x384xf32>) -> tensor<512x384xf32>
flow.dispatch.tensor.store %295, %arg5, offsets = [0, 0], sizes = [512, 384], strides = [1, 1] : tensor<512x384xf32> -> !flow.dispatch.tensor<writeonly:512x384xf32>
flow.return
} count(%arg3: index, %arg4: index, %arg5: index) -> (index, index, index) {
%x, %y, %z = flow.dispatch.default_workgroup_count %arg3, %arg4, %arg5
flow.return %x, %y, %z : index, index, index
}
%24 = flow.tensor.splat %cst_25 : tensor<512xf32>
%25:2 = linalg.generic {indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> (d1)>, affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> (d0)>], iterator_types = ["parallel", "reduction"]} ins(%23, %cst_29, %7 : tensor<512x384xf32>, tensor<384xf32>, tensor<512x384xf32>) outs(%3, %24 : tensor<512x384xf32>, tensor<512xf32>) {
^bb0(%arg3: f32, %arg4: f32, %arg5: f32, %arg6: f32, %arg7: f32):
%291 = arith.addf %arg3, %arg4 : f32
%292 = arith.addf %291, %arg5 : f32
%293 = arith.addf %arg7, %292 : f32
linalg.yield %292, %293 : f32, f32
} -> (tensor<512x384xf32>, tensor<512xf32>Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsDone
Activity
MaheshRavishankar commentedon Sep 9, 2022
Do you have a repro I could use?
MaheshRavishankar commentedon Sep 10, 2022
I was able to repro this... This is a reduced repro
MaheshRavishankar commentedon Sep 10, 2022
Some triaging information. THis is the output for the small repro
IIUC, the op that is left outside (
%1:2) is a clone of the op already moved inside (%13:2). So its a matter of insertion order of thelinalg.genericops. When moved into the dispatch it should have beenThen the op outside wont exist cause all its uses are coming from within the dispatch
This method collects the ops
iree/compiler/src/iree/compiler/Dialect/Flow/Transforms/DispatchLinalgOnTensors.cpp
Line 422 in 9121254
But it probably needs to be sorted topologically. This method should help there
iree/compiler/src/iree/compiler/Dialect/Flow/Transforms/DispatchLinalgOnTensors.cpp
Line 455 in 9121254
MaheshRavishankar commentedon Sep 10, 2022
That was it. #10362 Fixes the issue (I checked miniLM as well, the pass works as expected now)
Fix insertion order of operations moved into dispatch. (#10362)
pzread commentedon Sep 12, 2022
Confirmed the issue is fixed
Fix insertion order of operations moved into dispatch. (iree-org#10362)
Fix insertion order of operations moved into dispatch. (iree-org#10362)
Fix insertion order of operations moved into dispatch. (iree-org#10362)
Fix insertion order of operations moved into dispatch. (iree-org#10362)
Fix insertion order of operations moved into dispatch. (iree-org#10362)