fill
Static/Dynamic fills.
Every tensor has a fill value: the background value of a sparse tensor, and the value a newly constructed tensor is filled with. The fill value belongs to the tensor, and the tensor's format records whether a kernel may specialize on it:
StaticFillFType-- compile against this value, which is part of the format. It may be folded into generated code. Its values areStaticFills.DynamicFillFType-- do not compile against the value, so only its element type is part of the format. The value may change across invocations, so one compiled kernel serves every fill of the same element type. Its values areDynamicFills.
AbstractFill
¶
Bases: FTyped[AbstractFillFType], ABC
A tensor's fill value. Its ftype says whether kernels may specialize on it.
Source code in src/finch/algebra/fill.py
AbstractFillFType
¶
The fill of a format: the element type of its fill, and whether kernels may specialize on the value of the fill.
Source code in src/finch/algebra/fill.py
DynamicFill
¶
Bases: AbstractFill
A fill value which kernels must not specialize on. The value is known and is bound to the kernel at call time.
Equality and hashing are by element type only, i.e. two equal
DynamicFills may have different .value's.
Source code in src/finch/algebra/fill.py
DynamicFillError
¶
Bases: Exception
Raised when a fill value must be specialized on at compile time but the fill is Dynamic. Callers may catch this to fall back to value-specialized compilation.
DynamicFillFType
¶
Bases: AbstractFillFType
The fill of a format which kernels must not specialize on, so only its element type is part of the format. Each tensor holds its own fill value, which is bound to the kernel at call time.
Source code in src/finch/algebra/fill.py
StaticFill
¶
Bases: AbstractFill
A fill value which kernels may specialize on. Equality and hashing are by
value, matching StaticFillFType.
Source code in src/finch/algebra/fill.py
StaticFillFType
¶
Bases: AbstractFillFType
The fill of a format which kernels may specialize on, so its value is part of the format. Equality and hashing are by element type and value, so formats with different static fills are distinct and get distinct kernels.
Source code in src/finch/algebra/fill.py
apply_fill(op, *fills)
¶
Compute the fill value of mapping op over tensors with fills fills.
A fill stays static only while its value is one the algebra can act on. Combining static fills computes an arbitrary value -- adding 1 repeatedly walks a fill through 1, 2, 3, ... -- and a static fill is compared by value, so keeping those static would key a kernel per distinct value and make a loop cost a compilation per iteration.
Source code in src/finch/algebra/fill.py
apply_fill_type(op, *fill_types)
¶
The fill of the format which results from mapping op over tensors whose
formats have the fills fill_types. This is the format of apply_fill.
Source code in src/finch/algebra/fill.py
as_fill(fill)
¶
Normalize a raw value to a StaticFill, passing an AbstractFill through.
resolve_fill(fill_type, fill=None)
¶
The fill of a new tensor of a format whose fill is fill_type. A given
fill takes the element type of the format, and decides whether the fill of
the new tensor is dynamic. Otherwise the fill of the format must be static.