| 213 | } |
| 214 | |
| 215 | Status CpuElementwiseUnaryKernel::validate(ElementWiseUnary op, const ITensorInfo &src, const ITensorInfo &dst) |
| 216 | { |
| 217 | ARM_COMPUTE_TRACE_EVENT(ARM_COMPUTE_PROF_CAT_CPU, ARM_COMPUTE_PROF_LVL_CPU, "CpuElementwiseUnaryKernel::validate"); |
| 218 | if (!src.is_dynamic()) |
| 219 | { |
| 220 | ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(&src); |
| 221 | ARM_COMPUTE_RETURN_ERROR_ON(dst.is_dynamic()); |
| 222 | } |
| 223 | ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(&src); |
| 224 | |
| 225 | const auto *uk = CpuElementwiseUnaryKernel::get_implementation( |
| 226 | DataTypeISASelectorData{src.data_type(), CPUInfo::get().get_isa()}); |
| 227 | |
| 228 | ARM_COMPUTE_RETURN_ERROR_ON(uk == nullptr || uk->ukernel == nullptr); |
| 229 | |
| 230 | switch (op) |
| 231 | { |
| 232 | case ElementWiseUnary::EXP: |
| 233 | case ElementWiseUnary::RSQRT: |
| 234 | case ElementWiseUnary::LOG: |
| 235 | case ElementWiseUnary::ROUND: |
| 236 | case ElementWiseUnary::SIN: |
| 237 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&src, 1, DataType::F16, DataType::F32, |
| 238 | DataType::QASYMM8, DataType::QASYMM8_SIGNED); |
| 239 | break; |
| 240 | case ElementWiseUnary::NEG: |
| 241 | case ElementWiseUnary::ABS: |
| 242 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&src, 1, DataType::F16, DataType::F32, DataType::S32, |
| 243 | DataType::QASYMM8, DataType::QASYMM8_SIGNED); |
| 244 | break; |
| 245 | default: |
| 246 | ARM_COMPUTE_ERROR("ElementWiseUnary operation not supported"); |
| 247 | } |
| 248 | |
| 249 | // Validate in case of configured dst |
| 250 | if (dst.total_size() > 0) |
| 251 | { |
| 252 | ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(&dst); |
| 253 | ARM_COMPUTE_RETURN_ERROR_ON(src.is_dynamic()); |
| 254 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(&src, &dst); |
| 255 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(&src, &dst); |
| 256 | } |
| 257 | else |
| 258 | { |
| 259 | // No configured output, or it's dynamic. Since `dst` is expected to |
| 260 | // match `src, there's nothing extra to check in this case. |
| 261 | } |
| 262 | |
| 263 | return Status{}; |
| 264 | } |
| 265 | |
| 266 | void CpuElementwiseUnaryKernel::run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) |
| 267 | { |
nothing calls this directly
no test coverage detected