Apollo  6.0
Open source self driving car software
rt_common.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 The Apollo Authors. All Rights Reserved.
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 
17 #pragma once
18 
19 #include <map>
20 #include <string>
21 #include <vector>
22 
23 #include "NvCaffeParser.h"
24 #include "NvInfer.h"
25 #include <cudnn.h>
26 
27 #include "modules/perception/proto/rt.pb.h"
28 
29 #include "cyber/common/log.h"
31 
32 namespace apollo {
33 namespace perception {
34 namespace inference {
35 
36 typedef std::map<std::string, std::vector<nvinfer1::Weights>> WeightMap;
37 typedef std::map<std::string, nvinfer1::ITensor *> TensorMap;
38 typedef std::map<std::string, nvinfer1::DimsCHW> TensorDimsMap;
39 
40 nvinfer1::DimsCHW ReshapeDims(const nvinfer1::DimsCHW &dims,
41  const nvinfer1::DimsCHW &inputDims);
42 void ParseNetParam(const NetParameter &net_param,
43  TensorDimsMap *tensor_dims_map,
44  std::map<std::string, std::string> *tensor_modify_map,
45  std::vector<LayerParameter> *order);
46 
47 bool modify_pool_param(PoolingParameter *pool_param);
48 
49 struct ConvParam {
50  int kernel_h;
51  int kernel_w;
52  int padding_h;
53  int padding_w;
54  int stride_h;
55  int stride_w;
56  int group;
57  int dilation;
58 };
59 
60 bool ParserConvParam(const ConvolutionParameter &conv, ConvParam *param);
61 
62 inline nvinfer1::DimsCHW getCHW(const nvinfer1::Dims &d) {
63  assert(d.nbDims >= 3);
64  return nvinfer1::DimsCHW(d.d[d.nbDims - 3], d.d[d.nbDims - 2],
65  d.d[d.nbDims - 1]);
66 }
67 
68 } // namespace inference
69 } // namespace perception
70 } // namespace apollo
nvinfer1::DimsCHW ReshapeDims(const nvinfer1::DimsCHW &dims, const nvinfer1::DimsCHW &inputDims)
int padding_w
Definition: rt_common.h:53
std::map< std::string, nvinfer1::DimsCHW > TensorDimsMap
Definition: rt_common.h:38
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
std::map< std::string, std::vector< nvinfer1::Weights > > WeightMap
Definition: rt_common.h:36
std::map< std::string, nvinfer1::ITensor * > TensorMap
Definition: rt_common.h:37
int group
Definition: rt_common.h:56
int kernel_w
Definition: rt_common.h:51
int dilation
Definition: rt_common.h:57
bool modify_pool_param(PoolingParameter *pool_param)
void ParseNetParam(const NetParameter &net_param, TensorDimsMap *tensor_dims_map, std::map< std::string, std::string > *tensor_modify_map, std::vector< LayerParameter > *order)
int stride_h
Definition: rt_common.h:54
int kernel_h
Definition: rt_common.h:50
nvinfer1::DimsCHW getCHW(const nvinfer1::Dims &d)
Definition: rt_common.h:62
int stride_w
Definition: rt_common.h:55
bool ParserConvParam(const ConvolutionParameter &conv, ConvParam *param)
int padding_h
Definition: rt_common.h:52