returnn.frontend.const

Constant / full / fill / zeros / ones, etc

returnn.frontend.const.full(*, dims: Sequence[Dim], fill_value: int | float | complex | number | ndarray | bool | str | Tensor, dtype: str | None = None, device: str | None = None, sparse_dim: Dim | None = None, feature_dim: Dim | None = None) Tensor[source]

full, fill, constant.

https://data-apis.org/array-api/latest/API_specification/generated/array_api.full.html

Also see convert_to_tensor().

Parameters:
  • dims – shape

  • fill_value – scalar to fill the tensor

  • dtype

  • device

  • sparse_dim

  • feature_dim

returnn.frontend.const.fill(*, dims: Sequence[Dim], fill_value: int | float | complex | number | ndarray | bool | str | Tensor, dtype: str | None = None, device: str | None = None, sparse_dim: Dim | None = None, feature_dim: Dim | None = None) Tensor[source]

full, fill, constant.

https://data-apis.org/array-api/latest/API_specification/generated/array_api.full.html

Also see convert_to_tensor().

Parameters:
  • dims – shape

  • fill_value – scalar to fill the tensor

  • dtype

  • device

  • sparse_dim

  • feature_dim

returnn.frontend.const.constant(fill_value: int | float | complex | number | ndarray | bool | str, *, dims: Sequence[Dim], dtype: str | None = None, device: str | None = None, sparse_dim: Dim | None = None, feature_dim: Dim | None = None) Tensor[source]

alias to full(), mapping value to fill_value. also see convert_to_tensor()

returnn.frontend.const.zeros(dims: Sequence[Dim], *, dtype: str | None = None, device: str | None = None, sparse_dim: Dim | None = None, feature_dim: Dim | None = None) Tensor[source]

zeros. float by default.

returnn.frontend.const.ones(dims: Sequence[Dim], *, dtype: str | None = None, device: str | None = None, sparse_dim: Dim | None = None, feature_dim: Dim | None = None) Tensor[source]

ones. float by default.

returnn.frontend.const.zeros_like(other: Tensor) Tensor[source]

zeros like other

returnn.frontend.const.ones_like(other: Tensor) Tensor[source]

ones like other