Helper for transferring host data to device memory
(host_data)
| 70 | |
| 71 | |
| 72 | def _todevice(host_data): |
| 73 | """ |
| 74 | Helper for transferring host data to device memory |
| 75 | """ |
| 76 | if cutlass_cppgen.use_rmm: |
| 77 | return rmm.DeviceBuffer.to_device(host_data.tobytes()) |
| 78 | else: |
| 79 | nbytes = len(host_data.tobytes()) |
| 80 | dev_ptr_wrapper = device_mem_alloc(nbytes) |
| 81 | err, = cudart.cudaMemcpy( |
| 82 | dev_ptr_wrapper.ptr, |
| 83 | host_data.__array_interface__['data'][0], |
| 84 | nbytes, |
| 85 | cudart.cudaMemcpyKind.cudaMemcpyHostToDevice |
| 86 | ) |
| 87 | if err != cudart.cudaError_t.cudaSuccess: |
| 88 | raise Exception(f"cudaMemcpy failed with error {err}") |
| 89 | return dev_ptr_wrapper |
| 90 | |
| 91 | |
| 92 | def todevice(host_data, dtype=np.float32): |
no test coverage detected