Skip to content

view(factors, fac_scalar, instance, append=False) ΒΆ

Obtain a zero-copy instance from a vectorized factorization model.

Parameters:

Name Type Description Default
factors list

Factor tensors in the vectorized factorization model.

required
fac_scalar Factorization

A factorization model created from the original, un-vectorized tensor expression

required
instance int

Index along the vectorization dimension.

required
append bool

Indicates whether the vectorization dimension was appended or prepended.

False

Returns:

Type Description
Factorization

A factorization model.

Source code in funfact/vectorization.py
def view(factors, fac_scalar, instance: int, append: bool = False):
    '''Obtain a zero-copy instance from a vectorized factorization model.

    Args:
        factors (list):
            Factor tensors in the vectorized factorization model.
        fac_scalar (Factorization):
            A factorization model created from the original, un-vectorized
            tensor expression
        instance (int):
            Index along the vectorization dimension.
        append (bool):
            Indicates whether the vectorization dimension was appended
            or prepended.

    Returns:
        Factorization:
            A factorization model.
    '''
    indices = tuple([..., instance] if append else [instance, ...])
    for i, f in enumerate(factors):
        fac_scalar.factors[i] = f[indices]
    return fac_scalar
Back to top