From a043d361d8f454b649ee635e83da955512e40d72 Mon Sep 17 00:00:00 2001 From: csy0225 <78470701+csy0225@users.noreply.github.com> Date: Tue, 4 Apr 2023 09:52:05 +0800 Subject: [PATCH] [XPU] GetExecStream supports XPU (#52466) --- paddle/fluid/inference/api/analysis_predictor.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/inference/api/analysis_predictor.cc b/paddle/fluid/inference/api/analysis_predictor.cc index ce47e9ff5e4..b4c35e82c6e 100644 --- a/paddle/fluid/inference/api/analysis_predictor.cc +++ b/paddle/fluid/inference/api/analysis_predictor.cc @@ -502,14 +502,18 @@ void *AnalysisPredictor::GetExecStream() const { return reinterpret_cast(pool.Get(place_)) ->stream(); } - } else { - return nullptr; } - return nullptr; -#else +#endif +#if defined(PADDLE_WITH_XPU) + if (place_.GetType() == phi::AllocationType::XPU) { + paddle::platform::DeviceContextPool &pool = + paddle::platform::DeviceContextPool::Instance(); + return reinterpret_cast(pool.Get(place_)) + ->stream(); + } +#endif // TODO(inference): Support other backends. return nullptr; -#endif } const void *AnalysisPredictor::GetDeviceContexts() const { -- GitLab