40 Status validate_arguments(
const ITensorInfo *anchors,
const ITensorInfo *all_anchors,
const ComputeAnchorsInfo &
info)
47 if(all_anchors->total_size() > 0)
49 const size_t feature_height = info.feat_height();
50 const size_t feature_width = info.feat_width();
51 const size_t num_anchors = anchors->dimension(1);
68 : _anchors(nullptr), _all_anchors(nullptr), _anchors_info(0.f, 0.f, 0.f)
89 _all_anchors = all_anchors;
94 INEKernel::configure(win);
104 void NEComputeAllAnchorsKernel::internal_run<int16_t>(
const Window &
window)
111 const size_t feat_width = _anchors_info.
feat_width();
117 const size_t anchor_offset =
id.
y() % num_anchors;
119 const auto out_anchor_ptr =
reinterpret_cast<int16_t *
>(all_anchors_it.
ptr());
122 const size_t shift_idy =
id.y() / num_anchors;
123 const float shiftx = (shift_idy % feat_width) * stride;
124 const float shifty = (shift_idy / feat_width) * stride;
139 template <
typename T>
140 void NEComputeAllAnchorsKernel::internal_run(
const Window &
window)
142 Iterator all_anchors_it(_all_anchors, window);
143 Iterator anchors_it(_all_anchors, window);
147 const size_t feat_width = _anchors_info.
feat_width();
151 const size_t anchor_offset =
id.
y() % num_anchors;
153 const auto out_anchor_ptr =
reinterpret_cast<T *
>(all_anchors_it.
ptr());
156 const size_t shift_idy =
id.y() / num_anchors;
157 const T shiftx = (shift_idy % feat_width) * stride;
158 const T shifty = (shift_idy / feat_width) * stride;
160 *out_anchor_ptr = *anchor_ptr + shiftx;
161 *(out_anchor_ptr + 1) = *(1 + anchor_ptr) + shifty;
162 *(out_anchor_ptr + 2) = *(2 + anchor_ptr) + shiftx;
163 *(out_anchor_ptr + 3) = *(3 + anchor_ptr) + shifty;
178 internal_run<int16_t>(
window);
181 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 184 internal_run<float16_t>(
window);
187 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 190 internal_run<float>(
window);
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
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.
uint8_t * ptr_to_element(const Coordinates &id) const
Return a pointer to the element at the passed coordinates.
int16_t quantize_qsymm16(float value, const UniformQuantizationInfo &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given a 16-bit symmetric quantization scheme.
quantized, symmetric fixed-point 16-bit number
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(...)
size_t values_per_roi() const
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
#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
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
static Status validate(const ITensorInfo *anchors, const ITensorInfo *all_anchors, const ComputeAnchorsInfo &info)
Static function to check if given info will lead to a valid configuration of NEComputeAllAnchorsKerne...
void configure(const ITensor *anchors, ITensor *all_anchors, const ComputeAnchorsInfo &info)
Set the input and output tensors.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Interface for CPU tensor.
float spatial_scale() const
float feat_height() const
Copyright (c) 2017-2021 Arm Limited.
1 channel, 1 F16 per channel
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
float dequantize_qsymm16(int16_t value, const UniformQuantizationInfo &qinfo)
Dequantize a value given a 16-bit symmetric quantization scheme.
Class to describe a number of elements in each dimension.
UniformQuantizationInfo uniform() const
Return per layer quantization info.
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 ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
constexpr uint8_t * ptr() const
Return a pointer to the current pixel.
NEComputeAllAnchorsKernel()
Default constructor.
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Information about executing thread and CPU.
const QuantizationInfo qinfo
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
ComputeAnchors information class.
constexpr const Dimension & y() const
Alias to access the second dimension of the window.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Store the tensor's metadata.
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...
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_NOT_IN(t,...)
Iterator updated by execute_window_loop for each window element.
DataType
Available data types.
Describe a multidimensional execution window.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)