Bases: ModulePass
tensor.empty ops return a tensor of unspecified contents whose only purpose
is to carry the tensor shape. This pass converts such ops to
bufferization.alloc_tensor ops, which bufferize to buffer allocations.
Source code in xdsl/transforms/empty_tensor_to_alloc_tensor.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37 | class EmptyTensorToAllocTensorPass(ModulePass):
"""
tensor.empty ops return a tensor of unspecified contents whose only purpose
is to carry the tensor shape. This pass converts such ops to
bufferization.alloc_tensor ops, which bufferize to buffer allocations.
"""
name = "empty-tensor-to-alloc-tensor"
def apply(self, ctx: Context, op: builtin.ModuleOp) -> None:
PatternRewriteWalker(
EmptyTensorLoweringPattern(),
apply_recursively=False,
).rewrite_module(op)
|
Source code in xdsl/transforms/empty_tensor_to_alloc_tensor.py
| def apply(self, ctx: Context, op: builtin.ModuleOp) -> None:
PatternRewriteWalker(
EmptyTensorLoweringPattern(),
apply_recursively=False,
).rewrite_module(op)
|