@@ -744,7 +744,7 @@ void BindPaddlePredictor(py::module *m) {
744
744
paddle_predictor
745
745
.def (" run" ,
746
746
[](PaddlePredictor &self, const std::vector<PaddleTensor> &inputs) {
747
- #if defined(PADDLE_WITH_CUSTOM_DEVICE) && !defined(PADDLE_NO_PYTHON)
747
+ #if !defined(PADDLE_NO_PYTHON)
748
748
pybind11::gil_scoped_release release;
749
749
#endif
750
750
std::vector<PaddleTensor> outputs;
@@ -755,9 +755,15 @@ void BindPaddlePredictor(py::module *m) {
755
755
.def (" get_output_tensor" , &PaddlePredictor::GetOutputTensor)
756
756
.def (" get_input_names" , &PaddlePredictor::GetInputNames)
757
757
.def (" get_output_names" , &PaddlePredictor::GetOutputNames)
758
- .def (" zero_copy_run" ,
759
- &PaddlePredictor::ZeroCopyRun,
760
- py::arg (" switch_stream" ) = false )
758
+ .def (
759
+ " zero_copy_run" ,
760
+ [](PaddlePredictor &self, bool switch_stream) {
761
+ #if !defined(PADDLE_NO_PYTHON)
762
+ pybind11::gil_scoped_release release;
763
+ #endif
764
+ return self.ZeroCopyRun (switch_stream);
765
+ },
766
+ py::arg (" switch_stream" ) = false )
761
767
.def (" clone" , [](PaddlePredictor &self) { return self.Clone (nullptr ); })
762
768
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
763
769
.def (" clone" ,
@@ -797,7 +803,7 @@ void BindNativePredictor(py::module *m) {
797
803
.def (" run" ,
798
804
[](NativePaddlePredictor &self,
799
805
const std::vector<PaddleTensor> &inputs) {
800
- #if defined(PADDLE_WITH_CUSTOM_DEVICE) && !defined(PADDLE_NO_PYTHON)
806
+ #if !defined(PADDLE_NO_PYTHON)
801
807
pybind11::gil_scoped_release release;
802
808
#endif
803
809
std::vector<PaddleTensor> outputs;
@@ -806,9 +812,15 @@ void BindNativePredictor(py::module *m) {
806
812
})
807
813
.def (" get_input_tensor" , &NativePaddlePredictor::GetInputTensor)
808
814
.def (" get_output_tensor" , &NativePaddlePredictor::GetOutputTensor)
809
- .def (" zero_copy_run" ,
810
- &NativePaddlePredictor::ZeroCopyRun,
811
- py::arg (" switch_stream" ) = false )
815
+ .def (
816
+ " zero_copy_run" ,
817
+ [](NativePaddlePredictor &self, bool switch_stream) {
818
+ #if !defined(PADDLE_NO_PYTHON)
819
+ pybind11::gil_scoped_release release;
820
+ #endif
821
+ return self.ZeroCopyRun (switch_stream);
822
+ },
823
+ py::arg (" switch_stream" ) = false )
812
824
.def (" clone" ,
813
825
[](NativePaddlePredictor &self) { return self.Clone (nullptr ); })
814
826
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
@@ -1132,7 +1144,7 @@ void BindAnalysisPredictor(py::module *m) {
1132
1144
.def (
1133
1145
" run" ,
1134
1146
[](AnalysisPredictor &self, const std::vector<PaddleTensor> &inputs) {
1135
- #if defined(PADDLE_WITH_CUSTOM_DEVICE) && !defined(PADDLE_NO_PYTHON)
1147
+ #if !defined(PADDLE_NO_PYTHON)
1136
1148
pybind11::gil_scoped_release release;
1137
1149
#endif
1138
1150
std::vector<PaddleTensor> outputs;
@@ -1144,9 +1156,15 @@ void BindAnalysisPredictor(py::module *m) {
1144
1156
.def (" get_input_names" , &AnalysisPredictor::GetInputNames)
1145
1157
.def (" get_output_names" , &AnalysisPredictor::GetOutputNames)
1146
1158
.def (" get_input_tensor_shape" , &AnalysisPredictor::GetInputTensorShape)
1147
- .def (" zero_copy_run" ,
1148
- &AnalysisPredictor::ZeroCopyRun,
1149
- py::arg (" switch_stream" ) = false )
1159
+ .def (
1160
+ " zero_copy_run" ,
1161
+ [](AnalysisPredictor &self, bool switch_stream) {
1162
+ #if !defined(PADDLE_NO_PYTHON)
1163
+ pybind11::gil_scoped_release release;
1164
+ #endif
1165
+ return self.ZeroCopyRun (switch_stream);
1166
+ },
1167
+ py::arg (" switch_stream" ) = false )
1150
1168
.def (" clear_intermediate_tensor" ,
1151
1169
&AnalysisPredictor::ClearIntermediateTensor)
1152
1170
.def (" try_shrink_memory" , &AnalysisPredictor::TryShrinkMemory)
@@ -1185,7 +1203,7 @@ void BindPaddleInferPredictor(py::module *m) {
1185
1203
" run" ,
1186
1204
[](paddle_infer::Predictor &self,
1187
1205
const std::vector<paddle::Tensor> &in_tensor_list) {
1188
- #if defined(PADDLE_WITH_CUSTOM_DEVICE) && !defined(PADDLE_NO_PYTHON)
1206
+ #if !defined(PADDLE_NO_PYTHON)
1189
1207
pybind11::gil_scoped_release release;
1190
1208
#endif
1191
1209
std::vector<paddle::Tensor> outputs;
@@ -1195,7 +1213,7 @@ void BindPaddleInferPredictor(py::module *m) {
1195
1213
py::arg (" inputs" ))
1196
1214
.def (" run" ,
1197
1215
[](paddle_infer::Predictor &self) {
1198
- #if defined(PADDLE_WITH_CUSTOM_DEVICE) && !defined(PADDLE_NO_PYTHON)
1216
+ #if !defined(PADDLE_NO_PYTHON)
1199
1217
pybind11::gil_scoped_release release;
1200
1218
#endif
1201
1219
self.Run ();
0 commit comments