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
EyeLevelFType
dataclass
¶
Bases: LevelFType, ImmutableStructFType
The rows (nind == 0) or columns (nind == 1) of an eye tensor.
Source code in src/finch/tensor/patterns.py
607 608 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 637 638 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 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 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 | |
EyeTensorFType
dataclass
¶
Bases: PatternTensorFType, FinchTensorFType, MutableStructFType
An eye tensor is passed to kernels by its shape, so that a kernel may declare it as a workspace with the extents of its loops.
Source code in src/finch/tensor/patterns.py
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 | |
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
FillTensorFType
dataclass
¶
Bases: TensorFType
Source code in src/finch/tensor/patterns.py
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
IndexTensorFType
dataclass
¶
Bases: TensorFType
Source code in src/finch/tensor/patterns.py
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
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
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.