Bufferization
bufferization
¶
Bufferization = Dialect('bufferization', [AllocTensorOp, CloneOp, ToTensorOp, ToBufferOp, MaterializeInDestinationOp], [])
module-attribute
¶
TensorFromMemRefConstraint
dataclass
¶
Bases: AttrConstraint[TensorType[Attribute] | UnrankedTensorType[Attribute]]
Converts an input memref constraint to the corresponding tensor constraint, i.e. the constraints on element type and shape are the same as the input constraint, but the attribute is verified to be a tensor instead of a memref.
Source code in xdsl/dialects/bufferization.py
memref_constraint: AttrConstraint[MemRefType | UnrankedMemRefType]
instance-attribute
¶
__init__(memref_constraint: AttrConstraint[MemRefType | UnrankedMemRefType]) -> None
¶
tensor_to_memref(tensor: TensorType | UnrankedTensorType) -> MemRefType | UnrankedMemRefType
staticmethod
¶
Source code in xdsl/dialects/bufferization.py
memref_to_tensor(memref: MemRefType | UnrankedMemRefType) -> TensorType | UnrankedTensorType
staticmethod
¶
Source code in xdsl/dialects/bufferization.py
can_infer(var_constraint_names: AbstractSet[str]) -> bool
¶
infer(context: InferenceContext) -> TensorType[Attribute] | UnrankedTensorType[Attribute]
¶
verify(attr: Attribute, constraint_context: VerificationContext) -> None
¶
Source code in xdsl/dialects/bufferization.py
get_bases() -> set[type[Attribute]] | None
¶
mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> TensorFromMemRefConstraint
¶
AllocTensorOp
¶
Bases: IRDLOperation
bufferization.alloc_tensor materializes an uninitialized tensor with a
given shape (dynamic or static). It always bufferizes to a new buffer
allocation of the given shape. The optional copy operand specifies the
contents of the tensors. If no copy operand is specified, reading from the
result of an alloc_tensor op yields an undefined value.
If copy is specified, no dynamic sizes should be passed, since they are
the same as the dynamic sizes of the copy operand.
alloc_tensor is a helper op for bufferization. The operation is provided
as an anchor that marks the beginning of a new tensor SSA use-def chain. It
can be used to control in-place bufferization decisions during One-Shot
Bufferize: The bufferized result of a bufferization.alloc_tensor does not
alias with any other buffer, so it can be used to resolve read-after-write
conflicts that would have been introduced by the in-place bufferization of
another op.
The optional memory_space attribute specifies the memory space when
bufferizing this op. The memory space is inferred from copy if specified.
If neither copy nor memory_space is specified, the default memory space
is used during bufferization.
The optional size_hint operand specifies the number of non-zero elements
for sparse tensors. The value of size_hint should be not less than 1 and
not larger than the linear size of the corresponding dense tensor type. If
this requirement is not met, the behavior of the operator is undefined.
Note: An alloc_tensor with a copy should also be expressed as an
alloc_tensor without copy, followed by a copy_tensor.
Source code in xdsl/dialects/bufferization.py
name = 'bufferization.alloc_tensor'
class-attribute
instance-attribute
¶
T: ClassVar = VarConstraint('T', AnyTensorTypeConstr | AnyUnrankedTensorTypeConstr)
class-attribute
instance-attribute
¶
dynamic_sizes = var_operand_def(IndexType())
class-attribute
instance-attribute
¶
copy = opt_operand_def(T)
class-attribute
instance-attribute
¶
size_hint = opt_operand_def(IndexType())
class-attribute
instance-attribute
¶
tensor = result_def(T)
class-attribute
instance-attribute
¶
irdl_options = (AttrSizedOperandSegments(as_property=True),)
class-attribute
instance-attribute
¶
assembly_format = '`(` $dynamic_sizes `)` ( `copy` `(` $copy^ `)`)? (`size_hint` `=` $size_hint^)? attr-dict `:` type($tensor)'
class-attribute
instance-attribute
¶
__init__(result_type: Attribute, dynamic_sizes: Sequence[Operation | SSAValue] | None = None, copy: SSAValue | Operation | None = None, size_hint: SSAValue | Operation | None = None)
¶
Source code in xdsl/dialects/bufferization.py
CloneOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/bufferization.py
name = 'bufferization.clone'
class-attribute
instance-attribute
¶
T: ClassVar = VarConstraint('T', MemRefType.constr() | AnyUnrankedMemRefTypeConstr)
class-attribute
instance-attribute
¶
input = operand_def(T)
class-attribute
instance-attribute
¶
output = result_def(T)
class-attribute
instance-attribute
¶
assembly_format = '$input attr-dict `:` type($input) `to` type($output)'
class-attribute
instance-attribute
¶
ToTensorOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/bufferization.py
name = 'bufferization.to_tensor'
class-attribute
instance-attribute
¶
T: ClassVar = VarConstraint('T', MemRefType.constr() | AnyUnrankedMemRefTypeConstr)
class-attribute
instance-attribute
¶
memref = operand_def(T)
class-attribute
instance-attribute
¶
tensor = result_def(TensorFromMemRefConstraint(T))
class-attribute
instance-attribute
¶
writable = opt_prop_def(UnitAttr)
class-attribute
instance-attribute
¶
restrict = opt_prop_def(UnitAttr)
class-attribute
instance-attribute
¶
assembly_format = '$memref (`restrict` $restrict^)? (`writable` $writable^)? attr-dict `:` type($memref) `to` type($tensor)'
class-attribute
instance-attribute
¶
__init__(memref: SSAValue | Operation, restrict: bool = False, writable: bool = False)
¶
Source code in xdsl/dialects/bufferization.py
ToBufferOp
dataclass
¶
Bases: IRDLOperation
Source code in xdsl/dialects/bufferization.py
name = 'bufferization.to_buffer'
class-attribute
instance-attribute
¶
T: ClassVar = VarConstraint('T', MemRefType.constr() | AnyUnrankedMemRefTypeConstr)
class-attribute
instance-attribute
¶
tensor = operand_def(TensorFromMemRefConstraint(T))
class-attribute
instance-attribute
¶
memref = result_def(T)
class-attribute
instance-attribute
¶
read_only = opt_prop_def(UnitAttr)
class-attribute
instance-attribute
¶
assembly_format = '$tensor (`read_only` $read_only^)? `:` attr-dict type($tensor) `to` type($memref)'
class-attribute
instance-attribute
¶
MaterializeInDestinationOp
dataclass
¶
Bases: IRDLOperation