X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=documentation%2Fpooling__layer_8cl.xhtml;h=ec758408a1430967e2d2687e1b1a41095388ef5d;hb=HEAD;hp=1be3ec2ae469c65a814ef68b0fa016640ebe173c;hpb=8140e1e155d3430992fa46e04ef8938ff09ffd2d;p=platform%2Fupstream%2Farmcl.git diff --git a/documentation/pooling__layer_8cl.xhtml b/documentation/pooling__layer_8cl.xhtml index 1be3ec2..ec75840 100644 --- a/documentation/pooling__layer_8cl.xhtml +++ b/documentation/pooling__layer_8cl.xhtml @@ -40,7 +40,7 @@
Compute Library -  17.12 +  18.05
@@ -134,6 +134,8 @@ Macros   #define SQRT_OP(x)   sqrt((x))   +#define DIV_OP_NHWC(x, y)   (x * (VEC_DATA_TYPE(DATA_TYPE, 8))(1.f / y)) +  #define POOLING3x3_STRIDE1(res, input, output)   #define POOLING3x3_STRIDE2(res, input, output) @@ -143,14 +145,19 @@ Macros - - + + + + + + +

Functions

DATA_TYPE calculate_avg_scale (const int pool_size, const int upper_bound_w, const int upper_bound_h, const int pad_x, const int pad_y, const int stride_x, const int stride_y)
 
DATA_TYPE calculate_avg_scale (const int pool_size_x, const int pool_size_y, const int upper_bound_w, const int upper_bound_h, const int pad_x, const int pad_y, const int stride_x, const int stride_y)
 
__kernel void pooling_layer_2 (__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 *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)
 Performs a pooling function of pool size equal to 2. More...
 
__kernel void pooling_layer_3 (__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 *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)
 Performs a pooling function of pool size equal to 3. More...
 
DATA_TYPE calculate_avg_scale_nhwc (const int pool_size_x, const int pool_size_y, int upper_bound_w, int upper_bound_h, const int pad_x, const int pad_y, const int stride_x, const int stride_y)
 
__kernel void pooling_layer_MxN_nhwc (__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 *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)
 Performs a pooling function of pool size equal to N (NHWC) More...
 

Macro Definition Documentation

@@ -179,7 +186,37 @@ Functions

Definition at line 60 of file pooling_layer.cl.

-

Referenced by pooling_layer_2(), and pooling_layer_3().

+

Referenced by pooling_layer_2(), and pooling_layer_3().

+ + + + +
+
+ + + + + + + + + + + + + + + + + + +
#define DIV_OP_NHWC( x,
 
)   (x * (VEC_DATA_TYPE(DATA_TYPE, 8))(1.f / y))
+
+ +

Definition at line 65 of file pooling_layer.cl.

+ +

Referenced by pooling_layer_MxN_nhwc().

@@ -209,7 +246,7 @@ Functions

Definition at line 49 of file pooling_layer.cl.

-

Referenced by pooling_layer_2(), and pooling_layer_3().

+

Referenced by pooling_layer_2(), pooling_layer_3(), and pooling_layer_MxN_nhwc().

@@ -243,7 +280,7 @@ Functions
-

Definition at line 73 of file pooling_layer.cl.

+

Definition at line 75 of file pooling_layer.cl.

@@ -277,7 +314,7 @@ Functions
-

Definition at line 116 of file pooling_layer.cl.

+

Definition at line 118 of file pooling_layer.cl.

@@ -313,10 +350,10 @@ Functions Value:
({ \
VEC_DATA_TYPE(DATA_TYPE, 8) \
data00 = vload8(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, 0, 0)); \
VEC_DATA_TYPE(DATA_TYPE, 4) \
data01 = vload4(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, 0, 0) + 8); \
VEC_DATA_TYPE(DATA_TYPE, 8) \
data10 = vload8(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, 1, 0)); \
VEC_DATA_TYPE(DATA_TYPE, 4) \
data11 = vload4(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, 1, 0) + 8); \
VEC_DATA_TYPE(DATA_TYPE, 8) \
data20 = vload8(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, 2, 0)); \
VEC_DATA_TYPE(DATA_TYPE, 4) \
data21 = vload4(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, 2, 0) + 8); \
data00 = POW2_OP(data00, 8); \
data01 = POW2_OP(data01, 4); \
data10 = POW2_OP(data10, 8); \
data11 = POW2_OP(data11, 4); \
data20 = POW2_OP(data20, 8); \
data21 = POW2_OP(data21, 4); \
\
data00 = POOL_OP(data00, data10); \
data01 = POOL_OP(data01, data11); \
data00 = POOL_OP(data00, data20); \
data01 = POOL_OP(data01, data21); \
\
res = POOL_OP((VEC_DATA_TYPE(DATA_TYPE, 4))(data00.s036, data01.s1), (VEC_DATA_TYPE(DATA_TYPE, 4))(data00.s147, data01.s2)); \
res = POOL_OP(res, (VEC_DATA_TYPE(DATA_TYPE, 4))(data00.s25, data01.s03)); \
})
#define POOL_OP(x, y)
#define DATA_TYPE
#define POW2_OP(x, vec_size)
-
__global const uchar * tensor3D_offset(const Tensor3D *tensor, int x, int y, int z)
Get the pointer position of a Tensor3D.
Definition: helpers.h:313
+
__global const uchar * tensor3D_offset(const Tensor3D *tensor, int x, int y, int z)
Get the pointer position of a Tensor3D.
Definition: helpers.h:315
#define VEC_DATA_TYPE(type, size)
Definition: fixed_point.h:93
-

Definition at line 156 of file pooling_layer.cl.

+

Definition at line 158 of file pooling_layer.cl.

@@ -346,7 +383,7 @@ Functions

Definition at line 57 of file pooling_layer.cl.

-

Referenced by pooling_layer_2(), and pooling_layer_3().

+

Referenced by pooling_layer_2(), and pooling_layer_3().

@@ -366,12 +403,12 @@ Functions

Definition at line 61 of file pooling_layer.cl.

-

Referenced by pooling_layer_2(), and pooling_layer_3().

+

Referenced by pooling_layer_2(), pooling_layer_3(), and pooling_layer_MxN_nhwc().

Function Documentation

- +
@@ -379,7 +416,13 @@ Functions - + + + + + + + @@ -425,13 +468,83 @@ Functions
DATA_TYPE calculate_avg_scale ( const int pool_size, pool_size_x,
const int pool_size_y,
-

Definition at line 186 of file pooling_layer.cl.

+

Definition at line 188 of file pooling_layer.cl.

-

References arm_compute::test::fixed_point_arithmetic::detail::max(), and arm_compute::test::fixed_point_arithmetic::detail::min().

+

References arm_compute::test::fixed_point_arithmetic::detail::max(), and arm_compute::test::fixed_point_arithmetic::detail::min().

-

Referenced by pooling_layer_2(), and pooling_layer_3().

-
188 {
189  int start_x = get_global_id(0) * stride_x - pad_x;
190  int start_y = get_global_id(1) * stride_y - pad_y;
191  const int end_x = min(start_x + pool_size, upper_bound_w);
192  const int end_y = min(start_y + pool_size, upper_bound_h);
193 #if defined(EXCLUDE_PADDING)
194  start_x = max(0, start_x);
195  start_y = max(0, start_y);
196 #endif /* defined(EXCLUDE_PADDING) */
197  return ((end_y - start_y) * (end_x - start_x));
198 }
fixed_point< T > min(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:884
-
fixed_point< T > max(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:889
+

Referenced by pooling_layer_2(), and pooling_layer_3().

+
190 {
191  int start_x = get_global_id(0) * stride_x - pad_x;
192  int start_y = get_global_id(1) * stride_y - pad_y;
193  const int end_x = min(start_x + pool_size_x, upper_bound_w);
194  const int end_y = min(start_y + pool_size_y, upper_bound_h);
195 #if defined(EXCLUDE_PADDING)
196  start_x = max(0, start_x);
197  start_y = max(0, start_y);
198 #endif /* defined(EXCLUDE_PADDING) */
199  return ((end_y - start_y) * (end_x - start_x));
200 }
fixed_point< T > min(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:897
+
fixed_point< T > max(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:902
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DATA_TYPE calculate_avg_scale_nhwc (const int pool_size_x,
const int pool_size_y,
int upper_bound_w,
int upper_bound_h,
const int pad_x,
const int pad_y,
const int stride_x,
const int stride_y 
)
+
+ +

Definition at line 518 of file pooling_layer.cl.

+ +

References arm_compute::test::fixed_point_arithmetic::detail::max(), and arm_compute::test::fixed_point_arithmetic::detail::min().

+ +

Referenced by pooling_layer_MxN_nhwc().

+
520 {
521  int start_x = get_global_id(1) * stride_x - pad_x;
522  int start_y = get_global_id(2) * stride_y - pad_y;
523 
524 #if !defined(EXCLUDE_PADDING)
525  upper_bound_w += pad_x;
526  upper_bound_h += pad_y;
527 #endif /* defined(EXCLUDE_PADDING) */
528  const int end_x = min(start_x + pool_size_x, upper_bound_w);
529  const int end_y = min(start_y + pool_size_y, upper_bound_h);
530 #if defined(EXCLUDE_PADDING)
531  start_x = max(0, start_x);
532  start_y = max(0, start_y);
533 #endif /* defined(EXCLUDE_PADDING) */
534  return ((end_y - start_y) * (end_x - start_x));
535 }
fixed_point< T > min(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:897
+
fixed_point< T > max(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:902
@@ -569,19 +682,19 @@ In case of average pooling the following information must be passed at compile t -

Definition at line 226 of file pooling_layer.cl.

+

Definition at line 228 of file pooling_layer.cl.

-

References calculate_avg_scale(), CONVERT_TO_TENSOR3D_STRUCT, DATA_TYPE, DIV_OP, POOL_OP, POW2_OP, Tensor3D::ptr, SQRT_OP, tensor3D_offset(), and VEC_DATA_TYPE.

-
229 {
230  // Get pixels pointer
231  Tensor3D input = CONVERT_TO_TENSOR3D_STRUCT(input);
232  Tensor3D output = CONVERT_TO_TENSOR3D_STRUCT(output);
233 
234  // Load data
236  data0 = vload2(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, 0, 0));
238  data1 = vload2(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, 1, 0));
239 
240 #if defined(POOL_L2)
241  // Raise to power of 2 for L2 Pooling
242  data0 = POW2_OP(data0, 2);
243  data1 = POW2_OP(data1, 2);
244 #endif /* defined(POOL_L2) */
245 
246  // Perform calculations
247  data0 = POOL_OP(data0, data1);
248  DATA_TYPE res = POOL_OP(data0.s0, data0.s1);
249 
250 #if defined(POOL_AVG) || defined(POOL_L2)
251  // Divide by pool region in case of average or l2 pooling
252  res = DIV_OP(res, calculate_avg_scale(2, MAX_WIDTH, MAX_HEIGHT, PAD_X, PAD_Y, STRIDE_X, STRIDE_Y));
253 #endif /* defined(POOL_AVG) || defined(POOL_L2) */
254 
255 #if defined(POOL_L2)
256  // Take square root of the result in L2 pooling
257  res = SQRT_OP(res);
258 #endif /* defined(POOL_L2) */
259 
260  // Store result
261  *(__global DATA_TYPE *)output.ptr = res;
262 }
#define DIV_OP(x, y)
+

References calculate_avg_scale(), CONVERT_TO_TENSOR3D_STRUCT, DATA_TYPE, DIV_OP, POOL_OP, POW2_OP, Tensor3D::ptr, SQRT_OP, tensor3D_offset(), and VEC_DATA_TYPE.

+
231 {
232  // Get pixels pointer
233  Tensor3D input = CONVERT_TO_TENSOR3D_STRUCT(input);
234  Tensor3D output = CONVERT_TO_TENSOR3D_STRUCT(output);
235 
236  // Load data
238  data0 = vload2(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, 0, 0));
240  data1 = vload2(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, 1, 0));
241 
242 #if defined(POOL_L2)
243  // Raise to power of 2 for L2 Pooling
244  data0 = POW2_OP(data0, 2);
245  data1 = POW2_OP(data1, 2);
246 #endif /* defined(POOL_L2) */
247 
248  // Perform calculations
249  data0 = POOL_OP(data0, data1);
250  DATA_TYPE res = POOL_OP(data0.s0, data0.s1);
251 
252 #if defined(POOL_AVG) || defined(POOL_L2)
253  // Divide by pool region in case of average or l2 pooling
254  res = DIV_OP(res, calculate_avg_scale(2, 2, MAX_WIDTH, MAX_HEIGHT, PAD_X, PAD_Y, STRIDE_X, STRIDE_Y));
255 #endif /* defined(POOL_AVG) || defined(POOL_L2) */
256 
257 #if defined(POOL_L2)
258  // Take square root of the result in L2 pooling
259  res = SQRT_OP(res);
260 #endif /* defined(POOL_L2) */
261 
262  // Store result
263  *(__global DATA_TYPE *)output.ptr = res;
264 }
#define DIV_OP(x, y)
#define POOL_OP(x, y)
-
#define CONVERT_TO_TENSOR3D_STRUCT(name)
Definition: helpers.h:117
+
#define CONVERT_TO_TENSOR3D_STRUCT(name)
Definition: helpers.h:119
#define DATA_TYPE
-
Structure to hold 3D tensor information.
Definition: helpers.h:149
+
Structure to hold 3D tensor information.
Definition: helpers.h:151
#define POW2_OP(x, vec_size)
-
__global const uchar * tensor3D_offset(const Tensor3D *tensor, int x, int y, int z)
Get the pointer position of a Tensor3D.
Definition: helpers.h:313
-
DATA_TYPE calculate_avg_scale(const int pool_size, const int upper_bound_w, const int upper_bound_h, const int pad_x, const int pad_y, const int stride_x, const int stride_y)
+
DATA_TYPE calculate_avg_scale(const int pool_size_x, const int pool_size_y, const int upper_bound_w, const int upper_bound_h, const int pad_x, const int pad_y, const int stride_x, const int stride_y)
+
__global const uchar * tensor3D_offset(const Tensor3D *tensor, int x, int y, int z)
Get the pointer position of a Tensor3D.
Definition: helpers.h:315
#define VEC_DATA_TYPE(type, size)
Definition: fixed_point.h:93
-
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:151
+
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:153
#define SQRT_OP(x)
@@ -720,19 +833,179 @@ In case of average pooling the following information must be passed at compile t -

Definition at line 290 of file pooling_layer.cl.

+

Definition at line 292 of file pooling_layer.cl.

-

References calculate_avg_scale(), CONVERT_TO_TENSOR3D_STRUCT, DATA_TYPE, DIV_OP, POOL_OP, POW2_OP, Tensor3D::ptr, SQRT_OP, tensor3D_offset(), and VEC_DATA_TYPE.

-
293 {
294  // Get pixels pointer
295  Tensor3D input = CONVERT_TO_TENSOR3D_STRUCT(input);
296  Tensor3D output = CONVERT_TO_TENSOR3D_STRUCT(output);
297 
298  // Load data
300  data0 = vload3(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, 0, 0));
302  data1 = vload3(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, 1, 0));
303  VEC_DATA_TYPE(DATA_TYPE, 3)
304  data2 = vload3(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, 2, 0));
305 
306 #if defined(POOL_L2)
307  // Raise to power of 2 for L2 Pooling
308  data0 = POW2_OP(data0, 3);
309  data1 = POW2_OP(data1, 3);
310  data2 = POW2_OP(data2, 3);
311 #endif /* defined(POOL_L2) */
312 
313  // Perform calculations
314  data0 = POOL_OP(data0, data1);
315  data0 = POOL_OP(data0, data2);
316  DATA_TYPE res = POOL_OP(POOL_OP(data0.s0, data0.s1), data0.s2);
317 
318 #if defined(POOL_AVG) || defined(POOL_L2)
319  // Divide by pool region in case of average pooling
320  res = DIV_OP(res, calculate_avg_scale(3, MAX_WIDTH, MAX_HEIGHT, PAD_X, PAD_Y, STRIDE_X, STRIDE_Y));
321 #endif /* defined(POOL_AVG) || defined(POOL_L2) */
322 
323 #if defined(POOL_L2)
324  // Take square root of the result in L2 pooling
325  res = SQRT_OP(res);
326 #endif /* defined(POOL_L2) */
327 
328  // Store result
329  *(__global DATA_TYPE *)output.ptr = res;
330 }
#define DIV_OP(x, y)
+

References calculate_avg_scale(), CONVERT_TO_TENSOR3D_STRUCT, DATA_TYPE, DIV_OP, POOL_OP, POW2_OP, Tensor3D::ptr, SQRT_OP, tensor3D_offset(), and VEC_DATA_TYPE.

+
295 {
296  // Get pixels pointer
297  Tensor3D input = CONVERT_TO_TENSOR3D_STRUCT(input);
298  Tensor3D output = CONVERT_TO_TENSOR3D_STRUCT(output);
299 
300  // Load data
302  data0 = vload3(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, 0, 0));
304  data1 = vload3(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, 1, 0));
305  VEC_DATA_TYPE(DATA_TYPE, 3)
306  data2 = vload3(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, 2, 0));
307 
308 #if defined(POOL_L2)
309  // Raise to power of 2 for L2 Pooling
310  data0 = POW2_OP(data0, 3);
311  data1 = POW2_OP(data1, 3);
312  data2 = POW2_OP(data2, 3);
313 #endif /* defined(POOL_L2) */
314 
315  // Perform calculations
316  data0 = POOL_OP(data0, data1);
317  data0 = POOL_OP(data0, data2);
318  DATA_TYPE res = POOL_OP(POOL_OP(data0.s0, data0.s1), data0.s2);
319 
320 #if defined(POOL_AVG) || defined(POOL_L2)
321  // Divide by pool region in case of average pooling
322  res = DIV_OP(res, calculate_avg_scale(3, 3, MAX_WIDTH, MAX_HEIGHT, PAD_X, PAD_Y, STRIDE_X, STRIDE_Y));
323 #endif /* defined(POOL_AVG) || defined(POOL_L2) */
324 
325 #if defined(POOL_L2)
326  // Take square root of the result in L2 pooling
327  res = SQRT_OP(res);
328 #endif /* defined(POOL_L2) */
329 
330  // Store result
331  *(__global DATA_TYPE *)output.ptr = res;
332 }
#define DIV_OP(x, y)
#define POOL_OP(x, y)
-
#define CONVERT_TO_TENSOR3D_STRUCT(name)
Definition: helpers.h:117
+
#define CONVERT_TO_TENSOR3D_STRUCT(name)
Definition: helpers.h:119
#define DATA_TYPE
-
Structure to hold 3D tensor information.
Definition: helpers.h:149
+
Structure to hold 3D tensor information.
Definition: helpers.h:151
#define POW2_OP(x, vec_size)
-
__global const uchar * tensor3D_offset(const Tensor3D *tensor, int x, int y, int z)
Get the pointer position of a Tensor3D.
Definition: helpers.h:313
-
DATA_TYPE calculate_avg_scale(const int pool_size, const int upper_bound_w, const int upper_bound_h, const int pad_x, const int pad_y, const int stride_x, const int stride_y)
+
DATA_TYPE calculate_avg_scale(const int pool_size_x, const int pool_size_y, const int upper_bound_w, const int upper_bound_h, const int pad_x, const int pad_y, const int stride_x, const int stride_y)
+
__global const uchar * tensor3D_offset(const Tensor3D *tensor, int x, int y, int z)
Get the pointer position of a Tensor3D.
Definition: helpers.h:315
+
#define VEC_DATA_TYPE(type, size)
Definition: fixed_point.h:93
+
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:153
+
#define SQRT_OP(x)
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
__kernel void pooling_layer_MxN_nhwc (__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 * 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 
)
+
+ +

Performs a pooling function of pool size equal to N (NHWC)

+
Note
Datatype must be passed using -DDATA_TYPE e.g. -DDATA_TYPE=float. Supported data types are F16/F32
+
+-DFP16 must be passed at compile time if half float data type is used
+
+Pool sizes must be passed using -DPOOL_SIZE_X and -DPOOL_SIZE_Y e.g. -DPOOL_SIZE_X=13;
+
+Tensors width and height must be passed at compile time using -DMAX_WIDTH and -DMAX_HEIGHT
+
+Strides must be passed at compile time using -DSTRIDE_X and -DSTRIDE_Y which are the steps of the window along the x and y directions
+
+Pad values must be passed at compile time using -DPAD_X and -DPAD_Y which are the pooling paddings in x and y dimension
+
+In case of average pooling the following information must be passed at compile time: -DPOOL_AVG must be provided otherwise max pooling will be performed.
+
Parameters
+ + + + + + + + + + + + + + + + + +
[in]input_ptrPointer to the source image. Supported data types: F16/F32
[in]input_stride_xStride of the source image in X dimension (in bytes)
[in]input_step_xinput_stride_x * number of elements along X processed per workitem(in bytes)
[in]input_stride_yStride of the source image in Y dimension (in bytes)
[in]input_step_yinput_stride_y * number of elements along Y processed per workitem(in bytes)
[in]input_stride_zStride of the source tensor in Z dimension (in bytes)
[in]input_step_zinput_stride_z * number of elements along Z processed per workitem(in bytes)
[in]input_offset_first_element_in_bytesThe offset of the first element in the source image
[out]output_ptrPointer to the destination image. Supported data types: same as input_ptr
[in]output_stride_xStride of the destination image in X dimension (in bytes)
[in]output_step_xoutput_stride_x * number of elements along X processed per workitem(in bytes)
[in]output_stride_yStride of the destination image in Y dimension (in bytes)
[in]output_step_youtput_stride_y * number of elements along Y processed per workitem(in bytes)
[in]output_stride_zStride of the source tensor in Z dimension (in bytes)
[in]output_step_zoutput_stride_z * number of elements along Z processed per workitem(in bytes)
[in]output_offset_first_element_in_bytesThe offset of the first element in the destination image
+
+
+ +

Definition at line 565 of file pooling_layer.cl.

+ +

References calculate_avg_scale_nhwc(), CONVERT_TO_TENSOR3D_STRUCT, DIV_OP_NHWC, POOL_OP, Tensor3D::ptr, SQRT_OP, tensor3D_offset(), and VEC_DATA_TYPE.

+
568 {
569  // Get pixels pointer
570  Tensor3D input = CONVERT_TO_TENSOR3D_STRUCT(input);
571  Tensor3D output = CONVERT_TO_TENSOR3D_STRUCT(output);
572 
574  vdata = INITIAL_VALUE;
575  DATA_TYPE sdata = INITIAL_VALUE;
576 
577  const int idx_width = get_global_id(1) * STRIDE_X;
578  const int idx_height = get_global_id(2) * STRIDE_Y;
579 
580  for(int y = 0; y < POOL_SIZE_Y; ++y)
581  {
582  int y1 = select(y, PAD_Y - idx_height, y + idx_height < PAD_Y || y + idx_height > MAX_HEIGHT);
583  for(int x = 0; x < POOL_SIZE_X; ++x)
584  {
585  int x1 = select(x, PAD_X - idx_width - 1, x + idx_width < PAD_X || x + idx_width > MAX_WIDTH);
586  x1 = select(x1, PAD_X - idx_width - 1, y != y1);
587 
589  data0 = vload8(0, (__global DATA_TYPE *)tensor3D_offset(&input, 0, x1 - PAD_X, y1 - PAD_Y));
590 #if defined(POOL_L2)
591  // Raise to power of 2 for L2 Pooling
592  data0 *= data0;
593 #endif /* defined(POOL_L2) */
594  vdata = POOL_OP(vdata, data0);
595  }
596  }
597 
598 #if defined(POOL_AVG) || defined(POOL_L2)
599  // Divide by pool region in case of average pooling
600  vdata = DIV_OP_NHWC(vdata, calculate_avg_scale_nhwc(POOL_SIZE_X, POOL_SIZE_Y, MAX_WIDTH, MAX_HEIGHT, PAD_X, PAD_Y, STRIDE_X, STRIDE_Y));
601 #endif /* defined(POOL_AVG) || defined(POOL_L2) */
602 
603 #if defined(POOL_L2)
604  // Take square root of the result in L2 pooling
605  vdata = SQRT_OP(vdata);
606 #endif /* defined(POOL_L2) */
607 
608  // Store result
609  vstore8(vdata, 0, (__global DATA_TYPE *)output.ptr);
610 }
DATA_TYPE calculate_avg_scale_nhwc(const int pool_size_x, const int pool_size_y, int upper_bound_w, int upper_bound_h, const int pad_x, const int pad_y, const int stride_x, const int stride_y)
+
#define POOL_OP(x, y)
+
#define CONVERT_TO_TENSOR3D_STRUCT(name)
Definition: helpers.h:119
+
#define DATA_TYPE
+
Structure to hold 3D tensor information.
Definition: helpers.h:151
+
__global const uchar * tensor3D_offset(const Tensor3D *tensor, int x, int y, int z)
Get the pointer position of a Tensor3D.
Definition: helpers.h:315
#define VEC_DATA_TYPE(type, size)
Definition: fixed_point.h:93
-
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:151
+
#define DIV_OP_NHWC(x, y)
+
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:153
#define SQRT_OP(x)
@@ -743,7 +1016,7 @@ In case of average pooling the following information must be passed at compile t