48 Status
validate_arguments(
const ITensorInfo *
input,
const ITensorInfo *bias,
const ITensorInfo *output,
int min,
int max)
61 if(output->total_size() != 0)
70 std::pair<Status, Window> validate_and_configure_window(ITensorInfo *input, ITensorInfo *output)
80 coord.set_num_dimensions(output->num_dimensions());
81 output->set_valid_region(ValidRegion(coord, output->tensor_shape()));
83 return std::make_pair(Status{}, win);
89 template <
bool is_bounded_relu>
92 const int16x8_t min_s16 = vdupq_n_s16(static_cast<int16_t>(_min));
93 const int16x8_t max_s16 = vdupq_n_s16(static_cast<int16_t>(_max));
98 const int window_step_x = 8;
99 const auto window_start_x =
static_cast<int>(window.x().start());
100 const auto window_end_x =
static_cast<int>(window.x().end());
102 Window win_collapsed = window.collapse_if_possible(window,
Window::DimZ);
103 win_collapsed.set(
Window::DimX, Window::Dimension(0, 1, 1));
105 Iterator in(_input, win_collapsed);
106 Iterator out(_output, win_collapsed);
110 win_biases.set(
Window::DimX, Window::Dimension(0, 1, 1));
111 win_biases.set(
Window::DimY, Window::Dimension(0, 1, 1));
113 Iterator bias(_bias, win_biases);
117 int x = window_start_x;
118 for(; x <= (window_end_x - window_step_x); x += window_step_x)
123 vld1q_s32(reinterpret_cast<const int32_t *>(in.ptr()) + x + 0),
124 vld1q_s32(reinterpret_cast<const int32_t *>(in.ptr()) + x + 4)
128 const int32x4x2_t bias_s32 =
131 vld1q_s32(reinterpret_cast<const int32_t *>(bias.ptr()) + x + 0),
132 vld1q_s32(reinterpret_cast<const int32_t *>(bias.ptr()) + x + 4)
137 in_s32.val[0] = vaddq_s32(in_s32.val[0], bias_s32.val[0]);
138 in_s32.val[1] = vaddq_s32(in_s32.val[1], bias_s32.val[1]);
140 vst1q_s16(reinterpret_cast<int16_t *>(out.ptr()) + x, finalize_quantization_int16<is_bounded_relu>(in_s32, _result_fixedpoint_multiplier, _result_shift, min_s16, max_s16));
144 for(; x < window_end_x; ++x)
146 const int32_t bias_value = *(
reinterpret_cast<const int32_t *
>(bias.ptr()) + x);
147 int32_t in_value = *(
reinterpret_cast<const int32_t *
>(in.ptr()) + x);
150 in_value += bias_value;
152 *(
reinterpret_cast<int16_t *
>(out.ptr()) + x) = finalize_quantization_int16<is_bounded_relu>(in_value, _result_fixedpoint_multiplier, _result_shift,
static_cast<int16_t
>(_min),
153 static_cast<int16_t>(_max));
163 int x = window_start_x;
164 for(; x <= (window_end_x - window_step_x); x += window_step_x)
169 vld1q_s32(reinterpret_cast<const int32_t *>(in.ptr()) + x + 0),
170 vld1q_s32(reinterpret_cast<const int32_t *>(in.ptr()) + x + 4)
174 vst1q_s16(reinterpret_cast<int16_t *>(out.ptr()) + x, finalize_quantization_int16<is_bounded_relu>(in_s32, _result_fixedpoint_multiplier, _result_shift, min_s16, max_s16));
178 for(; x < window_end_x; ++x)
180 const int32_t in_value = *(
reinterpret_cast<const int32_t *
>(in.ptr()) + x);
183 *(
reinterpret_cast<int16_t *
>(out.ptr()) + x) = finalize_quantization_int16<is_bounded_relu>(in_value, _result_fixedpoint_multiplier, _result_shift,
static_cast<int16_t
>(_min),
184 static_cast<int16_t>(_max));
192 : _func(nullptr), _input(nullptr), _bias(nullptr), _output(nullptr), _result_fixedpoint_multiplier(0), _result_shift(0), _min(0), _max(0)
206 _result_fixedpoint_multiplier = result_fixedpoint_multiplier;
207 _result_shift = result_shift;
212 auto win_config = validate_and_configure_window(input->
info(), output->
info());
214 INEKernel::configure(win_config.second);
217 const bool is_bounded_relu = !(min <= -32768 && max >= 32767);
218 _func = is_bounded_relu ? &NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPointKernel::run<true> : &NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPointKernel::run<false>;
236 (this->*_func)(window);
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
static Status validate(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, int min=0, int max=0)
Static function to check if given info will lead to a valid configuration of NEGEMMLowpQuantizeDownIn...
const Window & window() const
The maximum window the kernel can be executed on.
quantized, symmetric fixed-point 16-bit number
void configure(const ITensor *input, const ITensor *bias, ITensor *output, int result_fixedpoint_multiplier, int result_shift, int min=0, int max=0)
Initialise the kernel's input and output.
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Interface for Neon tensor.
Copyright (c) 2017-2021 Arm Limited.
1 channel, 1 S32 per channel
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
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.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Information about executing thread and CPU.
#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,...)
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
#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.
NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPointKernel()
Constructor.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)