!35156 Return true when copy size is 0

Merge pull request !35156 from liangzelang/dev_master
This commit is contained in:
i-robot 2022-05-31 08:25:44 +00:00 committed by Gitee
commit 3c07413969
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 4 additions and 4 deletions

View File

@ -1075,6 +1075,10 @@ bool AscendKernelRuntime::SyncStream() {
bool AscendKernelRuntime::MemcpyAsync(void *dst, const void *src, uint64_t size, int32_t kind) {
SetCurrentContext();
if (size == 0) {
MS_LOG(DEBUG) << "rtMemcpyAsync size is 0, copy kind:" << kind;
return true;
}
if (stream_ == nullptr) {
MS_LOG(ERROR) << "MemcpyAsync failed. stream_ is nullptr";
return false;
@ -1092,10 +1096,6 @@ bool AscendKernelRuntime::MemcpyAsync(void *dst, const void *src, uint64_t size,
MS_LOG(ERROR) << "rtMemcpyAsync src ptr is null, copy kind:" << kind;
return false;
}
if (size == 0) {
MS_LOG(ERROR) << "rtMemcpyAsync size is 0, copy kind:" << kind;
return false;
}
// cppcheck-suppress unreadVariable
auto lock = device::KernelRuntime::LockRuntime(stream_);
if (RT_ERROR_NONE != rtMemcpyAsync(dst, size, src, size, static_cast<rtMemcpyKind_t>(kind), stream_)) {