26 #include "fastdeploy/runtime/backends/lite/option.h" 27 #include "fastdeploy/runtime/backends/openvino/option.h" 28 #include "fastdeploy/runtime/backends/ort/option.h" 29 #include "fastdeploy/runtime/backends/paddle/option.h" 30 #include "fastdeploy/runtime/backends/poros/option.h" 31 #include "fastdeploy/runtime/backends/rknpu2/option.h" 32 #include "fastdeploy/runtime/backends/sophgo/option.h" 33 #include "fastdeploy/runtime/backends/tensorrt/option.h" 34 #include "fastdeploy/benchmark/option.h" 47 void SetModelPath(
const std::string& model_path,
48 const std::string& params_path =
"",
57 void SetModelBuffer(
const std::string& model_buffer,
58 const std::string& params_buffer =
"",
65 void SetEncryptionKey(
const std::string& encryption_key);
70 void UseGpu(
int gpu_id = 0);
72 void UseRKNPU2(fastdeploy::rknpu2::CpuName rknpu2_name =
73 fastdeploy::rknpu2::CpuName::RK356X,
74 fastdeploy::rknpu2::CoreMask rknpu2_core =
75 fastdeploy::rknpu2::CoreMask::RKNN_NPU_CORE_AUTO);
108 void UseKunlunXin(
int kunlunxin_id = 0,
int l3_workspace_size = 0xfffc00,
109 bool locked =
false,
bool autotune =
true,
110 const std::string& autotune_file =
"",
111 const std::string& precision =
"int16",
112 bool adaptive_seqlen =
false,
113 bool enable_multi_stream =
false);
115 void SetExternalStream(
void* external_stream);
120 void SetCpuThreadNum(
int thread_num);
124 void UseOrtBackend();
126 void UseSophgoBackend();
128 void UseTrtBackend();
130 void UsePorosBackend();
132 void UseOpenVINOBackend();
142 void UseIpu(
int device_num = 1,
int micro_batch_size = 1,
143 bool enable_pipelining =
false,
int batches_per_step = 1);
167 void EnableProfiling(
bool inclue_h2d_d2h =
false,
168 int repeat = 100,
int warmup = 50) {
169 benchmark_option.enable_profile =
true;
170 benchmark_option.warmup = warmup;
171 benchmark_option.repeats = repeat;
172 benchmark_option.include_h2d_d2h = inclue_h2d_d2h;
177 void DisableProfiling() {
178 benchmark_option.enable_profile =
false;
184 void EnableValidBackendCheck() {
185 enable_valid_backend_check =
true;
190 void DisableValidBackendCheck() {
191 enable_valid_backend_check =
false;
195 benchmark::BenchmarkOption benchmark_option;
197 bool enable_valid_backend_check =
true;
202 std::string model_file =
"";
203 std::string params_file =
"";
204 bool model_from_memory_ =
false;
208 std::string encryption_key_ =
"";
212 int cpu_thread_num = -1;
216 Device device = Device::CPU;
218 void* external_stream_ =
nullptr;
220 bool enable_pinned_memory =
false;
224 void SetPaddleMKLDNN(
bool pd_mkldnn =
true);
225 void EnablePaddleToTrt();
226 void DeletePaddleBackendPass(
const std::string& delete_pass_name);
227 void EnablePaddleLogInfo();
228 void DisablePaddleLogInfo();
229 void SetPaddleMKLDNNCacheSize(
int size);
230 void SetOpenVINODevice(
const std::string& name =
"CPU");
231 void SetOpenVINOShapeInfo(
232 const std::map<std::string, std::vector<int64_t>>& shape_info) {
233 openvino_option.shape_infos = shape_info;
235 void SetOpenVINOCpuOperators(
const std::vector<std::string>& operators) {
238 void SetLiteOptimizedModelDir(
const std::string& optimized_model_dir);
239 void SetLiteSubgraphPartitionPath(
240 const std::string& nnadapter_subgraph_partition_config_path);
241 void SetLiteSubgraphPartitionConfigBuffer(
242 const std::string& nnadapter_subgraph_partition_config_buffer);
244 SetLiteContextProperties(
const std::string& nnadapter_context_properties);
245 void SetLiteModelCacheDir(
const std::string& nnadapter_model_cache_dir);
246 void SetLiteDynamicShapeInfo(
247 const std::map<std::string, std::vector<std::vector<int64_t>>>&
248 nnadapter_dynamic_shape_info);
249 void SetLiteMixedPrecisionQuantizationConfigPath(
250 const std::string& nnadapter_mixed_precision_quantization_config_path);
251 void EnableLiteFP16();
252 void DisableLiteFP16();
253 void EnableLiteInt8();
254 void DisableLiteInt8();
256 void SetTrtInputShape(
257 const std::string& input_name,
const std::vector<int32_t>& min_shape,
258 const std::vector<int32_t>& opt_shape = std::vector<int32_t>(),
259 const std::vector<int32_t>& max_shape = std::vector<int32_t>());
260 void SetTrtMaxWorkspaceSize(
size_t trt_max_workspace_size);
261 void SetTrtMaxBatchSize(
size_t max_batch_size);
262 void EnableTrtFP16();
263 void DisableTrtFP16();
264 void SetTrtCacheFile(
const std::string& cache_file_path);
265 void EnablePinnedMemory();
266 void DisablePinnedMemory();
267 void EnablePaddleTrtCollectShape();
268 void DisablePaddleTrtCollectShape();
269 void DisablePaddleTrtOPs(
const std::vector<std::string>& ops);
270 void SetOpenVINOStreams(
int num_streams);
271 void SetOrtGraphOptLevel(
int level = -1);
272 void UsePaddleBackend();
273 void UseLiteBackend();
Option object used when create a new Runtime object.
Definition: runtime_option.h:40
void UsePaddleInferBackend()
Set Paddle Inference as inference backend, support CPU/GPU.
Definition: runtime_option.h:122
Option object to configure ONNX Runtime backend.
Definition: option.h:28
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
ModelFormat
Definition: enum_variables.h:67
Backend
Definition: enum_variables.h:30
A brief file description.
Option object to configure Paddle Inference backend.
Definition: option.h:50
PaddleBackendOption paddle_infer_option
Option to configure Paddle Inference backend.
Definition: runtime_option.h:150
LitePowerMode
Definition: option.h:42
TrtBackendOption trt_option
Option to configure TensorRT backend.
Definition: runtime_option.h:148
Option object to configure Paddle Lite backend.
Definition: option.h:53
Option object to configure Poros backend.
Definition: option.h:27
OpenVINOBackendOption openvino_option
Option to configure OpenVINO backend.
Definition: runtime_option.h:154
LiteBackendOption paddle_lite_option
Option to configure Paddle Lite backend.
Definition: runtime_option.h:156
Option object to configure TensorRT backend.
Definition: option.h:26
Model with paddlepaddle format.
Definition: enum_variables.h:69
RKNPU2BackendOption rknpu2_option
Option to configure RKNPU2 backend.
Definition: runtime_option.h:158
Option object to configure OpenVINO backend.
Definition: option.h:28
void UsePaddleLiteBackend()
Set Paddle Lite as inference backend, only support arm cpu.
Definition: runtime_option.h:134
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16
Unknown inference backend.
Definition: enum_variables.h:31
PorosBackendOption poros_option
Option to configure Poros backend.
Definition: runtime_option.h:152
OrtBackendOption ort_option
Option to configure ONNX Runtime backend.
Definition: runtime_option.h:146