full
→Tensorfull(size: _int | list[_int] | tuple[_int, ...], fill_value: _float, dtype: DTypeLike = None, device: DeviceLike = None, requires_grad: _bool = False)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_valuefloatdtypelucid.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"))