clDNN
pooling.hpp
1 /*
2 // Copyright (c) 2016 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 
18 #pragma once
19 #include "../C/pooling.h"
20 #include "primitive.hpp"
21 
22 namespace cldnn
23 {
30 
32 enum class pooling_mode : int32_t
33 {
40 };
41 
44 struct pooling : public primitive_base<pooling, CLDNN_PRIMITIVE_DESC(pooling)>
45 {
46  CLDNN_DECLATE_PRIMITIVE(pooling)
47 
48 
49  pooling(
55  const primitive_id& id,
56  const primitive_id& input,
58  const tensor& size,
59  const tensor& stride,
60  const tensor& input_offset = { 0,0,0,0 },
61  const padding& output_padding = padding()
62  )
64  , mode(static_cast<pooling_mode>(mode))
66  , stride(stride)
67  , size(size)
68  , with_output_size(false)
69  {}
70 
79  const primitive_id& id,
80  const primitive_id& input,
82  const tensor& size,
83  const tensor& stride,
84  const tensor& input_offset,
86  const padding& output_padding = padding()
87  )
89  , mode(static_cast<pooling_mode>(mode))
91  , stride(stride)
92  , size(size)
93  , with_output_size(true)
95  {}
96 
98  pooling(const dto* dto)
100  , mode(static_cast<pooling_mode>(dto->mode))
102  , stride(dto->stride)
103  , size(dto->size)
106  {}
107 
117  const primitive_id& id,
118  const primitive_id& input,
121  const tensor& size,
122  const tensor& stride,
123  const tensor& input_offset = { 0,0,0,0 },
124  const padding& output_padding = padding()
125  )
126  {
128  }
129 
142 
143 protected:
144  void update_dto(dto& dto) const override
145  {
146  dto.mode = static_cast<int32_t>(mode);
148  dto.stride = stride;
149  dto.size = size;
152  }
153 };
157 }
uint32_t with_output_size
Indicates that the primitive has user-defined output size (non-zero value).
Definition: pooling.h:56
Average-pooling method - values.
pooling(const primitive_id &id, const primitive_id &input, pooling_mode mode, const tensor &size, const tensor &stride, const tensor &input_offset, tensor output_size, const padding &output_padding=padding())
Constructs pooling primitive (computes input paddings to match output size).
Definition: pooling.hpp:78
Average-pooling method without values which are outside of the input.
Definition: pooling.h:41
Maximum-pooling method.
Definition: pooling.h:37
Represents data padding information.
Definition: layout.hpp:125
Maximum-pooling method.
pooling(const dto *dto)
Constructs a copy from C API cldnn_pooling_desc.
Definition: pooling.hpp:98
tensor input_offset
Defines a shift, relative to (0,0) position of the input buffer, where (0,0) point of the pooling win...
Definition: pooling.hpp:133
bool with_output_size
Indicates that the primitive has user-defined output size (non-zero value).
Definition: pooling.hpp:139
N-dimensional vector. Mostly used to represent memory size.
Definition: tensor.hpp:256
pooling_mode
Select method for the pooling layer.
Definition: pooling.hpp:32
tensor size
Pooling kernel size.
Definition: pooling.hpp:137
cldnn_tensor input_offset
Defines a shift, relative to (0,0) position of the input buffer, where (0,0) point of the pooling win...
Definition: pooling.h:50
cldnn_tensor output_size
User-defined output data size of the primitive (w/o padding).
Definition: pooling.h:58
Performs "pooling" operation which is a form of non-linear down-sampling.
Definition: pooling.hpp:44
Average-pooling method.
Definition: pooling.h:39
cldnn_tensor size
Pooling kernel size.
Definition: pooling.h:54
const primitive_id id
Primitive&#39;s id.
Definition: primitive.hpp:143
int32_t mode
Pooling method. See cldnn_pooling_mode.
Definition: pooling.h:48
Performs "pooling" operation which is a form of non-linear down-sampling.
Definition: pooling.h:46
static pooling create_with_output_size(const primitive_id &id, const primitive_id &input, tensor output_size, pooling_mode mode, const tensor &size, const tensor &stride, const tensor &input_offset={ 0, 0, 0, 0 }, const padding &output_padding=padding())
Constructs pooling primitive (computes input paddings to match output size).
Definition: pooling.hpp:116
pooling(const primitive_id &id, const primitive_id &input, pooling_mode mode, const tensor &size, const tensor &stride, const tensor &input_offset={ 0, 0, 0, 0 }, const padding &output_padding=padding())
Constructs pooling primitive.
Definition: pooling.hpp:54
std::string primitive_id
Unique id of a primitive within a topology.
Definition: primitive.hpp:42
tensor stride
Defines shift in input buffer between adjacent calculations of output values.
Definition: pooling.hpp:135
fixed_size_vector_ref input
List of ids of input primitives.
Definition: primitive.hpp:146
cldnn_tensor stride
Defines shift in input buffer between adjacent calculations of output values.
Definition: pooling.h:52
base class for all primitives implementations.
Definition: primitive.hpp:190
pooling_mode mode
Pooling mode.
Definition: pooling.hpp:131
padding output_padding
Requested output padding.
Definition: primitive.hpp:149
tensor output_size
User-defined output data size of the primitive (w/o padding).
Definition: pooling.hpp:141
Average-pooling method without values which are outside of the input.