MCPcopy Create free account
hub / github.com/NVIDIA/DALI / py_buffer_from_address

Function py_buffer_from_address

dali/test/python/test_utils.py:581–596  ·  view source on GitHub ↗
(address, shape, dtype, gpu=False)

Source from the content-addressed store, hash-verified

579
580
581def py_buffer_from_address(address, shape, dtype, gpu=False):
582 import_numpy()
583
584 buff = {"data": (address, False), "shape": tuple(shape), "typestr": np.dtype(dtype).str}
585
586 class py_holder(object):
587 pass
588
589 holder = py_holder()
590 holder.__array_interface__ = buff
591 holder.__cuda_array_interface__ = buff
592 if not gpu:
593 return np.array(holder, copy=False)
594 else:
595 import_cupy()
596 return cp.asanyarray(holder)
597
598
599class check_output_pattern:

Callers 4

test_data_ptr_tensor_gpuFunction · 0.90
test_data_ptr_tensor_cpuFunction · 0.90

Calls 4

py_holderClass · 0.85
import_cupyFunction · 0.85
import_numpyFunction · 0.70
dtypeMethod · 0.45

Tested by

no test coverage detected