Skip to content

Commit

Permalink
[XPU]. Fixed the bug in buffer free to wait stream.
Browse files Browse the repository at this point in the history
  • Loading branch information
wbn03 committed Jan 31, 2023
1 parent faa6135 commit f895534
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lite/backends/xpu/xpu_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ class XPUBuffer : public Buffer {
XPUBuffer() {
target_ = TargetType::kXPU;
xpu_l3_cache_block_ = lite::TargetWrapperXPU::CreateL3CacheBlock();
xpu_stream_ = TargetWrapperXPU::get_xpu_stream();
}

void ResetLazy(TargetType target, size_t size) override {
CHECK(target == TargetType::kXPU);
CHECK_EQ(own_data_, true) << "Can not reset unowned buffer.";
if (global_mem_space_ < size) {
if (global_mem_space_ > 0) {
void* xpu_stream = TargetWrapperXPU::get_xpu_stream();
XPU_CALL(xpu_wait(xpu_stream));
xpu_stream_ = TargetWrapperXPU::get_xpu_stream();
XPU_CALL(xpu_wait(xpu_stream_));
XPU_CALL(xpu_free(global_mem_data_));
global_mem_data_ = nullptr;
}
Expand Down

0 comments on commit f895534

Please sign in to comment.