| Stella Laurenzo | b8668c1 | 2019-10-30 14:39:16 -0700 | [diff] [blame] | 1 | // Copyright 2019 Google LLC |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #ifndef IREE_INTEGRATIONS_TENSORFLOW_COMPILER_PASSES_H_ |
| 16 | #define IREE_INTEGRATIONS_TENSORFLOW_COMPILER_PASSES_H_ |
| 17 | |
| 18 | #include "mlir/Pass/Pass.h" |
| 19 | |
| 20 | namespace mlir { |
| 21 | namespace iree_compiler { |
| 22 | |
| 23 | //===----------------------------------------------------------------------===// |
| Sean Silva | 339828e | 2020-01-28 11:14:54 -0800 | [diff] [blame] | 24 | // IREE-specific Passes For TensorFlow Import |
| Stella Laurenzo | b8668c1 | 2019-10-30 14:39:16 -0700 | [diff] [blame] | 25 | //===----------------------------------------------------------------------===// |
| 26 | |
| Sean Silva | 339828e | 2020-01-28 11:14:54 -0800 | [diff] [blame] | 27 | // In a module tagged with `tf_saved_model.semantics`, lowers |
| 28 | // `tf_saved_model.global_variable`'s to `flow.variable`'s. |
| 29 | // |
| 30 | // This pass should be run before adopting the exports, which transitions to |
| 31 | // a module that does not have `tf_saved_model.semantics`. |
| Benjamin Kramer | df6e17d | 2020-04-08 03:30:48 -0700 | [diff] [blame] | 32 | std::unique_ptr<OperationPass<ModuleOp>> createTFSavedModelLowerGlobalTensors(); |
| Sean Silva | 339828e | 2020-01-28 11:14:54 -0800 | [diff] [blame] | 33 | |
| 34 | // In a module tagged with `tf_saved_model.semantics`, lowers any tf_saved_model |
| 35 | // exported functions to IREE exported functions with appropriate reflection |
| 36 | // metadata. |
| Benjamin Kramer | df6e17d | 2020-04-08 03:30:48 -0700 | [diff] [blame] | 37 | std::unique_ptr<OperationPass<ModuleOp>> |
| Sean Silva | 339828e | 2020-01-28 11:14:54 -0800 | [diff] [blame] | 38 | createTFSavedModelLowerExportedFunctions(); |
| 39 | |
| Rob Suderman | 60b7343 | 2020-06-19 10:32:02 -0700 | [diff] [blame] | 40 | // Push resource casts forward to better propagate resource related shapes. |
| 41 | std::unique_ptr<OperationPass<ModuleOp>> createPropagateResourceCasts(); |
| 42 | |
| rsuderman | 7fa75e6 | 2020-10-22 19:32:42 -0700 | [diff] [blame] | 43 | // Validates whether any Tensorflow operations remain. |
| 44 | std::unique_ptr<OperationPass<FuncOp>> createCheckNoTF(); |
| 45 | |
| Sean Silva | 339828e | 2020-01-28 11:14:54 -0800 | [diff] [blame] | 46 | // Create a single pipeline that will run all the needed IREE-specific TF import |
| 47 | // passes in the right order. |
| 48 | void createIreeTfImportPipeline(OpPassManager &pm); |
| Stella Laurenzo | b8668c1 | 2019-10-30 14:39:16 -0700 | [diff] [blame] | 49 | |
| 50 | } // namespace iree_compiler |
| 51 | } // namespace mlir |
| 52 | |
| 53 | #endif // IREE_INTEGRATIONS_TENSORFLOW_COMPILER_PASSES_H_ |