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

Function validate_arguments

src/cpu/kernels/CpuAddKernel.cpp:115–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113 REGISTER_QSYMM16_NEON(arm_compute::cpu::add_qsymm16_neon)}};
114
115Status
116validate_arguments(const ITensorInfo &src0, const ITensorInfo &src1, const ITensorInfo &dst, ConvertPolicy policy)
117{
118 ARM_COMPUTE_UNUSED(policy);
119
120 ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(&src0, &src1);
121
122 ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(&src0);
123 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&src0, 1, DataType::U8, DataType::QASYMM8,
124 DataType::QASYMM8_SIGNED, DataType::S16, DataType::QSYMM16,
125 DataType::F16, DataType::S32, DataType::F32);
126 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(&src0, &src1);
127
128 const TensorShape out_shape = TensorShape::broadcast_shape(src0.tensor_shape(), src1.tensor_shape());
129
130 ARM_COMPUTE_RETURN_ERROR_ON_MSG(out_shape.total_size() == 0, "Inputs are not broadcast compatible");
131 ARM_COMPUTE_RETURN_ERROR_ON_MSG(
132 (src0.tensor_shape().x() != src1.tensor_shape().x()) &&
133 ((src0.data_type() != src1.data_type()) || (src0.data_type() != dst.data_type()) ||
134 (src1.data_type() != dst.data_type())),
135 "Broadcasting across width is supported on configurations where all tensors have the same data type");
136
137 // Validate in case of configured dst
138 if (dst.total_size() > 0)
139 {
140 ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(&dst);
141 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(&src0, &dst);
142 ARM_COMPUTE_RETURN_ERROR_ON_MSG(detail::have_different_dimensions(out_shape, dst.tensor_shape(), 0),
143 "Wrong shape for dst");
144 }
145 else
146 {
147 const auto dst_info = TensorInfo(out_shape, 1, src0.data_type());
148 ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(&dst_info);
149 }
150
151 const auto can_use_fixedpoint = add_q8_neon_fixedpoint_possible(&src0, &src1, &dst);
152#ifdef ARM_COMPUTE_ENABLE_SME2
153 const auto can_use_sme2_impl = add_q8_sme2_fixedpoint_possible(&src0, &src1, &dst);
154#else /* ARM_COMPUTE_ENABLE_SME2 */
155 const auto can_use_sme2_impl = false;
156#endif /* ARM_COMPUTE_ENABLE_SME2 */
157 const auto uk =
158 CpuAddKernel::get_implementation<CpuAddKernelDataTypeISASelectorData>(CpuAddKernelDataTypeISASelectorData{
159 src0.data_type(), CPUInfo::get().get_isa(), can_use_fixedpoint, can_use_sme2_impl});
160
161 ARM_COMPUTE_RETURN_ERROR_ON(uk == nullptr || uk->ukernel == nullptr);
162
163 return Status{};
164}
165} // namespace
166
167void CpuAddKernel::configure(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst, ConvertPolicy policy)

Callers 2

configureMethod · 0.70
validateMethod · 0.70

Calls 8

get_isaMethod · 0.80
TensorInfoClass · 0.50
total_sizeMethod · 0.45
xMethod · 0.45
data_typeMethod · 0.45

Tested by

no test coverage detected