| 201 | } // namespace |
| 202 | |
| 203 | void CpuActivationKernel::configure(const ITensorInfo *src, ITensorInfo *dst, ActivationLayerInfo activation_info) |
| 204 | { |
| 205 | ARM_COMPUTE_TRACE_EVENT(ARM_COMPUTE_PROF_CAT_CPU, ARM_COMPUTE_PROF_LVL_CPU, "CpuActivationKernel::configure"); |
| 206 | ARM_COMPUTE_ERROR_ON_NULLPTR(src); |
| 207 | ARM_COMPUTE_ERROR_THROW_ON(CpuActivationKernel::validate(src, dst, activation_info)); |
| 208 | |
| 209 | heuristics::CpuActivationKernelHeuristics heuristics(src, dst, activation_info); |
| 210 | _heuristics = std::move(heuristics); |
| 211 | |
| 212 | _src_padding = src->padding(); |
| 213 | _inplace = (dst == nullptr); |
| 214 | if (!_inplace) |
| 215 | { |
| 216 | // dst auto inizialitation if not yet initialized |
| 217 | auto_init_if_empty(*dst, *src->clone()); |
| 218 | _dst_padding = dst->padding(); |
| 219 | } |
| 220 | |
| 221 | const auto *uk = _heuristics.kernel(); |
| 222 | ARM_COMPUTE_ERROR_ON_NULLPTR(uk); |
| 223 | |
| 224 | _name = std::string("CpuActivationKernel").append("/").append(uk->name); |
| 225 | |
| 226 | #ifdef __aarch64__ |
| 227 | // Initialise lut_manager |
| 228 | LUTManager &lut_manager = LUTManager::get_instance(); |
| 229 | |
| 230 | // TODO (COMPMID-7511): delegate to LUTManager |
| 231 | if ((src->data_type() == DataType::QASYMM8 || src->data_type() == DataType::QASYMM8_SIGNED) && |
| 232 | activation_info.activation() != ActivationFunction::RELU) |
| 233 | { |
| 234 | ActivationLayerInfo::LookupTable256 tmp_lut; |
| 235 | init_lut(activation_info.activation(), src->data_type(), src->quantization_info().uniform(), |
| 236 | (dst) ? dst->quantization_info().uniform() : src->quantization_info().uniform(), tmp_lut, |
| 237 | activation_info.a(), activation_info.b()); |
| 238 | activation_info.setLookupTable256(tmp_lut); |
| 239 | } |
| 240 | |
| 241 | // Kernel specific logic should be mirrored in prepare() |
| 242 | if (std::string(uk->name) == "sve_fp16_activation_lut") |
| 243 | { |
| 244 | // Create info using init list. |
| 245 | const LUTInfo info = {activation_info.activation(), activation_info.a(), activation_info.b(), src->data_type(), |
| 246 | src->quantization_info().uniform()}; |
| 247 | activation_info.setLookupTable65536((lut_manager.get_lut_table<LookupTable65536>(info))); |
| 248 | } |
| 249 | #endif // __aarch64__ |
| 250 | _act_info = activation_info; |
| 251 | |
| 252 | ICPPKernel::configure(_heuristics.window()); |
| 253 | } |
| 254 | |
| 255 | Status |
| 256 | CpuActivationKernel::validate(const ITensorInfo *src, const ITensorInfo *dst, const ActivationLayerInfo &act_info) |
nothing calls this directly
no test coverage detected