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

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roccv/checkouts/latest/include/kernels/device/gamma_contrast_device.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/device/gamma_contrast_device.hpp Source File
gamma_contrast_device.hpp
Go to the documentation of this file.
1 
23 #pragma once
24 
25 #include <hip/hip_runtime.h>
27 #include "core/detail/casting.hpp"
28 
29 #include "operator_types.h"
30 
31 namespace Kernels {
32 namespace Device {
33 template <typename SrcWrapper, typename DstWrapper>
34 __global__ void gamma_contrast(SrcWrapper input, DstWrapper output, float gamma) {
35  using namespace roccv::detail; // For RangeCast, NumElements, etc.
36  using src_type = typename SrcWrapper::ValueType;
37  using dst_type = typename DstWrapper::ValueType;
38  using work_type = MakeType<float, NumElements<src_type>>;
39 
40  const int x = threadIdx.x + blockIdx.x * blockDim.x;
41  const int y = threadIdx.y + blockIdx.y * blockDim.y;
42  const int batch = blockIdx.z;
43 
44  if (x >= output.width() || y >= output.height() || batch >= output.batches()) return;
45 
46  auto inVal = (RangeCast<work_type>(input.at(batch, y, x, 0)));
47  work_type result = math::vpowf(inVal, gamma);
48  if constexpr (NumElements<dst_type> == 4) {
49  output.at(batch, y, x, 0) = RangeCast<dst_type>((MakeType<float, 4>){result.x, result.y, result.z, inVal.w});
50  } else {
51  output.at(batch, y, x, 0) = RangeCast<dst_type>(result);
52  }
53 
54 }
55 } // namespace Device
56 } // namespace Kernels
__global__ void gamma_contrast(SrcWrapper input, DstWrapper output, float gamma)
Definition: gamma_contrast_device.hpp:34
Definition: non_max_suppression_helpers.hpp:26
Definition: strided_data_wrap.hpp:33
MakeType_t< T, C >::type MakeType
Definition: type_traits.hpp:97
This header defines common arithmetic operators for HIP vectorized types.