-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fold standalone linalg.fill ops into flow.tensor.splat ops (#5614)
This allows us to use DMA instead of kernels for pure data fills. This is another step towards performance: it further decreases the number of dispatches for MobileNetv2 from 94 to 76, and reduced the kernel execution latency by 3ms (17ms -> 14ms) on Galaxy S20 (Mali G77).
- Loading branch information
1 parent
268a305
commit 323108e
Showing
10 changed files
with
112 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
iree/compiler/Dialect/Flow/Transforms/test/convert_to_flow_tensor_ops_after.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// RUN: iree-opt -iree-flow-convert-to-flow-tensor-ops-pass='run-before-dispatch-region-formation=false' -canonicalize -cse -split-input-file %s | IreeFileCheck %s | ||
|
||
func @turn_fill_into_splat(%arg0: tensor<?x?xf32>, %arg1: tensor<f32>, %arg2: index, %arg3: index, %arg4: index, %arg5: index) -> tensor<?x?xf32> { | ||
%c0 = constant 0 : index | ||
%c1 = constant 1 : index | ||
%0 = tensor.extract %arg1[] : tensor<f32> | ||
%1 = tensor.dim %arg0, %c0 : tensor<?x?xf32> | ||
%2 = tensor.dim %arg0, %c1 : tensor<?x?xf32> | ||
%3 = affine.apply affine_map<(d0)[s0, s1] -> (d0 + s0 + s1)>(%1)[%arg2, %arg4] | ||
%4 = affine.apply affine_map<(d0)[s0, s1] -> (d0 + s0 + s1)>(%2)[%arg3, %arg5] | ||
%5 = linalg.init_tensor [%3, %4] : tensor<?x?xf32> | ||
%6 = linalg.fill(%0, %5) : f32, tensor<?x?xf32> -> tensor<?x?xf32> | ||
%7 = flow.tensor.update %arg0, %6[%arg2, %arg3] : tensor<?x?xf32>{%1, %2} -> tensor<?x?xf32>{%3, %4} | ||
return %7 : tensor<?x?xf32> | ||
} | ||
|
||
// CHECK: #[[MAP:.+]] = affine_map<()[s0, s1, s2] -> (s0 + s1 + s2)> | ||
// CHECK: func @turn_fill_into_splat | ||
// CHECK-SAME: %[[ARG0:[a-zA-Z0-9]+]]: tensor<?x?xf32> | ||
// CHECK-SAME: %[[ARG1:[a-zA-Z0-9]+]]: tensor<f32> | ||
// CHECK-SAME: %[[ARG2:[a-zA-Z0-9]+]]: index | ||
// CHECK-SAME: %[[ARG3:[a-zA-Z0-9]+]]: index | ||
// CHECK-SAME: %[[ARG4:[a-zA-Z0-9]+]]: index | ||
// CHECK-SAME: %[[ARG5:[a-zA-Z0-9]+]]: index | ||
// CHECK-DAG: %[[C0:.+]] = constant 0 : index | ||
// CHECK-DAG: %[[C1:.+]] = constant 1 : index | ||
// CHECK: %[[VAL:.+]] = tensor.extract %[[ARG1]][] | ||
// CHECK-DAG: %[[D0:.+]] = tensor.dim %[[ARG0]], %[[C0]] | ||
// CHECK-DAG: %[[D1:.+]] = tensor.dim %[[ARG0]], %[[C1]] | ||
// CHECK-DAG: %[[RD0:.+]] = affine.apply #[[MAP]]()[%[[ARG2]], %[[ARG4]], %[[D0]]] | ||
// CHECK-DAG: %[[RD1:.+]] = affine.apply #[[MAP]]()[%[[ARG3]], %[[ARG5]], %[[D1]]] | ||
// CHECK: %[[SPLAT:.+]] = flow.tensor.splat %[[VAL]] : tensor<?x?xf32>{%[[RD0]], %[[RD1]]} | ||
// CHECK: flow.tensor.update %[[ARG0]], %[[SPLAT]] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters