2 #include <dlprim/tensor.hpp> 3 #include <dlprim/context.hpp> 12 int padded_size = in_size + pad*2;
13 DLPRIM_CHECK(padded_size >= kernel);
14 int offset = ceil_mode ? (stride-1) : 0;
15 int size = (padded_size - kernel + offset) / stride + 1;
16 if((size - 1) * stride >= in_size + pad) {
30 virtual size_t workspace() = 0;
44 int kernel[2],
int pad[2],
int stride[2],
55 int kernel[2],
int pad[2],
int stride[2],
bool count_include_pad=
false,
73 virtual size_t workspace() = 0;
92 static std::unique_ptr<MaxPooling2DBackward> create(
94 int kernel[2],
int pad[2],
int stride[2],
98 static std::unique_ptr<MaxPooling2DBackward> create_global(
125 static std::unique_ptr<AvgPooling2DBackward> create(
127 int kernel[2],
int pad[2],
int stride[2],
bool count_include_pad=
false,
131 static std::unique_ptr<AvgPooling2DBackward> create_global(
Tensor shape.
Definition: shape.hpp:18
Backward computation for max pooling.
Definition: pool.hpp:87
2d pooling
Definition: pool.hpp:26
This is main object that represent the pair of OpenCL platform and device all other objects use it...
Definition: context.hpp:302
static std::unique_ptr< Pooling2DForward > create_avg_pooling(Context &ctx, int kernel[2], int pad[2], int stride[2], bool count_include_pad=false, DataType dt=float_data)
Create max pooling for kernel, pad, stride.
DataType
type definition
Definition: definitions.hpp:70
static std::unique_ptr< Pooling2DForward > create_global_avg_pooling(Context &ctx, Shape const &in_shape, DataType dt=float_data)
Avergage global pooling.
virtual void enqueue(Tensor &, Tensor &dX, Tensor &dY, float factor, ExecutionContext const &e)
for Avg pooling we don't need X so you can call directrly enqueue(dX,dY,factor,e) ...
Definition: pool.hpp:112
Mane namespace.
Definition: context.hpp:9
Central Data Contrainer - Tensor.
Definition: tensor.hpp:99
Backward pooling computation.
Definition: pool.hpp:70
static std::unique_ptr< Pooling2DForward > create_max_pooling(Context &ctx, int kernel[2], int pad[2], int stride[2], DataType dt=float_data)
Create max pooling for kernel, pad, stride.
static std::unique_ptr< Pooling2DForward > create_global_max_pooling(Context &ctx, Shape const &in_shape, DataType dt=float_data)
Max global pooling.
virtual void enqueue(Tensor &X, Tensor &Y, ExecutionContext const &e)=0
when used with kernel based pooling (not global) X and Y dimensions should match at batch and channel...
int calc_pooling_output_size(int in_size, int kernel, int pad, int stride, bool ceil_mode)
Compute output size of the tensor after pooling in specific dimentions.
Definition: pool.hpp:10
This class is used to pass cl::Events that the kernel should wait for and/or signal event completion...
Definition: context.hpp:121