returnn.frontend._numpy_backend
#
Allow to use Numpy arrays. This backend will probably never be feature-complete. It just has the bare minimum such that the user can assign Numpy arrays to Tensor.raw_tensor.
- class returnn.frontend._numpy_backend.NumpyBackend[source]#
Numpy backend
- static get_dtype_name_raw(raw_tensor: ndarray) str [source]#
- Returns:
dtype of raw tensor, as string. e.g. “int64” etc.
- static as_dtype_raw(dtype_name: str) dtype [source]#
- Parameters:
dtype_name – e.g. “float32”
- Returns:
dtype object
- static get_ndim_raw(raw_tensor: ndarray) int [source]#
- Returns:
ndim of raw tensor. assumes it is known
- static get_shape_tuple_raw(raw_tensor: ndarray) Tuple[int] [source]#
- Returns:
shape of raw tensor. assumes that ndim is known. In eager frameworks, all dims are int.
- static get_known_shape_raw(raw_tensor: ndarray) Tuple[int] [source]#
- Returns:
shape of raw tensor, int for static known, None otherwise. assumes that ndim is known. This will not create any ops. In eager frameworks, all dims are known.
- static expand_dims_raw(raw_tensor: ndarray, axis: int) ndarray [source]#
- Parameters:
raw_tensor –
axis – e.g. 1
- Returns:
raw tensor with new axis
- static transpose_raw(raw_tensor: ndarray, perm: Sequence[int]) ndarray [source]#
- Parameters:
raw_tensor –
perm – e.g. [0, 2, 1]
- Returns:
permuted (transposed) raw tensor
- static reshape_raw(raw_tensor: ndarray, shape: Sequence[int | ndarray] | ndarray) ndarray [source]#
reshape raw
- static compare_raw(a: ndarray, kind: str, b: ndarray) ndarray [source]#
- Parameters:
a –
kind – “equal”, “less”, “less_equal”, “greater”, “greater_equal”, “not_equal”
b –
- Returns:
a kind b
- static combine_raw(a: ndarray, kind: str, b: ndarray) ndarray [source]#
- Parameters:
a –
kind – “add”, “sub”, “mul”, “truediv”, “floordiv”, “mod”, “pow”, “maximum”, “minimum”, “logical_and”, “logical_or”, “squared_difference”
b –
- Returns:
a kind b