Memref stream
memref_stream
¶
A target-independent representation of streams of buffers over time.
Currently a higher-level representation of the snitch_stream dialect, operating on
memrefs instead of registers storing pointers.
MemRefStream = Dialect('memref_stream', [ReadOp, WriteOp, StreamingRegionOp, GenericOp, YieldOp, FillOp], [ReadableStreamType, WritableStreamType, IteratorTypeAttr, StridePattern])
module-attribute
¶
ReadableStreamType
dataclass
¶
Bases: ParametrizedAttribute, TypeAttribute, ContainerType[_StreamTypeElement], Generic[_StreamTypeElement]
Source code in xdsl/dialects/memref_stream.py
name = 'memref_stream.readable'
class-attribute
instance-attribute
¶
element_type: _StreamTypeElement
instance-attribute
¶
get_element_type() -> _StreamTypeElement
¶
constr(element_type: AttrConstraint[_StreamTypeElement] = AnyAttr()) -> ParamAttrConstraint[ReadableStreamType[_StreamTypeElement]]
staticmethod
¶
Source code in xdsl/dialects/memref_stream.py
WritableStreamType
dataclass
¶
Bases: ParametrizedAttribute, TypeAttribute, ContainerType[_StreamTypeElement], Generic[_StreamTypeElement]
Source code in xdsl/dialects/memref_stream.py
name = 'memref_stream.writable'
class-attribute
instance-attribute
¶
element_type: _StreamTypeElement
instance-attribute
¶
get_element_type() -> _StreamTypeElement
¶
constr(element_type: AttrConstraint[_StreamTypeElement] = AnyAttr()) -> ParamAttrConstraint[WritableStreamType[_StreamTypeElement]]
staticmethod
¶
Source code in xdsl/dialects/memref_stream.py
IteratorType
¶
Bases: StrEnum
Iterator type for memref_stream Attribute
Source code in xdsl/dialects/memref_stream.py
PARALLEL = auto()
class-attribute
instance-attribute
¶
The corresponding iterators appear in the output.
REDUCTION = auto()
class-attribute
instance-attribute
¶
The corresponding iterators do not appear in the output.
INTERLEAVED = auto()
class-attribute
instance-attribute
¶
All inputs and outputs of the operation will be operated this many times in parallel. This is helpful to circumvent the latency in the loop. For example, if the ALU of the target has a pipeline of length 4, and the operation accumulates its innermost dimension, there will be stalls waiting fof the pipeline to clear in each iteration. By interleaving the loop with a factor of 4, four dimensions can be processed in parallel, removing the stalls. The corresponding iterators may appear in the output.
IteratorTypeAttr
dataclass
¶
Bases: EnumAttribute[IteratorType]
Source code in xdsl/dialects/memref_stream.py
StridePattern
dataclass
¶
Bases: ParametrizedAttribute
Attribute representing the order and offsets in which elements will be read from or written to a stream.
// 2D access pattern
#pat = #memref_stream.stride_pattern<ub = [16, 8], strides = (d0, d1) -> (d0 + 1, d1 + 2)>
// Corresponds to the following locations
// for i in range(16):
// for j in range(8):
// yield (i + 1, j + 2)
// Note that the upper bounds and strides go from the outermost loop inwards
Source code in xdsl/dialects/memref_stream.py
name = 'memref_stream.stride_pattern'
class-attribute
instance-attribute
¶
ub: ArrayAttr[IntegerAttr[IndexType]]
instance-attribute
¶
index_map: AffineMapAttr
instance-attribute
¶
parse_parameters(parser: AttrParser) -> Sequence[Attribute]
classmethod
¶
Source code in xdsl/dialects/memref_stream.py
print_parameters(printer: Printer) -> None
¶
Source code in xdsl/dialects/memref_stream.py
verify() -> None
¶
Source code in xdsl/dialects/memref_stream.py
index_iter() -> Iterator[tuple[int, ...]]
¶
ReadOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/memref_stream.py
name = 'memref_stream.read'
class-attribute
instance-attribute
¶
T: ClassVar = VarConstraint('T', AnyAttr())
class-attribute
instance-attribute
¶
stream = operand_def(ReadableStreamType.constr(T))
class-attribute
instance-attribute
¶
res = result_def(T)
class-attribute
instance-attribute
¶
assembly_format = '`from` $stream attr-dict `:` type($res)'
class-attribute
instance-attribute
¶
__init__(stream_val: SSAValue, result_type: Attribute | None = None)
¶
Source code in xdsl/dialects/memref_stream.py
WriteOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/memref_stream.py
name = 'memref_stream.write'
class-attribute
instance-attribute
¶
T: ClassVar = VarConstraint('T', AnyAttr())
class-attribute
instance-attribute
¶
value = operand_def(T)
class-attribute
instance-attribute
¶
stream = operand_def(WritableStreamType.constr(T))
class-attribute
instance-attribute
¶
assembly_format = '$value `to` $stream attr-dict `:` type($value)'
class-attribute
instance-attribute
¶
__init__(value: SSAValue, stream: SSAValue)
¶
StreamingRegionOp
¶
Bases: IRDLOperation
An operation that creates streams from access patterns, which are only available to read from and write to within the body of the operation.
Within the loop body, memrefs that are streamed must not be otherwise accessed via memref.load, memref.store or any other access means, including extraction (e.g.: memref.view).
Source code in xdsl/dialects/memref_stream.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
name = 'memref_stream.streaming_region'
class-attribute
instance-attribute
¶
inputs = var_operand_def(memref.MemRefType)
class-attribute
instance-attribute
¶
Pointers to memory buffers that will be streamed. The corresponding stride pattern defines the order in which the elements of the input buffers will be read.
outputs = var_operand_def(memref.MemRefType)
class-attribute
instance-attribute
¶
Pointers to memory buffers that will be streamed. The corresponding stride pattern defines the order in which the elements of the input buffers will be written to.
patterns = prop_def(ArrayAttr[StridePattern])
class-attribute
instance-attribute
¶
Stride patterns that define the order of the input and output streams. Like in linalg.generic, the indexing maps corresponding to inputs are followed by the indexing maps for the outputs.
body = region_def('single_block')
class-attribute
instance-attribute
¶
irdl_options = (AttrSizedOperandSegments(as_property=True),)
class-attribute
instance-attribute
¶
traits = traits_def(NoTerminator())
class-attribute
instance-attribute
¶
__init__(inputs: Sequence[SSAValue], outputs: Sequence[SSAValue], patterns: ArrayAttr[StridePattern], body: Region) -> None
¶
Source code in xdsl/dialects/memref_stream.py
print(printer: Printer)
¶
Source code in xdsl/dialects/memref_stream.py
parse(parser: Parser) -> Self
classmethod
¶
Source code in xdsl/dialects/memref_stream.py
GenericOpHasCanonicalizationPatternsTrait
dataclass
¶
Bases: HasCanonicalizationPatternsTrait
Source code in xdsl/dialects/memref_stream.py
get_canonicalization_patterns()
classmethod
¶
GenericOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/memref_stream.py
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 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 605 606 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 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 | |
name = 'memref_stream.generic'
class-attribute
instance-attribute
¶
inputs = var_operand_def()
class-attribute
instance-attribute
¶
Pointers to memory buffers or streams to be operated on. The corresponding stride pattern defines the order in which the elements of the input buffers will be read.
outputs = var_operand_def(MemRefType.constr() | WritableStreamType.constr())
class-attribute
instance-attribute
¶
Pointers to memory buffers or streams to be operated on. The corresponding stride pattern defines the order in which the elements of the input buffers will be written to.
inits = var_operand_def()
class-attribute
instance-attribute
¶
Initial values for outputs. The outputs are at corresponding init_indices. The
inits may be set only for the imperfectly nested form.
indexing_maps = prop_def(ArrayAttr[AffineMapAttr])
class-attribute
instance-attribute
¶
Stride patterns that define the order of the input and output streams. Like in linalg.generic, the indexing maps corresponding to inputs are followed by the indexing maps for the outputs.
bounds = prop_def(ArrayAttr[IntegerAttr[IndexType]])
class-attribute
instance-attribute
¶
The bounds of the iteration space, from the outermost loop inwards.
All indexing maps must have the same number of dimensions as the length of bounds.
iterator_types = prop_def(ArrayAttr[IteratorTypeAttr])
class-attribute
instance-attribute
¶
init_indices = prop_def(ArrayAttr[IntAttr])
class-attribute
instance-attribute
¶
Indices into the outputs that correspond to the initial values in inits.
doc = opt_prop_def(StringAttr)
class-attribute
instance-attribute
¶
library_call = opt_prop_def(StringAttr)
class-attribute
instance-attribute
¶
body = region_def('single_block')
class-attribute
instance-attribute
¶
traits = traits_def(GenericOpHasCanonicalizationPatternsTrait())
class-attribute
instance-attribute
¶
irdl_options = (AttrSizedOperandSegments(as_property=True),)
class-attribute
instance-attribute
¶
is_imperfectly_nested: bool
property
¶
__init__(inputs: Sequence[SSAValue], outputs: Sequence[SSAValue], inits: Sequence[SSAValue], body: Region, indexing_maps: ArrayAttr[AffineMapAttr], iterator_types: ArrayAttr[Attribute], bounds: ArrayAttr[IntegerAttr[IndexType]], init_indices: ArrayAttr[IntAttr], doc: StringAttr | None = None, library_call: StringAttr | None = None) -> None
¶
Source code in xdsl/dialects/memref_stream.py
get_static_loop_ranges() -> tuple[tuple[int, ...], tuple[int, ...]]
¶
This operation can represent two sets of perfectly nested loops, or one. If it is one, then the first element of the returned tuple has all the loop bounds, and the second is empty. If there are two, then the first element of the returned tuple has the outer bounds, and the second the inner. Interleaved iterators are not returned in either tuple.
Source code in xdsl/dialects/memref_stream.py
print(printer: Printer)
¶
Source code in xdsl/dialects/memref_stream.py
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 605 606 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 | |
parse(parser: Parser) -> Self
classmethod
¶
Source code in xdsl/dialects/memref_stream.py
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 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 | |
verify_() -> None
¶
Source code in xdsl/dialects/memref_stream.py
826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 | |
YieldOp
dataclass
¶
Bases: AbstractYieldOperation[Attribute]
Source code in xdsl/dialects/memref_stream.py
FillOp
¶
Bases: IRDLOperation