34 const int img_h = std::floor(bbinfo.
img_height() / bbinfo.
scale() + 0.5f);
35 const int img_w = std::floor(bbinfo.
img_width() / bbinfo.
scale() + 0.5f);
38 const auto scale_before = bbinfo.
scale();
51 const auto ptr =
reinterpret_cast<uint16_t *
>(box_it.
ptr());
56 const float width = (b2 / scale_before) - (b0 / scale_before) + 1.f;
57 const float height = (b3 / scale_before) - (b1 / scale_before) + 1.f;
58 const float ctr_x = (b0 / scale_before) + 0.5f * width;
59 const float ctr_y = (b1 / scale_before) + 0.5f * height;
60 for(
size_t j = 0; j < num_classes; ++j)
63 const size_t delta_id =
id.y() * deltas_width + 4u * j;
72 const float pred_ctr_x = dx * width + ctr_x;
73 const float pred_ctr_y = dy * height + ctr_y;
74 const float pred_w = std::exp(dw) * width;
75 const float pred_h = std::exp(dh) * height;
77 pred_ptr[delta_id] =
quantize_qasymm16(scale_after * utility::clamp<float>(pred_ctr_x - 0.5f * pred_w, 0.f, img_w - 1.f), pred_qinfo);
78 pred_ptr[delta_id + 1] =
quantize_qasymm16(scale_after * utility::clamp<float>(pred_ctr_y - 0.5f * pred_h, 0.f, img_h - 1.f), pred_qinfo);
79 pred_ptr[delta_id + 2] =
quantize_qasymm16(scale_after * utility::clamp<float>(pred_ctr_x + 0.5f * pred_w -
offset, 0.f, img_w - 1.f), pred_qinfo);
80 pred_ptr[delta_id + 3] =
quantize_qasymm16(scale_after * utility::clamp<float>(pred_ctr_y + 0.5f * pred_h -
offset, 0.f, img_h - 1.f), pred_qinfo);
91 const int img_h = std::floor(bbinfo.
img_height() / bbinfo.
scale() + 0.5f);
92 const int img_w = std::floor(bbinfo.
img_width() / bbinfo.
scale() + 0.5f);
95 const auto scale_before = T(bbinfo.
scale());
105 const auto ptr =
reinterpret_cast<T *
>(box_it.
ptr());
106 const auto b0 = *ptr;
107 const auto b1 = *(ptr + 1);
108 const auto b2 = *(ptr + 2);
109 const auto b3 = *(ptr + 3);
110 const T width = (b2 / scale_before) - (b0 / scale_before) + T(1.f);
111 const T height = (b3 / scale_before) - (b1 / scale_before) + T(1.f);
112 const T ctr_x = (b0 / scale_before) + T(0.5f) * width;
113 const T ctr_y = (b1 / scale_before) + T(0.5f) * height;
114 for(
size_t j = 0; j < num_classes; ++j)
117 const size_t delta_id =
id.y() * deltas_width + 4u * j;
118 const T dx = delta_ptr[delta_id] / T(bbinfo.
weights()[0]);
119 const T dy = delta_ptr[delta_id + 1] / T(bbinfo.
weights()[1]);
120 T dw = delta_ptr[delta_id + 2] / T(bbinfo.
weights()[2]);
121 T dh = delta_ptr[delta_id + 3] / T(bbinfo.
weights()[3]);
126 const T pred_ctr_x = dx * width + ctr_x;
127 const T pred_ctr_y = dy * height + ctr_y;
128 const T pred_w = std::exp(dw) * width;
129 const T pred_h = std::exp(dh) * height;
131 pred_ptr[delta_id] = scale_after * utility::clamp<T>(pred_ctr_x - T(0.5f) * pred_w, T(0), T(img_w - 1));
132 pred_ptr[delta_id + 1] = scale_after * utility::clamp<T>(pred_ctr_y - T(0.5f) * pred_h, T(0), T(img_h - 1));
133 pred_ptr[delta_id + 2] = scale_after * utility::clamp<T>(pred_ctr_x + T(0.5f) * pred_w -
offset, T(0), T(img_w - 1));
134 pred_ptr[delta_id + 3] = scale_after * utility::clamp<T>(pred_ctr_y + T(0.5f) * pred_h -
offset, T(0), T(img_h - 1));
142 #if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && defined(ENABLE_FP16_KERNELS) 144 #endif //defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && defined(ENABLE_FP16_KERNELS) __global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
void bounding_box_transform_qsymm16(const ITensor *boxes, ITensor *pred_boxes, const ITensor *deltas, BoundingBoxTransformInfo bbinfo, const Window &window)
float dequantize_qasymm8(uint8_t value, const INFO_TYPE &qinfo)
Dequantize a value given an unsigned 8-bit asymmetric quantization scheme.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Interface for CPU tensor.
template void bounding_box_transform< float >(const ITensor *boxes, ITensor *pred_boxes, const ITensor *deltas, BoundingBoxTransformInfo bbinfo, const Window &window)
Copyright (c) 2017-2022 Arm Limited.
float dequantize_qasymm16(uint16_t value, const UniformQuantizationInfo &qinfo)
Dequantize a value given a 16-bit asymmetric quantization scheme.
void bounding_box_transform(const ITensor *boxes, ITensor *pred_boxes, const ITensor *deltas, BoundingBoxTransformInfo bbinfo, const Window &window)
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
virtual uint8_t * buffer() const =0
Interface to be implemented by the child class to return a pointer to CPU memory. ...
UniformQuantizationInfo uniform() const
Return per layer quantization info.
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.
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
virtual size_t offset_first_element_in_bytes() const =0
The offset from the beginning of the memory allocation to the first element of the tensor...
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...
Iterator updated by execute_window_loop for each window element.
Describe a multidimensional execution window.
uint16_t quantize_qasymm16(float value, const UniformQuantizationInfo &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given a 16-bit asymmetric quantization scheme.