[Backend] support ort offline graph optimize option (#2268)

* support ort offline graph optimize option

* support ort offline graph optimize option
This commit is contained in:
DefTruth
2023-11-02 09:19:33 +08:00
committed by GitHub
parent d910d6116c
commit 6a8cd4d759
4 changed files with 15 additions and 8 deletions

View File

@@ -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) {

View File

@@ -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

View File

@@ -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();

View File

@@ -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 \