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

Function LeakyReluPrepare

tensorflow/lite/kernels/activations.cc:248–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248TfLiteStatus LeakyReluPrepare(TfLiteContext* context, TfLiteNode* node) {
249 TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);
250 TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);
251 const TfLiteTensor* input = GetInput(context, node, 0);
252 TfLiteTensor* output = GetOutput(context, node, 0);
253 TF_LITE_ENSURE_EQ(context, input->type, output->type);
254
255 LeakyReluOpData* data = reinterpret_cast<LeakyReluOpData*>(node->user_data);
256
257 if (output->type == kTfLiteUInt8) {
258 const auto* params =
259 reinterpret_cast<TfLiteLeakyReluParams*>(node->builtin_data);
260 // Quantize the alpha with same zero-point and scale as of input
261 data->q_alpha = static_cast<uint8_t>(std::max<float>(
262 std::numeric_limits<uint8_t>::min(),
263 std::min<float>(std::numeric_limits<uint8_t>::max(),
264 std::round(input->params.zero_point +
265 (params->alpha / input->params.scale)))));
266
267 double real_multiplier =
268 input->params.scale * input->params.scale / output->params.scale;
269 QuantizeMultiplierSmallerThanOneExp(
270 real_multiplier, &data->output_multiplier, &data->output_shift);
271 }
272 return context->ResizeTensor(context, output,
273 TfLiteIntArrayCopy(input->dims));
274}
275
276template <KernelType kernel_type>
277TfLiteStatus TanhPrepare(TfLiteContext* context, TfLiteNode* node) {

Callers

nothing calls this directly

Calls 10

NumInputsFunction · 0.85
GetInputFunction · 0.85
GetOutputFunction · 0.85
TfLiteIntArrayCopyFunction · 0.85
ResizeTensorMethod · 0.80
NumOutputsFunction · 0.70
minFunction · 0.50
maxFunction · 0.50
roundFunction · 0.50

Tested by

no test coverage detected