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 | #include "tensorflow/core/common_runtime/isolate_placer_inspection_required_ops_pass.h" |
16 | |
17 | #include "tensorflow/core/common_runtime/optimization_registry.h" |
18 | #include "tensorflow/core/common_runtime/placer_inspection_required_ops_utils.h" |
19 | #include "tensorflow/core/framework/function.h" |
20 | #include "tensorflow/core/graph/graph.h" |
21 | #include "tensorflow/core/lib/core/status.h" |
22 | #include "tensorflow/core/util/dump_graph.h" |
23 | |
24 | namespace tensorflow { |
25 | |
26 | Status IsolatePlacerInspectionRequiredOpsPass::Run( |
27 | const GraphOptimizationPassOptions& options) { |
28 | if (options.graph == nullptr) { |
29 | VLOG(1) << "Not running IsolatePlacerInspectionRequiredOpsPass because no " |
30 | "graph is provided" ; |
31 | return OkStatus(); |
32 | } |
33 | |
34 | VLOG(1) << "IsolatePlacerInspectionRequiredOpsPass::Run" ; |
35 | |
36 | Graph* graph = options.graph->get(); |
37 | if (VLOG_IS_ON(3)) { |
38 | DumpGraphToFile("isolate_deep_ops_before" , *graph, nullptr, "/tmp" ); |
39 | } |
40 | |
41 | Status status = IsolatePlacerInspectionRequiredOps(*options.flib_def, graph); |
42 | |
43 | if (VLOG_IS_ON(3) && status.ok()) { |
44 | DumpGraphToFile("isolate_deep_ops_after" , *graph, nullptr, "/tmp" ); |
45 | } |
46 | return status; |
47 | } |
48 | |
49 | REGISTER_OPTIMIZATION(OptimizationPassRegistry::PRE_PLACEMENT, 35, |
50 | IsolatePlacerInspectionRequiredOpsPass); |
51 | |
52 | } // namespace tensorflow |
53 | |