Apollo 11.0
自动驾驶开放平台
paddle_net.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2022 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#include <memory>
23
24#include "paddle/include/paddle_inference_api.h"
27
28
29namespace apollo {
30namespace perception {
31namespace inference {
32
33constexpr uint64_t MemoryPoolInitSizeMb = 1000;
34
35class PaddleNet : public Inference {
36 public:
37 PaddleNet(const std::string& model_file,
38 const std::string& params_file,
39 const std::vector<std::string>& outputs,
40 const std::vector<std::string>& inputs);
41 virtual ~PaddleNet();
42
43 bool Init(const std::map<std::string, std::vector<int>>& shapes) override;
44
45 void Infer() override;
46
47 base::BlobPtr<float> get_blob(const std::string& name) override;
48
49 protected:
50 bool shape(const std::string &name, std::vector<int> *res);
51 std::shared_ptr<paddle_infer::Predictor> predictor_;
52
53 private:
54 std::string model_file_;
55 std::string params_file_;
56 std::vector<std::string> output_names_;
57 std::vector<std::string> input_names_;
58 BlobMap blobs_;
59};
60
61} // namespace inference
62} // namespace perception
63} // namespace apollo
std::shared_ptr< paddle_infer::Predictor > predictor_
Definition paddle_net.h:51
bool Init(const std::map< std::string, std::vector< int > > &shapes) override
Definition paddle_net.cc:37
base::BlobPtr< float > get_blob(const std::string &name) override
bool shape(const std::string &name, std::vector< int > *res)
std::shared_ptr< Blob< Dtype > > BlobPtr
Definition blob.h:313
constexpr uint64_t MemoryPoolInitSizeMb
Definition paddle_net.h:33
std::map< std::string, base::BlobPtr< float > > BlobMap
Definition inference.h:39
class register implement
Definition arena_queue.h:37