!46622 fix LockRuntime stream nullptr

Merge pull request !46622 from baihuawei/fix_stream_null2.0
This commit is contained in:
i-robot 2022-12-09 08:11:47 +00:00 committed by Gitee
commit 4e04eec424
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 9 additions and 7 deletions

View File

@ -1102,19 +1102,21 @@ bool AscendKernelRuntime::RunTask(const session::KernelGraph &graph) {
bool AscendKernelRuntime::SyncStream() {
SetCurrentContext();
{
if (stream_ != nullptr) {
// cppcheck-suppress unreadVariable
auto lock = device::KernelRuntime::LockRuntime(stream_);
if (stream_ != nullptr && !AscendStreamMng::GetInstance().SyncStream(stream_)) {
if (!AscendStreamMng::GetInstance().SyncStream(stream_)) {
MS_LOG(ERROR) << "Sync default stream failed.";
return false;
}
}
// cppcheck-suppress unreadVariable
auto lock = device::KernelRuntime::LockRuntime(communication_stream_);
if (communication_stream_ != nullptr && !AscendStreamMng::GetInstance().SyncStream(communication_stream_)) {
MS_LOG(ERROR) << "Sync default stream failed.";
return false;
if (communication_stream_ != nullptr) {
// cppcheck-suppress unreadVariable
auto lock = device::KernelRuntime::LockRuntime(communication_stream_);
if (!AscendStreamMng::GetInstance().SyncStream(communication_stream_)) {
MS_LOG(ERROR) << "Sync default stream failed.";
return false;
}
}
return true;
}