patterns
ChunkMaskTensor
Bases: PatternTensor
Map n indices to chunks of size b.
shape is (ceil(n / b), n), and row j holds the indices of chunk
j, so that the efficient row-major traversal visits each chunk and then
its indices. The last chunk may be shorter.
Source code in src/finch/tensor/patterns.py
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 | |
FillTensor
Bases: OverrideTensor
A tensor that has a specific shape but contains no actual data. Used primarily for broadcasting operations where a tensor of a specific shape is needed but the values are irrelevant.
Source code in src/finch/tensor/patterns.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
element_type
property
Data type of the tensor's elements.
fill_value
property
Default fill value.
shape_type
property
Shape type of the tensor.
FillTensorFType
dataclass
Bases: TensorFType
Source code in src/finch/tensor/patterns.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
__call__(val)
Convert a tensor to this fill tensor type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
Any
|
A tensor to convert to this type. |
required |
Returns: A FillTensor instance of this type.
Source code in src/finch/tensor/patterns.py
161 162 163 164 165 166 167 168 169 170 171 172 | |
IndexTensor
Bases: OverrideTensor
A tensor that has a specific shape and returns the linear (flattened) index used to access it.
Source code in src/finch/tensor/patterns.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
element_type
property
Data type of the tensor's elements.
fill_value
property
Default fill value.
shape_type
property
Shape type of the tensor.
IndexTensorFType
dataclass
Bases: TensorFType
Source code in src/finch/tensor/patterns.py
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
__call__(val)
Convert a tensor to this index tensor type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
Any
|
A tensor to convert to this type. |
required |
Returns: An IndexTensor instance of this type.
Source code in src/finch/tensor/patterns.py
102 103 104 105 106 107 108 109 110 111 112 113 | |
RandomMaskTensor
Bases: PatternTensor
A reproducible random mask with true probability p and no stored entries.
shape may be an integer for a vector, or a tuple (including ()).
An omitted seed draws one random 64-bit seed from rng (a new NumPy
generator by default). Reads consume no randomness; a fixed seed and
coordinates give the same value even if the shape changes.
Like Finch.jl, indexed masks mix the seed, then each one-based coordinate
from the first axis to the last, which is Finch.jl's order once the axes
are reversed like other tensors. Scalar masks use the seed directly.
The high 53 bits give a value in [0, 1) that is compared with p.
Source code in src/finch/tensor/patterns.py
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 | |
RepeatTensor
Bases: PatternTensor
Map each of n indices to k repeated indices.
shape is (n, n * k), and row i holds the repeats j of i,
so that the efficient row-major traversal visits each index and then its
repeats. For k <= 0, all entries are false.
Source code in src/finch/tensor/patterns.py
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 | |
SplitMaskTensor
Bases: PatternTensor
Partition n indices into p contiguous regions of nearly equal size.
shape is (p, n), and row j covers n*j//p <= i < n*(j+1)//p,
so that the efficient row-major traversal visits each region and then its
indices.
Source code in src/finch/tensor/patterns.py
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 | |