46 struct AddSelectorData
62 static const AddKernel available_kernels[] =
64 #if defined(__ARM_FEATURE_SVE) 67 [](
const AddSelectorData & data) {
return ((data.dt1 == data.dt2) && (data.dt1 ==
DataType::F32)); },
72 [](
const AddSelectorData & data) {
return ((data.dt1 == data.dt2) && (data.dt1 ==
DataType::F16)); },
77 [](
const AddSelectorData & data) {
return ((data.dt1 == data.dt2) && (data.dt1 == data.dt3) && (data.dt1 ==
DataType::U8)); },
82 [](
const AddSelectorData & data) {
return ((data.dt1 == data.dt2) && (data.dt1 == data.dt3) && (data.dt1 ==
DataType::S16)); },
87 [](
const AddSelectorData & data) {
return ((data.dt1 == data.dt2) && (data.dt1 == data.dt3) && (data.dt1 ==
DataType::S32)); },
102 [](
const AddSelectorData & data) {
return ((data.dt1 == data.dt2) && (data.dt3 ==
DataType::S16)); },
108 [](
const AddSelectorData & data) {
return ((data.dt1 == data.dt2) && (data.dt1 ==
DataType::F32)); },
111 #if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) 114 [](
const AddSelectorData & data) {
return ((data.dt1 == data.dt2) && (data.dt1 ==
DataType::F16)); },
120 [](
const AddSelectorData & data) {
return ((data.dt1 == data.dt2) && (data.dt1 == data.dt3) && (data.dt1 ==
DataType::U8)); },
125 [](
const AddSelectorData & data) {
return ((data.dt1 == data.dt2) && (data.dt1 == data.dt3) && (data.dt1 ==
DataType::S16)); },
130 [](
const AddSelectorData & data) {
return ((data.dt1 == data.dt2) && (data.dt1 == data.dt3) && (data.dt1 ==
DataType::S32)); },
134 "add_u8_s16_s16_neon",
139 "add_s16_u8_s16_neon",
144 "add_u8_u8_s16_neon",
145 [](
const AddSelectorData & data) {
return ((data.dt1 == data.dt2) && (data.dt3 ==
DataType::S16)); },
150 #if defined(__ARM_FEATURE_SVE2) 153 [](
const AddSelectorData & data) {
return ((data.dt1 == data.dt2) && (data.dt1 ==
DataType::QASYMM8)); },
157 "add_qasymm8_signed_sve",
163 [](
const AddSelectorData & data) {
return ((data.dt1 == data.dt2) && (data.dt1 ==
DataType::QSYMM16)); },
169 [](
const AddSelectorData & data) {
return ((data.dt1 == data.dt2) && (data.dt1 ==
DataType::QASYMM8)); },
173 "add_qasymm8_signed_neon",
179 [](
const AddSelectorData & data) {
return ((data.dt1 == data.dt2) && (data.dt1 ==
DataType::QSYMM16)); },
194 for(
const auto &uk : available_kernels)
196 if(uk.is_selected({ dt1, dt2, dt3 }))
219 ARM_COMPUTE_RETURN_ERROR_ON_MSG((src0.tensor_shape().x() != src1.tensor_shape().x()) && ((src0.data_type() != src1.data_type()) || (src0.data_type() != dst.data_type())
220 || (src1.data_type() != dst.data_type())),
221 "Broadcasting across width is supported on configurations where all tensors have the same data type");
224 if(dst.total_size() > 0)
238 "You called addition with the wrong image formats");
241 "Wrong shape for dst");
244 const auto *uk = get_implementation(src0.data_type(), src1.data_type(), dst.data_type());
250 std::pair<Status, Window> validate_and_configure_window(
const ITensorInfo &src0,
const ITensorInfo &src1, ITensorInfo &dst)
253 const TensorShape &out_shape = broadcast_pair.first;
254 const ValidRegion &
valid_region = broadcast_pair.second;
294 coord.set_num_dimensions(dst.num_dimensions());
295 dst.set_valid_region(valid_region);
296 return std::make_pair(Status{}, win);
308 auto win_config = validate_and_configure_window(*src0, *src1, *dst);
310 ICpuKernel::configure(win_config.second);
338 uk->ukernel(src0, src1, dst, _policy, window);
343 return "CpuAddKernel";
bool set_format_if_unknown(ITensorInfo &info, Format format)
Set the format, data type and number of channels to the specified value if the current data type is u...
void add_s16_u8_s16_neon(const ITensor *src0, const ITensor *src1, ITensor *dst, const ConvertPolicy &policy, const Window &window)
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
const Window & window() const
The maximum window the kernel can be executed on.
quantized, symmetric fixed-point 16-bit number
bool set_data_type_if_unknown(ITensorInfo &info, DataType data_type)
Set the data type and number of channels to the specified value if the current data type is unknown...
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
#define REGISTER_FP16_NEON(func_name)
bool empty() const
Checks if pack is empty.
1 channel, 1 U8 per channel
#define REGISTER_FP32_NEON(func_name)
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
1 channel, 1 F32 per channel
#define REGISTER_FP32_SVE(func_name)
static TensorShape broadcast_shape(const Shapes &... shapes)
If shapes are broadcast compatible, return the broadcasted shape.
#define REGISTER_QASYMM8_SVE(func_name)
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
#define REGISTER_QASYMM8_SIGNED_NEON(func_name)
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
const ValidRegion valid_region
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
static std::pair< TensorShape, ValidRegion > broadcast_shape_and_valid_region(const Infos &... infos)
If infos are broadcast compatible tensor info's, return the broadcasted shape and the intersection of...
decltype(strategy::transforms) typedef type
Interface for Neon tensor.
Copyright (c) 2017-2021 Arm Limited.
1 channel, 1 F16 per channel
void add_qsymm16_neon(const ITensor *src0, const ITensor *src1, ITensor *dst, const ConvertPolicy &policy, const Window &window)
void add_qasymm8_neon(const ITensor *src0, const ITensor *src1, ITensor *dst, const ConvertPolicy &policy, const Window &window)
#define REGISTER_INTEGER_NEON(func_name)
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
#define REGISTER_QASYMM8_SIGNED_SVE(func_name)
1 channel, 1 S32 per channel
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
void run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
void add_u8_u8_s16_neon(const ITensor *src0, const ITensor *src1, ITensor *dst, const ConvertPolicy &policy, const Window &window)
#define REGISTER_QASYMM8_NEON(func_name)
quantized, asymmetric fixed-point 8-bit number unsigned
#define REGISTER_QSYMM16_NEON(func_name)
#define REGISTER_INTEGER_SVE(func_name)
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
bool set_shape_if_empty(ITensorInfo &info, const TensorShape &shape)
Set the shape to the specified value if the current assignment is empty.
bool have_different_dimensions(const Dimensions< T > &dim1, const Dimensions< T > &dim2, unsigned int upper_dim)
const char * name() const override
Name of the kernel.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
1 channel, 1 S16 per channel
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
Information about executing thread and CPU.
#define REGISTER_QSYMM16_SVE(func_name)
#define REGISTER_FP16_SVE(func_name)
static Status validate(const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst, ConvertPolicy policy)
Static function to check if given info will lead to a valid configuration of CpuAddKernel.
void configure(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst, ConvertPolicy policy)
Initialise the kernel's input, dst and border mode.
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
void add_qasymm8_signed_neon(const ITensor *src0, const ITensor *src1, ITensor *dst, const ConvertPolicy &policy, const Window &window)
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
quantized, asymmetric fixed-point 8-bit number signed
DataType
Available data types.
const AddSelectorPtr is_selected
Describe a multidimensional execution window.
ConvertPolicy
Policy to handle overflow.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
void add_u8_s16_s16_neon(const ITensor *src0, const ITensor *src1, ITensor *dst, const ConvertPolicy &policy, const Window &window)