|
3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// Modifications (c) Copyright 2025 Advanced Micro Devices, Inc. or its affiliates |
6 | 7 | // |
7 | 8 | // Modifications (c) Copyright 2023-2025 Advanced Micro Devices, Inc. or its |
8 | 9 | // affiliates |
@@ -148,4 +149,41 @@ def TosaReduceTransposes : Pass<"tosa-reduce-transposes", "func::FuncOp"> { |
148 | 149 | }]; |
149 | 150 | } |
150 | 151 |
|
| 152 | +def SinkInputOpsThroughConcat : Pass<"sink-input-ops-through-concat", "mlir::ModuleOp"> { |
| 153 | + let summary = "Sinks same operation through a Concat operation"; |
| 154 | + let description = [{ |
| 155 | + Pass that sinks the same operation through a concatenation, simplifying |
| 156 | + later optimizations. |
| 157 | + |
| 158 | + To explain with a picture: |
| 159 | + ``` |
| 160 | + Replacing with |
| 161 | + - Op -\ -\ |
| 162 | + - Op ---> Concat ==> ---> Concat -> Op |
| 163 | + - Op -/ -/ |
| 164 | + ``` |
| 165 | + |
| 166 | + The pass works greedy (i.e., it sinks operator chains) and does not do any |
| 167 | + cost-benefit assessment. It it restricted to an explicit list of tosa |
| 168 | + operations as input for the concatentation that are known to be "sinkable". |
| 169 | + }]; |
| 170 | + let options = [ |
| 171 | + Option<"enableElementwises", "enable-elementwises", "bool", |
| 172 | + /*default=*/"true", |
| 173 | + "Sink down elementwise operations.">, |
| 174 | + Option<"enableReductions", "enable-reductions", "bool", |
| 175 | + /*default=*/"true", |
| 176 | + "Sink down reduce operations.">, |
| 177 | + Option<"enableReshape", "enable-reshape", "bool", |
| 178 | + /*default=*/"true", |
| 179 | + "Sink down the reshape operation.">, |
| 180 | + Option<"enableMatmul", "enable-matmul", "bool", |
| 181 | + /*default=*/"true", |
| 182 | + "Sink down the matrix multiplication.">, |
| 183 | + Option<"matchUntransformedOperations", "match-untransformed-operations", "bool", |
| 184 | + /*default=*/"false", |
| 185 | + "Print operations that have potential to be sunken but are not actually sunken down.">, |
| 186 | + ]; |
| 187 | +} |
| 188 | + |
151 | 189 | #endif // MLIR_DIALECT_TOSA_TRANSFORMS_PASSES |
0 commit comments