From 2d3e61582d61c4edd4ff42cc1c87d68e59d9ad7c Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 23 Sep 2022 11:16:02 +0800 Subject: [PATCH] Rename pybind/fastdeploy_runtime.cc to pybind/runtime.cc (#273) * fix yaml * Rename pybind/fastdeploy_runtime.cc to runtime.cc --- examples/runtime/python/infer_onnx_openvino.py | 3 ++- examples/runtime/python/infer_onnx_tensorrt.py | 3 ++- fastdeploy/pybind/{fastdeploy_runtime.cc => runtime.cc} | 0 fastdeploy/runtime.cc | 8 ++++---- fastdeploy/runtime.h | 2 +- python/fastdeploy/__init__.py | 2 +- python/fastdeploy/runtime.py | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-) rename fastdeploy/pybind/{fastdeploy_runtime.cc => runtime.cc} (100%) diff --git a/examples/runtime/python/infer_onnx_openvino.py b/examples/runtime/python/infer_onnx_openvino.py index 9c30c1601..12d6aef67 100644 --- a/examples/runtime/python/infer_onnx_openvino.py +++ b/examples/runtime/python/infer_onnx_openvino.py @@ -13,6 +13,7 @@ # limitations under the License. import fastdeploy as fd +from fastdeploy import ModelFormat import numpy as np # 下载模型并解压 @@ -21,7 +22,7 @@ fd.download(model_url, path=".") option = fd.RuntimeOption() -option.set_model_path("mobilenetv2.onnx", model_format="onnx") +option.set_model_path("mobilenetv2.onnx", model_format=ModelFormat.ONNX) option.use_openvino_backend() diff --git a/examples/runtime/python/infer_onnx_tensorrt.py b/examples/runtime/python/infer_onnx_tensorrt.py index 76c73beef..7dc0f05aa 100644 --- a/examples/runtime/python/infer_onnx_tensorrt.py +++ b/examples/runtime/python/infer_onnx_tensorrt.py @@ -13,6 +13,7 @@ # limitations under the License. import fastdeploy as fd +from fastdeploy import ModelFormat import numpy as np # 下载模型并解压 @@ -21,7 +22,7 @@ fd.download(model_url, path=".") option = fd.RuntimeOption() -option.set_model_path("mobilenetv2.onnx", model_format="onnx") +option.set_model_path("mobilenetv2.onnx", model_format=ModelFormat.ONNX) # **** GPU 配置 *** option.use_gpu(0) diff --git a/fastdeploy/pybind/fastdeploy_runtime.cc b/fastdeploy/pybind/runtime.cc similarity index 100% rename from fastdeploy/pybind/fastdeploy_runtime.cc rename to fastdeploy/pybind/runtime.cc diff --git a/fastdeploy/runtime.cc b/fastdeploy/runtime.cc index 9f876ed00..dc600c46d 100644 --- a/fastdeploy/runtime.cc +++ b/fastdeploy/runtime.cc @@ -139,16 +139,16 @@ ModelFormat GuessModelFormat(const std::string& model_file) { void RuntimeOption::SetModelPath(const std::string& model_path, const std::string& params_path, - const std::string& _model_format) { - if (_model_format == "paddle") { + const ModelFormat& format) { + if (format == ModelFormat::PADDLE) { model_file = model_path; params_file = params_path; model_format = ModelFormat::PADDLE; - } else if (_model_format == "onnx") { + } else if (format == ModelFormat::ONNX) { model_file = model_path; model_format = ModelFormat::ONNX; } else { - FDASSERT(false, "The model format only can be 'paddle' or 'onnx'."); + FDASSERT(false, "The model format only can be ModelFormat::PADDLE/ModelFormat::ONNX."); } } diff --git a/fastdeploy/runtime.h b/fastdeploy/runtime.h index 65585efec..84efdc4c8 100644 --- a/fastdeploy/runtime.h +++ b/fastdeploy/runtime.h @@ -43,7 +43,7 @@ struct FASTDEPLOY_DECL RuntimeOption { // model_format support 'paddle' / 'onnx' now. void SetModelPath(const std::string& model_path, const std::string& params_path = "", - const std::string& _model_format = "paddle"); + const ModelFormat& format = ModelFormat::PADDLE); // set model inference in GPU void UseCpu(); diff --git a/python/fastdeploy/__init__.py b/python/fastdeploy/__init__.py index 657a6cf40..ccb740abd 100644 --- a/python/fastdeploy/__init__.py +++ b/python/fastdeploy/__init__.py @@ -18,7 +18,7 @@ import sys from .c_lib_wrap import (ModelFormat, Backend, FDDataType, TensorInfo, Device, FDTensor, is_built_with_gpu, is_built_with_ort, - is_built_with_paddle, is_built_with_trt, + ModelFormat, is_built_with_paddle, is_built_with_trt, get_default_cuda_directory) from .runtime import Runtime, RuntimeOption diff --git a/python/fastdeploy/runtime.py b/python/fastdeploy/runtime.py index 42d5ac62e..2a6edbdf6 100644 --- a/python/fastdeploy/runtime.py +++ b/python/fastdeploy/runtime.py @@ -55,7 +55,7 @@ class RuntimeOption: self._option = C.RuntimeOption() def set_model_path(self, model_path, params_path="", - model_format="paddle"): + model_format=C.ModelFormat.PADDLE): return self._option.set_model_path(model_path, params_path, model_format)