Skip to content
fn

absorbs_phantom_write

→bool
bool absorbs_phantom_write(const int & dst, const int & src, int op)

The one write rule for phantom storage, at every place a write lands — TensorImpl's copy_from / write_through / take_storage_from, write_elements (an optimizer's or BatchNorm's in-place update), accumulate_into and a leaf's first gradient, an assigned .grad.

Returns

bool

true when dst is a phantom: it takes any write and keeps no values, so the caller writes nothing (and moves the version where a write would). false for an ordinary write between real storages.

Raises

LucidError
dst is real and src a phantom. The phantom has no values to give, and taking it in place of the real values would turn a tensor made outside the block into a phantom in silence.