MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / validate

Method validate

src/cpu/kernels/CpuElementwiseUnaryKernel.cpp:215–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213}
214
215Status 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
266void CpuElementwiseUnaryKernel::run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info)
267{

Callers

nothing calls this directly

Calls 5

get_isaMethod · 0.80
get_implementationFunction · 0.50
is_dynamicMethod · 0.45
data_typeMethod · 0.45
total_sizeMethod · 0.45

Tested by

no test coverage detected