gt4py.storage package
Submodules
gt4py.storage.interface module
- gt4py.storage.interface.dace_descriptor(shape: typing.Sequence[int], dtype: typing.Union[numpy.dtype[typing.Any], None, typing.Type[typing.Any], numpy._typing._dtype_like._SupportsDType[numpy.dtype[typing.Any]], str, typing.Tuple[typing.Any, int], typing.Tuple[typing.Any, typing.Union[typing.SupportsIndex, typing.Sequence[typing.SupportsIndex]]], typing.List[typing.Any], numpy._typing._dtype_like._DTypeDict, typing.Tuple[typing.Any, typing.Any]] = <class 'numpy.float64'>, *, backend: str, aligned_index: typing.Optional[typing.Sequence[int]] = None, dimensions: typing.Optional[typing.Sequence[str]] = None) dace.data.Array[source]
- Return a DaCe data descriptor which describes performance-optimal strides and alignment. - Parameters
- shape (Sequence of int) – The shape of the resulting data descriptor. 
- dtype (DTypeLike, optional) – The dtype encoded in the resulting data descriptor. 
 
- Keyword Arguments
- backend (str) – The target backend for which the described allocation is optimized. 
- aligned_index (Sequence of int, optional) – Indicate the index of the resulting array that most commonly corresponds to the origin of the compute domain. If not passed, it is aligned at the data origin. 
- dimensions (Sequence of str, optional) – Indicate the semantic meaning of the dimensions in the data descriptor. Only used for determining optimal strides, the information is not stored. 
 
- Returns
- With strides that encode padding and aligned to provide optimal performance for the given backend and aligned_index 
- Return type
- DaCe data descriptor 
- Raises
- TypeError – If arguments of an unexpected type are specified. 
- ValueError – If illegal or inconsistent arguments are specified. 
 
 
- gt4py.storage.interface.empty(shape: typing.Sequence[int], dtype: typing.Union[numpy.dtype[typing.Any], None, typing.Type[typing.Any], numpy._typing._dtype_like._SupportsDType[numpy.dtype[typing.Any]], str, typing.Tuple[typing.Any, int], typing.Tuple[typing.Any, typing.Union[typing.SupportsIndex, typing.Sequence[typing.SupportsIndex]]], typing.List[typing.Any], numpy._typing._dtype_like._DTypeDict, typing.Tuple[typing.Any, typing.Any]] = <class 'numpy.float64'>, *, backend: str, aligned_index: typing.Optional[typing.Sequence[int]] = None, dimensions: typing.Optional[typing.Sequence[str]] = None) Union[numpy.ndarray, cp.ndarray][source]
- Allocate an array of uninitialized (undefined) values with performance-optimal strides and alignment. - Parameters
- shape (Sequence of int) – The shape of the resulting ndarray 
- dtype (DTypeLike, optional) – The dtype of the resulting ndarray 
 
- Keyword Arguments
- backend (str) – The target backend for which the allocation is optimized. 
- aligned_index (Sequence of int, optional) – Indicate the index of the resulting array that most commonly corresponds to the origin of the compute domain. If not passed, it is aligned at the data origin. 
- dimensions (Sequence of str, optional) – Indicate the semantic meaning of the dimensions in the provided array. Only used for determining optimal strides, the information is not stored. 
 
- Returns
- With uninitialized values, padded and aligned to provide optimal performance for the given backend and aligned_index 
- Return type
- NumPy or CuPy ndarray 
- Raises
- TypeError – If arguments of an unexpected type are specified. 
- ValueError – If illegal or inconsistent arguments are specified. 
 
 
- gt4py.storage.interface.from_array(data: typing.Union[numpy._typing._array_like._SupportsArray[numpy.dtype], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[typing.Union[bool, int, float, complex, str, bytes]]], dtype: typing.Union[numpy.dtype[typing.Any], None, typing.Type[typing.Any], numpy._typing._dtype_like._SupportsDType[numpy.dtype[typing.Any]], str, typing.Tuple[typing.Any, int], typing.Tuple[typing.Any, typing.Union[typing.SupportsIndex, typing.Sequence[typing.SupportsIndex]]], typing.List[typing.Any], numpy._typing._dtype_like._DTypeDict, typing.Tuple[typing.Any, typing.Any]] = <class 'numpy.float64'>, *, backend: str, aligned_index: typing.Optional[typing.Sequence[int]] = None, dimensions: typing.Optional[typing.Sequence[str]] = None) Union[numpy.ndarray, cp.ndarray][source]
- Allocate an array with values initialized to those of data with performance-optimal strides and alignment. - This copies the values from data to the resulting buffer. - Parameters
- data (ArrayLike) – Source data to be copied, from which also the shape of the result is derived. 
- dtype (DTypeLike, optional) – The dtype of the resulting ndarray 
 
- Keyword Arguments
- backend (str) – The target backend for which the allocation is optimized. 
- aligned_index (Sequence of int, optional) – Indicate the index of the resulting array that most commonly corresponds to the origin of the compute domain. If not passed, it is aligned at the data origin. 
- dimensions (Sequence of str, optional) – Indicate the semantic meaning of the dimensions in the provided array. Only used for determining optimal strides, the information is not stored. 
 
- Returns
- Copy of data, padded and aligned to provide optimal performance for the given backend and aligned_index 
- Return type
- NumPy or CuPy ndarray 
- Raises
- TypeError – If arguments of an unexpected type are specified. 
- ValueError – If illegal or inconsistent arguments are specified. 
 
 
- gt4py.storage.interface.full(shape: typing.Sequence[int], fill_value: numbers.Number, dtype: typing.Union[numpy.dtype[typing.Any], None, typing.Type[typing.Any], numpy._typing._dtype_like._SupportsDType[numpy.dtype[typing.Any]], str, typing.Tuple[typing.Any, int], typing.Tuple[typing.Any, typing.Union[typing.SupportsIndex, typing.Sequence[typing.SupportsIndex]]], typing.List[typing.Any], numpy._typing._dtype_like._DTypeDict, typing.Tuple[typing.Any, typing.Any]] = <class 'numpy.float64'>, *, backend: str, aligned_index: typing.Optional[typing.Sequence[int]] = None, dimensions: typing.Optional[typing.Sequence[str]] = None) Union[numpy.ndarray, cp.ndarray][source]
- Allocate an array with values initialized to fill_value with performance-optimal strides and alignment. - Parameters
- shape (Sequence of int) – The shape of the resulting ndarray 
- fill_value (numbers.Number) – The value to which the array elements are initialized. 
- dtype (DTypeLike, optional) – The dtype of the resulting ndarray 
 
- Keyword Arguments
- backend (str) – The target backend for which the allocation is optimized. 
- aligned_index (Sequence of int, optional) – Indicate the index of the resulting array that most commonly corresponds to the origin of the compute domain. If not passed, it is aligned at the data origin. 
- dimensions (Sequence of str, optional) – Indicate the semantic meaning of the dimensions in the provided array. Only used for determining optimal strides, the information is not stored. 
 
- Returns
- Initialized to fill_value, padded and aligned to provide optimal performance for the given backend and aligned_index 
- Return type
- NumPy or CuPy ndarray 
- Raises
- TypeError – If arguments of an unexpected type are specified. 
- ValueError – If illegal or inconsistent arguments are specified. 
 
 
- gt4py.storage.interface.ones(shape: typing.Sequence[int], dtype: typing.Union[numpy.dtype[typing.Any], None, typing.Type[typing.Any], numpy._typing._dtype_like._SupportsDType[numpy.dtype[typing.Any]], str, typing.Tuple[typing.Any, int], typing.Tuple[typing.Any, typing.Union[typing.SupportsIndex, typing.Sequence[typing.SupportsIndex]]], typing.List[typing.Any], numpy._typing._dtype_like._DTypeDict, typing.Tuple[typing.Any, typing.Any]] = <class 'numpy.float64'>, *, backend: str, aligned_index: typing.Optional[typing.Sequence[int]] = None, dimensions: typing.Optional[typing.Sequence[str]] = None) Union[numpy.ndarray, cp.ndarray][source]
- Allocate an array with values initialized to 1.0 with performance-optimal strides and alignment. - Parameters
- shape (Sequence of int) – The shape of the resulting ndarray 
- dtype (DTypeLike, optional) – The dtype of the resulting ndarray 
 
- Keyword Arguments
- backend (str) – The target backend for which the allocation is optimized. 
- aligned_index (Sequence of int, optional) – Indicate the index of the resulting array that most commonly corresponds to the origin of the compute domain. If not passed, it is aligned at the data origin. 
- dimensions (Sequence of str, optional) – Indicate the semantic meaning of the dimensions in the provided array. Only used for determining optimal strides, the information is not stored. 
 
- Returns
- Initialized to 1.0, padded and aligned to provide optimal performance for the given backend and aligned_index 
- Return type
- NumPy or CuPy ndarray 
- Raises
- TypeError – If arguments of an unexpected type are specified. 
- ValueError – If illegal or inconsistent arguments are specified. 
 
 
- gt4py.storage.interface.zeros(shape: typing.Sequence[int], dtype: typing.Union[numpy.dtype[typing.Any], None, typing.Type[typing.Any], numpy._typing._dtype_like._SupportsDType[numpy.dtype[typing.Any]], str, typing.Tuple[typing.Any, int], typing.Tuple[typing.Any, typing.Union[typing.SupportsIndex, typing.Sequence[typing.SupportsIndex]]], typing.List[typing.Any], numpy._typing._dtype_like._DTypeDict, typing.Tuple[typing.Any, typing.Any]] = <class 'numpy.float64'>, *, backend: str, aligned_index: typing.Optional[typing.Sequence[int]] = None, dimensions: typing.Optional[typing.Sequence[str]] = None) Union[numpy.ndarray, cp.ndarray][source]
- Allocate an array with values initialized to 0.0 with performance-optimal strides and alignment. - Parameters
- shape (Sequence of int) – The shape of the resulting ndarray 
- dtype (DTypeLike, optional) – The dtype of the resulting ndarray 
 
- Keyword Arguments
- backend (str) – The target backend for which the allocation is optimized. 
- aligned_index (Sequence of int, optional) – Indicate the index of the resulting array that most commonly corresponds to the origin of the compute domain. If not passed, it is aligned at the data origin. 
- dimensions (Sequence of str, optional) – Indicate the semantic meaning of the dimensions in the provided array. Only used for determining optimal strides, the information is not stored. 
 
- Returns
- Initialized to 0.0, padded and aligned to provide optimal performance for the given backend and aligned_index 
- Return type
- NumPy or CuPy ndarray 
- Raises
- TypeError – If arguments of an unexpected type are specified. 
- ValueError – If illegal or inconsistent arguments are specified. 
 
 
gt4py.storage.layout module
- gt4py.storage.layout.from_name(name: str) Optional[gt4py.storage.layout.LayoutInfo][source]
- gt4py.storage.layout.layout_maker_factory(base_layout: Tuple[int, ...]) Callable[[Tuple[str, ...]], Tuple[int, ...]][source]
- gt4py.storage.layout.make_cuda_layout_map(dimensions: Tuple[str, ...]) Tuple[Optional[int], ...][source]
- gt4py.storage.layout.make_gtcpu_ifirst_layout_map(dimensions: Tuple[str, ...]) Tuple[int, ...][source]
gt4py.storage.utils module
- gt4py.storage.utils.allocate(aligned_index, shape, layout_map, dtype, alignment_bytes, allocate_f)[source]
- gt4py.storage.utils.allocate_cpu(shape: Sequence[int], layout_map: Iterable[Optional[int]], dtype: Union[numpy.dtype[Any], None, Type[Any], numpy._typing._dtype_like._SupportsDType[numpy.dtype[Any]], str, Tuple[Any, int], Tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any], numpy._typing._dtype_like._DTypeDict, Tuple[Any, Any]], alignment_bytes: int, aligned_index: Optional[Sequence[int]]) Tuple[numpy.ndarray, numpy.ndarray][source]
- gt4py.storage.utils.allocate_gpu(shape: Sequence[int], layout_map: Iterable[Optional[int]], dtype: Union[numpy.dtype[Any], None, Type[Any], numpy._typing._dtype_like._SupportsDType[numpy.dtype[Any]], str, Tuple[Any, int], Tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any], numpy._typing._dtype_like._DTypeDict, Tuple[Any, Any]], alignment_bytes: int, aligned_index: Optional[Sequence[int]]) Tuple[cp.ndarray, cp.ndarray][source]
- gt4py.storage.utils.as_cupy(array: Union[cp.ndarray, numpy.ndarray, gt4py.storage.utils.ArrayInterfaceType, gt4py.storage.utils.CudaArrayInterfaceType]) cp.ndarray[source]
- gt4py.storage.utils.as_numpy(array: Union[cp.ndarray, numpy.ndarray, gt4py.storage.utils.ArrayInterfaceType, gt4py.storage.utils.CudaArrayInterfaceType]) numpy.ndarray[source]
- gt4py.storage.utils.cpu_copy(array: Union[numpy.ndarray, cp.ndarray])[source]
- gt4py.storage.utils.get_dims(obj: gt4py.storage.utils.GtDimsInterface) Optional[Tuple[str, ...]][source]
- gt4py.storage.utils.get_origin(obj: gt4py.storage.utils.GtOriginInterface) Optional[Tuple[int, ...]][source]
- gt4py.storage.utils.normalize_storage_spec(aligned_index: Optional[Sequence[int]], shape: Sequence[int], dtype: Union[numpy.dtype[Any], None, Type[Any], numpy._typing._dtype_like._SupportsDType[numpy.dtype[Any]], str, Tuple[Any, int], Tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any], numpy._typing._dtype_like._DTypeDict, Tuple[Any, Any]], dimensions: Optional[Sequence[str]]) Tuple[Sequence[int], Sequence[int], Union[numpy.dtype[Any], None, Type[Any], numpy._typing._dtype_like._SupportsDType[numpy.dtype[Any]], str, Tuple[Any, int], Tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any], numpy._typing._dtype_like._DTypeDict, Tuple[Any, Any]], Tuple[str, ...]][source]
- Normalize the fields of the storage spec in a homogeneous representation. - Returns
- The output tuple fields verify the following semantics:
- aligned_index: tuple of ints with default origin values for the non-masked dimensions 
- shape: tuple of ints with shape values for the non-masked dimensions 
- dtype: scalar numpy.dtype (non-structured and without subarrays) 
- backend: backend identifier string (numpy, gt:cpu_kfirst, gt:gpu, …) 
- dimensions: a tuple of dimension identifier strings 
 
 
- Return type
- tuple(aligned_index, shape, dtype, mask) 
 
Module contents
GridTools storages classes.