• 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 #ifndef TENSORFLOW_JAVA_SRC_GEN_CC_OP_GENERATOR_H_
17 #define TENSORFLOW_JAVA_SRC_GEN_CC_OP_GENERATOR_H_
18 
19 #include <string>
20 #include <vector>
21 
22 #include "tensorflow/core/framework/api_def.pb.h"
23 #include "tensorflow/core/framework/op_def.pb.h"
24 #include "tensorflow/core/lib/core/status.h"
25 #include "tensorflow/core/platform/env.h"
26 #include "tensorflow/java/src/gen/cc/op_specs.h"
27 
28 namespace tensorflow {
29 namespace java {
30 
31 // A generator of Java operation wrappers.
32 //
33 // This generator takes a list of ops definitions in input and outputs
34 // a Java Op wrapper for each of them in the provided directory. The same
35 // generator instance can be invoked multiple times with a different list of
36 // ops definitions.
37 class OpGenerator {
38  public:
39   explicit OpGenerator(const std::vector<string>& api_dirs,
40                        Env* env = Env::Default())
api_dirs_(api_dirs)41       : api_dirs_(api_dirs), env_(env) {}
42 
43   // Generates wrappers for the given list of 'ops'.
44   //
45   // Output files are generated in <output_dir>/<base_package>/<op_package>,
46   // where 'op_package' is derived from ops endpoints.
47   Status Run(const OpList& op_list, const string& base_package,
48              const string& output_dir);
49 
50  private:
51   const std::vector<string> api_dirs_;
52   Env* env_;
53 };
54 
55 }  // namespace java
56 }  // namespace tensorflow
57 
58 #endif  // TENSORFLOW_JAVA_SRC_GEN_CC_OP_GENERATOR_H_
59