MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ParseOpData

Function ParseOpData

tensorflow/lite/core/api/flatbuffer_conversions.cc:136–822  ·  view source on GitHub ↗

Parse the appropriate data out of the op. This handles builtin data explicitly as there are flatbuffer schemas. If it returns kTfLiteOk, it passes the data out with `builtin_data`, which need to be released by calling `free`.` If it returns kTfLiteError, `builtin_data` will be `nullptr`.

Source from the content-addressed store, hash-verified

134// need to be released by calling `free`.`
135// If it returns kTfLiteError, `builtin_data` will be `nullptr`.
136TfLiteStatus ParseOpData(const Operator* op, BuiltinOperator op_type,
137 ErrorReporter* error_reporter,
138 BuiltinDataAllocator* allocator, void** builtin_data) {
139 auto parse_padding = [](Padding padding) {
140 switch (padding) {
141 case Padding_SAME:
142 return kTfLitePaddingSame;
143 case Padding_VALID:
144 return kTfLitePaddingValid;
145 }
146 return kTfLitePaddingUnknown;
147 };
148 auto parse_activation = [](ActivationFunctionType activation) {
149 switch (activation) {
150 case ActivationFunctionType_NONE:
151 return kTfLiteActNone;
152 case ActivationFunctionType_RELU:
153 return kTfLiteActRelu;
154 case ActivationFunctionType_RELU_N1_TO_1:
155 return kTfLiteActRelu1;
156 case ActivationFunctionType_RELU6:
157 return kTfLiteActRelu6;
158 case ActivationFunctionType_TANH:
159 return kTfLiteActTanh;
160 case ActivationFunctionType_SIGN_BIT:
161 return kTfLiteActSignBit;
162 }
163 return kTfLiteActNone;
164 };
165 auto parseLSHProjectionType = [](LSHProjectionType type) {
166 switch (type) {
167 case LSHProjectionType_SPARSE:
168 return kTfLiteLshProjectionSparse;
169 case LSHProjectionType_DENSE:
170 return kTfLiteLshProjectionDense;
171 default:
172 return kTfLiteLshProjectionUnknown;
173 }
174 };
175 auto parseCombinerType = [](CombinerType type) {
176 switch (type) {
177 case CombinerType_MEAN:
178 return kTfLiteCombinerTypeMean;
179 case CombinerType_SQRTN:
180 return kTfLiteCombinerTypeSqrtn;
181 case CombinerType_SUM:
182 default:
183 return kTfLiteCombinerTypeSum;
184 }
185 };
186
187 SafeBuiltinDataAllocator safe_allocator(allocator);
188 *builtin_data = nullptr;
189 switch (op_type) {
190 case BuiltinOperator_CONV_2D: {
191 auto params = safe_allocator.Allocate<TfLiteConvParams>();
192 if (auto* conv_params = op->builtin_options_as_Conv2DOptions()) {
193 params->padding = parse_padding(conv_params->padding());

Callers 3

ParseNodesMethod · 0.85
TEST_FFunction · 0.85
InvokeMethod · 0.85

Calls 15

ConvertTensorTypeFunction · 0.85
combinerMethod · 0.80
betaMethod · 0.80
alphaMethod · 0.80
num_splitsMethod · 0.80
values_countMethod · 0.80
numMethod · 0.80
typeMethod · 0.65
paddingMethod · 0.45
releaseMethod · 0.45
rankMethod · 0.45

Tested by 1

TEST_FFunction · 0.68