Struct melior::dialect::ods::bufferization::ToTensorOperation
source · pub struct ToTensorOperation<'c> { /* private fields */ }
Expand description
A to_tensor
operation. Create a tensor from a memref
.
An operation that creates a tensor from a memref
. 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.
%t = bufferization.to_tensor %m : memref<4x?xf32, #layout, 0>
If the writable
unit attribute is set, the produced tensor is considered
“writable” during bufferization. Otherwise, every OpOperand that bufferizes
to a write to the future buffer of the resulting tensor (or an alias
thereof) will bufferize out-of-place to prevent emitting any writes to
memref
during bufferization.
If the given memref does not alias with any other memref passed to another
to_tensor
op, the restrict
unit attribute can be set. Only such
operations are supported by One-Shot Bufferize. (Otherwise, potential memref
aliasing relationships would have to be captured in One-Shot Bufferize.)
Example:
%t = bufferization.to_tensor %m restrict writable : memref<4xf32>
// %t is writable, so the tensor.insert may bufferize in-place in the
// absence of other conflicts.
%r = tensor.insert %f into %t[%idx] : tensor<4xf32>
to_tensor
ops are not bufferized. They are expected to fold away after
bufferization. If there are non-bufferizable ops in the IR and
allowUnknownOps
is set, they may be part of the resulting IR and not fold
away. However, such IR is no longer bufferizable with One-Shot Bufferize.
Implementations§
source§impl<'c> ToTensorOperation<'c>
impl<'c> ToTensorOperation<'c>
sourcepub fn as_operation(&self) -> &Operation<'c>
pub fn as_operation(&self) -> &Operation<'c>
Returns a generic operation.
sourcepub fn builder(
context: &'c Context,
location: Location<'c>
) -> ToTensorOperationBuilder<'c, Unset, Unset>
pub fn builder( context: &'c Context, location: Location<'c> ) -> ToTensorOperationBuilder<'c, Unset, Unset>
Creates a builder.