ut3_apply_masks#
- t3toolbox.backend.ut3_masking.ut3_apply_masks(x)#
def ut3_apply_masks( x: typ.Tuple[ NDArray, # tucker_supercore, shape=(d,)+stack_shape+(n,N) NDArray, # tt_supercore, shape=(d,)+stack_shape+(r,n,r) typ.Sequence[int], # shape = (N0,...,N(d-1)), static int tuple typ.Tuple[ NDArray, # tucker_edge_mask, HOST bool, static NDArray, # tt_edge_mask, HOST bool, static ], ], ) -> typ.Tuple[ NDArray, # masked_tucker_supercore, shape=(d,)+stack_shape+(n,N) NDArray, # masked_tt_supercore, shape=(d,)+stack_shape+(r,n,r) ]:
Zero the padded (“garbage”) regions of the supercores by multiplying through the edge masks.
The mask chokepoint: every mask-using op masks on entry, so the guard here covers the whole layer.
xnp.einsumon the supercore with the numpy mask as a constant operand is fine (jax promotes it). The physicalshape_maskis reconstructed on the host from the staticshapeints (np, neverjnp– a traced mask breaks the layer; seedocs/contributor/uniform_pytree_composition.md).