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

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roccv/checkouts/latest/include/kernels/host/histogram_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/histogram_host.hpp Source File
histogram_host.hpp
Go to the documentation of this file.
1 
23 #pragma once
24 
25 #include <hip/hip_runtime.h>
26 
27 #include "operator_types.h"
28 
29 namespace Kernels {
30 namespace Host {
31 template <typename T, typename SrcWrapper>
32 void histogram_kernel(SrcWrapper input, roccv::GenericTensorWrapper<T> histogram) {
33 #pragma omp parallel for
34  for (int b = 0; b < input.batches(); b++) {
35  for (int y = 0; y < input.height(); y++) {
36  for (int x = 0; x < input.width(); x++) {
37  auto hist_idx = input.at(b, y, x, 0);
38  histogram.at(b, hist_idx.x, 0) += 1;
39  }
40  }
41  }
42 }
43 
44 template <typename T, typename SrcWrapper, typename MaskWrapper>
45 void histogram_kernel(SrcWrapper input, MaskWrapper mask, roccv::GenericTensorWrapper<T> histogram) {
46 #pragma omp parallel for
47  for (int b = 0; b < input.batches(); b++) {
48  for (int y = 0; y < input.height(); y++) {
49  for (int x = 0; x < input.width(); x++) {
50  if (mask.at(b, y, x, 0) != 0) {
51  auto hist_idx = input.at(b, y, x, 0);
52  histogram.at(b, hist_idx.x, 0) += 1;
53  }
54  }
55  }
56  }
57 }
58 } // namespace Host
59 } // namespace Kernels
Definition: generic_tensor_wrapper.hpp:28
__device__ __host__ T & at(ARGS... idx)
Definition: generic_tensor_wrapper.hpp:48
void histogram_kernel(SrcWrapper input, roccv::GenericTensorWrapper< T > histogram)
Definition: histogram_host.hpp:32
Definition: non_max_suppression_helpers.hpp:26