• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2017 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 // An optimization passes that marks nodes that are to be compiled with
17 // attribute kXlaClusterAttr. Nodes with the same cluster ID will be compiled
18 // together.
19 
20 #ifndef TENSORFLOW_COMPILER_JIT_MARK_FOR_COMPILATION_PASS_H_
21 #define TENSORFLOW_COMPILER_JIT_MARK_FOR_COMPILATION_PASS_H_
22 
23 #include "tensorflow/core/common_runtime/optimization_registry.h"
24 
25 namespace tensorflow {
26 
27 // The attribute that marks nodes to be grouped into functions by the
28 // encapsulate subgraphs pass.
29 extern const char* const kXlaClusterAttr;
30 
31 // The attribute that marks nodes in a cluster to be placed outside the xla
32 // compilation by the encapsulate subgraphs pass.
33 extern const char* const kXlaOutsideCompilationAttr;
34 
35 // Pass that marks a subset of operators in the graph with attribute
36 // _XlaCluster so they are compiled by the EncapsulateSubgraphsPass.
37 class MarkForCompilationPass : public GraphOptimizationPass {
38  public:
39   MarkForCompilationPass() = default;
40 
41   Status Run(const GraphOptimizationPassOptions& options) override;
42 
43  private:
44   Status RunImpl(const GraphOptimizationPassOptions& options,
45                  const std::function<bool(const Node*, const DeviceType&)>&
46                      is_compilable_fn = {});
47 
48   friend class MarkForCompilationPassTestHelper;
49 };
50 
51 // Returns true iff 'ndef' is a call to a function that is compilable.  A
52 // function is compilable iff every operator in the function body is
53 // compilable.
54 bool IsCompilable(FunctionLibraryRuntime* flr, const NodeDef& ndef);
55 }  // namespace tensorflow
56 
57 #endif  // TENSORFLOW_COMPILER_JIT_MARK_FOR_COMPILATION_PASS_H_
58