File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -125,11 +125,11 @@ struct XPUContext::Impl {
125125 void Wait () {
126126 backends::xpu::XPUDeviceGuard guard (place_.GetDeviceId ());
127127 PD_CHECK (context_ != nullptr , " the xpu context is nullptr." );
128- xpu_wait (context_->xpu_stream );
128+ PADDLE_ENFORCE_XRE_SUCCESS ( xpu_wait (context_->xpu_stream ) );
129129 xpu::Context* ctx_t = GetXdlCtx ();
130130 if (ctx_t ) {
131131 PD_CHECK (ctx_t != nullptr , " the xpu context is nullptr." );
132- xpu_wait (ctx_t ->xpu_stream );
132+ PADDLE_ENFORCE_XRE_SUCCESS ( xpu_wait (ctx_t ->xpu_stream ) );
133133 }
134134
135135 ClearStashedMemory ();
@@ -220,7 +220,7 @@ struct XPUContext::Impl {
220220 void SetXContext (xpu::Context* context) {
221221 if (context_ != nullptr ) {
222222 backends::xpu::XPUDeviceGuard guard (place_.GetDeviceId ());
223- xpu_wait (context_->xpu_stream );
223+ PADDLE_ENFORCE_XRE_SUCCESS ( xpu_wait (context_->xpu_stream ) );
224224 if (context_->xpu_stream != nullptr && stream_owned_) {
225225 xpu_stream_destroy (context_->xpu_stream );
226226 stream_owned_ = false ;
Original file line number Diff line number Diff line change 2323#include " paddle/phi/backends/xpu/xpu_header.h"
2424#include " paddle/phi/backends/xpu/xpu_info.h"
2525#include " paddle/phi/common/place.h"
26+ #include " paddle/phi/core/memory/memory.h"
2627#include " paddle/phi/core/platform/device/device_wrapper.h"
2728#include " paddle/phi/core/platform/device_context.h"
2829#include " paddle/phi/core/platform/lock_guard_ptr.h"
@@ -162,6 +163,7 @@ class RecordedXPUMallocHelper {
162163 auto result = xpu_malloc (ptr, size);
163164 if (result == XPU_SUCCESS) {
164165 cur_size_.fetch_add (size);
166+ DEVICE_MEMORY_STAT_UPDATE (Reserved, dev_id_, size);
165167 return result;
166168 } else {
167169 RaiseNonOutOfMemoryError (result);
@@ -183,6 +185,7 @@ class RecordedXPUMallocHelper {
183185 dev_ctx->Wait ();
184186 xpu_free (ptr);
185187 cur_size_.fetch_sub (size);
188+ DEVICE_MEMORY_STAT_UPDATE (Reserved, dev_id_, -size);
186189 }
187190
188191 inline bool NeedRecord () const { return limit_size_ != 0 ; }
You can’t perform that action at this time.
0 commit comments