MCPcopy Create free account
hub / github.com/NVIDIA/cutlass / _todevice

Function _todevice

python/cutlass_cppgen/backend/memory_manager.py:72–89  ·  view source on GitHub ↗

Helper for transferring host data to device memory

(host_data)

Source from the content-addressed store, hash-verified

70
71
72def _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
92def todevice(host_data, dtype=np.float32):

Callers 1

todeviceFunction · 0.85

Calls 2

device_mem_allocFunction · 0.85
to_deviceMethod · 0.45

Tested by

no test coverage detected