24.02.1
|
Go to the documentation of this file.
24 #ifndef SRC_CORE_SVE_KERNELS_BOUNDINGBOXTRANFORM_IMPL_H
25 #define SRC_CORE_SVE_KERNELS_BOUNDINGBOXTRANFORM_IMPL_H
41 const int img_h = std::floor(bbinfo.
img_height() / bbinfo.
scale() + 0.5f);
42 const int img_w = std::floor(bbinfo.
img_width() / bbinfo.
scale() + 0.5f);
45 const auto scale_before = T(bbinfo.
scale());
57 const auto ptr =
reinterpret_cast<T *
>(box_it.
ptr());
59 const auto b1 = *(ptr + 1);
60 const auto b2 = *(ptr + 2);
61 const auto b3 = *(ptr + 3);
62 const T width = (b2 / scale_before) - (b0 / scale_before) + T(1.f);
63 const T height = (b3 / scale_before) - (b1 / scale_before) + T(1.f);
64 const T ctr_x = (b0 / scale_before) + T(0.5f) * width;
65 const T ctr_y = (b1 / scale_before) + T(0.5f) * height;
66 for (
size_t j = 0; j < num_classes; ++j)
69 const size_t delta_id =
id.y() * deltas_width + 4u * j;
70 const T dx = delta_ptr[delta_id] / T(bbinfo.
weights()[0]);
71 const T dy = delta_ptr[delta_id + 1] / T(bbinfo.
weights()[1]);
72 T dw = delta_ptr[delta_id + 2] / T(bbinfo.
weights()[2]);
73 T dh = delta_ptr[delta_id + 3] / T(bbinfo.
weights()[3]);
78 const T pred_ctr_x = dx * width + ctr_x;
79 const T pred_ctr_y = dy * height + ctr_y;
80 const T pred_w = std::exp(dw) * width;
81 const T pred_h = std::exp(dh) * height;
83 pred_ptr[delta_id] = scale_after * utility::clamp<T>(pred_ctr_x - T(0.5f) * pred_w, T(0), T(img_w - 1));
84 pred_ptr[delta_id + 1] =
85 scale_after * utility::clamp<T>(pred_ctr_y - T(0.5f) * pred_h, T(0), T(img_h - 1));
86 pred_ptr[delta_id + 2] =
87 scale_after * utility::clamp<T>(pred_ctr_x + T(0.5f) * pred_w -
offset, T(0), T(img_w - 1));
88 pred_ptr[delta_id + 3] =
89 scale_after * utility::clamp<T>(pred_ctr_y + T(0.5f) * pred_h -
offset, T(0), T(img_h - 1));
102 #endif //define SRC_CORE_SVE_KERNELS_BOUNDINGBOXTRANFORM_IMPL_H
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
Interface for CPU tensor.
void bounding_box_transform(const ITensor *boxes, ITensor *pred_boxes, const ITensor *deltas, BoundingBoxTransformInfo bbinfo, const Window &window)
void bounding_box_transform_qsymm16(const ITensor *boxes, ITensor *pred_boxes, const ITensor *deltas, BoundingBoxTransformInfo bbinfo, const Window &window)
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
constexpr uint8_t * ptr() const
Return a pointer to the current pixel.
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.
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Describe a multidimensional execution window.
Copyright (c) 2017-2024 Arm Limited.
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.
virtual uint8_t * buffer() const =0
Interface to be implemented by the child class to return a pointer to CPU memory.