clDNN
roi_pooling.hpp
1 /*
2 // Copyright (c) 2017 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 "pooling.hpp"
20 #include "../C/roi_pooling.h"
21 #include "primitive.hpp"
22 
23 
24 namespace cldnn
25 {
32 
33 struct roi_pooling : public primitive_base<roi_pooling, CLDNN_PRIMITIVE_DESC(roi_pooling)>
34 {
35  CLDNN_DECLATE_PRIMITIVE(roi_pooling)
36 
38  const primitive_id& id,
39  const primitive_id& input_data,
40  const primitive_id& input_rois,
41  pooling_mode mode,
42  int pooled_width,
43  int pooled_height,
44  float spatial_scale,
45  int group_sz = 0,
46  const padding& output_padding = padding()
47  )
48  : primitive_base(id, {input_data, input_rois}, output_padding)
49  , mode(mode)
50  , pooled_width(pooled_width)
51  , pooled_height(pooled_height)
52  , spatial_scale(spatial_scale)
53  , group_sz(group_sz)
54  {}
55 
56  roi_pooling(const dto* dto)
58  , mode(static_cast<pooling_mode>(dto->mode))
59  , pooled_width(dto->pooled_width)
60  , pooled_height(dto->pooled_height)
61  , spatial_scale(dto->spatial_scale)
62  , group_sz(dto->group_sz)
63  {}
64 
65  pooling_mode mode;
66  int pooled_width;
67  int pooled_height;
68  float spatial_scale;
69  int group_sz;
70 
71 protected:
72  void update_dto(dto& dto) const override
73  {
74  dto.mode = static_cast<int32_t>(mode);
75  dto.pooled_width = pooled_width;
76  dto.pooled_height = pooled_height;
77  dto.spatial_scale = spatial_scale;
78  dto.group_sz = group_sz;
79  }
80 };
81 
85 }
int pooled_height
Output height.
Definition: roi_pooling.h:41
Represents data padding information.
Definition: layout.hpp:125
float spatial_scale
Ratio of the coordinates used in RoIs to the width (and height) of the input data.
Definition: roi_pooling.h:43
int group_sz
Group size as defined by PSRoIPooling when > 0, else if 0 means regular RoIPooling.
Definition: roi_pooling.h:46
int32_t mode
Pooling method. See cldnn_pooling_mode.
Definition: roi_pooling.h:36
pooling_mode
Select method for the pooling layer.
Definition: pooling.hpp:32
std::string primitive_id
Unique id of a primitive within a topology.
Definition: primitive.hpp:42
int pooled_width
Output width.
Definition: roi_pooling.h:39
base class for all primitives implementations.
Definition: primitive.hpp:190
padding output_padding
Requested output padding.
Definition: primitive.hpp:149