Apollo 10.0
自动驾驶开放平台
apollo::perception::inference 命名空间参考

struct  AccuracyParameter
 
struct  AnchorBox
 
struct  AnnotatedDataParameter
 
struct  AnnotatedDatum
 
struct  Annotation
 
struct  AnnotationGroup
 
struct  ArgMaxParameter
 
struct  BatchNormParameter
 
struct  BatchSampler
 
class  BatchStream
 
struct  BBox3D
 
struct  BBoxRegParameter
 
struct  BiasParameter
 
struct  BlobProto
 
struct  BlobShape
 
struct  ConcatParameter
 
struct  ContrastiveLossParameter
 
struct  ConvolutionParameter
 
struct  ConvParam
 
struct  CropParameter
 
class  CudaUtil
 
struct  DataParameter
 
struct  DatasetParameter
 
struct  Datum
 
struct  DetectionEvaluateParameter
 
struct  DetectionOutputParameter
 
struct  DetectionOutputSSDParameter
 
struct  dfmb_psroi_align_op
 
struct  DFMBPSROIAlignParameter
 
class  DFMBPSROIAlignPlugin
 
struct  DimensionStatistics
 
struct  DistortionParameter
 
struct  DropoutParameter
 
struct  DummyDataParameter
 
struct  EltwiseParameter
 
struct  ELUParameter
 
struct  EmbedParameter
 
struct  EmitConstraint
 
struct  ExpansionParameter
 
struct  ExpParameter
 
struct  FillerParameter
 
struct  FlattenParameter
 Message that stores parameters used by FlattenLayer 更多...
 
struct  GenAnchorParameter
 
class  GPUL2Norm
 
struct  HDF5DataParameter
 
struct  HDF5OutputParameter
 
struct  HingeLossParameter
 
struct  ImageDataParameter
 
class  Inference
 
struct  InfogainLossParameter
 
struct  InnerProductParameter
 
struct  InputParameter
 
struct  LabelMap
 
struct  LabelMapItem
 
class  Layer
 
struct  LayerParameter
 
struct  LogParameter
 
struct  LossParameter
 
struct  LRNParameter
 
struct  MemoryDataParameter
 
class  MINet
 
struct  MultiBoxLossParameter
 
struct  MVNParameter
 
struct  NetParameter
 
struct  NetState
 
struct  NetStateRule
 
struct  NMSSSDParameter
 
struct  NoiseParameter
 
struct  NonMaximumSuppressionParameter
 
struct  NormalizedBBox
 
struct  NormalizeParameter
 
class  ObstacleDetector
 
struct  PaddingParameter
 
class  PaddleNet
 
struct  ParameterParameter
 
struct  ParamSpec
 
struct  PermuteParameter
 
struct  PoolingParameter
 
struct  PowerParameter
 
struct  PReLUParameter
 
struct  PriorBoxParameter
 
struct  PythonParameter
 
struct  rcnn_proposal_op
 
class  RCNNProposalPlugin
 
struct  RecurrentParameter
 
struct  ReductionParameter
 
struct  RegionOutputParameter
 
struct  RegionParameter
 
struct  RegionProposalParameter
 
struct  ReLUParameter
 
struct  ReorgParameter
 
struct  RepeatedList
 
struct  ReshapeParameter
 
struct  ResizeParameter
 
class  ROIPoolingLayer
 
struct  ROIPoolingParameter
 
struct  rpn_proposal_ssd_op
 
class  RPNProposalSSDPlugin
 
class  RTNet
 
struct  SaltPepperParameter
 
struct  SampleConstraint
 
struct  Sampler
 
struct  SaveOutputParameter
 
struct  ScaleParameter
 
struct  SigmoidParameter
 
class  SingleBatchInference
 
struct  SliceParameter
 
struct  SoftmaxParameter
 
struct  SPPParameter
 
struct  TanHParameter
 
struct  ThresholdParameter
 
struct  TileParameter
 
class  TorchNet
 
struct  TransformationParameter
 
struct  V0LayerParameter
 
struct  V1LayerParameter
 
struct  VideoDataParameter
 
struct  Weights
 
struct  WindowDataParameter
 
struct  YoloAnchorsParameter
 
struct  YoloDumpParameter
 
struct  YoloLossParameter
 
struct  YoloTargetParameter
 

类型定义

typedef std::map< std::string, base::BlobPtr< float > > BlobMap
 
typedef std::vector< int > TensorDims
 
typedef std::map< std::string, TensorDimsTensorDimsMap
 
typedef migraphx::instruction_ref Tensor
 
typedef migraphx::shape Shape
 
typedef migraphx::operation Operation
 
typedef std::map< std::string, std::vector< Weights > > WeightMap
 
typedef std::map< std::string, TensorTensorMap
 
typedef std::map< std::string, std::string > TensorModifyMap
 
using BlobPtr = std::shared_ptr< apollo::perception::base::Blob< float > >
 

枚举

enum  Phase { TRAIN = 0 , TEST = 1 }
 

函数

InferenceCreateInferenceByName (const std::string &frame_work, const std::string &proto_file, const std::string &weight_file, const std::vector< std::string > &outputs, const std::vector< std::string > &inputs, const std::string &model_root)
 
InferenceCreateInferenceByName (const common::Framework &frame_work, const std::string &proto_file, const std::string &weight_file, const std::vector< std::string > &outputs, const std::vector< std::string > &inputs, const std::string &model_root)
 
void ParseNetParam (const NetParameter &net_param, TensorDimsMap *tensor_dims_map, std::map< std::string, std::string > *tensor_modify_map, std::vector< LayerParameter > *order)
 
bool ParserConvParam (const ConvolutionParameter &conv, ConvParam *param)
 
bool modify_pool_param (PoolingParameter *pool_param)
 
Dims GetDims (std::vector< size_t > lens, bool remove_batch=true)
 
bool ReadProtoFromTextFile (const std::string &filename, google::protobuf::Message *proto)
 
bool ReadProtoFromBinaryFile (const std::string &filename, google::protobuf::Message *proto)
 
bool loadNetParams (const std::string &param_file, NetParameter *param)
 
std::string locateFile (const std::string &network, const std::string &input)
 
void bbox_transform_inv_cuda (int block_size, int thread_size, int shared_mem, cudaStream_t stream, const int nthreads, const float *boxes, const float *deltas, const int num_box, const int num_channel, float *out_boxes)
 
void clip_boxes_cuda (int block_size, int thread_size, int shared_mem, cudaStream_t stream, const int nthreads, float *boxes, const float height, const float width)
 
void filter_boxes_cuda (int block_size, int thread_size, int shared_mem, cudaStream_t stream, const int nthreads, const float *boxes, const float *scores, const float *all_probs, const int num_box, const int num_channel, const int num_class, const int num_prob, const int filter_channel, const int filter_class, const int min_size_mode, const float min_size_h, const float min_size_w, const float threshold_score, float *filtered_boxes, float *filtered_scores, float *filtered_all_probs, int *filtered_count)
 
void keep_topN_boxes_cuda (int block_size, int thread_size, int shared_mem, cudaStream_t stream, const int nthreads, const float *boxes, const float *scores, const float *all_probs, const int *indexes, const int *count, const bool keep_score, const int num_box, const int num_prob, const int topN, float *out_boxes, float *out_scores, float *out_all_probs)
 
void repeatedly_add_cuda (int block_size, int thread_size, int shared_mem, cudaStream_t stream, const int nthreads, const float *in_data, float *out_data, const float *add_vec, int add_vec_size)
 
void repeatedly_mul_cuda (int block_size, int thread_size, int shared_mem, cudaStream_t stream, const int nthreads, const float *in_data, float *out_data, const float *mul_vec, int mul_vec_size)
 
void slice2d_cuda (int block_size, int thread_size, int shared_mem, cudaStream_t stream, const int nthreads, const float *in_data, float *out_data, const int *slice_axises, int slice_axis_num, int input_axis_size)
 
void NmsForward (bool rpn_proposal_output_score, int host_filter_count, int num_box_corners, float nms_overlap_threshold, int num_candidate, int top_n, int batch_id, int num_prob, float *dev_sorted_box_for_nms, float *scores, float *all_probs, float *out_boxes, int *acc_box_num, cudaStream_t stream)
 GPU Non-Maximum Suppresion for network output
 
std::vector< std::string > GetBlobNames (const google::protobuf::RepeatedPtrField< common::ModelBlob > &model_blobs)
 
void AddShape (std::map< std::string, std::vector< int > > *shape_map, const google::protobuf::RepeatedPtrField< common::ModelBlob > &model_blobs)
 
nvinfer1::DimsCHW ReshapeDims (const nvinfer1::DimsCHW &dims, const nvinfer1::DimsCHW &inputDims)
 
nvinfer1::DimsCHW getCHW (const nvinfer1::Dims &d)
 
std::string get_dtype (const base::Blob< double > &blob)
 
std::string get_dtype (const base::Blob< float > &blob)
 
size_t BinaryReadString (FILE *fp, char *name)
 
size_t BinaryWriteString (FILE *fp, const std::string &str)
 
template<typename Dtype >
std::shared_ptr< base::Blob< Dtype > > BinaryReadBlob (FILE *fp)
 
template<typename Dtype >
void BinaryWriteBlob (FILE *fp, const base::Blob< Dtype > &blob)
 
template std::shared_ptr< base::Blob< float > > BinaryReadBlob (FILE *fp)
 
template void BinaryWriteBlob (FILE *fp, const base::Blob< float > &blob)
 
template void BinaryWriteBlob (FILE *fp, const base::Blob< double > &blob)
 
template<typename Dtype >
std::map< std::string, std::shared_ptr< base::Blob< Dtype > > > BinaryReadFile (const char *file_path)
 
template<typename Btype >
bool BinaryWriteFile (const char *file_path, const std::map< std::string, Btype > &data_dict)
 
template std::map< std::string, std::shared_ptr< base::Blob< float > > > BinaryReadFile (const char *file_path)
 
template bool BinaryWriteFile (const char *file_path, const std::map< std::string, std::shared_ptr< base::Blob< float > > > &data_dict)
 
template bool BinaryWriteFile (const char *file_path, const std::map< std::string, std::shared_ptr< base::Blob< double > > > &data_dict)
 
template bool BinaryWriteFile (const char *file_path, const std::map< std::string, base::Blob< float > * > &data_dict)
 
template bool BinaryWriteFile (const char *file_path, const std::map< std::string, base::Blob< double > * > &data_dict)
 
void GPUGemmFloat (const CBLAS_TRANSPOSE TransA, const CBLAS_TRANSPOSE TransB, const int M, const int N, const int K, const float alpha, const float *A, const float *B, const float beta, float *C)
 
void GPUMultiFloat (const int n, const float *a, const float *b, float *result)
 
void GPUMSetFloat (const int n, const float alpha, float *result)
 
bool ResizeGPU (const base::Image8U &src, std::shared_ptr< apollo::perception::base::Blob< float > > dst, int stepwidth, int start_axis)
 
bool ResizeGPU (const apollo::perception::base::Blob< uint8_t > &src_gpu, std::shared_ptr< apollo::perception::base::Blob< float > > dst, int stepwidth, int start_axis, int mean_b, int mean_g, int mean_r, bool channel_axis, float scale)
 
bool ResizeGPU (const base::Image8U &src, std::shared_ptr< apollo::perception::base::Blob< float > > dst, int stepwidth, int start_axis, float mean_b, float mean_g, float mean_r, bool channel_axis, float scale)
 
bool ResizeGPU (const base::Image8U &src, std::shared_ptr< apollo::perception::base::Blob< float > > dst, int stepwidth, int start_axis, float mean_b, float mean_g, float mean_r, bool channel_axis, float std_b, float std_g, float std_r)
 
bool ImageZeroPadding (const base::Image8U &src, base::Image8U *dst, int stepwidth, int left_pad, int right_pad, int top_pad, int bottom_pad, int value, cudaStream_t stream, bool same_order)
 
std::shared_ptr< float > load_binary_data (const std::string &filename)
 
bool write_result (const std::string &out_path, const std::vector< float > &results)
 
template<typename T >
void load_data (const std::string &filename, std::vector< T > *outputs)
 
bool write_result (const std::string &out_path, const std::map< std::string, std::vector< float > > &results)
 

变量

const std::map< std::string, std::string > active_map
 
const std::map< EltwiseParameter::EltwiseOp, std::string > eltwise_map
 
constexpr uint64_t MemoryPoolInitSizeMb = 1000
 
const std::vector< std::string > _gpu_checklist
 
constexpr size_t kMaxStrLen = 64
 
constexpr int kMinDim = 1
 
constexpr int kMaxDim = std::numeric_limits<int>::max()
 

类型定义说明

◆ BlobMap

typedef std::map<std::string, base::BlobPtr<float> > apollo::perception::inference::BlobMap

在文件 inference.h39 行定义.

◆ BlobPtr

在文件 onnx_single_batch_infer.h43 行定义.

◆ Operation

typedef migraphx::operation apollo::perception::inference::Operation

在文件 mi_net.h62 行定义.

◆ Shape

typedef migraphx::shape apollo::perception::inference::Shape

在文件 mi_net.h61 行定义.

◆ Tensor

typedef migraphx::instruction_ref apollo::perception::inference::Tensor

在文件 mi_net.h60 行定义.

◆ TensorDims

在文件 mi_common.h32 行定义.

◆ TensorDimsMap

在文件 mi_common.h33 行定义.

◆ TensorMap

typedef std::map< std::string, nvinfer1::ITensor * > apollo::perception::inference::TensorMap

在文件 mi_net.h64 行定义.

◆ TensorModifyMap

typedef std::map< std::string, std::string > apollo::perception::inference::TensorModifyMap

在文件 mi_net.h66 行定义.

◆ WeightMap

typedef std::map< std::string, std::vector< nvinfer1::Weights > > apollo::perception::inference::WeightMap

在文件 mi_net.h63 行定义.

枚举类型说明

◆ Phase

枚举值
TRAIN 
TEST 

在文件 rt.proto223 行定义.

函数说明

◆ AddShape()

void apollo::perception::inference::AddShape ( std::map< std::string, std::vector< int > > *  shape_map,
const google::protobuf::RepeatedPtrField< common::ModelBlob > &  model_blobs 
)

在文件 model_util.cc32 行定义.

34 {
35 for (const auto& blob : model_blobs) {
36 std::vector<int> shape(blob.shape().begin(), blob.shape().end());
37 shape_map->insert(std::make_pair(blob.name(), shape));
38 }
39}

◆ bbox_transform_inv_cuda()

void apollo::perception::inference::bbox_transform_inv_cuda ( int  block_size,
int  thread_size,
int  shared_mem,
cudaStream_t  stream,
const int  nthreads,
const float *  boxes,
const float *  deltas,
const int  num_box,
const int  num_channel,
float *  out_boxes 
)

◆ BinaryReadBlob() [1/2]

template<typename Dtype >
std::shared_ptr< base::Blob< Dtype > > apollo::perception::inference::BinaryReadBlob ( FILE *  fp)

在文件 binary_data.cc56 行定义.

56 {
57 int ndim;
58 std::shared_ptr<base::Blob<Dtype>> blob(new base::Blob<Dtype>());
59 char dtype[kMaxStrLen];
60
61 // read dtype
62 size_t nmemb = BinaryReadString(fp, dtype);
63 CHECK_GT(nmemb, 0U);
64 CHECK_EQ(get_dtype(*blob), dtype);
65
66 // read dims
67 nmemb = fread(&ndim, sizeof(ndim), 1, fp);
68 CHECK_EQ(nmemb, 1U);
69 std::vector<int> shape(ndim);
70 for (int i = 0; i < ndim; ++i) {
71 nmemb = fread(&shape[i], sizeof(shape[i]), 1, fp);
72 CHECK_EQ(nmemb, 1U);
73 }
74 if (ndim == 0) {
75 return blob;
76 }
77
78 // init blob
79 blob->Reshape(shape);
80 CHECK_GE(blob->count(), kMinDim);
81
82 // read data
83 nmemb = fread(blob->mutable_cpu_data(), sizeof(Dtype), blob->count(), fp);
84 CHECK_EQ(static_cast<int>(nmemb), blob->count());
85
86 return blob;
87}
A wrapper around SyncedMemory holders serving as the basic computational unit for images,...
Definition blob.h:88
size_t BinaryReadString(FILE *fp, char *name)
std::string get_dtype(const base::Blob< double > &blob)
constexpr size_t kMaxStrLen
Definition binary_data.h:29

◆ BinaryReadBlob() [2/2]

template std::shared_ptr< base::Blob< float > > apollo::perception::inference::BinaryReadBlob ( FILE *  fp)

◆ BinaryReadFile() [1/2]

template<typename Dtype >
std::map< std::string, std::shared_ptr< base::Blob< Dtype > > > apollo::perception::inference::BinaryReadFile ( const char *  file_path)

在文件 binary_data.cc115 行定义.

116 {
117 char name[kMaxStrLen];
118 std::map<std::string, std::shared_ptr<base::Blob<Dtype>>> data_dict;
119
120 FILE *fp = fopen(file_path, "rb");
121 if (NULL == fp) {
122 AERROR << "Failed opening Binaryary file: " << file_path;
123 return data_dict;
124 }
125
126 // read blob name
127 while (BinaryReadString(fp, name)) {
128 // insert into data_dict
129 data_dict[name] = BinaryReadBlob<Dtype>(fp);
130 }
131
132 fclose(fp);
133 return data_dict;
134}
#define AERROR
Definition log.h:44

◆ BinaryReadFile() [2/2]

template std::map< std::string, std::shared_ptr< base::Blob< float > > > apollo::perception::inference::BinaryReadFile ( const char *  file_path)

◆ BinaryReadString()

size_t apollo::perception::inference::BinaryReadString ( FILE *  fp,
char *  name 
)

在文件 binary_data.cc35 行定义.

35 {
36 size_t len = 0;
37 size_t nmemb = fread(&len, sizeof(len), 1, fp);
38 if (nmemb != 1 || len == 0) {
39 return 0;
40 }
41 CHECK_LT(len, kMaxStrLen);
42 nmemb = fread(name, sizeof(name[0]), len, fp);
43 CHECK_EQ(nmemb, len);
44 name[len] = 0;
45 return len;
46}

◆ BinaryWriteBlob() [1/3]

template void apollo::perception::inference::BinaryWriteBlob ( FILE *  fp,
const base::Blob< double > &  blob 
)

◆ BinaryWriteBlob() [2/3]

template<typename Dtype >
void apollo::perception::inference::BinaryWriteBlob ( FILE *  fp,
const base::Blob< Dtype > &  blob 
)

在文件 binary_data.cc90 行定义.

90 {
91 int ndim, dim;
92 // write dtype
94 // write dims
95 ndim = blob.num_axes();
96 fwrite(&ndim, sizeof(ndim), 1, fp);
97 for (int i = 0; i < ndim; ++i) {
98 dim = blob.shape(i);
99 fwrite(&dim, sizeof(dim), 1, fp);
100 }
101
102 // write data
103 if (blob.count() > 0) {
104 fwrite(blob.cpu_data(), sizeof(Dtype), blob.count(), fp);
105 }
106}
const Dtype * cpu_data() const
Definition blob.cc:137
const std::vector< int > & shape() const
Definition blob.h:130
size_t BinaryWriteString(FILE *fp, const std::string &str)

◆ BinaryWriteBlob() [3/3]

template void apollo::perception::inference::BinaryWriteBlob ( FILE *  fp,
const base::Blob< float > &  blob 
)

◆ BinaryWriteFile() [1/5]

template bool apollo::perception::inference::BinaryWriteFile ( const char *  file_path,
const std::map< std::string, base::Blob< double > * > &  data_dict 
)

◆ BinaryWriteFile() [2/5]

template bool apollo::perception::inference::BinaryWriteFile ( const char *  file_path,
const std::map< std::string, base::Blob< float > * > &  data_dict 
)

◆ BinaryWriteFile() [3/5]

template<typename Btype >
bool apollo::perception::inference::BinaryWriteFile ( const char *  file_path,
const std::map< std::string, Btype > &  data_dict 
)

在文件 binary_data.cc137 行定义.

138 {
139 FILE *fp = fopen(file_path, "wb");
140 if (NULL == fp) {
141 AERROR << "Failed opening Binaryary file: " << file_path;
142 return false;
143 }
144
145 typename std::map<std::string, Btype>::const_iterator it = data_dict.begin();
146 while (it != data_dict.end()) {
147 // write blob name
148 BinaryWriteString(fp, it->first);
149 // write blob
150 BinaryWriteBlob(fp, *it->second);
151
152 ++it;
153 }
154 int end = 0;
155 fwrite(&end, sizeof(end), 1, fp);
156
157 fclose(fp);
158 return true;
159}

◆ BinaryWriteFile() [4/5]

template bool apollo::perception::inference::BinaryWriteFile ( const char *  file_path,
const std::map< std::string, std::shared_ptr< base::Blob< double > > > &  data_dict 
)

◆ BinaryWriteFile() [5/5]

template bool apollo::perception::inference::BinaryWriteFile ( const char *  file_path,
const std::map< std::string, std::shared_ptr< base::Blob< float > > > &  data_dict 
)

◆ BinaryWriteString()

size_t apollo::perception::inference::BinaryWriteString ( FILE *  fp,
const std::string &  str 
)

在文件 binary_data.cc48 行定义.

48 {
49 size_t len = str.length();
50 fwrite(&len, sizeof(len), 1, fp);
51 fwrite(str.c_str(), sizeof(str[0]), len, fp);
52 return len;
53}

◆ clip_boxes_cuda()

void apollo::perception::inference::clip_boxes_cuda ( int  block_size,
int  thread_size,
int  shared_mem,
cudaStream_t  stream,
const int  nthreads,
float *  boxes,
const float  height,
const float  width 
)

◆ CreateInferenceByName() [1/2]

Inference * apollo::perception::inference::CreateInferenceByName ( const common::Framework &  frame_work,
const std::string &  proto_file,
const std::string &  weight_file,
const std::vector< std::string > &  outputs,
const std::vector< std::string > &  inputs,
const std::string &  model_root 
)

在文件 inference_factory.cc62 行定义.

67 {
68 switch (frame_work) {
69 case common::TensorRT:
70 if (model_root.empty()) {
71 return new RTNET;
72 }
73 return new RTNET8;
74 case common::PyTorch:
75 return new TorchNet(proto_file, outputs, inputs);
76 case common::PaddlePaddle:
77 return new PaddleNet(proto_file, weight_file, outputs, inputs);
78 case common::Obstacle:
79 return new ObstacleDetector(proto_file, weight_file, outputs, inputs);
80 case common::Onnx:
81 return new SingleBatchInference(proto_file, outputs, inputs);
82 default:
83 break;
84 }
85 return nullptr;
86}
#define RTNET
#define RTNET8

◆ CreateInferenceByName() [2/2]

Inference * apollo::perception::inference::CreateInferenceByName ( const std::string &  frame_work,
const std::string &  proto_file,
const std::string &  weight_file,
const std::vector< std::string > &  outputs,
const std::vector< std::string > &  inputs,
const std::string &  model_root 
)

在文件 inference_factory.cc39 行定义.

44 {
45 if (frame_work == "RTNet") {
46 return new RTNET;
47 } else if (frame_work == "RTNetInt8") {
48 return new RTNET8;
49 } else if (frame_work == "TorchNet") {
50 // PyTorch just have model file, we use proto_file as model file
51 return new TorchNet(proto_file, outputs, inputs);
52 } else if (frame_work == "Obstacle") {
53 return new ObstacleDetector(proto_file, weight_file, outputs, inputs);
54 } else if (frame_work == "Onnx") {
55 return new SingleBatchInference(proto_file, outputs, inputs);
56 } else if (frame_work == "PaddleNet") {
57 return new PaddleNet(proto_file, weight_file, outputs, inputs);
58 }
59 return nullptr;
60}

◆ filter_boxes_cuda()

void apollo::perception::inference::filter_boxes_cuda ( int  block_size,
int  thread_size,
int  shared_mem,
cudaStream_t  stream,
const int  nthreads,
const float *  boxes,
const float *  scores,
const float *  all_probs,
const int  num_box,
const int  num_channel,
const int  num_class,
const int  num_prob,
const int  filter_channel,
const int  filter_class,
const int  min_size_mode,
const float  min_size_h,
const float  min_size_w,
const float  threshold_score,
float *  filtered_boxes,
float *  filtered_scores,
float *  filtered_all_probs,
int *  filtered_count 
)

◆ get_dtype() [1/2]

std::string apollo::perception::inference::get_dtype ( const base::Blob< double > &  blob)
inline

在文件 binary_data.cc27 行定义.

27 {
28 return "float64";
29}

◆ get_dtype() [2/2]

std::string apollo::perception::inference::get_dtype ( const base::Blob< float > &  blob)
inline

在文件 binary_data.cc31 行定义.

31 {
32 return "float32";
33}

◆ GetBlobNames()

std::vector< std::string > apollo::perception::inference::GetBlobNames ( const google::protobuf::RepeatedPtrField< common::ModelBlob > &  model_blobs)

在文件 model_util.cc23 行定义.

24 {
25 std::vector<std::string> blob_names;
26 for (const auto& blob : model_blobs) {
27 blob_names.push_back(blob.name());
28 }
29 return blob_names;
30}

◆ getCHW()

nvinfer1::DimsCHW apollo::perception::inference::getCHW ( const nvinfer1::Dims &  d)
inline

在文件 rt_common.h85 行定义.

85 {
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}

◆ GetDims()

Dims apollo::perception::inference::GetDims ( std::vector< size_t >  lens,
bool  remove_batch = true 
)

在文件 mi_net.cc58 行定义.

58 {
59 Dims dims;
60
61 // remove batch dimension for compatibility with Dims
62 if (remove_batch) lens.erase(lens.begin());
63
64 dims.nbDims = lens.size();
65 for (size_t j = 0; j < lens.size(); j++) {
66 dims.d[j] = lens[j];
67 }
68
69 return dims;
70}
Definition plugin.h:24
int32_t d[MAX_DIMS]
Definition plugin.h:28
int32_t nbDims
Definition plugin.h:27

◆ GPUGemmFloat()

void apollo::perception::inference::GPUGemmFloat ( const CBLAS_TRANSPOSE  TransA,
const CBLAS_TRANSPOSE  TransB,
const int  M,
const int  N,
const int  K,
const float  alpha,
const float *  A,
const float *  B,
const float  beta,
float *  C 
)

◆ GPUMSetFloat()

void apollo::perception::inference::GPUMSetFloat ( const int  n,
const float  alpha,
float *  result 
)

◆ GPUMultiFloat()

void apollo::perception::inference::GPUMultiFloat ( const int  n,
const float *  a,
const float *  b,
float *  result 
)

◆ ImageZeroPadding()

bool apollo::perception::inference::ImageZeroPadding ( const base::Image8U src,
base::Image8U dst,
int  stepwidth,
int  left_pad,
int  right_pad,
int  top_pad,
int  bottom_pad,
int  value,
cudaStream_t  stream,
bool  same_order 
)

◆ keep_topN_boxes_cuda()

void apollo::perception::inference::keep_topN_boxes_cuda ( int  block_size,
int  thread_size,
int  shared_mem,
cudaStream_t  stream,
const int  nthreads,
const float *  boxes,
const float *  scores,
const float *  all_probs,
const int *  indexes,
const int *  count,
const bool  keep_score,
const int  num_box,
const int  num_prob,
const int  topN,
float *  out_boxes,
float *  out_scores,
float *  out_all_probs 
)

◆ load_binary_data()

std::shared_ptr< float > apollo::perception::inference::load_binary_data ( const std::string &  filename)

在文件 util.cc24 行定义.

24 {
25 std::ifstream ifs(filename, std::ifstream::binary);
26 if (!ifs) {
27 return nullptr;
28 }
29
30 ifs.seekg(0, ifs.end);
31 int length = static_cast<int>(ifs.tellg() / sizeof(float));
32 ifs.seekg(0, ifs.beg);
33 std::shared_ptr<float> outputs;
34 outputs.reset(new float[length]);
35 ifs.read(reinterpret_cast<char *>(outputs.get()), sizeof(float) * length);
36 ifs.close();
37 return outputs;
38}

◆ load_data()

template<typename T >
void apollo::perception::inference::load_data ( const std::string &  filename,
std::vector< T > *  outputs 
)

在文件 util.h32 行定义.

32 {
33 std::ifstream ifs(filename, std::ifstream::in);
34
35 if (ifs.good()) {
36 outputs->clear();
37 T output;
38 while (ifs >> output) {
39 outputs->push_back(output);
40 }
41 ifs.close();
42 }
43}

◆ loadNetParams()

bool apollo::perception::inference::loadNetParams ( const std::string &  param_file,
NetParameter param 
)

在文件 mi_utils.cc64 行定义.

64 {
65 return ReadProtoFromTextFile(param_file, param);
66}
bool ReadProtoFromTextFile(const std::string &filename, google::protobuf::Message *proto)
Definition mi_utils.cc:29

◆ locateFile()

std::string apollo::perception::inference::locateFile ( const std::string &  network,
const std::string &  input 
)

在文件 mi_utils.cc67 行定义.

67 {
68 return network + "/" + input;
69}

◆ modify_pool_param()

bool apollo::perception::inference::modify_pool_param ( PoolingParameter pool_param)

在文件 mi_common.cc101 行定义.

101 {
102 if (pool_param->has_kernel_size()) {
103 pool_param->set_kernel_h(pool_param->kernel_size());
104 pool_param->set_kernel_w(pool_param->kernel_size());
105 }
106 if (pool_param->kernel_w() == 0 || pool_param->kernel_h() == 0) {
107 return false;
108 }
109 if (pool_param->has_pad()) {
110 pool_param->set_pad_h(pool_param->pad());
111 pool_param->set_pad_w(pool_param->pad());
112 }
113 if (pool_param->has_stride()) {
114 pool_param->set_stride_h(pool_param->stride());
115 pool_param->set_stride_w(pool_param->stride());
116 }
117 if (pool_param->stride_w() == 0 || pool_param->stride_h() == 0) {
118 return false;
119 }
120 return true;
121}

◆ NmsForward()

void apollo::perception::inference::NmsForward ( bool  rpn_proposal_output_score,
int  host_filter_count,
int  num_box_corners,
float  nms_overlap_threshold,
int  num_candidate,
int  top_n,
int  batch_id,
int  num_prob,
float *  dev_sorted_box_for_nms,
float *  scores,
float *  all_probs,
float *  out_boxes,
int *  acc_box_num,
cudaStream_t  stream 
)

GPU Non-Maximum Suppresion for network output

参数
[in]rpn_proposal_output_scoreWhether to output scores
[in]host_filter_countNumber of filtered output
[in]num_box_cornersNumber of corners for 2D box
[in]nms_overlap_thresholdIOU threshold for NMS
[in]num_candidatePre-defined maximum number of candidates
[in]top_nPre-defined maximum number of output boxes
[in]batch_idId of current batch instance
[in]num_probNumber of probs
[in]dev_sorted_box_for_nmsBounding box output sorted by score
[in]scoresScores of boxes
[in]all_probsProbs of boxes for all classes and objectness
[in]out_boxesOutput boxes
[in]acc_box_numAccumulated box num

NMS in GPU and postprocessing for selecting box in CPU

◆ ParseNetParam()

void apollo::perception::inference::ParseNetParam ( const NetParameter net_param,
TensorDimsMap tensor_dims_map,
std::map< std::string, std::string > *  tensor_modify_map,
std::vector< LayerParameter > *  order 
)

在文件 mi_common.cc27 行定义.

30 {
31 for (int i = 0; i < net_param.layer_size(); ++i) {
32 LayerParameter tensorrt_layer_param = net_param.layer(i);
33 if (tensorrt_layer_param.type() == "Input") {
34 InputParameter input = tensorrt_layer_param.input_param();
35 for (int j = 0; j < tensorrt_layer_param.top().size(); ++j) {
36 TensorDims dims{static_cast<int>(input.shape(j).dim(0)),
37 static_cast<int>(input.shape(j).dim(1)),
38 static_cast<int>(input.shape(j).dim(2)),
39 static_cast<int>(input.shape(j).dim(3))};
40 auto name = tensorrt_layer_param.top(j);
41 tensor_dims_map->insert(std::make_pair(name, dims));
42 tensor_modify_map->insert(
43 std::make_pair(name, tensorrt_layer_param.top(j)));
44 }
45 } else {
46 order->push_back(tensorrt_layer_param);
47 }
48 }
49}
std::vector< int > TensorDims
Definition mi_common.h:32

◆ ParserConvParam()

bool apollo::perception::inference::ParserConvParam ( const ConvolutionParameter conv,
ConvParam param 
)

在文件 mi_common.cc51 行定义.

51 {
52 if (conv.has_kernel_h() || conv.has_kernel_w()) {
53 if (conv.kernel_size_size() != 0) {
54 return false;
55 }
56 param->kernel_h = conv.kernel_h();
57 param->kernel_w = conv.kernel_w();
58 } else {
59 if (conv.kernel_size_size() < 1) {
60 return false;
61 }
62 param->kernel_h = conv.kernel_size(0);
63 param->kernel_w = (conv.kernel_size_size() > 1 ? conv.kernel_size(1)
64 : conv.kernel_size(0));
65 }
66 if (param->kernel_h == 0 || param->kernel_w == 0) {
67 return false;
68 }
69
70 if (conv.has_pad_h() || conv.has_pad_w()) {
71 if (conv.pad_size() != 0) {
72 return false;
73 }
74 param->padding_h = conv.pad_h();
75 param->padding_w = conv.pad_w();
76 } else {
77 param->padding_h = (conv.pad().empty() ? 0 : conv.pad(0));
78 param->padding_w = (conv.pad_size() > 1 ? conv.pad(1) : param->padding_h);
79 }
80
81 if (conv.has_stride_h() || conv.has_stride_w()) {
82 if (conv.stride_size() != 0) {
83 return false;
84 }
85 param->stride_h = conv.stride_h();
86 param->stride_w = conv.stride_w();
87 } else {
88 param->stride_h = (conv.stride().empty() ? 1 : conv.stride(0));
89 param->stride_w =
90 (conv.stride_size() > 1 ? conv.stride(1) : param->stride_h);
91 }
92 if (param->stride_h == 0 || param->stride_w == 0) {
93 return false;
94 }
95
96 param->dilation = conv.dilation().empty() ? 1 : conv.dilation(0);
97 param->group = conv.has_group() ? conv.group() : 1;
98 return true;
99}

◆ ReadProtoFromBinaryFile()

bool apollo::perception::inference::ReadProtoFromBinaryFile ( const std::string &  filename,
google::protobuf::Message *  proto 
)

在文件 mi_utils.cc44 行定义.

45 {
46 int fd = open(filename.c_str(), O_RDONLY);
47 if (fd < 0) {
48 AERROR << "cannot open file " << filename;
49 return false;
50 }
51 google::protobuf::io::FileInputStream raw_input(fd);
52 google::protobuf::io::CodedInputStream coded_input(&raw_input);
53#if GOOGLE_PROTOBUF_VERSION >= 3002000
54 coded_input.SetTotalBytesLimit(std::numeric_limits<int>::max());
55#else
56 coded_input.SetTotalBytesLimit(std::numeric_limits<int>::max(), 536870912);
57#endif
58
59 bool success = proto->ParseFromCodedStream(&coded_input);
60
61 close(fd);
62 return success;
63}

◆ ReadProtoFromTextFile()

bool apollo::perception::inference::ReadProtoFromTextFile ( const std::string &  filename,
google::protobuf::Message *  proto 
)

在文件 mi_utils.cc29 行定义.

30 {
31 int fd = open(filename.c_str(), O_RDONLY);
32 if (fd < 0) {
33 AERROR << "cannot open file " << filename;
34 return false;
35 }
36 google::protobuf::io::FileInputStream raw_input(fd);
37
38 bool success = google::protobuf::TextFormat::Parse(&raw_input, proto);
39
40 close(fd);
41 return success;
42}

◆ repeatedly_add_cuda()

void apollo::perception::inference::repeatedly_add_cuda ( int  block_size,
int  thread_size,
int  shared_mem,
cudaStream_t  stream,
const int  nthreads,
const float *  in_data,
float *  out_data,
const float *  add_vec,
int  add_vec_size 
)

◆ repeatedly_mul_cuda()

void apollo::perception::inference::repeatedly_mul_cuda ( int  block_size,
int  thread_size,
int  shared_mem,
cudaStream_t  stream,
const int  nthreads,
const float *  in_data,
float *  out_data,
const float *  mul_vec,
int  mul_vec_size 
)

◆ ReshapeDims()

nvinfer1::DimsCHW apollo::perception::inference::ReshapeDims ( const nvinfer1::DimsCHW dims,
const nvinfer1::DimsCHW inputDims 
)

在文件 rt_common.cc34 行定义.

35 {
36 nvinfer1::DimsCHW outDims = inputDims;
37 int count = inputDims.d[0] * inputDims.d[1] * inputDims.d[2];
38 int constant = 1;
39 int axis_inference = -1;
40 for (int i = 0; i < inputDims.nbDims; ++i) {
41 if (dims.d[i] == 0) {
42 outDims.d[i] = inputDims.d[i];
43 constant *= outDims.d[i];
44 } else if (dims.d[i] > 0) {
45 constant *= dims.d[i];
46 } else if (dims.d[i] == -1) {
47 CHECK_EQ(axis_inference, -1);
48 outDims.d[i] = count / constant;
49 axis_inference = i;
50 }
51 }
52 return outDims;
53}

◆ ResizeGPU() [1/4]

bool apollo::perception::inference::ResizeGPU ( const apollo::perception::base::Blob< uint8_t > &  src_gpu,
std::shared_ptr< apollo::perception::base::Blob< float > >  dst,
int  stepwidth,
int  start_axis,
int  mean_b,
int  mean_g,
int  mean_r,
bool  channel_axis,
float  scale 
)

◆ ResizeGPU() [2/4]

bool apollo::perception::inference::ResizeGPU ( const base::Image8U src,
std::shared_ptr< apollo::perception::base::Blob< float > >  dst,
int  stepwidth,
int  start_axis 
)

◆ ResizeGPU() [3/4]

bool apollo::perception::inference::ResizeGPU ( const base::Image8U src,
std::shared_ptr< apollo::perception::base::Blob< float > >  dst,
int  stepwidth,
int  start_axis,
float  mean_b,
float  mean_g,
float  mean_r,
bool  channel_axis,
float  scale 
)

◆ ResizeGPU() [4/4]

bool apollo::perception::inference::ResizeGPU ( const base::Image8U src,
std::shared_ptr< apollo::perception::base::Blob< float > >  dst,
int  stepwidth,
int  start_axis,
float  mean_b,
float  mean_g,
float  mean_r,
bool  channel_axis,
float  std_b,
float  std_g,
float  std_r 
)

◆ slice2d_cuda()

void apollo::perception::inference::slice2d_cuda ( int  block_size,
int  thread_size,
int  shared_mem,
cudaStream_t  stream,
const int  nthreads,
const float *  in_data,
float *  out_data,
const int *  slice_axises,
int  slice_axis_num,
int  input_axis_size 
)

◆ write_result() [1/2]

bool apollo::perception::inference::write_result ( const std::string &  out_path,
const std::map< std::string, std::vector< float > > &  results 
)

◆ write_result() [2/2]

bool apollo::perception::inference::write_result ( const std::string &  out_path,
const std::vector< float > &  results 
)

在文件 util.cc40 行定义.

41 {
42 std::ofstream outf(out_path, std::ios::binary | std::ios::out);
43 if (!outf.is_open()) {
44 AINFO << "Cannot open output file: " << out_path;
45 return false;
46 }
47 outf.write(reinterpret_cast<const char *>(results.data()),
48 sizeof(float) * results.size());
49 outf.close();
50 return true;
51}
#define AINFO
Definition log.h:42

变量说明

◆ _gpu_checklist

const std::vector<std::string> apollo::perception::inference::_gpu_checklist
初始值:
{"GeForce GTX 1080",
"GeForce GTX 1080 Ti",
"Tesla P4",
"Tesla P40",
"GeForce GTX 1070",
"GeForce GTX 1060",
"Tesla V100-SXM2-16GB",
"Orin"}

在文件 rt_net.h64 行定义.

64 {"GeForce GTX 1080",
65 "GeForce GTX 1080 Ti",
66 "Tesla P4",
67 "Tesla P40",
68 "GeForce GTX 1070",
69 "GeForce GTX 1060",
70 "Tesla V100-SXM2-16GB",
71 "Orin"};

◆ active_map

const std::map< std::string, nvinfer1::ActivationType > apollo::perception::inference::active_map
初始值:
{
{"Sigmoid", "sigmoid"},
{"TanH", "tanh"},
{"ReLU", "relu"},
{"LeakyReLU", "leaky_relu"}}

在文件 mi_net.h68 行定义.

68 {
69 {"Sigmoid", "sigmoid"},
70 {"TanH", "tanh"},
71 {"ReLU", "relu"},
72 {"LeakyReLU", "leaky_relu"}};

◆ eltwise_map

const std::map< EltwiseParameter::EltwiseOp, nvinfer1::ElementWiseOperation > apollo::perception::inference::eltwise_map
初始值:
{
{EltwiseParameter_EltwiseOp_PROD, "mul"},
{EltwiseParameter_EltwiseOp_SUM, "add"},
{EltwiseParameter_EltwiseOp_MAX, "max"}}

在文件 mi_net.h74 行定义.

74 {
75 {EltwiseParameter_EltwiseOp_PROD, "mul"},
76 {EltwiseParameter_EltwiseOp_SUM, "add"},
77 {EltwiseParameter_EltwiseOp_MAX, "max"}};

◆ kMaxDim

constexpr int apollo::perception::inference::kMaxDim = std::numeric_limits<int>::max()
constexpr

在文件 binary_data.h31 行定义.

◆ kMaxStrLen

constexpr size_t apollo::perception::inference::kMaxStrLen = 64
constexpr

在文件 binary_data.h29 行定义.

◆ kMinDim

constexpr int apollo::perception::inference::kMinDim = 1
constexpr

在文件 binary_data.h30 行定义.

◆ MemoryPoolInitSizeMb

constexpr uint64_t apollo::perception::inference::MemoryPoolInitSizeMb = 1000
constexpr

在文件 paddle_net.h33 行定义.