Skip to content

Commit 6a8cd4d

Browse files
authored
[Backend] support ort offline graph optimize option (#2268)
* support ort offline graph optimize option * support ort offline graph optimize option
1 parent d910d61 commit 6a8cd4d

4 files changed

Lines changed: 15 additions & 8 deletions

File tree

fastdeploy/runtime/backends/ort/option.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ struct OrtBackendOption {
4848
void* external_stream_ = nullptr;
4949
/// Use fp16 to infer
5050
bool enable_fp16 = false;
51+
/// file path for optimized model
52+
std::string optimized_model_filepath;
5153

5254
std::vector<std::string> ort_disabled_ops_{};
5355
void DisableOrtFP16OpTypes(const std::vector<std::string>& ops) {

fastdeploy/runtime/backends/ort/ort_backend.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ bool OrtBackend::BuildOption(const OrtBackendOption& option) {
4646
if (option.execution_mode >= 0) {
4747
session_options_.SetExecutionMode(ExecutionMode(option.execution_mode));
4848
}
49+
if (!option.optimized_model_filepath.empty()) {
50+
session_options_.SetOptimizedModelFilePath(option.optimized_model_filepath.c_str());
51+
}
4952

5053
#ifdef WITH_DIRECTML
5154
// If use DirectML

fastdeploy/runtime/runtime.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ struct FASTDEPLOY_DECL Runtime {
108108
return backend_->benchmark_result_.time_of_runtime;
109109
}
110110

111+
bool Initialized() const { return backend_->Initialized(); }
112+
111113
private:
112114
void CreateOrtBackend();
113115
void CreatePaddleBackend();

scripts/linux/build_linux_x86_64_cpp_cpu.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ __build_fastdeploy_linux_x86_64_shared() {
6262
cmake -DCMAKE_BUILD_TYPE=Release \
6363
-DWITH_GPU=OFF \
6464
-DENABLE_ORT_BACKEND=ON \
65-
-DENABLE_PADDLE_BACKEND=ON \
66-
-DENABLE_OPENVINO_BACKEND=ON \
65+
-DENABLE_PADDLE_BACKEND=OFF \
66+
-DENABLE_OPENVINO_BACKEND=OFF \
6767
-DENABLE_PADDLE2ONNX=ON \
68-
-DENABLE_VISION=ON \
69-
-DENABLE_BENCHMARK=ON \
68+
-DENABLE_VISION=OFF \
69+
-DENABLE_BENCHMARK=OFF \
7070
-DENABLE_FLYCV=OFF \
7171
-DWITH_FLYCV_STATIC=OFF \
7272
-DBUILD_EXAMPLES=OFF \
@@ -84,11 +84,11 @@ __build_fastdeploy_linux_x86_64_shared_custom_paddle() {
8484
cmake -DCMAKE_BUILD_TYPE=Release \
8585
-DWITH_GPU=OFF \
8686
-DENABLE_ORT_BACKEND=ON \
87-
-DENABLE_PADDLE_BACKEND=ON \
88-
-DENABLE_OPENVINO_BACKEND=ON \
87+
-DENABLE_PADDLE_BACKEND=OFF \
88+
-DENABLE_OPENVINO_BACKEND=OFF \
8989
-DENABLE_PADDLE2ONNX=ON \
90-
-DENABLE_VISION=ON \
91-
-DENABLE_BENCHMARK=ON \
90+
-DENABLE_VISION=OFF \
91+
-DENABLE_BENCHMARK=OFF \
9292
-DPADDLEINFERENCE_DIRECTORY=${PADDLEINFERENCE_DIRECTORY} \
9393
-DPADDLEINFERENCE_VERSION=${PADDLEINFERENCE_VERSION} \
9494
-DENABLE_FLYCV=OFF \

0 commit comments

Comments
 (0)