Apollo  6.0
Open source self driving car software
roipooling_layer.h
Go to the documentation of this file.
1 /******************************************************************************
2 COPYRIGHT
3 
4 All contributions by the University of California:
5 Copyright (c) 2014-2017 The Regents of the University of California (Regents)
6 All rights reserved.
7 
8 All other contributions:
9 Copyright (c) 2014-2017, the respective contributors
10 All rights reserved.
11 
12 Caffe uses a shared copyright model: each contributor holds copyright over
13 their contributions to Caffe. The project versioning records all such
14 contribution and copyright details. If a contributor wants to further mark
15 their specific copyright on a particular contribution, they should indicate
16 their copyright solely in the commit message of the change when it is
17 committed.
18 
19 LICENSE
20 
21 Redistribution and use in source and binary forms, with or without
22 modification, are permitted provided that the following conditions are met:
23 
24 1. Redistributions of source code must retain the above copyright notice, this
25  list of conditions and the following disclaimer.
26 2. Redistributions in binary form must reproduce the above copyright notice,
27  this list of conditions and the following disclaimer in the documentation
28  and/or other materials provided with the distribution.
29 
30 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
31 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
34 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 
41 CONTRIBUTION AGREEMENT
42 
43 By contributing to the BVLC/caffe repository through pull-request, comment,
44 or otherwise, the contributor releases their content to the
45 license and copyright terms herein.
46  *****************************************************************************/
47 
48 /******************************************************************************
49  * Copyright 2018 The Apollo Authors. All Rights Reserved.
50  *
51  * Licensed under the Apache License, Version 2.0 (the "License");
52  * you may not use this file except in compliance with the License.
53  * You may obtain a copy of the License at
54  *
55  * http://www.apache.org/licenses/LICENSE-2.0
56  *
57  * Unless required by applicable law or agreed to in writing, software
58  * distributed under the License is distributed on an "AS IS" BASIS,
59  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
60  * See the License for the specific language governing permissions and
61  * limitations under the License.
62  *****************************************************************************/
63 
64 #pragma once
65 
66 #include <limits>
67 #include <memory>
68 #include <vector>
69 
71 
72 namespace apollo {
73 namespace perception {
74 namespace inference {
75 
76 template <typename Dtype>
77 class ROIPoolingLayer : public Layer<Dtype> {
78  public:
79  ROIPoolingLayer(int pooled_h, int pooled_w, bool use_floor,
80  float spatial_scale, int channels, int max_objs = 1000)
81  : channels_(0),
82  height_(0),
83  width_(0),
84  pooled_height_(pooled_h),
85  pooled_width_(pooled_w),
86  use_floor_(use_floor),
87  float_max_(std::numeric_limits<float>::max()),
88  spatial_scale_(spatial_scale) {
89  max_idx_.Reshape(max_objs, channels, pooled_height_, pooled_width_);
90  }
91  void ForwardGPU(const std::vector<std::shared_ptr<base::Blob<Dtype>>> &bottom,
92  const std::vector<std::shared_ptr<base::Blob<Dtype>>> &top);
93  void ForwardCPU(const std::vector<std::shared_ptr<base::Blob<Dtype>>> &bottom,
94  const std::vector<std::shared_ptr<base::Blob<Dtype>>> &top);
95 
96  private:
97  base::Blob<int> max_idx_;
98  int channels_;
99  int height_;
100  int width_;
101  int pooled_height_;
102  int pooled_width_;
103  bool use_floor_;
104  const float float_max_;
105  float spatial_scale_;
106 };
107 
108 } // namespace inference
109 } // namespace perception
110 } // namespace apollo
Definition: roipooling_layer.h:77
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
void ForwardGPU(const std::vector< std::shared_ptr< base::Blob< Dtype >>> &bottom, const std::vector< std::shared_ptr< base::Blob< Dtype >>> &top)
Definition: future.h:29
void ForwardCPU(const std::vector< std::shared_ptr< base::Blob< Dtype >>> &bottom, const std::vector< std::shared_ptr< base::Blob< Dtype >>> &top)
A wrapper around SyncedMemory holders serving as the basic computational unit for images...
Definition: blob.h:88
void Reshape(const int num, const int channels, const int height, const int width)
Deprecated; use Reshape(const std::vector<int>& shape).
ROIPoolingLayer(int pooled_h, int pooled_w, bool use_floor, float spatial_scale, int channels, int max_objs=1000)
Definition: roipooling_layer.h:79