Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some compile problem in Linux #41

Merged
merged 20 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7f076e7
Add custom operator for onnxruntime ans fix paddle backend
jiangjiajun Jul 23, 2022
7c07dd0
Merge branch 'develop' of https://github.com/PaddlePaddle/FastDeploy …
jiangjiajun Jul 23, 2022
900a8fe
Polish cmake files and runtime apis
jiangjiajun Jul 24, 2022
f6d66fb
Remove copy libraries
jiangjiajun Jul 24, 2022
a218986
fix some issue
jiangjiajun Jul 24, 2022
e69b051
fix bug
jiangjiajun Jul 24, 2022
dac68cb
fix bug
jiangjiajun Jul 24, 2022
326aa12
Merge branch 'develop' of https://github.com/PaddlePaddle/FastDeploy …
jiangjiajun Jul 25, 2022
a38eef9
Merge branch 'develop' of https://github.com/PaddlePaddle/FastDeploy …
jiangjiajun Jul 25, 2022
7eb9632
Merge branch 'develop' of https://github.com/PaddlePaddle/FastDeploy …
jiangjiajun Jul 26, 2022
8c11c14
Support remove multiclass_nms to enable paddledetection run tensorrt
jiangjiajun Jul 26, 2022
1e5f84f
Support remove multiclass_nms to enable paddledetection run tensorrt
jiangjiajun Jul 26, 2022
5c75bce
Support remove multiclass_nms to enable paddledetection run tensorrt
jiangjiajun Jul 26, 2022
6891b58
Support remove multiclass_nms to enable paddledetection run tensorrt
jiangjiajun Jul 26, 2022
e8765cd
add common operator multiclassnms
jiangjiajun Jul 26, 2022
50a0b39
fix compile problem
Jul 26, 2022
0e55073
fix some compile problem in linux
Jul 26, 2022
d70aa0c
Merge branch 'develop' into ppyoloe
jiangjiajun Jul 26, 2022
59bfad3
remove debug log
Jul 26, 2022
550be89
Merge branch 'ppyoloe' of https://github.com/PaddlePaddle/FastDeploy …
Jul 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ else()
set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS_RELEASE -s)
endif()

find_package(OpenMP)
if(OpenMP_CXX_FOUND)
list(APPEND DEPEND_LIBS OpenMP::OpenMP_CXX)
endif()
#find_package(OpenMP)
#if(OpenMP_CXX_FOUND)
# list(APPEND DEPEND_LIBS OpenMP::OpenMP_CXX)
#endif()
set_target_properties(${LIBRARY_NAME} PROPERTIES VERSION ${FASTDEPLOY_VERSION})
target_link_libraries(${LIBRARY_NAME} ${DEPEND_LIBS})

Expand Down
2 changes: 1 addition & 1 deletion VERSION_NUMBER
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.0
0.2.0
69 changes: 66 additions & 3 deletions fastdeploy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
from __future__ import absolute_import
import logging
from .fastdeploy_main import Frontend, Backend, FDDataType, TensorInfo, RuntimeOption, Device
from .fastdeploy_main import Frontend, Backend, FDDataType, TensorInfo, Device
from .fastdeploy_runtime import *
from . import fastdeploy_main as C
from . import vision
Expand All @@ -26,6 +26,71 @@ def TensorInfoStr(tensor_info):
return message


class RuntimeOption:
def __init__(self):
self._option = C.RuntimeOption()

def set_model_path(self, model_path, params_path="", model_format="paddle"):
return self._option.set_model_path(model_path, params_path, model_format)

def use_gpu(self, device_id=0):
return self._option.use_gpu(device_id)

def use_cpu(self):
return self._option.use_cpu()

def set_cpu_thread_num(self, thread_num=8):
return self._option.set_cpu_thread_num(thread_num)

def use_paddle_backend(self):
return self._option.use_paddle_backend()

def use_ort_backend(self):
return self._option.use_ort_backend()

def use_trt_backend(self):
return self._option.use_trt_backend()

def enable_paddle_mkldnn(self):
return self._option.enable_paddle_mkldnn()

def disable_paddle_mkldnn(self):
return self._option.disable_paddle_mkldnn()

def set_paddle_mkldnn_cache_size(self, cache_size):
return self._option.set_paddle_mkldnn_cache_size(cache_size)

def set_trt_input_shape(self, tensor_name, min_shape, opt_shape=None, max_shape=None):
if opt_shape is None and max_shape is None:
opt_shape = min_shape
max_shape = min_shape
else:
assert opt_shape is not None and max_shape is not None, "Set min_shape only, or set min_shape, opt_shape, max_shape both."
return self._option.set_trt_input_shape(tensor_name, min_shape, opt_shape, max_shape)

def set_trt_cache_file(self, cache_file_path):
return self._option.set_trt_cache_file(cache_file_path)

def enable_trt_fp16(self):
return self._option.enable_trt_fp16()

def dissable_trt_fp16(self):
return self._option.disable_trt_fp16()

def __repr__(self):
attrs = dir(self._option)
message = "RuntimeOption(\n"
for attr in attrs:
if attr.startswith("__"):
continue
if hasattr(getattr(self._option, attr), "__call__"):
continue
message += " {} : {}\t\n".format(attr, getattr(self._option, attr))
message.strip("\n")
message += ")"
return message


def RuntimeOptionStr(runtime_option):
attrs = dir(runtime_option)
message = "RuntimeOption(\n"
Expand All @@ -38,7 +103,5 @@ def RuntimeOptionStr(runtime_option):
message.strip("\n")
message += ")"
return message


C.TensorInfo.__repr__ = TensorInfoStr
C.RuntimeOption.__repr__ = RuntimeOptionStr
5 changes: 5 additions & 0 deletions fastdeploy/fastdeploy_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ void RuntimeOption::EnableTrtFP16() { trt_enable_fp16 = true; }

void RuntimeOption::DisableTrtFP16() { trt_enable_fp16 = false; }

void RuntimeOption::SetTrtCacheFile(const std::string& cache_file_path) {
trt_serialize_file = cache_file_path;
}


bool Runtime::Init(const RuntimeOption& _option) {
option = _option;
if (option.model_format == Frontend::AUTOREC) {
Expand Down
6 changes: 2 additions & 4 deletions fastdeploy/fastdeploy_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,14 @@ struct FASTDEPLOY_DECL RuntimeOption {
// disable half precision, change to full precision(float32)
void DisableTrtFP16();

void SetTrtCacheFile(const std::string& cache_file_path);

Backend backend = Backend::UNKNOWN;
// for cpu inference and preprocess
int cpu_thread_num = 8;
int device_id = 0;

#ifdef WITH_GPU
Device device = Device::GPU;
#else
Device device = Device::CPU;
#endif

// ======Only for ORT Backend========
// -1 means use default value by ort
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/fastdeploy_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class FastDeployModel:
def __init__(self, option):
self._model = None
self._runtime_option = option
self._runtime_option = option._option
if self._runtime_option is None:
self._runtime_option = C.RuntimeOption()

Expand Down
1 change: 1 addition & 0 deletions fastdeploy/pybind/fastdeploy_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void BindRuntime(pybind11::module& m) {
.def("set_trt_input_shape", &RuntimeOption::SetTrtInputShape)
.def("enable_trt_fp16", &RuntimeOption::EnableTrtFP16)
.def("disable_trt_fp16", &RuntimeOption::DisableTrtFP16)
.def("set_trt_cache_file", &RuntimeOption::SetTrtCacheFile)
.def_readwrite("model_file", &RuntimeOption::model_file)
.def_readwrite("params_file", &RuntimeOption::params_file)
.def_readwrite("model_format", &RuntimeOption::model_format)
Expand Down
4 changes: 2 additions & 2 deletions fastdeploy/vision/ppdet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def __init__(self,
model_file,
params_file,
config_file,
backend_option=None,
runtime_option=None,
model_format=Frontend.PADDLE):
super(PPYOLOE, self).__init__(backend_option)
super(PPYOLOE, self).__init__(runtime_option)

assert model_format == Frontend.PADDLE, "PPYOLOE only support model format of Frontend.Paddle now."
self._model = C.vision.ppdet.PPYOLOE(model_file, params_file,
Expand Down
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def run(self):
shutil.copy(
os.path.join(".setuptools-cmake-build", f), "fastdeploy/libs")
if f.count("fastdeploy_main.cpython-"):
pybind_so_file = f
pybind_so_file = os.path.join(".setuptools-cmake-build", f)

if not os.path.exists(".setuptools-cmake-build/third_libs/install"):
raise Exception(
Expand All @@ -360,19 +360,18 @@ def run(self):
symlinks=True)

if platform.system().lower() == "linux":
rpaths = ["${ORIGIN}"]
rpaths = ["$ORIGIN:$ORIGIN/libs"]
for root, dirs, files in os.walk(
".setuptools-cmake-build/third_libs/install"):
for d in dirs:
if d == "lib":
path = os.path.relpath(
os.path.join(root, d),
".setuptools-cmake-build/third_libs/install")
rpaths.append("${ORIGIN}/" + os.path.join(
rpaths.append("$ORIGIN/" + os.path.join(
"libs/third_libs", path))
rpaths = ":".join(rpaths)
command = "patchelf --set-rpath '{}' ".format(rpaths) + os.path.join(
"fastdeploy/libs", pybind_so_file)
command = "patchelf --set-rpath '{}' ".format(rpaths) + pybind_so_file
# The sw_64 not suppot patchelf, so we just disable that.
if platform.machine() != 'sw_64' and platform.machine() != 'mips64':
assert os.system(
Expand Down