| 66 | ActivationLayerInfo::ActivationFunction::HARD_SWISH, ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU}; |
| 67 | |
| 68 | Status validate_arguments(const ITensorInfo *src, const ITensorInfo *dst, const ActivationLayerInfo &activation_info) |
| 69 | { |
| 70 | ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(src); |
| 71 | ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(src); |
| 72 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(src, 1, DataType::QASYMM8_SIGNED, DataType::QASYMM8, |
| 73 | DataType::QSYMM16, DataType::F16, DataType::F32); |
| 74 | |
| 75 | heuristics::CpuActivationKernelHeuristics heuristics(src, dst, activation_info); |
| 76 | const auto *uk = heuristics.kernel(); |
| 77 | ARM_COMPUTE_RETURN_ERROR_ON(uk == nullptr || uk->ukernel == nullptr); |
| 78 | |
| 79 | const DataType data_type = src->data_type(); |
| 80 | const QuantizationInfo &oq_info = (dst != nullptr) ? dst->quantization_info() : src->quantization_info(); |
| 81 | const ActivationLayerInfo::ActivationFunction f_act = activation_info.activation(); |
| 82 | |
| 83 | ARM_COMPUTE_RETURN_ERROR_ON_MSG( |
| 84 | is_data_type_quantized_asymmetric_char(data_type) && oq_info.is_dynamic() && |
| 85 | (std::find(std::begin(qasymm8_static_quant_activations), std::end(qasymm8_static_quant_activations), |
| 86 | f_act) == std::end(qasymm8_static_quant_activations)), |
| 87 | "For QASYMM8 statically quantized, only relu and lower/upper bounded relu are supported"); |
| 88 | |
| 89 | ARM_COMPUTE_RETURN_ERROR_ON_MSG( |
| 90 | is_data_type_quantized_asymmetric(data_type) && |
| 91 | (std::find(std::begin(qasymm8_activations), std::end(qasymm8_activations), f_act) == |
| 92 | std::end(qasymm8_activations)), |
| 93 | "For QASYMM8 only hard swish, leaky relu, tanh, logistic, relu and lower/upper bounded relu are supported"); |
| 94 | |
| 95 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(is_data_type_quantized_symmetric(data_type) && |
| 96 | (std::find(std::begin(qsymm16_activations), std::end(qsymm16_activations), |
| 97 | f_act) == std::end(qsymm16_activations)), |
| 98 | "For QSYMM16 only tanh and logistic are supported"); |
| 99 | ARM_COMPUTE_RETURN_ERROR_ON((data_type == DataType::QASYMM8 || data_type == DataType::QASYMM16) && |
| 100 | (f_act == ActivationLayerInfo::ActivationFunction::TANH) && |
| 101 | (oq_info != QuantizationInfo(1.f / 128.f, 128))); |
| 102 | ARM_COMPUTE_RETURN_ERROR_ON((data_type == DataType::QASYMM8 || data_type == DataType::QASYMM16) && |
| 103 | (f_act == ActivationLayerInfo::ActivationFunction::LOGISTIC) && |
| 104 | (oq_info != QuantizationInfo(1.f / 256.f, 0))); |
| 105 | |
| 106 | ARM_COMPUTE_RETURN_ERROR_ON(data_type == DataType::QASYMM8_SIGNED && |
| 107 | (f_act == ActivationLayerInfo::ActivationFunction::TANH) && |
| 108 | (oq_info != QuantizationInfo(1.f / 128.f, 0))); |
| 109 | ARM_COMPUTE_RETURN_ERROR_ON(data_type == DataType::QASYMM8_SIGNED && |
| 110 | (f_act == ActivationLayerInfo::ActivationFunction::LOGISTIC) && |
| 111 | (oq_info != QuantizationInfo(1.f / 256.f, -128))); |
| 112 | |
| 113 | ARM_COMPUTE_RETURN_ERROR_ON(is_data_type_quantized_symmetric(data_type) && |
| 114 | (f_act == ActivationLayerInfo::ActivationFunction::TANH) && |
| 115 | (oq_info != QuantizationInfo(1.f / 32768.f, 0))); |
| 116 | ARM_COMPUTE_RETURN_ERROR_ON(is_data_type_quantized_symmetric(data_type) && |
| 117 | (f_act == ActivationLayerInfo::ActivationFunction::LOGISTIC) && |
| 118 | (oq_info != QuantizationInfo(1.f / 32768.f, 0))); |
| 119 | |
| 120 | // Checks performed when dst is configured |
| 121 | if ((dst != nullptr) && (dst->total_size() != 0)) |
| 122 | { |
| 123 | ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(dst); |
| 124 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(src, dst); |
| 125 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, dst); |
no test coverage detected