full(size: _int | list[_int] | tuple[_int, ...], fill_value: _complex, dtype: DTypeLike = None, device: DeviceLike = None, requires_grad: _bool = False)Implementing kernel
C++ engine symbols that back this Python API.Return a tensor filled with a constant scalar value.
Every element of the output equals fill_value:
where is fill_value. This is a generalisation of zeros
() and ones () to an arbitrary constant.
Parameters
sizeint or list[int] or tuple[int, ...]*size varargs of
zeros / ones, this is a single positional argument, so
multi-dimensional shapes must be passed as a list or tuple:
full((2, 3), 7.0).fill_valuebool, int, float or complexdtype: an integer keeps every digit (the
fill does not pass through a double) and a complex keeps its
imaginary part. A complex value into a real dtype raises
TypeError, a non-finite float into an integer dtype
ValueError, and an integer outside dtype's range
OverflowError.dtypelucid.dtypeNone, inferred from fill_value
(integers → int64, floats → the global default float dtype).devicestr or lucid.device"cpu" or "metal".requires_gradboolTrue, downstream operations are tracked by autograd.
Default: False.Returns
TensorConstant tensor of shape size filled with fill_value.
Notes
Every output element is assigned fill_value exactly — there is no
broadcasting needed once the scalar reaches the engine. When
dtype is omitted, the type is inferred from the Python type of
fill_value: int literals promote to int64 and float
literals to the global default floating dtype (lucid.float32 by
default). If fill_value is a 0-d tensor (Tensor of shape
()), its scalar value is extracted via Tensor.item and
broadcast across the full tensor; element-wise broadcasting from a
larger tensor is not supported here (use lucid.broadcast_to
instead).
Examples
>>> import lucid
>>> lucid.full((2, 3), 3.14).shape
(2, 3)
>>> lucid.full(4, -1.0).tolist()
[-1.0, -1.0, -1.0, -1.0]
Mask of a fixed value (e.g. $-\infty$ for attention masking):
>>> mask = lucid.full((4, 4), float("-inf"))
Integers past $2^{53}$ and complex values are stored exactly:
>>> lucid.full((1,), 2**60 + 1, dtype=lucid.int64).item()
1152921504606846977
>>> lucid.full((2,), 2 + 3j, dtype=lucid.complex64).tolist()
[(2+3j), (2+3j)]