-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtensorflow.cfg.py
203 lines (177 loc) · 5.58 KB
/
tensorflow.cfg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#
# This config file defines the various options
# and overrides for converting a C++ API to KL
# The output files are intended to be consumed
# by kl2edk utility
#
# Name of this project
project_name = 'Tensorflow'
# Specify the root of the doxygen output directory. This dir is relative to this file
xml_dir = 'DoxygenXML/xml'
# List all source (C++) files to convert to KL
filesToProcess = [
"tf_wrapper.h"
]
# Any elements named in this list will not be exported
elementsToIgnore = [
'operator=' # By default, do not export copy constructors
]
#
# A basic type mapping - each native argument
# encountered will be converted to the KL type
#
cppToKLTypeMapping = {
'unsigned int': 'UInt32',
'uint32_t': 'UInt32',
'int': 'SInt32',
'float': 'Float32',
'double': 'Float64',
'long long': 'SInt64',
'bool': 'Boolean',
'boolean': 'Boolean',
'UINT': 'UInt32',
'void*': 'Data',
'void': '',
'char*': 'String',
}
#
# Allow renaming functions
# Mainly used to turn overloaded fn's into
# something usable in KL
#
rename_cpp_fns = {
'operator[]' : '_get',
'operator==' : '_compare'
}
#
# if no SAL annotations are present, the most frequent issue
# we fail on is the declaration of a C-style array in
# function arguments, eg
# void aFunction(float* indices, int numIndices);
#
# In the following array we can define parameter pairs that
# are converted from C-array + arrayLength to a KL array
#
# The declaration format is
# 'C Array name' = ['C Array Type', 'C Array length type', 'C Array length name']
#
c_array_to_kl_array = {
'inputs' : ['float*', 'int', 'numinputs'],
'outputs' : ['float*', 'int', 'numoutputs']
}
# C++ types can be organized into namespaces. Unfortunately,
# KL types cannot. Strip the given namespaces (or maybe just
# strip all namespaces?
#
#
# Add a C++ typename here to force it to be always be
# treated as an IO type. This is useful for types that
# that are typedef'ed from pointers, eg
# typedef float[3] Vector
force_io_types = [
]
# Some API's (thanks MS) have additional semantics written
# into them to describe how function parameters are meant
# to be used. If this info exists, we can attempt to infer
# the correct usage of a parameter (in, out, array etc)
# from these additional semantics
# see: https://msdn.microsoft.com/en-CA/library/hh916383.aspx
use_ms_sal = False
#
# When multiple C++ types map to a single KL
# type, it becomes impossible to correctly remap
# the conversion functions for the KL type back
# to the correct C++ type. To resolve these
# issues, we can create a KL 'alias' for the type
# which allows us to specify a unique KL type in the
# generated fn signatures, and this type lets us know
# the correct C++ type to convert to in the
# kl2edk phase
# NOTE: The alias must be named the same as the C++ type
#
kl_alias_file_name = '_aliases'
kl_type_aliases = {
}
# C-Style API's often use typedef's
# to name their types sanely, eg:
# typedef enum _MyType MyType;
# enum _MyType;
# We can use fabric's alias function
# to support the multiple names:
# alias _MyType UInt32;
# alias MyType _MyType;
convert_typedef_to_alias = False;
#
# If an SDK exposes opaque types (eg, handles) then
# the only interaction KL can have with these objects
# is to pass them around as Data pointers. To maintain
# some type-safety, we can generate structs to wrap
# these pointers that simply contain a Data ptr.
# Note - the opaque_file_name should not conflict
# with any filesToProcess, or it may be overwritten
#
opaque_file_name = '_opaque_types'
opaque_type_wrappers = [
"TFGraphWrapper"
]
# If you need to manually set any ordering, specify the files
# in this list and they will be added to the FPM last, in ther
# order specified here.
fpm_enforced_order = [
]
#
# We need to define a list of KL POD types
# When generating the fn definition in kl2edk,
# complex (non-POD) types will be passed an IO
# parameter to set as a return value, while
# POD types will return their value directly.
# We need to know which is which in order to
# correctly generate the function implementations
#
kl_pod_types = [
'UInt8',
'SInt8',
'UInt16',
'SInt16',
'UInt32',
'SInt32',
'UInt64',
'SInt64',
'Float32',
'Float64',
'Boolean',
'Data'
]
# Specify where the output files are written. This dir is
# relative to cfg file supplied as an argument to build.py
output_dir = 'GenKL'
output_h_dir = 'GenCPP/h'
output_cpp_dir = 'GenCPP/cpp'
# specify where custom CPP files (if any) are located
custom_cpp_dir = 'CustomCPP'
# specify where custom KL files (if any) are located
custom_KL_dir = 'CustomKL'
# Add extensions to be required. Should
# this be per-file? Or common for the whole project?
extns_required = [
'Util'
]
# Add custom code to be added to the head of a file.
# It is possible to override built in translations by
# ignoring an element, and defining it explicitly here.
custom_add_to_file = {
'ExampleHeader.h' : '// This is some code\n'
'// That would be added to\n'
'// ExampleHeader.kl\n'
}
# Define this value to true to not expose inline functions
skipInlineFunctions = True
#####
# The following parameters deal with creating a codegen file
# Specify a file to be merged with the auto-generated codegen file
# Items in this file will override the auto-generated items
# This file should be specified relative to this file
merge_codegen_file = project_name + ".codegen.json"
# The parameter prefix is used to fill in the auto-generated
# codegen.json file. It is required to auto-generate function bodies
parameter_prefix = 'cpp2kl'