mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 17:17:14 +08:00
reuse setStream c++ interface, add set_raw_stream python api
This commit is contained in:
@@ -48,7 +48,10 @@ void BindOption(pybind11::module& m) {
|
|||||||
.def_readwrite("poros_option", &RuntimeOption::poros_option)
|
.def_readwrite("poros_option", &RuntimeOption::poros_option)
|
||||||
.def_readwrite("paddle_infer_option", &RuntimeOption::paddle_infer_option)
|
.def_readwrite("paddle_infer_option", &RuntimeOption::paddle_infer_option)
|
||||||
.def("set_external_stream", &RuntimeOption::SetExternalStream)
|
.def("set_external_stream", &RuntimeOption::SetExternalStream)
|
||||||
.def("set_external_raw_stream", &RuntimeOption::SetExternalRawStream)
|
.def("set_external_raw_stream",
|
||||||
|
[](RuntimeOption& self, size_t external_stream) {
|
||||||
|
self.SetExternalStream(reinterpret_cast<void*>(external_stream));
|
||||||
|
})
|
||||||
.def("set_cpu_thread_num", &RuntimeOption::SetCpuThreadNum)
|
.def("set_cpu_thread_num", &RuntimeOption::SetCpuThreadNum)
|
||||||
.def("use_paddle_backend", &RuntimeOption::UsePaddleBackend)
|
.def("use_paddle_backend", &RuntimeOption::UsePaddleBackend)
|
||||||
.def("use_poros_backend", &RuntimeOption::UsePorosBackend)
|
.def("use_poros_backend", &RuntimeOption::UsePorosBackend)
|
||||||
|
@@ -93,10 +93,6 @@ void RuntimeOption::SetExternalStream(void* external_stream) {
|
|||||||
external_stream_ = external_stream;
|
external_stream_ = external_stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuntimeOption::SetExternalRawStream(size_t external_stream) {
|
|
||||||
external_stream_ = (void*) external_stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RuntimeOption::SetCpuThreadNum(int thread_num) {
|
void RuntimeOption::SetCpuThreadNum(int thread_num) {
|
||||||
FDASSERT(thread_num > 0, "The thread_num must be greater than 0.");
|
FDASSERT(thread_num > 0, "The thread_num must be greater than 0.");
|
||||||
cpu_thread_num = thread_num;
|
cpu_thread_num = thread_num;
|
||||||
|
@@ -105,8 +105,6 @@ struct FASTDEPLOY_DECL RuntimeOption {
|
|||||||
|
|
||||||
void SetExternalStream(void* external_stream);
|
void SetExternalStream(void* external_stream);
|
||||||
|
|
||||||
void SetExternalRawStream(size_t external_stream);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Set number of cpu threads while inference on CPU, by default it will decided by the different backends
|
* @brief Set number of cpu threads while inference on CPU, by default it will decided by the different backends
|
||||||
*/
|
*/
|
||||||
|
@@ -591,10 +591,12 @@ class RuntimeOption:
|
|||||||
replica_num=1,
|
replica_num=1,
|
||||||
available_memory_proportion=1.0,
|
available_memory_proportion=1.0,
|
||||||
enable_half_partial=False):
|
enable_half_partial=False):
|
||||||
logging.warning("`RuntimeOption.set_ipu_config` will be deprecated in v1.2.0, please use `RuntimeOption.paddle_infer_option.set_ipu_config()` instead.")
|
logging.warning(
|
||||||
self._option.paddle_infer_option.set_ipu_config(enable_fp16, replica_num,
|
"`RuntimeOption.set_ipu_config` will be deprecated in v1.2.0, please use `RuntimeOption.paddle_infer_option.set_ipu_config()` instead."
|
||||||
available_memory_proportion,
|
)
|
||||||
enable_half_partial)
|
self._option.paddle_infer_option.set_ipu_config(
|
||||||
|
enable_fp16, replica_num, available_memory_proportion,
|
||||||
|
enable_half_partial)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def poros_option(self):
|
def poros_option(self):
|
||||||
@@ -657,6 +659,11 @@ class RuntimeOption:
|
|||||||
"""
|
"""
|
||||||
return self._option.disable_profiling()
|
return self._option.disable_profiling()
|
||||||
|
|
||||||
|
def set_external_raw_stream(self, cuda_stream):
|
||||||
|
"""Set the external raw stream used by fastdeploy runtime.
|
||||||
|
"""
|
||||||
|
self._option.set_external_raw_stream(cuda_stream)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
attrs = dir(self._option)
|
attrs = dir(self._option)
|
||||||
message = "RuntimeOption(\n"
|
message = "RuntimeOption(\n"
|
||||||
|
Reference in New Issue
Block a user