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

[Paddle Inference]add_varlen_python_api #57948

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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__ = [ # noqa
Expand Down