44 void matrix_addition_f32(
const ITensor *
src, ITensor *
dst,
const Window &window,
float beta)
47 const float32x4_t beta_f32 = vdupq_n_f32(beta);
49 constexpr
int window_step_x = 16;
50 const auto window_start_x =
static_cast<int>(window.x().start());
51 const auto window_end_x =
static_cast<int>(window.x().end());
53 Window win = window.collapse_if_possible(window,
Window::DimZ);
56 Iterator in(src, win);
57 Iterator out(dst, win);
61 const auto in_ptr =
reinterpret_cast<const float *
>(in.ptr());
62 const auto out_ptr =
reinterpret_cast<float *
>(out.ptr());
64 int x = window_start_x;
65 for(; x < (window_end_x - window_step_x); x += window_step_x)
67 float32x4x4_t alpha_ab = vld4q_f32(out_ptr + x);
68 const float32x4x4_t c = vld4q_f32(in_ptr + x);
71 alpha_ab.val[0] = vmlaq_f32(alpha_ab.val[0], c.val[0], beta_f32);
72 alpha_ab.val[1] = vmlaq_f32(alpha_ab.val[1], c.val[1], beta_f32);
73 alpha_ab.val[2] = vmlaq_f32(alpha_ab.val[2], c.val[2], beta_f32);
74 alpha_ab.val[3] = vmlaq_f32(alpha_ab.val[3], c.val[3], beta_f32);
76 vst4q_f32(out_ptr + x, alpha_ab);
80 for(; x < window_end_x; ++x)
82 *(out_ptr + x) += *(in_ptr + x) * beta;
88 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 89 void matrix_addition_f16(
const ITensor *src, ITensor *dst,
const Window &window,
float beta)
92 const float16x8_t beta_f16 = vdupq_n_f16(beta);
94 constexpr
int window_step_x = 16;
95 const auto window_start_x =
static_cast<int>(window.x().start());
96 const auto window_end_x =
static_cast<int>(window.x().end());
98 Window win = window.collapse_if_possible(window,
Window::DimZ);
101 Iterator in(src, win);
102 Iterator out(dst, win);
106 const auto in_ptr =
reinterpret_cast<const float16_t *
>(in.ptr());
107 const auto out_ptr =
reinterpret_cast<float16_t *
>(out.ptr());
109 int x = window_start_x;
110 for(; x < (window_end_x - window_step_x); x += window_step_x)
112 float16x8x2_t alpha_ab = vld2q_f16(out_ptr + x);
113 const float16x8x2_t c = vld2q_f16(in_ptr + x);
118 vst2q_f16(out_ptr + x, alpha_ab);
122 for(; x < window_end_x; ++x)
124 *(out_ptr + x) += *(in_ptr + x) *
static_cast<float16_t
>(beta);
145 _func = &matrix_addition_f32;
148 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 149 _func = &matrix_addition_f16;
159 ICPPKernel::configure(win);
196 return "CpuGemmMatrixAdditionKernel";
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.
float16x8_t vmulq_f16(float16x8_t, float16x8_t)
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
bool empty() const
Checks if pack is empty.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
1 channel, 1 F32 per channel
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Store the tensor's metadata.
float16x8_t vaddq_f16(float16x8_t, float16x8_t)
#define ARM_COMPUTE_ERROR_THROW_ON(status)
void run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
Interface for CPU tensor.
SimpleTensor< float > src
Copyright (c) 2017-2021 Arm Limited.
1 channel, 1 F16 per channel
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Class to describe a number of elements in each dimension.
void configure(const ITensorInfo *src, ITensorInfo *dst, float beta)
Initialise the kernel's input and output.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
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.
const char * name() const override
Name of the kernel.
Information about executing thread and CPU.
virtual size_t total_size() const =0
Returns the total size of the tensor in bytes.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
void execute_window_loop(const Window &w, L &&lambda_function, Ts &&... iterators)
Iterate through the passed window, automatically adjusting the iterators and calling the lambda_funct...
Describe a multidimensional execution window.
static Status validate(const ITensorInfo *src, const ITensorInfo *dst, float beta)
Static function to check if given info will lead to a valid configuration of CpuGemmMatrixAdditionKer...
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)