66OMStatus inline Logistic(
const int flat_size,
const int8_t *input_data,
float input_scale,
67 int input_zero_point, int8_t *output_data,
float output_scale,
68 int output_zero_point)
70 const float cutoff_upper = 16.619047164916992188f;
71 const float cutoff_lower = -9.f;
81 for (
int i = 0; i < flat_size; i++)
84 float val =
static_cast<float>((input_data[i] - input_zero_point) * input_scale);
86 if (val > cutoff_upper)
90 else if (val < cutoff_lower)
92 result = std::exp(val);
96 result = 1.f / (1.f + std::exp(-val));
99 int8_t output =
static_cast<int8_t
>(std::round(result / output_scale) + output_zero_point);
100 output_data[i] = output;