diff --git a/paddle/fluid/pybind/inference_api.cc b/paddle/fluid/pybind/inference_api.cc index 3c6d1926d13242ed4b33cf15fcd351f8123b178b..dd9cb65142a3de71fec247185328ebed8c98a03a 100644 --- a/paddle/fluid/pybind/inference_api.cc +++ b/paddle/fluid/pybind/inference_api.cc @@ -543,7 +543,10 @@ void BindAnalysisConfig(py::module *m) { [](AnalysisConfig &self, const std::string &pass) { self.pass_builder()->DeletePass(pass); }) - .def("pass_builder", &AnalysisConfig::pass_builder, + .def("pass_builder", + [](AnalysisConfig &self) { + return dynamic_cast(self.pass_builder()); + }, py::return_value_policy::reference); }