| 246 | } |
| 247 | |
| 248 | TfLiteStatus 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 | |
| 276 | template <KernelType kernel_type> |
| 277 | TfLiteStatus TanhPrepare(TfLiteContext* context, TfLiteNode* node) { |
nothing calls this directly
no test coverage detected