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

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roccv/checkouts/latest/include/kernels/device/custom_crop_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/custom_crop_device.hpp Source File
custom_crop_device.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 Device {
31 template <typename SrcWrapper, typename DstWrapper>
32 __global__ void custom_crop(SrcWrapper input, DstWrapper output, Box_t cropRect) {
33  const int x = blockIdx.x * blockDim.x + threadIdx.x;
34  const int y = blockIdx.y * blockDim.y + threadIdx.y;
35  const int b = blockIdx.z;
36 
37  if (x >= cropRect.width || y >= cropRect.height || b >= output.batches()) return;
38 
39  const int srcX = x + cropRect.x;
40  const int srcY = y + cropRect.y;
41  const int dstX = x;
42  const int dstY = y;
43 
44  output.at(b, dstY, dstX, 0) = input.at(b, srcY, srcX, 0);
45 }
46 } // namespace Device
47 } // namespace Kernels
__global__ void custom_crop(SrcWrapper input, DstWrapper output, Box_t cropRect)
Definition: custom_crop_device.hpp:32
Definition: non_max_suppression_helpers.hpp:26
Definition: operator_types.h:90
int32_t height
width of the box.
Definition: operator_types.h:94
int32_t width
y coordinate of the top-left corner.
Definition: operator_types.h:93
int64_t y
x coordinate of the top-left corner.
Definition: operator_types.h:92
int64_t x
Definition: operator_types.h:91