1 | /* Copyright 2019 The TensorFlow Authors. All Rights Reserved. |
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 | http://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 | |
16 | #ifndef TENSORFLOW_CORE_COMMON_RUNTIME_ISOLATE_PLACER_INSPECTION_REQUIRED_OPS_PASS_H_ |
17 | #define TENSORFLOW_CORE_COMMON_RUNTIME_ISOLATE_PLACER_INSPECTION_REQUIRED_OPS_PASS_H_ |
18 | |
19 | #include "tensorflow/core/common_runtime/optimization_registry.h" |
20 | |
21 | namespace tensorflow { |
22 | // Adds Identities for each input/output of function-calling ops. |
23 | // |
24 | // For example, the following graph calling a function on inputs `a` and `b` |
25 | // and producing output `y` will be rewritted to include identities on all |
26 | // edges: |
27 | // |
28 | // a b |
29 | // | | |
30 | // v v |
31 | // f (PartitionedCallOp) |
32 | // | |
33 | // v |
34 | // y |
35 | // |
36 | // is transformed to |
37 | // |
38 | // a b |
39 | // | | |
40 | // a_f (Identity) a_f (Identity) |
41 | // | | |
42 | // v v |
43 | // f (PartitionedCallOp) |
44 | // | |
45 | // f_y (Identity) |
46 | // | |
47 | // v |
48 | // y |
49 | // |
50 | // This pass is currently needed to simplify correctly placing the nodes |
51 | // producing inputs for as well as consuming output from function-calling ops. |
52 | // |
53 | // This pass should also help to implement replacing PartitionedCallOp with |
54 | // component function calls (to avoid copying input/output tensors), if we get |
55 | // to it. |
56 | class IsolatePlacerInspectionRequiredOpsPass : public GraphOptimizationPass { |
57 | public: |
58 | Status Run(const GraphOptimizationPassOptions& options) override; |
59 | }; |
60 | |
61 | } // namespace tensorflow |
62 | |
63 | #endif // TENSORFLOW_CORE_COMMON_RUNTIME_ISOLATE_PLACER_INSPECTION_REQUIRED_OPS_PASS_H_ |
64 | |