FastDeploy  latest
Fast & Easy to Deploy!
option.h
1 // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include "fastdeploy/core/fd_type.h"
18 #include <iostream>
19 #include <memory>
20 #include <string>
21 #include <vector>
22 #include <map>
23 #include <set>
24 namespace fastdeploy {
25 
29  std::string device = "CPU";
30  int cpu_thread_num = -1;
31 
33  int num_streams = 1;
34 
36  std::string affinity = "YES";
37 
39  std::string hint = "UNDEFINED";
40 
44  void SetDevice(const std::string& name = "CPU") {
45  device = name;
46  }
47 
52  const std::map<std::string, std::vector<int64_t>>& _shape_infos) {
53  shape_infos = _shape_infos;
54  }
55 
59  void SetCpuOperators(const std::vector<std::string>& operators) {
60  for (const auto& op : operators) {
61  cpu_operators.insert(op);
62  }
63  }
64 
68  void SetAffinity (const std::string& _affinity) {
69  FDASSERT(_affinity == "YES" || _affinity == "NO" || _affinity == "NUMA" ||
70  _affinity == "HYBRID_AWARE",
71  "The affinity mode should be one of the list "
72  "['YES', 'NO', 'NUMA', "
73  "'HYBRID_AWARE'] ");
74  affinity = _affinity;
75  }
76 
80  void SetPerformanceHint (const std::string& _hint) {
81  FDASSERT(_hint == "LATENCY" || _hint == "THROUGHPUT" ||
82  _hint == "CUMULATIVE_THROUGHPUT" || _hint == "UNDEFINED",
83  "The performance hint should be one of the list "
84  "['LATENCY', 'THROUGHPUT', 'CUMULATIVE_THROUGHPUT', "
85  "'UNDEFINED'] ");
86  hint = _hint;
87  }
88 
92  void SetStreamNum (int _num_streams) {
93  FDASSERT(_num_streams > 0, "The stream_num must be greater than 0.");
94  num_streams = _num_streams;
95  }
96 
97 
98  std::map<std::string, std::vector<int64_t>> shape_infos;
99  std::set<std::string> cpu_operators{"MulticlassNms"};
100 };
101 } // namespace fastdeploy
std::string hint
Performance hint mode.
Definition: option.h:39
void SetShapeInfo(const std::map< std::string, std::vector< int64_t >> &_shape_infos)
Set shape info for OpenVINO.
Definition: option.h:51
void SetPerformanceHint(const std::string &_hint)
Set the Performance Hint.
Definition: option.h:80
void SetStreamNum(int _num_streams)
Set the number of streams.
Definition: option.h:92
void SetCpuOperators(const std::vector< std::string > &operators)
While use OpenVINO backend with intel GPU, use this interface to specify operators run on CPU...
Definition: option.h:59
std::string affinity
Affinity mode.
Definition: option.h:36
void SetAffinity(const std::string &_affinity)
Set Affinity mode.
Definition: option.h:68
int num_streams
Number of streams while use OpenVINO.
Definition: option.h:33
void SetDevice(const std::string &name="CPU")
Set device name for OpenVINO, default &#39;CPU&#39;, can also be &#39;AUTO&#39;, &#39;GPU&#39;, &#39;GPU.1&#39;....
Definition: option.h:44
Option object to configure OpenVINO backend.
Definition: option.h:28
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16