Skip to content

Commit

Permalink
[Backend] support ort offline graph optimize option (#2268)
Browse files Browse the repository at this point in the history
* support ort offline graph optimize option

* support ort offline graph optimize option
  • Loading branch information
DefTruth committed Nov 2, 2023
1 parent d910d61 commit 6a8cd4d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions fastdeploy/runtime/backends/ort/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> ort_disabled_ops_{};
void DisableOrtFP16OpTypes(const std::vector<std::string>& ops) {
Expand Down
3 changes: 3 additions & 0 deletions fastdeploy/runtime/backends/ort/ort_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions fastdeploy/runtime/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 8 additions & 8 deletions scripts/linux/build_linux_x86_64_cpp_cpu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down

0 comments on commit 6a8cd4d

Please sign in to comment.