pub struct InsertSliceOperation<'c> { /* private fields */ }
Expand description
An insert_slice
operation. Insert_slice operation.
The “insert_slice” operation insert a tensor source
into another
tensor dest
as specified by the operation’s offsets, sizes and strides
arguments.
It returns a copy of dest
with the proper slice updated with the value
of source
.
The insert_slice operation supports the following arguments:
- source: the tensor that is inserted.
- dest: the tensor into which the source tensor is inserted.
- offsets: tensor-rank number of offsets into the
dest
tensor into which the slice is inserted. - sizes: tensor-rank number of sizes which specify the sizes of the source tensor type.
- strides: tensor-rank number of strides that specify subsampling in each dimension.
The representation based on offsets, sizes and strides support a
partially-static specification via attributes specified through the
static_offsets
, static_sizes
and static_strides
arguments. A special
sentinel value ShapedType::kDynamic encodes that the corresponding entry has
a dynamic value.
After buffer allocation, the “insert_slice” op is expected to lower into a memref.subview op.
An insert_slice operation may additionally specify insertion into a tensor of higher rank than the source tensor, along dimensions that are statically known to be of size 1. This rank-altering behavior is not required by the op semantics: this flexibility allows to progressively drop unit dimensions while lowering between different flavors of ops on that operate on tensors. The rank-altering behavior of tensor.insert_slice matches the rank-reducing behavior of tensor.extract_slice.
§Verification in the rank-reduced case
The same verification discussion and mechanisms apply as for ExtractSliceOp. Unlike ExtractSliceOp however, there is no need for a specific inference.
Example:
// Rank-altering insert_slice.
%1 = tensor.insert_slice %t into %0[0, 0, 0][1, 16, 4][1, 1, 1] :
tensor<16x4xf32> into tensor<8x16x4xf32>
%3 = tensor.insert_slice %tt into %2[%o0, 4, %o2][1, %sz1, 1][1, %st1, 1] :
tensor<1x?xf32> into tensor<8x16x4xf32>
Implementations§
source§impl<'c> InsertSliceOperation<'c>
impl<'c> InsertSliceOperation<'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>
) -> InsertSliceOperationBuilder<'c, Unset, Unset, Unset, Unset, Unset, Unset, Unset, Unset, Unset>
pub fn builder( context: &'c Context, location: Location<'c> ) -> InsertSliceOperationBuilder<'c, Unset, Unset, Unset, Unset, Unset, Unset, Unset, Unset, Unset>
Creates a builder.