A fixed-size multi-dimensional array containing values of the same type. Attributes: dtype (DType): The data type of the array. ndim (int): The number of array dimensions. size (int): The number of items in the array. capacity (int): The amount of memory in bytes
| 3042 | |
| 3043 | |
| 3044 | class array(Array[DType, NDim]): |
| 3045 | """A fixed-size multi-dimensional array containing values of the same type. |
| 3046 | |
| 3047 | Attributes: |
| 3048 | dtype (DType): The data type of the array. |
| 3049 | ndim (int): The number of array dimensions. |
| 3050 | size (int): The number of items in the array. |
| 3051 | capacity (int): The amount of memory in bytes allocated for this array. |
| 3052 | shape (tuple[int]): Dimensions of the array. |
| 3053 | strides (tuple[int]): Number of bytes in each dimension between successive elements of the array. |
| 3054 | ptr (int): Pointer to underlying memory allocation backing the array. |
| 3055 | device (Device): The device where the array's memory allocation resides. |
| 3056 | pinned (bool): Indicates whether the array was allocated in pinned host memory. |
| 3057 | is_contiguous (bool): Indicates whether this array has a contiguous memory layout. |
| 3058 | deleter (Callable[[int, int], None]): A function to be called when the array is deleted, |
| 3059 | taking two arguments: pointer and size. If ``None``, then no function is called. |
| 3060 | """ |
| 3061 | |
| 3062 | @classmethod |
| 3063 | def __class_getitem__(cls, params): |
| 3064 | """Support ``wp.array[dtype]`` and ``wp.array[dtype, Literal[ndim]]`` syntax.""" |
| 3065 | return _parse_array_subscript(cls, params) |
| 3066 | |
| 3067 | def __new__(cls, *args, **kwargs): |
| 3068 | instance = super().__new__(cls) |
| 3069 | instance.deleter = None |
| 3070 | return instance |
| 3071 | |
| 3072 | def __init__( |
| 3073 | self, |
| 3074 | data: list | tuple | npt.NDArray | None = None, |
| 3075 | dtype: Any = Any, |
| 3076 | shape: int | tuple[int, ...] | list[int] | None = None, |
| 3077 | strides: tuple[int, ...] | None = None, |
| 3078 | ptr: int | None = None, |
| 3079 | capacity: int | None = None, |
| 3080 | device: warp.DeviceLike = None, |
| 3081 | pinned: builtins.bool = False, |
| 3082 | copy: builtins.bool = True, |
| 3083 | deleter: Callable[[int, int], None] | None = None, |
| 3084 | ndim: int | None = None, |
| 3085 | grad: array | None = None, |
| 3086 | requires_grad: builtins.bool = False, |
| 3087 | retain_grad: builtins.bool = False, |
| 3088 | ): |
| 3089 | """Construct a new Warp array object. |
| 3090 | |
| 3091 | When the ``data`` argument is a valid list, tuple, or ndarray the array will be constructed from this object's data. |
| 3092 | For objects that are not stored sequentially in memory (e.g.: a list), then the data will first |
| 3093 | be flattened before being transferred to the memory space given by device. |
| 3094 | |
| 3095 | The second construction path occurs when the ``ptr`` argument is a non-zero uint64 value representing the |
| 3096 | start address in memory where existing array data resides, e.g.: from an external or C-library. The memory |
| 3097 | allocation should reside on the same device given by the device argument, and the user should set the length |
| 3098 | and dtype parameter appropriately. |
| 3099 | |
| 3100 | If neither ``data`` nor ``ptr`` are specified, the ``shape`` argument is checked next. |
| 3101 | This construction path can be used to create new uninitialized arrays, but users are encouraged to call |
no outgoing calls
no test coverage detected