Apollo 11.0
自动驾驶开放平台
rt_common.h
浏览该文件的文档.
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 <NvInferVersion.h>
20
21#ifdef NV_TENSORRT_MAJOR
22 #if NV_TENSORRT_MAJOR == 8
24 #endif
25#endif
26
27#include <map>
28#include <string>
29#include <vector>
30
31#include "NvCaffeParser.h"
32#include "NvInfer.h"
33#if GPU_PLATFORM == NVIDIA
34 #include <cudnn.h>
35#elif GPU_PLATFORM == AMD
36 #include <miopen/miopen.h>
37 #define CUDNN_DATA_FLOAT miopenFloat
38 #define CUDNN_SOFTMAX_ACCURATE MIOPEN_SOFTMAX_ACCURATE
39 #define CUDNN_SOFTMAX_MODE_CHANNEL MIOPEN_SOFTMAX_MODE_CHANNEL
40 #define cudnnCreate miopenCreate
41 #define cudnnCreateTensorDescriptor miopenCreateTensorDescriptor
42 #define cudnnDestroy miopenDestroy
43 #define cudnnDestroyTensorDescriptor miopenDestroyTensorDescriptor
44 #define cudnnHandle_t miopenHandle_t
45 #define cudnnSetStream miopenSetStream
46 #define cudnnSetTensor4dDescriptorEx miopenSet4dTensorDescriptorEx
47 #define cudnnTensorDescriptor_t miopenTensorDescriptor_t
48#endif
49
50#include "modules/perception/common/proto/rt.pb.h"
51
52#include "cyber/common/log.h"
54
55namespace apollo {
56namespace perception {
57namespace inference {
58
59typedef std::map<std::string, std::vector<nvinfer1::Weights>> WeightMap;
60typedef std::map<std::string, nvinfer1::ITensor *> TensorMap;
61typedef std::map<std::string, nvinfer1::DimsCHW> TensorDimsMap;
62
64 const nvinfer1::DimsCHW &inputDims);
65void ParseNetParam(const NetParameter &net_param,
66 TensorDimsMap *tensor_dims_map,
67 std::map<std::string, std::string> *tensor_modify_map,
68 std::vector<LayerParameter> *order);
69
70bool modify_pool_param(PoolingParameter *pool_param);
71
72struct ConvParam {
73 int kernel_h;
74 int kernel_w;
75 int padding_h;
76 int padding_w;
77 int stride_h;
78 int stride_w;
79 int group;
80 int dilation;
81};
82
83bool ParserConvParam(const ConvolutionParameter &conv, ConvParam *param);
84
85inline nvinfer1::DimsCHW getCHW(const nvinfer1::Dims &d) {
86 assert(d.nbDims >= 3);
87 return nvinfer1::DimsCHW(d.d[d.nbDims - 3], d.d[d.nbDims - 2],
88 d.d[d.nbDims - 1]);
89}
90
91} // namespace inference
92} // namespace perception
93} // namespace apollo
bool ParserConvParam(const ConvolutionParameter &conv, ConvParam *param)
Definition mi_common.cc:51
std::map< std::string, Tensor > TensorMap
Definition mi_net.h:64
void ParseNetParam(const NetParameter &net_param, TensorDimsMap *tensor_dims_map, std::map< std::string, std::string > *tensor_modify_map, std::vector< LayerParameter > *order)
Definition mi_common.cc:27
nvinfer1::DimsCHW ReshapeDims(const nvinfer1::DimsCHW &dims, const nvinfer1::DimsCHW &inputDims)
Definition rt_common.cc:34
std::map< std::string, TensorDims > TensorDimsMap
Definition mi_common.h:33
bool modify_pool_param(PoolingParameter *pool_param)
Definition mi_common.cc:101
std::map< std::string, std::vector< Weights > > WeightMap
Definition mi_net.h:63
nvinfer1::DimsCHW getCHW(const nvinfer1::Dims &d)
Definition rt_common.h:85
class register implement
Definition arena_queue.h:37