'bufferization' Dialect
Bufferization in MLIR is the process of converting the tensor
type to the
memref
type.
The bufferization
dialect is intended to collect operations/interfaces
specific to the bufferization passes.
Overview of the bufferization infrastructure and important conceptual details related to using the MLIR dialect conversion infrastructure can be found in bufferization and buffer deallocation.
Operation definition ¶
bufferization.alloc_tensor
(::mlir::bufferization::AllocTensorOp) ¶
buffer allocation in tensor land
Syntax:
operation ::= `bufferization.alloc_tensor` `(`$dynamicSizes`)` attr-dict `:` type($result)
bufferization.alloc_tensor
is an operation that bufferizes to a buffer
allocation of a given shape. The shape could be dynamic or static.
Reading from the result of an alloc_tensor
op yields an undefined value.
alloc_tensor
is a helper op for bufferization. It marks the beginning of
a new tensor SSA use-def chain and is used to control in-place bufferization
decisions during One-Shot Bufferize.
Interfaces: BufferizableOpInterface, ReifyRankedShapedTypeOpInterface
Operands: ¶
Operand | Description |
---|---|
dynamicSizes | index |
Results: ¶
Result | Description |
---|---|
result | tensor of any type values |
bufferization.clone
(::mlir::bufferization::CloneOp) ¶
Syntax:
operation ::= `bufferization.clone` $input attr-dict `:` type($input) `to` type($output)
Clones the data in the input view into an implicitly defined output view.
Usage:
%arg1 = bufferization.clone %arg0 : memref<?xf32> to memref<?xf32>
Valid implementations of this operation may alias the input and output views or create an actual copy. Mutating the source or result of the clone operation after the clone operation thus leads to undefined behavior.
Interfaces: AllocationOpInterface, CopyOpInterface, MemoryEffectOpInterface
Operands: ¶
Operand | Description |
---|---|
input | unranked.memref of any type values or memref of any type values |
Results: ¶
Result | Description |
---|---|
output | unranked.memref of any type values or memref of any type values |
bufferization.to_memref
(::mlir::bufferization::ToMemrefOp) ¶
tensor to memref cast operation
Syntax:
operation ::= `bufferization.to_memref` $tensor attr-dict `:` type($memref)
Casts a tensor to a memref.
// Result type is tensor<4x?xf32>
%12 = bufferization.to_memref %10 : memref<4x?xf32, #map0, 42>
Note, that mutating the result of the to_memref operation leads to undefined behavior.
This operation is a specialized variant of the built-in unrealized_conversion_cast and is intended for use in the context of gradual bufferization.
Traits: SameOperandsAndResultElementType, SameOperandsAndResultShape
Interfaces: BufferizableOpInterface, NoSideEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands: ¶
Operand | Description |
---|---|
tensor | tensor of any type values |
Results: ¶
Result | Description |
---|---|
memref | unranked.memref of any type values or memref of any type values |
bufferization.to_tensor
(::mlir::bufferization::ToTensorOp) ¶
memref to tensor operation
Syntax:
operation ::= `bufferization.to_tensor` $memref attr-dict `:` type($memref)
Create a tensor from a memref, making an independent copy of the element data. The result value is a tensor whose shape and element type match the memref operand.
The opposite of this op is to_memref. Together, these two ops are useful for source/target materializations when doing type conversions involving tensors and memrefs.
Example:
// Produces a value of tensor<4x?xf32> type.
%12 = bufferization.to_tensor %10 : memref<4x?xf32, #layout, memspace0>
If tensor load is used in the bufferization steps, mutating the source buffer after loading leads to undefined behavior.
Traits: SameOperandsAndResultElementType, SameOperandsAndResultShape
Interfaces: BufferizableOpInterface
Operands: ¶
Operand | Description |
---|---|
memref | unranked.memref of any type values or memref of any type values |
Results: ¶
Result | Description |
---|---|
result | tensor of any type values |