Skip to content

Commit

Permalink
[Paddle Inference]add_varlen_python_api (PaddlePaddle#57948)
Browse files Browse the repository at this point in the history
* add_varlen_python_api
  • Loading branch information
Wangzheee authored Oct 10, 2023
1 parent 712cfc7 commit 5cf90f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions paddle/fluid/pybind/inference_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ using paddle::PaddlePredictor;
using paddle::PaddleTensor;
using paddle::PassStrategy;
using paddle::ZeroCopyTensor;
using paddle_infer::experimental::InternalUtils;

namespace {
void BindPaddleDType(py::module *m);
Expand All @@ -116,6 +117,7 @@ void BindPaddlePassBuilder(py::module *m);
void BindPaddleInferPredictor(py::module *m);
void BindPaddleInferTensor(py::module *m);
void BindPredictorPool(py::module *m);
void BindInternalUtils(py::module *m);

#ifdef PADDLE_WITH_DNNL
void BindMkldnnQuantizerConfig(py::module *m);
Expand Down Expand Up @@ -509,6 +511,7 @@ void BindInferenceApi(py::module *m) {
BindPaddleInferTensor(m);
BindPaddlePassBuilder(m);
BindPredictorPool(m);
BindInternalUtils(m);
#ifdef PADDLE_WITH_DNNL
BindMkldnnQuantizerConfig(m);
#endif
Expand Down Expand Up @@ -1304,6 +1307,19 @@ void BindPaddlePassBuilder(py::module *m) {
.def("enable_mkldnn_quantizer", &GpuPassStrategy::EnableMkldnnQuantizer)
.def("enable_mkldnn_bfloat16", &GpuPassStrategy::EnableMkldnnBfloat16);
}

void BindInternalUtils(py::module *m) {
py::class_<InternalUtils> internal_utils(*m, "InternalUtils");
internal_utils
.def_static("set_transformer_posid",
[](paddle_infer::Config &config, std::string tensor_name) {
InternalUtils::SetTransformerPosid(&config, tensor_name);
})
.def_static("set_transformer_maskid",
[](paddle_infer::Config &config, std::string tensor_name) {
InternalUtils::SetTransformerMaskid(&config, tensor_name);
});
}
} // namespace
} // namespace pybind
} // namespace paddle
1 change: 1 addition & 0 deletions python/paddle/inference/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
get_num_bytes_of_data_type,
PredictorPool,
XpuConfig,
InternalUtils,
)

__all__ = [
Expand Down

0 comments on commit 5cf90f4

Please sign in to comment.