diff --git a/fastdeploy/runtime/backends/ort/option.h b/fastdeploy/runtime/backends/ort/option.h index 4bc0874c7..595a2fcfd 100755 --- a/fastdeploy/runtime/backends/ort/option.h +++ b/fastdeploy/runtime/backends/ort/option.h @@ -48,6 +48,8 @@ struct OrtBackendOption { void* external_stream_ = nullptr; /// Use fp16 to infer bool enable_fp16 = false; + /// file path for optimized model + std::string optimized_model_filepath; std::vector ort_disabled_ops_{}; void DisableOrtFP16OpTypes(const std::vector& ops) { diff --git a/fastdeploy/runtime/backends/ort/ort_backend.cc b/fastdeploy/runtime/backends/ort/ort_backend.cc index 987bf1882..c9dfee821 100644 --- a/fastdeploy/runtime/backends/ort/ort_backend.cc +++ b/fastdeploy/runtime/backends/ort/ort_backend.cc @@ -46,6 +46,9 @@ bool OrtBackend::BuildOption(const OrtBackendOption& option) { if (option.execution_mode >= 0) { session_options_.SetExecutionMode(ExecutionMode(option.execution_mode)); } + if (!option.optimized_model_filepath.empty()) { + session_options_.SetOptimizedModelFilePath(option.optimized_model_filepath.c_str()); + } #ifdef WITH_DIRECTML // If use DirectML diff --git a/fastdeploy/runtime/runtime.h b/fastdeploy/runtime/runtime.h index a1adf53fa..c84d47e2a 100755 --- a/fastdeploy/runtime/runtime.h +++ b/fastdeploy/runtime/runtime.h @@ -108,6 +108,8 @@ struct FASTDEPLOY_DECL Runtime { return backend_->benchmark_result_.time_of_runtime; } + bool Initialized() const { return backend_->Initialized(); } + private: void CreateOrtBackend(); void CreatePaddleBackend(); diff --git a/scripts/linux/build_linux_x86_64_cpp_cpu.sh b/scripts/linux/build_linux_x86_64_cpp_cpu.sh index 83a255324..3456e93d7 100755 --- a/scripts/linux/build_linux_x86_64_cpp_cpu.sh +++ b/scripts/linux/build_linux_x86_64_cpp_cpu.sh @@ -62,11 +62,11 @@ __build_fastdeploy_linux_x86_64_shared() { cmake -DCMAKE_BUILD_TYPE=Release \ -DWITH_GPU=OFF \ -DENABLE_ORT_BACKEND=ON \ - -DENABLE_PADDLE_BACKEND=ON \ - -DENABLE_OPENVINO_BACKEND=ON \ + -DENABLE_PADDLE_BACKEND=OFF \ + -DENABLE_OPENVINO_BACKEND=OFF \ -DENABLE_PADDLE2ONNX=ON \ - -DENABLE_VISION=ON \ - -DENABLE_BENCHMARK=ON \ + -DENABLE_VISION=OFF \ + -DENABLE_BENCHMARK=OFF \ -DENABLE_FLYCV=OFF \ -DWITH_FLYCV_STATIC=OFF \ -DBUILD_EXAMPLES=OFF \ @@ -84,11 +84,11 @@ __build_fastdeploy_linux_x86_64_shared_custom_paddle() { cmake -DCMAKE_BUILD_TYPE=Release \ -DWITH_GPU=OFF \ -DENABLE_ORT_BACKEND=ON \ - -DENABLE_PADDLE_BACKEND=ON \ - -DENABLE_OPENVINO_BACKEND=ON \ + -DENABLE_PADDLE_BACKEND=OFF \ + -DENABLE_OPENVINO_BACKEND=OFF \ -DENABLE_PADDLE2ONNX=ON \ - -DENABLE_VISION=ON \ - -DENABLE_BENCHMARK=ON \ + -DENABLE_VISION=OFF \ + -DENABLE_BENCHMARK=OFF \ -DPADDLEINFERENCE_DIRECTORY=${PADDLEINFERENCE_DIRECTORY} \ -DPADDLEINFERENCE_VERSION=${PADDLEINFERENCE_VERSION} \ -DENABLE_FLYCV=OFF \