void* Utils::CopyDataHostToDvpp(void* data, int size) { void* buffer = nullptr; auto aclRet = acldvppMalloc(&buffer, size); if (aclRet != ACL_SUCCESS) { ERROR_LOG("acl malloc dvpp data failed, dataSize=%u, ret=%d", size, aclRet); return nullptr; } // INFO_LOG("malloc dvpp memory size %d ok", size); // copy input to device memory aclRet = aclrtMemcpy(buffer, size, data, size, ACL_MEMCPY_HOST_TO_DEVICE); if (aclRet != ACL_SUCCESS) { ERROR_LOG("acl memcpy data to dvpp failed, size %u, error %d", size, aclRet); acldvppFree(buffer); return nullptr; } // INFO_LOG("copy data to dvpp ok"); return buffer; }中申请的内存空间不用释放么
时间: 2024-01-16 18:03:09 浏览: 147
在这个函数中,确实需要释放申请的内存空间。可以在调用该函数的代码中,使用acldvppFree函数来释放内存空间,例如:
```c++
void* data = // some data on host;
int size = // size of the data;
void* dvppData = Utils::CopyDataHostToDvpp(data, size);
// use dvppData for some DVPP operation
acldvppFree(dvppData); // release the memory space on DVPP device
```
这样可以保证程序在使用完DVPP设备上的内存后,能够正确地释放该内存。
阅读全文