CopyToNpuSync
Function Usage
Copies data from the host to the device synchronously. The data copy is completed in blocking mode and will not be placed in the executor task queue. The device memory allocated in this API needs to be freed by the caller.
Prototype
const aclTensor *CopyToNpuSync(const aclTensor *src, aclOpExecutor *executor)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
src |
Input |
Data to be copied from the host to the device. |
executor |
Input |
Operator executor object declared by the L2 first-phase API. |
Returns
aclTensor that points to the data copied to the device. If the task fails to be created, nullptr is returned.
Constraints
The input parameter pointer must not be null.
Example
1 2 3 4 5 6 | // Initialize a tensor on the host and copy it to the device (dst is a tensor on the device). void Func(aclOpExecutor *executor) { int64_t myArray[10]; auto src = executor->ConvertToTensor(myArray, 10, DT_INT64); auto dst = CopyToNpuSync(src, executor); } |
Parent topic: framework_op