/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roccv/checkouts/latest/include/kernels/host/bnd_box_host.hpp Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roccv/checkouts/latest/include/kernels/host/bnd_box_host.hpp Source File#

2 min read time

Applies to Linux

rocCV: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roccv/checkouts/latest/include/kernels/host/bnd_box_host.hpp Source File
bnd_box_host.hpp
Go to the documentation of this file.
1 
23 #pragma once
24 
25 #include <hip/hip_runtime.h>
28 #include "operator_types.h"
29 
30 using namespace roccv;
31 
32 namespace Kernels {
33 namespace Host {
34 template <bool has_alpha, typename T, typename SrcWrapper, typename DstWrapper, typename BT = detail::BaseType<T>>
35 void bndbox_kernel(SrcWrapper input, DstWrapper output, Rect_t *rects,
36  size_t n_rects, int64_t batch, int64_t height,
37  int64_t width) {
38  // Working type for internal pixel format, which has 4 channels.
39  using WorkType = detail::MakeType<BT, 4>;
40 
41  for (int64_t b_idx = 0; b_idx < batch; b_idx++) {
42  for (int64_t y_idx = 0; y_idx < height; y_idx++) {
43  for (int64_t x_idx = 0; x_idx < width; x_idx++) {
44  WorkType shaded_pixel{0, 0, 0, 0};
45 
46  for (size_t i = 0; i < n_rects; i++) {
47  Rect_t curr_rect = rects[i];
48  if (curr_rect.batch <= b_idx)
49  shade_rectangle<WorkType>(curr_rect, x_idx, y_idx, &shaded_pixel);
50  }
51 
52  WorkType out_color = MathVector::fill(input.at(b_idx, y_idx, x_idx, 0));
53  out_color.w = has_alpha ? out_color.w : (std::numeric_limits<BT>::max());
54 
55  if (shaded_pixel.w != 0)
56  blend_single_color<WorkType>(out_color, shaded_pixel);
57 
58  MathVector::trunc(out_color, &output.at(b_idx, y_idx, x_idx, 0));
59  }
60  }
61  }
62 }
63 }; // namespace Host
64 }; // namespace Kernels
__host__ static __device__ HIP_vector_type< T, 4 > fill(HIP_vector_type< T, rank > vec)
Definition: math_vector.hpp:107
__host__ static __device__ void trunc(HIP_vector_type< T, 4 > vec, HIP_vector_type< T, rank > *dst)
Definition: math_vector.hpp:136
void bndbox_kernel(SrcWrapper input, DstWrapper output, Rect_t *rects, size_t n_rects, int64_t batch, int64_t height, int64_t width)
Definition: bnd_box_host.hpp:35
Definition: non_max_suppression_helpers.hpp:26
MakeType_t< T, C >::type MakeType
Definition: type_traits.hpp:97
Definition: strided_data_wrap.hpp:33
Definition: operator_types.h:115
int64_t batch
Definition: operator_types.h:116