Stencil
stencil
¶
StencilTypeConstr = FieldType.constr() | TempType.constr()
module-attribute
¶
FieldTypeConstr = FieldType[Attribute].constr()
module-attribute
¶
TempTypeConstr = TempType[Attribute].constr()
module-attribute
¶
AnyTempType: TypeAlias = TempType[Attribute]
module-attribute
¶
Stencil = Dialect('stencil', [AllocOp, CastOp, CombineOp, DynAccessOp, ExternalLoadOp, ExternalStoreOp, IndexOp, AccessOp, LoadOp, BufferOp, StoreOp, ApplyOp, StoreResultOp, ReturnOp, ReduceOp, YieldOp], [FieldType, TempType, ResultType, IndexAttr, StencilBoundsAttr])
module-attribute
¶
IndexAttr
¶
Bases: ParametrizedAttribute, Iterable[int]
Source code in xdsl/dialects/stencil.py
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 114 115 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 | |
name = 'stencil.index'
class-attribute
instance-attribute
¶
array: ArrayAttr[IntAttr]
instance-attribute
¶
__init__(indices: ArrayAttr[IntAttr])
¶
from_indices(*indices: int)
classmethod
¶
parse_parameters(parser: AttrParser) -> list[Attribute]
classmethod
¶
parse_indices(parser: AttrParser) -> ArrayAttr[IntAttr]
classmethod
¶
Parse a comma-separated, square delimited, list of integers into an ArrayAttr of IntAttrs.
e.g.: [1, 2, 3]
Source code in xdsl/dialects/stencil.py
print_parameters(printer: Printer) -> None
¶
print_indices(printer: Printer) -> None
¶
verify() -> None
¶
__neg__() -> IndexAttr
¶
__add__(o: IndexAttr) -> IndexAttr
¶
__sub__(o: IndexAttr) -> IndexAttr
¶
__lt__(o: IndexAttr) -> bool
¶
min(a: IndexAttr, b: IndexAttr | None) -> IndexAttr
staticmethod
¶
max(a: IndexAttr, b: IndexAttr | None) -> IndexAttr
staticmethod
¶
__len__()
¶
StencilBoundsAttr
¶
Bases: ParametrizedAttribute
This attribute represents known bounds over a stencil type.
Source code in xdsl/dialects/stencil.py
166 167 168 169 170 171 172 173 174 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 229 230 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 | |
name = 'stencil.bounds'
class-attribute
instance-attribute
¶
lb: IndexAttr
instance-attribute
¶
ub: IndexAttr
instance-attribute
¶
__init__(bounds: IndexAttr | Iterable[tuple[int | IntAttr, int | IntAttr]], ub: IndexAttr | None = None)
¶
Source code in xdsl/dialects/stencil.py
from_bounds(bounds: Iterable[tuple[int, int]]) -> StencilBoundsAttr
classmethod
¶
print_parameters(printer: Printer) -> None
¶
parse_parameters(parser: AttrParser) -> list[Attribute]
classmethod
¶
Source code in xdsl/dialects/stencil.py
union(other: StencilBoundsAttr | IntAttr) -> StencilBoundsAttr
¶
intersection(other: StencilBoundsAttr | IntAttr) -> StencilBoundsAttr
¶
Source code in xdsl/dialects/stencil.py
__or__(value: StencilBoundsAttr | IntAttr) -> StencilBoundsAttr
¶
__ror__(value: StencilBoundsAttr | IntAttr) -> StencilBoundsAttr
¶
__and__(value: StencilBoundsAttr | IntAttr) -> StencilBoundsAttr
¶
__rand__(value: StencilBoundsAttr | IntAttr) -> StencilBoundsAttr
¶
__add__(o: IndexAttr) -> StencilBoundsAttr
¶
StencilType
dataclass
¶
Bases: ParametrizedAttribute, TypeAttribute, ShapedType, ContainerType[_FieldTypeElement], Generic[_FieldTypeElement]
Source code in xdsl/dialects/stencil.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 | |
name = 'stencil.type'
class-attribute
instance-attribute
¶
bounds: StencilBoundsAttr | IntAttr
instance-attribute
¶
Represents the bounds information of a stencil.field or stencil.temp.
A StencilBoundsAttr encodes known bounds, where an IntAttr encodes the rank of unknown bounds. A stencil.field or stencil.temp cannot be unranked!
element_type: _FieldTypeElement
instance-attribute
¶
__init__(bounds: Iterable[tuple[int, int]] | int | IntAttr | StencilBoundsAttr, element_type: _FieldTypeElement) -> None
¶
A StencilBoundsAttr encodes known bounds, where an IntAttr encodes the
rank of unknown bounds. A stencil.field or stencil.temp cannot be unranked!
examples:¶
Field(3,f32)is represented asstencil.field<?x?x?xf32>Field([(-1,17),(-2,18)],f32)is represented asstencil.field<[-1,17]x[-2,18]xf32>,
Source code in xdsl/dialects/stencil.py
get_num_dims() -> int
¶
get_shape() -> tuple[int, ...]
¶
get_element_type() -> _FieldTypeElement
¶
parse_parameters(parser: AttrParser) -> list[Attribute]
classmethod
¶
Source code in xdsl/dialects/stencil.py
print_parameters(printer: Printer) -> None
¶
Source code in xdsl/dialects/stencil.py
constr(*, bounds: IRDLAttrConstraint | None = None, element_type: AttrConstraint[_FieldTypeElement] | None = None) -> AttrConstraint[StencilType[_FieldTypeElement]]
staticmethod
¶
Source code in xdsl/dialects/stencil.py
FieldType
dataclass
¶
Bases: StencilType[_FieldTypeElement], ParametrizedAttribute, TypeAttribute, Generic[_FieldTypeElement]
stencil.field represents memory from which stencil input values will be loaded, or to which stencil output values will be stored.
stencil.temp are loaded from or stored to stencil.field
Source code in xdsl/dialects/stencil.py
name = 'stencil.field'
class-attribute
instance-attribute
¶
TempType
dataclass
¶
Bases: StencilType[_FieldTypeElement], ParametrizedAttribute, TypeAttribute, Generic[_FieldTypeElement]
stencil.temp represents stencil values, and is the type on which stencil.apply operates. It has value-semantics: it won't necesseraly be lowered to an actual buffer.
Source code in xdsl/dialects/stencil.py
name = 'stencil.temp'
class-attribute
instance-attribute
¶
ResultType
dataclass
¶
Bases: ParametrizedAttribute, TypeAttribute
Source code in xdsl/dialects/stencil.py
ApplyOpHasCanonicalizationPatternsTrait
dataclass
¶
Bases: HasCanonicalizationPatternsTrait
Source code in xdsl/dialects/stencil.py
get_canonicalization_patterns() -> tuple[RewritePattern, ...]
classmethod
¶
Source code in xdsl/dialects/stencil.py
ApplyOpHasShapeInferencePatternsTrait
dataclass
¶
Bases: HasShapeInferencePatternsTrait
Source code in xdsl/dialects/stencil.py
get_shape_inference_patterns() -> tuple[RewritePattern, ...]
classmethod
¶
ApplyMemoryEffect
dataclass
¶
Bases: RecursiveMemoryEffect
Source code in xdsl/dialects/stencil.py
get_effects(op: Operation)
classmethod
¶
Source code in xdsl/dialects/stencil.py
ApplyOp
¶
Bases: IRDLOperation
This operation takes a stencil function plus parameters and applies the stencil function to the output temp.
Example:
%0 = stencil.apply (%arg0=%0 : !stencil.temp<?x?x?xf64>) -> !stencil.temp<?x?x?xf64> { ... }
The computation bounds are defined by the bounds of the output types, which are constrained to be all equals.
Source code in xdsl/dialects/stencil.py
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 | |
name = 'stencil.apply'
class-attribute
instance-attribute
¶
args = var_operand_def(Attribute)
class-attribute
instance-attribute
¶
dest = var_operand_def(FieldType)
class-attribute
instance-attribute
¶
region = region_def()
class-attribute
instance-attribute
¶
res = var_result_def(TempType)
class-attribute
instance-attribute
¶
bounds = opt_prop_def(StencilBoundsAttr)
class-attribute
instance-attribute
¶
traits = traits_def(IsolatedFromAbove(), ApplyOpHasCanonicalizationPatternsTrait(), ApplyOpHasShapeInferencePatternsTrait(), ApplyMemoryEffect())
class-attribute
instance-attribute
¶
irdl_options = (AttrSizedOperandSegments(as_property=True),)
class-attribute
instance-attribute
¶
__init__(args: Sequence[SSAValue] | Sequence[Operation], body: Block | Region, result_types: Sequence[TempType[Attribute]] | None = None, bounds: StencilBoundsAttr | None = None)
¶
Source code in xdsl/dialects/stencil.py
print(printer: Printer)
¶
Source code in xdsl/dialects/stencil.py
parse(parser: Parser)
classmethod
¶
Source code in xdsl/dialects/stencil.py
verify_() -> None
¶
Source code in xdsl/dialects/stencil.py
get_rank() -> int
¶
get_accesses() -> Iterable[AccessPattern]
¶
Return the access patterns of each input.
- An offset is a tuple describing a relative access
- An access pattern is a class wrapping a sequence of offsets
- This method returns an access pattern for each stencil field of the apply operation.
Source code in xdsl/dialects/stencil.py
AllocOpEffect
dataclass
¶
Bases: MemoryEffect
Source code in xdsl/dialects/stencil.py
AllocOp
dataclass
¶
Bases: IRDLOperation
Source code in xdsl/dialects/stencil.py
name = 'stencil.alloc'
class-attribute
instance-attribute
¶
field = result_def(FieldType[Attribute])
class-attribute
instance-attribute
¶
assembly_format = 'attr-dict `:` qualified(type($field))'
class-attribute
instance-attribute
¶
traits = traits_def(AllocOpEffect())
class-attribute
instance-attribute
¶
CastOpHasCanonicalizationPatternsTrait
dataclass
¶
Bases: HasCanonicalizationPatternsTrait
Source code in xdsl/dialects/stencil.py
get_canonicalization_patterns() -> tuple[RewritePattern, ...]
classmethod
¶
CastOp
¶
Bases: IRDLOperation
This operation casts dynamically shaped input fields to statically shaped fields.
Example
%0 = stencil.cast %in : !stencil.field<?x?x?xf64> -> !stencil.field<70x70x60xf64> # noqa
Source code in xdsl/dialects/stencil.py
name = 'stencil.cast'
class-attribute
instance-attribute
¶
field = operand_def(FieldType[Attribute].constr(element_type=MessageConstraint(VarConstraint('T', AnyAttr()), 'Input and output fields must have the same element types')))
class-attribute
instance-attribute
¶
result = result_def(FieldType[Attribute].constr(element_type=MessageConstraint(VarConstraint('T', AnyAttr()), 'Input and output fields must have the same element types')))
class-attribute
instance-attribute
¶
assembly_format = '$field attr-dict-with-keyword `:` qualified(type($field)) `->` qualified(type($result))'
class-attribute
instance-attribute
¶
traits = traits_def(NoMemoryEffect(), CastOpHasCanonicalizationPatternsTrait())
class-attribute
instance-attribute
¶
__init__(field: OperandArg, bounds: StencilBoundsAttr, res_type: FieldType[_FieldTypeElement] | FieldType[Attribute] | None = None)
¶
Source code in xdsl/dialects/stencil.py
verify_() -> None
¶
Source code in xdsl/dialects/stencil.py
CombineOpHasShapeInferencePatternsTrait
dataclass
¶
Bases: HasShapeInferencePatternsTrait
Source code in xdsl/dialects/stencil.py
get_shape_inference_patterns() -> tuple[RewritePattern, ...]
classmethod
¶
CombineOp
dataclass
¶
Bases: IRDLOperation
Combines the results computed on a lower with the results computed on
an upper domain. The operation combines the domain at a given index/offset
in a given dimension. Optional extra operands allow to combine values
that are only written / defined on the lower or upper subdomain. The result
values have the order upper/lower, lowerext, upperext.
Example:
`%res1, %res2 = stencil.combine 1 at 11 lower = (%0 : !stencil.temp<?x?x?xf64>) upper = (%1 : !stencil.temp<?x?x?xf64>) lowerext = (%2 : !stencil.temp<?x?x?xf64>): !stencil.temp<?x?x?xf64>, !stencil.temp<?x?x?xf64>`
Can be illustrated as:
dim 1 offset offset
┌──► (=11) (=11)
0 │ │ │
▼ ┌────────┼─────────┐ ┌────────┼─────────┐
│ │ │ │ │ │
│ │ │ │ │ │
%res1│ lower │ upper │ │lowerext│ │%res2
│ %0 │ %1 │ │ %0 │ │
│ │ │ │ │ │
│ │ │ │ │ │
└────────┼─────────┘ └────────┼─────────┘
│ │
Source code in xdsl/dialects/stencil.py
name = 'stencil.combine'
class-attribute
instance-attribute
¶
dim = prop_def(IntegerAttr[IndexType])
class-attribute
instance-attribute
¶
index = prop_def(IntegerAttr[IndexType])
class-attribute
instance-attribute
¶
lower = var_operand_def(TempType)
class-attribute
instance-attribute
¶
upper = var_operand_def(TempType)
class-attribute
instance-attribute
¶
lowerext = var_operand_def(TempType)
class-attribute
instance-attribute
¶
upperext = var_operand_def(TempType)
class-attribute
instance-attribute
¶
results_ = var_result_def(TempType)
class-attribute
instance-attribute
¶
traits = traits_def(Pure(), CombineOpHasShapeInferencePatternsTrait())
class-attribute
instance-attribute
¶
assembly_format = '$dim `at` $index `lower` `=` `(` $lower `:` type($lower) `)` `upper` `=` `(` $upper `:` type($upper) `)` (`lowerext` `=` $lowerext^ `:` type($lowerext))? (`upperext` `=` $upperext^ `:` type($upperext))? attr-dict-with-keyword `:` type($results_)'
class-attribute
instance-attribute
¶
irdl_options = (AttrSizedOperandSegments(),)
class-attribute
instance-attribute
¶
DynAccessOpHasShapeInferencePatternsTrait
dataclass
¶
Bases: HasShapeInferencePatternsTrait
Source code in xdsl/dialects/stencil.py
DynAccessOp
¶
Bases: IRDLOperation
This operation accesses a temporary element given a dynamic offset. The offset is specified in absolute coordinates. An additional range attribute specifies the maximal access extent relative to the iteration domain of the parent apply operation.
Example
%0 = stencil.dyn_access %temp [%i, %j, %k] in [-1, -1, -1] : [1, 1, 1] : !stencil.temp<?x?x?xf64>
Source code in xdsl/dialects/stencil.py
name = 'stencil.dyn_access'
class-attribute
instance-attribute
¶
temp = operand_def(StencilType[Attribute].constr(element_type=MessageConstraint(VarConstraint('T', AnyAttr()), "Expected result type to be the accessed temp's element type.")))
class-attribute
instance-attribute
¶
offset = var_operand_def(builtin.IndexType())
class-attribute
instance-attribute
¶
lb = prop_def(IndexAttr)
class-attribute
instance-attribute
¶
ub = prop_def(IndexAttr)
class-attribute
instance-attribute
¶
res = result_def(MessageConstraint(VarConstraint('T', AnyAttr()), "Expected result type to be the accessed temp's element type."))
class-attribute
instance-attribute
¶
assembly_format = '$temp `[` $offset `]` `in` $lb `:` $ub attr-dict-with-keyword `:` type($temp)'
class-attribute
instance-attribute
¶
traits = traits_def(HasAncestor(ApplyOp), NoMemoryEffect(), DynAccessOpHasShapeInferencePatternsTrait())
class-attribute
instance-attribute
¶
__init__(temp: OperandArg, offset: Sequence[OperandArg], lb: IndexAttr, ub: IndexAttr)
¶
Source code in xdsl/dialects/stencil.py
ExternalLoadOp
¶
Bases: IRDLOperation
This operation loads from an external field type, e.g. to bring data into the stencil
Example
%0 = stencil.external_load %in : !fir.array<128x128xf64> -> !stencil.field<128x128xf64>
Source code in xdsl/dialects/stencil.py
name = 'stencil.external_load'
class-attribute
instance-attribute
¶
field = operand_def(Attribute)
class-attribute
instance-attribute
¶
result = result_def(FieldType | MemRefType)
class-attribute
instance-attribute
¶
assembly_format = '$field attr-dict-with-keyword `:` type($field) `->` type($result)'
class-attribute
instance-attribute
¶
ExternalStoreOp
dataclass
¶
Bases: IRDLOperation
This operation takes a stencil field and then stores this to an external type
Example
stencil.store %temp to %field : !stencil.field<128x128xf64> to !fir.array<128x128xf64> # noqa
Source code in xdsl/dialects/stencil.py
name = 'stencil.external_store'
class-attribute
instance-attribute
¶
temp = operand_def(FieldType)
class-attribute
instance-attribute
¶
field = operand_def(Attribute)
class-attribute
instance-attribute
¶
assembly_format = '$temp `to` $field attr-dict-with-keyword `:` qualified(type($temp)) `to` type($field)'
class-attribute
instance-attribute
¶
IndexOp
dataclass
¶
Bases: IRDLOperation
This operation returns the index of the current loop iteration for the chosen direction (0, 1, or 2). The offset is specified relative to the current position.
Example
%0 = stencil.index 0 [-1, 0, 0]
Source code in xdsl/dialects/stencil.py
name = 'stencil.index'
class-attribute
instance-attribute
¶
dim = prop_def(IntegerAttr[IndexType])
class-attribute
instance-attribute
¶
offset = prop_def(IndexAttr)
class-attribute
instance-attribute
¶
idx = result_def(builtin.IndexType())
class-attribute
instance-attribute
¶
assembly_format = '$dim $offset attr-dict-with-keyword'
class-attribute
instance-attribute
¶
traits = traits_def(HasAncestor(ApplyOp), Pure())
class-attribute
instance-attribute
¶
get_apply()
¶
Simple helper to get the parent apply and raise otherwise.
Source code in xdsl/dialects/stencil.py
AccessOpHasShapeInferencePatternsTrait
dataclass
¶
Bases: HasShapeInferencePatternsTrait
Source code in xdsl/dialects/stencil.py
get_shape_inference_patterns() -> tuple[RewritePattern, ...]
classmethod
¶
AccessOp
¶
Bases: IRDLOperation
This operation accesses a value from a stencil.temp given the specified offset. offset. The offset is specified relative to the current position.
The optional offset mapping will determine which offset corresponds to which result dimension and is needed when we are accessing an array which has fewer dimensions than the result.
Example
%0 = stencil.access %temp[-1, 0, 0] : !stencil.temp<?x?x?xf64>
Source code in xdsl/dialects/stencil.py
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 | |
name = 'stencil.access'
class-attribute
instance-attribute
¶
temp = operand_def(StencilType[Attribute].constr(element_type=MessageConstraint(VarConstraint('T', AnyAttr()), "Expected return type to match the accessed temp's element type.")))
class-attribute
instance-attribute
¶
offset = attr_def(IndexAttr)
class-attribute
instance-attribute
¶
offset_mapping = opt_attr_def(IndexAttr)
class-attribute
instance-attribute
¶
res = result_def(MessageConstraint(VarConstraint('T', AnyAttr()), "Expected return type to match the accessed temp's element type."))
class-attribute
instance-attribute
¶
traits = traits_def(HasAncestor(ApplyOp), Pure(), AccessOpHasShapeInferencePatternsTrait())
class-attribute
instance-attribute
¶
__init__(temp: OperandArg, offset: Sequence[int], offset_mapping: Sequence[int] | IndexAttr | None = None)
¶
Source code in xdsl/dialects/stencil.py
print(printer: Printer)
¶
Source code in xdsl/dialects/stencil.py
parse(parser: Parser)
classmethod
¶
Source code in xdsl/dialects/stencil.py
verify_() -> None
¶
Source code in xdsl/dialects/stencil.py
get_apply()
¶
Simple helper to get the parent apply and raise otherwise.
Source code in xdsl/dialects/stencil.py
LoadOpHasShapeInferencePatternsTrait
dataclass
¶
Bases: HasShapeInferencePatternsTrait
Source code in xdsl/dialects/stencil.py
get_shape_inference_patterns() -> tuple[RewritePattern, ...]
classmethod
¶
LoadOpMemoryEffect
dataclass
¶
Bases: MemoryEffect
Source code in xdsl/dialects/stencil.py
TensorIgnoreSizeConstraint
dataclass
¶
Bases: VarConstraint[Attribute]
Source code in xdsl/dialects/stencil.py
ranks_and_element_types_match(attr: TensorType, other: Attribute) -> bool
staticmethod
¶
Source code in xdsl/dialects/stencil.py
verify(attr: Attribute, constraint_context: VerificationContext) -> None
¶
Source code in xdsl/dialects/stencil.py
LoadOp
¶
Bases: IRDLOperation
This operation takes a field and returns its values.
Example
%0 = stencil.load %field : !stencil.field<70x70x60xf64> -> !stencil.temp<?x?x?xf64>
Source code in xdsl/dialects/stencil.py
1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 | |
name = 'stencil.load'
class-attribute
instance-attribute
¶
field = operand_def(FieldType[Attribute].constr(bounds=StencilBoundsAttr, element_type=MessageConstraint(TensorIgnoreSizeConstraint('T', AnyAttr()), 'Expected element types to match.')))
class-attribute
instance-attribute
¶
res = result_def(TempType[Attribute].constr(element_type=MessageConstraint(TensorIgnoreSizeConstraint('T', AnyAttr()), 'Expected element types to match.')))
class-attribute
instance-attribute
¶
assembly_format = '$field attr-dict-with-keyword `:` type($field) `->` type($res)'
class-attribute
instance-attribute
¶
traits = traits_def(LoadOpHasShapeInferencePatternsTrait(), LoadOpMemoryEffect())
class-attribute
instance-attribute
¶
__init__(field: OperandArg, lb: IndexAttr | None = None, ub: IndexAttr | None = None)
¶
Source code in xdsl/dialects/stencil.py
verify_() -> None
¶
Source code in xdsl/dialects/stencil.py
BufferOpHasShapeInferencePatternsTrait
dataclass
¶
Bases: HasShapeInferencePatternsTrait
Source code in xdsl/dialects/stencil.py
get_shape_inference_patterns() -> tuple[RewritePattern, ...]
classmethod
¶
BufferOp
¶
Bases: IRDLOperation
Prevents fusion of consecutive stencil.apply operations.
Example
%0 = stencil.buffer %buffered : (!stencil.temp<?x?x?xf64>)
Source code in xdsl/dialects/stencil.py
1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 | |
name = 'stencil.buffer'
class-attribute
instance-attribute
¶
temp = operand_def(TempType[Attribute].constr(bounds=MessageConstraint(VarConstraint('B', AnyAttr()), 'Expected input and output to have the same bounds'), element_type=MessageConstraint(VarConstraint('E', AnyAttr()), 'Expected input and output to have the same element type')))
class-attribute
instance-attribute
¶
res = result_def(StencilType[Attribute].constr(bounds=MessageConstraint(VarConstraint('B', AnyAttr()), 'Expected input and output to have the same bounds'), element_type=MessageConstraint(VarConstraint('E', AnyAttr()), 'Expected input and output to have the same element type')))
class-attribute
instance-attribute
¶
assembly_format = '$temp attr-dict-with-keyword `:` type($temp) `->` type($res)'
class-attribute
instance-attribute
¶
traits = traits_def(Pure(), BufferOpHasShapeInferencePatternsTrait())
class-attribute
instance-attribute
¶
__init__(temp: OperandArg)
¶
verify_() -> None
¶
Source code in xdsl/dialects/stencil.py
StoreOpHasShapeInferencePatternsTrait
dataclass
¶
Bases: HasShapeInferencePatternsTrait
Source code in xdsl/dialects/stencil.py
get_shape_inference_patterns() -> tuple[RewritePattern, ...]
classmethod
¶
StoreOpMemoryEffect
dataclass
¶
Bases: MemoryEffect
Source code in xdsl/dialects/stencil.py
StoreOp
¶
Bases: IRDLOperation
This operation writes values to a field on a user defined range.
Example
stencil.store %temp to %field ([-3, -3, 0] : [67, 67, 60]): !stencil.temp<?x?x?xf64> to !stencil.field<70x70x60xf64> # noqa
Source code in xdsl/dialects/stencil.py
name = 'stencil.store'
class-attribute
instance-attribute
¶
temp = operand_def(TempType[Attribute].constr(element_type=MessageConstraint(TensorIgnoreSizeConstraint('T', AnyAttr()), 'Input and output fields must have the same element types')))
class-attribute
instance-attribute
¶
field = operand_def(FieldType[Attribute].constr(bounds=MessageConstraint(StencilBoundsAttr, "Output type's size must be explicit"), element_type=MessageConstraint(TensorIgnoreSizeConstraint('T', AnyAttr()), 'Input and output fields must have the same element types')))
class-attribute
instance-attribute
¶
bounds = prop_def(StencilBoundsAttr)
class-attribute
instance-attribute
¶
assembly_format = '$temp `to` $field `` `(` $bounds `)` attr-dict-with-keyword `:` type($temp) `to` type($field)'
class-attribute
instance-attribute
¶
traits = traits_def(StoreOpHasShapeInferencePatternsTrait(), StoreOpMemoryEffect())
class-attribute
instance-attribute
¶
__init__(temp: OperandArg, field: OperandArg, bounds: StencilBoundsAttr)
¶
StoreResultOp
dataclass
¶
Bases: IRDLOperation
The store_result operation either stores an operand value or nothing.
Examples:
stencil.store_result %0 : !stencil.result
Source code in xdsl/dialects/stencil.py
name = 'stencil.store_result'
class-attribute
instance-attribute
¶
arg = opt_operand_def(MessageConstraint(VarConstraint('T', AnyAttr()), 'Expected return type to carry the operand type.'))
class-attribute
instance-attribute
¶
res = result_def(ParamAttrConstraint.get(ResultType, MessageConstraint(VarConstraint('T', AnyAttr()), 'Expected return type to carry the operand type.')))
class-attribute
instance-attribute
¶
assembly_format = '$arg attr-dict-with-keyword `:` qualified(type($res))'
class-attribute
instance-attribute
¶
traits = traits_def(HasAncestor(ApplyOp), Pure())
class-attribute
instance-attribute
¶
ReturnOp
¶
Bases: IRDLOperation
The return operation terminates the stencil.apply and writes the results of the stencil operator to the temporary values returned by the stencil.apply operation. The types and the number of operands must match the results of the stencil.apply operation.
The optional unroll attribute enables the implementation of loop unrolling at the stencil dialect level.
Examples:
stencil.return %0 : !stencil.result
Source code in xdsl/dialects/stencil.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 | |
name = 'stencil.return'
class-attribute
instance-attribute
¶
arg = var_operand_def(Attribute)
class-attribute
instance-attribute
¶
unroll = opt_prop_def(IndexAttr)
class-attribute
instance-attribute
¶
assembly_format = '$arg (`unroll` $unroll^)? attr-dict-with-keyword `:` type($arg)'
class-attribute
instance-attribute
¶
unroll_factor: int
property
¶
traits = traits_def(HasParent(ApplyOp), IsTerminator(), Pure())
class-attribute
instance-attribute
¶
__init__(res: Sequence[OperandArg])
¶
verify_() -> None
¶
Source code in xdsl/dialects/stencil.py
ReduceOp
¶
Bases: IRDLOperation
Reduce operation for accumulating values across stencil iterations.
Source code in xdsl/dialects/stencil.py
name = 'stencil.reduce'
class-attribute
instance-attribute
¶
T: ClassVar = VarConstraint('T', AnyAttr())
class-attribute
instance-attribute
¶
acc = operand_def(T)
class-attribute
instance-attribute
¶
init = operand_def(T)
class-attribute
instance-attribute
¶
body = region_def('single_block', entry_args=RangeOf(T).of_length(2))
class-attribute
instance-attribute
¶
assembly_format = '$acc `init` $init $body attr-dict `:` type($acc)'
class-attribute
instance-attribute
¶
__init__(operand: SSAValue, init: SSAValue, body: Region)
¶
verify_() -> None
¶
Source code in xdsl/dialects/stencil.py
YieldOp
¶
Bases: IRDLOperation
Simple terminator for stencil operations with regions.
Source code in xdsl/dialects/stencil.py
AccessPattern
dataclass
¶
Represents access patterns of a stencil.apply operation.
Contains helpers to get common information about accesses such as diagonals.
Source code in xdsl/dialects/stencil.py
1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 | |
offsets: tuple[tuple[int, ...], ...]
instance-attribute
¶
dims
property
¶
Dimensionality of the accesses.
is_diagonal: bool
property
¶
Check if the access pattern has diagonal accesses.
__init__(offsets: tuple[tuple[int, ...], ...]) -> None
¶
get_diagonals(degree: int = 2) -> Iterable[tuple[int, ...]]
¶
Returns all offsets that have
For
For
Source code in xdsl/dialects/stencil.py
halo_in_axis(axis: int) -> tuple[int, int]
¶
Returns the minimum and maximum access distance for a single axis.
Source code in xdsl/dialects/stencil.py
halos() -> tuple[tuple[int, int], ...]
¶
Return a tuple containing the maximum and minimum offsets in each axis. E.g. ((-2, 2), (-1, 1)) represents a pattern that accesses cells at most (-2, 2) away in the x-axis, and -1, 1 away in the y-axis.
Source code in xdsl/dialects/stencil.py
max_distance() -> int
¶
Returns the maximum absolute accessed distance across all axes.
visual_pattern() -> str
¶
Returns a visual equivalent of the access pattern, only works for 1d and 2d.
Returns patterns where O signifies the center point and X represents an access. E.g.:
X XOX X
For a 2d-4pt stencil.