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 #include "tensorflow/compiler/aot/flags.h"
17
18 namespace tensorflow {
19 namespace tfcompile {
20
AppendMainFlags(std::vector<Flag> * flag_list,MainFlags * flags)21 void AppendMainFlags(std::vector<Flag>* flag_list, MainFlags* flags) {
22 const std::vector<Flag> tmp = {
23 {"graph", &flags->graph,
24 "Input GraphDef file. If the file ends in '.pbtxt' it is expected to "
25 "be in the human-readable proto text format, otherwise it is expected "
26 "to be in the proto binary format."},
27 {"config", &flags->config,
28 "Input file containing Config proto. If the file ends in '.pbtxt' it "
29 "is expected to be in the human-readable proto text format, otherwise "
30 "it is expected to be in the proto binary format."},
31 {"dump_fetch_nodes", &flags->dump_fetch_nodes,
32 "If set, only flags related to fetches are processed, and the resulting "
33 "fetch nodes will be dumped to stdout in a comma-separated list. "
34 "Typically used to format arguments for other tools, e.g. "
35 "freeze_graph."},
36 // Flags controlling the XLA ahead-of-time compilation, that correspond to
37 // the fields of xla::cpu::CpuAotCompilationOptions.
38 //
39 // TODO(toddw): The following flags also need to be supported:
40 // --xla_cpu_llvm_opt_level
41 // --xla_cpu_llvm_cl_opts
42 {"target_triple", &flags->target_triple,
43 "Target platform, similar to the clang -target flag. The general "
44 "format is <arch><sub>-<vendor>-<sys>-<abi>. "
45 "http://clang.llvm.org/docs/CrossCompilation.html#target-triple."},
46 {"target_cpu", &flags->target_cpu,
47 "Target cpu, similar to the clang -mcpu flag. "
48 "http://clang.llvm.org/docs/CrossCompilation.html#cpu-fpu-abi"},
49 {"target_features", &flags->target_features,
50 "Target features, e.g. +avx2, +neon, etc."},
51 {"entry_point", &flags->entry_point,
52 "Name of the generated function. If multiple generated object files "
53 "will be linked into the same binary, each will need a unique entry "
54 "point."},
55 {"cpp_class", &flags->cpp_class,
56 "Name of the generated C++ class, wrapping the generated function. The "
57 "syntax of this flag is [[<optional_namespace>::],...]<class_name>. "
58 "This mirrors the C++ syntax for referring to a class, where multiple "
59 "namespaces may precede the class name, separated by double-colons. "
60 "The class will be generated in the given namespace(s), or if no "
61 "namespaces are given, within the global namespace."},
62 {"out_function_object", &flags->out_function_object,
63 "Output object file containing the generated function for the "
64 "TensorFlow model."},
65 {"out_header", &flags->out_header, "Output header file name."},
66 {"out_metadata_object", &flags->out_metadata_object,
67 "Output object file name containing optional metadata for the generated "
68 "function."},
69 {"out_session_module", &flags->out_session_module,
70 "Output session module proto."},
71 {"gen_name_to_index", &flags->gen_name_to_index,
72 "Generate name-to-index data for Lookup{Arg,Result}Index methods."},
73 {"gen_program_shape", &flags->gen_program_shape,
74 "Generate program shape data for the ProgramShape method."},
75 };
76 flag_list->insert(flag_list->end(), tmp.begin(), tmp.end());
77 }
78
79 } // namespace tfcompile
80 } // namespace tensorflow
81