Apollo  6.0
Open source self driving car software
inference.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 <memory>
21 #include <string>
22 #include <vector>
23 
24 #include <boost/shared_ptr.hpp>
25 
27 
28 namespace apollo {
29 namespace perception {
30 namespace inference {
31 
32 typedef std::map<std::string,
33  std::shared_ptr<apollo::perception::base::Blob<float>>>
35 
36 class Inference {
37  public:
38  virtual void Infer() = 0;
39  Inference() = default;
40 
41  virtual ~Inference() = default;
42 
43  virtual bool Init(const std::map<std::string, std::vector<int>> &shapes) = 0;
44 
45  void set_max_batch_size(const int &batch_size);
46 
47  void set_gpu_id(const int &gpu_id);
48 
49  virtual std::shared_ptr<apollo::perception::base::Blob<float>> get_blob(
50  const std::string &name) = 0;
51 
52  protected:
53  int max_batch_size_ = 1;
54  int gpu_id_ = 0;
55 };
56 
57 } // namespace inference
58 } // namespace perception
59 } // namespace apollo
virtual bool Init(const std::map< std::string, std::vector< int >> &shapes)=0
virtual std::shared_ptr< apollo::perception::base::Blob< float > > get_blob(const std::string &name)=0
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
std::map< std::string, std::shared_ptr< apollo::perception::base::Blob< float > > > BlobMap
Definition: inference.h:34
void set_max_batch_size(const int &batch_size)
int gpu_id_
Definition: inference.h:54
int max_batch_size_
Definition: inference.h:53