blob: 8b3b219aa453481d87d7b31968ef3713c44a7d32 [file] [log] [blame]
Stella Laurenzob8668c12019-10-30 14:39:16 -07001// 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
20namespace mlir {
21namespace iree_compiler {
22
23//===----------------------------------------------------------------------===//
Sean Silva339828e2020-01-28 11:14:54 -080024// IREE-specific Passes For TensorFlow Import
Stella Laurenzob8668c12019-10-30 14:39:16 -070025//===----------------------------------------------------------------------===//
26
Sean Silva339828e2020-01-28 11:14:54 -080027// 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 Kramerdf6e17d2020-04-08 03:30:48 -070032std::unique_ptr<OperationPass<ModuleOp>> createTFSavedModelLowerGlobalTensors();
Sean Silva339828e2020-01-28 11:14:54 -080033
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 Kramerdf6e17d2020-04-08 03:30:48 -070037std::unique_ptr<OperationPass<ModuleOp>>
Sean Silva339828e2020-01-28 11:14:54 -080038createTFSavedModelLowerExportedFunctions();
39
Rob Suderman60b73432020-06-19 10:32:02 -070040// Push resource casts forward to better propagate resource related shapes.
41std::unique_ptr<OperationPass<ModuleOp>> createPropagateResourceCasts();
42
rsuderman7fa75e62020-10-22 19:32:42 -070043// Validates whether any Tensorflow operations remain.
44std::unique_ptr<OperationPass<FuncOp>> createCheckNoTF();
45
Sean Silva339828e2020-01-28 11:14:54 -080046// Create a single pipeline that will run all the needed IREE-specific TF import
47// passes in the right order.
48void createIreeTfImportPipeline(OpPassManager &pm);
Stella Laurenzob8668c12019-10-30 14:39:16 -070049
50} // namespace iree_compiler
51} // namespace mlir
52
53#endif // IREE_INTEGRATIONS_TENSORFLOW_COMPILER_PASSES_H_