| 116 | } |
| 117 | |
| 118 | void ClActivationKernel::configure(const ClCompileContext &compile_context, |
| 119 | ITensorInfo *src, |
| 120 | ITensorInfo *dst, |
| 121 | ActivationLayerInfo act_info) |
| 122 | { |
| 123 | ARM_COMPUTE_ERROR_ON_NULLPTR(src); |
| 124 | |
| 125 | auto padding_info = get_padding_info({src, dst}); |
| 126 | |
| 127 | _run_in_place = (dst == nullptr) || (dst == src); |
| 128 | |
| 129 | if (dst != nullptr) |
| 130 | { |
| 131 | // Destination auto inizialitation if not yet initialized |
| 132 | auto_init_if_empty(*dst, *src->clone()); |
| 133 | } |
| 134 | |
| 135 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, (dst != nullptr) ? dst : nullptr, act_info)); |
| 136 | |
| 137 | const unsigned int num_elems_processed_per_iteration = adjust_vec_size(16 / src->element_size(), src->dimension(0)); |
| 138 | |
| 139 | const DataType dt = src->data_type(); |
| 140 | float a_const = act_info.a(); |
| 141 | float b_const = act_info.b(); |
| 142 | |
| 143 | const ActivationLayerInfo::ActivationFunction f_act = act_info.activation(); |
| 144 | const bool is_quantized = is_data_type_quantized(dt); |
| 145 | const bool perform_activation_in_float = (f_act == ActivationLayerInfo::ActivationFunction::LOGISTIC) || |
| 146 | (f_act == ActivationLayerInfo::ActivationFunction::TANH) || |
| 147 | (f_act == ActivationLayerInfo::ActivationFunction::HARD_SWISH) || |
| 148 | (f_act == ActivationLayerInfo::ActivationFunction::LEAKY_RELU); |
| 149 | |
| 150 | // Set build options |
| 151 | CLBuildOptions build_opts; |
| 152 | build_opts.add_option_if(perform_activation_in_float, "-DFLOAT_DOMAIN"); |
| 153 | build_opts.add_option_if(_run_in_place, "-DIN_PLACE"); |
| 154 | build_opts.add_option("-DACT=" + lower_string(string_from_activation_func(f_act))); |
| 155 | build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(dt)); |
| 156 | build_opts.add_option("-DVEC_SIZE=" + support::cpp11::to_string(num_elems_processed_per_iteration)); |
| 157 | build_opts.add_option("-DVEC_SIZE_LEFTOVER=" + |
| 158 | support::cpp11::to_string(src->dimension(0) % num_elems_processed_per_iteration)); |
| 159 | |
| 160 | std::string kernel_name = std::string("activation_layer"); |
| 161 | |
| 162 | // Set quantization info build options |
| 163 | if (is_quantized) |
| 164 | { |
| 165 | const UniformQuantizationInfo iq_info = src->quantization_info().uniform(); |
| 166 | |
| 167 | if (!perform_activation_in_float) |
| 168 | { |
| 169 | int a_const_int = 0; |
| 170 | int b_const_int = 0; |
| 171 | |
| 172 | // Create quantized version of constants a, b if needed |
| 173 | switch (dt) |
| 174 | { |
| 175 | case DataType::QASYMM8: |
nothing calls this directly
no test coverage detected