Csl stencil bufferize
csl_stencil_bufferize
¶
StencilTypeConversion
dataclass
¶
Bases: TypeConversionPattern
Converts from tensorised stencil.field types to memref by extracting the element type which is a tensor and converting it to memref.
For instance
!stencil.field<[-1,1023]x[-1,511]xtensor<512xf32> to memref<512xf32>
Source code in xdsl/transforms/csl_stencil_bufferize.py
convert_type(typ: stencil.FieldType[TensorType[Attribute]]) -> memref.MemRefType
¶
Source code in xdsl/transforms/csl_stencil_bufferize.py
ApplyOpBufferize
dataclass
¶
Bases: RewritePattern
Bufferizes csl_stencil.apply, rewriting args and block args, changing them from tensor to memref types.
For each converted arg, creates a bufferization.to_memref before the apply op.
For each converted block arg, creates a bufferization.to_tensor at the start of the block.
Source code in xdsl/transforms/csl_stencil_bufferize.py
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 164 165 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 | |
__init__() -> None
¶
match_and_rewrite(op: csl_stencil.ApplyOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/csl_stencil_bufferize.py
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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
AccessOpBufferize
dataclass
¶
Bases: RewritePattern
Bufferizes AccessOp.
The type conversion pass creates the scenario that some csl_stencil.access ops are equal input and output types,
for instance, (memref<512xf32>) -> memref<512xf32>. This only happens for ops accessing own data. In this case,
the access op has no effect and can safely be folded away.
Source code in xdsl/transforms/csl_stencil_bufferize.py
__init__() -> None
¶
match_and_rewrite(op: csl_stencil.AccessOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/csl_stencil_bufferize.py
YieldOpBufferize
dataclass
¶
Bases: RewritePattern
Bufferizes YieldOp.
Source code in xdsl/transforms/csl_stencil_bufferize.py
__init__() -> None
¶
match_and_rewrite(op: csl_stencil.YieldOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/csl_stencil_bufferize.py
FuncOpBufferize
dataclass
¶
Bases: RewritePattern
Replace the function_type and let a separate type conversion pass handle the block args.
Source code in xdsl/transforms/csl_stencil_bufferize.py
__init__() -> None
¶
match_and_rewrite(op: func.FuncOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/csl_stencil_bufferize.py
ArithConstBufferize
dataclass
¶
Bases: RewritePattern
Bufferize arith tensor constants to prevent mlir bufferize from promoting them to globals.
Source code in xdsl/transforms/csl_stencil_bufferize.py
__init__() -> None
¶
match_and_rewrite(op: arith.ConstantOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/csl_stencil_bufferize.py
InjectApplyOutsIntoLinalgOuts
dataclass
¶
Bases: RewritePattern
Source code in xdsl/transforms/csl_stencil_bufferize.py
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 436 437 438 439 440 441 442 443 444 445 446 447 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 | |
__init__() -> None
¶
match_and_rewrite(op: csl_stencil.ApplyOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/csl_stencil_bufferize.py
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 436 437 438 439 440 441 442 443 444 445 446 447 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 | |
ReselectLinalgOutsFromInputs
dataclass
¶
Bases: RewritePattern
Reselects the DPS outs of a linalg op if it is one of its inputs.
* select writable tensor input with no later use, or else
* select linalg op input with no later use
Source code in xdsl/transforms/csl_stencil_bufferize.py
__init__() -> None
¶
match_and_rewrite(op: linalg.abstract_ops.NamedOperation | linalg.ops.GenericOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/csl_stencil_bufferize.py
is_writable(val: SSAValue) -> bool
staticmethod
¶
Returns if val is a writable tensor.
Source code in xdsl/transforms/csl_stencil_bufferize.py
CslStencilBufferize
dataclass
¶
Bases: ModulePass
Bufferizes the csl_stencil dialect.
Attempts to inject csl_stencil.apply.recv_chunk_cb.accumulator into linalg compute ops outs within that region
for improved bufferization. Ideally be run after --lift-arith-to-linalg.
In preparation for bufferization with minimal overhead, linalg ops outs are set as follows:
if a linalg op's destination is one of its inputs
1. prefer a writable input with no other uses
2. prefer a linalg op input with no other uses
Source code in xdsl/transforms/csl_stencil_bufferize.py
name = 'csl-stencil-bufferize'
class-attribute
instance-attribute
¶
__init__() -> None
¶
apply(ctx: Context, op: ModuleOp) -> None
¶
Source code in xdsl/transforms/csl_stencil_bufferize.py
tensor_to_memref_type(t: TensorType[AttributeInvT]) -> memref.MemRefType[AttributeInvT]
¶
Type conversion from tensor to memref.
to_buffer_op(op: SSAValue) -> bufferization.ToBufferOp
¶
Creates a bufferization.to_memref operation.
Source code in xdsl/transforms/csl_stencil_bufferize.py
to_tensor_op(op: SSAValue, writable: bool = False, restrict: bool = True) -> bufferization.ToTensorOp
¶
Creates a bufferization.to_tensor operation.