cuda.core.experimental.utils.args_viewable_as_strided_memory

cuda.core.experimental.utils.args_viewable_as_strided_memory(tuple arg_indices)

Decorator to create proxy objects to StridedMemoryView for the specified positional arguments.

This allows array/tensor attributes to be accessed inside the function implementation, while keeping the function body array-library-agnostic (if desired).

Inside the decorated function, the specified arguments become instances of an (undocumented) proxy type, regardless of its original source. A StridedMemoryView instance can be obtained by passing the (consumer) stream pointer (as a Python int) to the proxies’s view() method. For example:

@args_viewable_as_strided_memory((1,))
def my_func(arg0, arg1, arg2, stream: Stream):
    # arg1 can be any object supporting DLPack or CUDA Array Interface
    view = arg1.view(stream.handle)
    assert isinstance(view, StridedMemoryView)
    ...
Parameters:

arg_indices (tuple) – The indices of the target positional arguments.