Skip to content

tensor_stats

StatsFactory

Bases: ABC, Generic[TS]

Source code in src/finch/finch_logic/tensor_stats.py
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
class StatsFactory(ABC, Generic[TS]):
    @abstractmethod
    def __call__(self, tensor: Any, fields: tuple[Field, ...]) -> TS: ...

    @abstractmethod
    def copy(self, stat: TS) -> TS: ...

    def support(self, stat: TS) -> TS:
        """Statistics of the boolean indicator of non-fill entries."""
        # Support preserves the non-fill structure, even for dynamic fills.
        result = self.copy(stat)
        result.fill_type = StaticFillFType(False)
        return result

    @abstractmethod
    def mapjoin(self, op: FinchOperator, *args: TS) -> TS: ...

    @abstractmethod
    def aggregate(
        self,
        op: FinchOperator,
        init: Any | None,
        reduce_indices: tuple[Field, ...],
        stats: TS,
    ) -> TS: ...

    @abstractmethod
    def relabel(self, stats: TS, relabel_indices: tuple[Field, ...]) -> TS: ...

    @abstractmethod
    def reorder(self, stats: TS, reorder_indices: tuple[Field, ...]) -> TS: ...

support(stat)

Statistics of the boolean indicator of non-fill entries.

Source code in src/finch/finch_logic/tensor_stats.py
45
46
47
48
49
50
def support(self, stat: TS) -> TS:
    """Statistics of the boolean indicator of non-fill entries."""
    # Support preserves the non-fill structure, even for dynamic fills.
    result = self.copy(stat)
    result.fill_type = StaticFillFType(False)
    return result

TensorStats

Bases: ABC

Source code in src/finch/finch_logic/tensor_stats.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class TensorStats(ABC):
    @property
    @abstractmethod
    def idxs(self) -> tuple[Field, ...]: ...

    @property
    def index_order(self) -> tuple[Field, ...]:
        return self.idxs

    @property
    @abstractmethod
    def dim_sizes(self) -> MutableMapping[Field, float]: ...

    @property
    @abstractmethod
    def fill_type(self) -> AbstractFillFType:
        """The fill of the tensor's format, which a kernel may depend on."""

    @fill_type.setter
    @abstractmethod
    def fill_type(self, value: AbstractFillFType) -> None: ...

fill_type abstractmethod property writable

The fill of the tensor's format, which a kernel may depend on.