24 const circle::Tensor *input,
25 const circle::Tensor *filter,
26 const circle::Tensor *output,
27 circle::ActivationFunctionType act_type)
29 assert(input->quantization() !=
nullptr);
30 assert(filter->quantization() !=
nullptr);
31 assert(output->quantization() !=
nullptr);
33 const auto *input_scales = input->quantization()->scale();
34 const auto *filter_scales = filter->quantization()->scale();
35 const auto *output_scales = output->quantization()->scale();
37 assert(input_scales !=
nullptr);
38 assert(filter_scales !=
nullptr);
39 assert(output_scales !=
nullptr);
41 assert(input_scales->size() != 0);
42 assert(filter_scales->size() != 0);
43 assert(output_scales->size() != 0);
45 const auto input_zero_points = input->quantization()->zero_point();
46 const auto filter_zero_points = filter->quantization()->zero_point();
47 const auto output_zero_points = output->quantization()->zero_point();
49 assert(input_zero_points !=
nullptr);
50 assert(filter_zero_points !=
nullptr);
51 assert(output_zero_points !=
nullptr);
53 assert(input_zero_points->size() != 0);
54 assert(filter_zero_points->size() != 0);
55 assert(output_zero_points->size() != 0);
57 const auto input_zp = input_zero_points->operator[](0);
58 const auto filter_zp = filter_zero_points->operator[](0);
59 const auto output_zp = output_zero_points->operator[](0);
61 const auto output_scale = output_scales->operator[](0);
63 int32_t activation_min{};
64 int32_t activation_max{};
66 act_type,
static_cast<int32_t
>(output_zp), output_scale, output->type(), &activation_min,
79 assert(filter_scales->size() > 1);
81 const auto input_scale = input_scales->operator[](0);
82 const std::vector<double> effective_output_scale =
85 size_t n = effective_output_scale.size();
88 for (
size_t i = 0; i < n; ++i)
OMStatus calculateActivationRangeQuantized(circle::ActivationFunctionType activation, int32_t output_zero_point, float output_scale, circle::TensorType data_type, int32_t *activation_min, int32_t *activation_max)