23.11
|
Go to the documentation of this file.
29 #define VEC_MAX vec4_max
32 #define VEC_MAX vec8_max
35 #define VEC_MAX vec16_max
37 #error "Unsupported data size"
41 #if defined(OFFSET_OUT) && defined(SCALE_OUT)
42 #define MAX(x, y) max(x, y)
43 #else // !(defined(OFFSET_OUT) && defined(SCALE_OUT)
44 #define MAX(x, y) fmax(x, y)
45 #endif // defined(OFFSET_OUT) && defined(SCALE_OUT)
50 temp =
MAX(vec.lo, vec.hi);
51 return MAX(temp.x, temp.y);
57 temp =
MAX(vec.lo, vec.hi);
64 temp =
MAX(vec.lo, vec.hi);
79 inline DATA_TYPE
roi_pool_1x1(
const Tensor3D *
input,
int region_start_x,
int region_end_x,
int region_start_y,
int region_end_y,
int pz)
82 if((region_end_x <= region_start_x) || (region_end_y <= region_start_y))
88 int num_iter = (int)((region_end_x - region_start_x) /
VEC_SIZE);
92 for(
int j = region_start_y; j < region_end_y; ++j)
94 int i = region_start_x;
99 curr_max =
MAX(val, curr_max);
101 for(; i < region_end_x; ++i)
104 curr_max =
MAX(curr_max, val);
108 const DATA_TYPE temp = (DATA_TYPE)VEC_MAX(curr_max);
110 #if defined(OFFSET_OUT) && defined(SCALE_OUT)
111 return QUANTIZE(temp, OFFSET_OUT, SCALE_OUT, DATA_TYPE, 1);
155 unsigned int input_stride_w,
unsigned int output_stride_w)
162 const int px = get_global_id(0);
163 const int py = get_global_id(1);
164 const int pw = get_global_id(2);
168 const ushort roi_batch = (ushort) * ((__global ushort *)
offset(&rois, 0, pw));
170 roi = vload4(0, (__global ushort *)
offset(&rois, 1, pw));
171 const int2 roi_anchor = convert_int2_sat(
round(convert_float2(roi.s01) * (
float)SPATIAL_SCALE));
172 const int2 roi_dims = convert_int2_sat(fmax(
round(convert_float2(roi.s23 - roi.s01) * (
float)SPATIAL_SCALE), 1.f));
175 const float2 spatial_indx = (float2)(px, py);
176 const float2 pooled_dims = (float2)(POOLED_DIM_X, POOLED_DIM_Y);
177 const int2 max_spatial_dims = (int2)(MAX_DIM_X, MAX_DIM_Y);
178 int2 region_start = convert_int2_sat(floor(spatial_indx / pooled_dims * convert_float2(roi_dims))) + roi_anchor;
179 int2 region_end = convert_int2_sat(floor((spatial_indx + 1) / pooled_dims * convert_float2(roi_dims))) + roi_anchor;
181 region_start =
clamp(region_start, 0, max_spatial_dims);
182 region_end =
clamp(region_end, 0, max_spatial_dims);
185 input.ptr += roi_batch * input_stride_w;
186 output.
ptr += pw * output_stride_w;
188 for(
int pz = 0; pz < MAX_DIM_Z; ++pz)
#define CONVERT_TO_IMAGE_STRUCT_NO_STEP(name)
DATA_TYPE vec4_max(DATA_TYPE4 vec)
#define VEC_DATA_TYPE(type, size)
Structure to hold Image information.
#define QUANTIZE(input, offset, scale, type, size)
Structure to hold 3D tensor information.
DataType clamp(const DataType &n, const DataType &lower=std::numeric_limits< RangeType >::lowest(), const DataType &upper=std::numeric_limits< RangeType >::max())
Performs clamping among a lower and upper value.
DATA_TYPE roi_pool_1x1(const Tensor3D *input, int region_start_x, int region_end_x, int region_start_y, int region_end_y, int pz)
Performs a roi pooling on a single output pixel.
#define TENSOR3D_DECLARATION(name)
int round(float x, RoundingPolicy rounding_policy)
Return a rounded value of x.
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
__global uchar * ptr
Pointer to the starting postion of the buffer.
__kernel void roi_pooling_layer(__global uchar *input_ptr, uint input_stride_x, uint input_step_x, uint input_stride_y, uint input_step_y, uint input_stride_z, uint input_step_z, uint input_offset_first_element_in_bytes, __global uchar *rois_ptr, uint rois_stride_x, uint rois_step_x, uint rois_stride_y, uint rois_step_y, uint rois_offset_first_element_in_bytes, __global uchar *output_ptr, uint output_stride_x, uint output_step_x, uint output_stride_y, uint output_step_y, uint output_stride_z, uint output_step_z, uint output_offset_first_element_in_bytes, unsigned int input_stride_w, unsigned int output_stride_w)
Performs a roi pooling function.
#define IMAGE_DECLARATION(name)
#define CONVERT_TO_TENSOR3D_STRUCT_NO_STEP(name)
DATA_TYPE vec16_max(DATA_TYPE16 vec)
const __global uchar * tensor3D_offset(const Tensor3D *tensor, int x, int y, int z)
Get the pointer position of a Tensor3D.
DATA_TYPE vec8_max(DATA_TYPE8 vec)