tensorflow/lite/kernels/elementwise.cc
// Non-quantized evaluation of Abs op when input is int16.
Non-quantized evaluation of Abs op when input is int16.
Non - quantized evaluation of Abs op when input is int16 .
inline TfLiteStatus AbsInt16EvalImpl(TfLiteContext* context, TfLiteNode* node,
                                     TfLiteType expected_type) {
  const TfLiteTensor* input;
  TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input));
  TfLiteTensor* output;
  TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output));
  TF_LITE_ENSURE_TYPES_EQ(context, input->type, expected_type);
  const int64_t num_elements = NumElements(input);
  const int16_t* in_data = GetTensorData<int16_t>(input);
  int16_t* out_data = GetTensorData<int16_t>(output);
  for (int64_t i = 0; i < num_elements; ++i) {
    out_data[i] = static_cast<int16_t>(
        std::abs<int32_t>(static_cast<int32_t>(in_data[i])));
  }
  return kTfLiteOk;
}
inline TfLiteStatus AbsInt16EvalImpl ( TfLiteContext * context , TfLiteNode * node , TfLiteType expected_type ) { const TfLiteTensor * input ; TF_LITE_ENSURE_OK ( context , GetInputSafe ( context , node , 0 , & input ) ) ; TfLiteTensor * output ; TF_LITE_ENSURE_OK ( context , GetOutputSafe ( context , node , 0 , & output ) ) ; TF_LITE_ENSURE_TYPES_EQ ( context , input -> type , expected_type ) ; const int64_t num_elements = NumElements ( input ) ; const int16_t * in_data = GetTensorData < int16_t > ( input ) ; int16_t * out_data = GetTensorData < int16_t > ( output ) ; for ( int64_t i = 0 ; i < num_elements ; ++ i ) { out_data [ i ] = static_cast < int16_t > ( std :: abs < int32_t > ( static_cast < int32_t > ( in_data [ i ] ) ) ) ; } return kTfLiteOk ; }
Non-quantized evaluation of Abs op when input is int16.
Non - quantized evaluation of Abs op when input is int16 .