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

[XPU] fixed bug: xpu set stream. #9842

Merged
merged 1 commit into from
Dec 19, 2022
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
2 changes: 1 addition & 1 deletion lite/api/cxx_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class CxxPaddleApiImpl : public lite_api::PaddlePredictor {
lite_api::LiteModelType model_type = lite_api::LiteModelType::kProtobuf,
bool record_info = false) override;

void SetStream(TargetType target, void* stream);
void SetStream(TargetType target, void* stream) override;

private:
std::shared_ptr<Predictor> raw_predictor_;
Expand Down
1 change: 1 addition & 0 deletions lite/api/paddle_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class LITE_API PaddlePredictor {
const std::string& model_dir,
LiteModelType model_type = LiteModelType::kProtobuf,
bool record_info = false);
virtual void SetStream(TargetType target, void* stream) {}

virtual ~PaddlePredictor() = default;

Expand Down
8 changes: 4 additions & 4 deletions lite/backends/xpu/runtime_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ class XPUStream {
public:
XPUStream() {}
~XPUStream() {
if (xpu_stream_ != nullptr) {
if (xpu_stream_origin_ != nullptr) {
XPU_CALL(xpu_set_device(devid_));
VLOG(6) << "thread 0x" << std::hex << std::this_thread::get_id()
<< " Destory context xpu stream: " << xpu_stream_;
CHECK(xpu_stream_destroy(xpu_stream_) == 0)
<< " Destory context xpu stream: " << xpu_stream_origin_;
CHECK(xpu_stream_destroy(xpu_stream_origin_) == 0)
<< "xpu stream destroy failed.";
xpu_stream_ = nullptr;
xpu_stream_origin_ = nullptr;
}
}

Expand Down
4 changes: 4 additions & 0 deletions lite/backends/xpu/target_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ namespace paddle {
namespace lite {

XPUL3CacheBlock* TargetWrapperXPU::CreateL3CacheBlock() {
if (xpu_runtime_ptr == nullptr) {
return nullptr;
}

xpu_runtime_ptr->xpu_l3_block_dict.push_back(new XPUL3CacheBlock());
return xpu_runtime_ptr->xpu_l3_block_dict.back();
}
Expand Down
3 changes: 0 additions & 3 deletions lite/backends/xpu/target_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ class TargetWrapper<TARGET(kXPU)> {
}

if (!xpu_runtime_ptr->xpu_enable_multi_stream) {
CHECK(xpu_runtime_ptr->xpu_stream.GetXPUStream() == nullptr)
<< " xpu default stream should be nullptr: "
<< xpu_runtime_ptr->xpu_stream.GetXPUStream();
VLOG(3) << "all threads share the default xpu stream";
} else {
// use different stream per thread
Expand Down
3 changes: 3 additions & 0 deletions lite/backends/xpu/xpu_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class XPUBuffer : public Buffer {
data_ = global_mem_data_;
space_ = global_mem_space_;
}
} else {
data_ = global_mem_data_;
space_ = global_mem_space_;
}
}

Expand Down