fn sequence_insert(self: Array<Tensor<T>>, tensor: @Tensor<T>, position: Option<Tensor<i32>>) -> Array<Tensor<T>>;
Returns a tensor sequence that inserts 'tensor' into 'self' at 'position'.
Tensor sequence containing 'tensor' inserted into 'self' at 'position'.
Let's insert the tensor [2] into the sequence [[1], [3]] at position 1.
use orion::operators::tensor::{TensorTrait, Tensor, I32Tensor, U32Tensor};
fn sequence_insert_example() -> Array<Tensor<u32>> {
// Prepare sequence
let mut sequence = ArrayTrait::new();
let mut shape = ArrayTrait::<usize>::new();
shape.append(1);
let mut data = ArrayTrait::new();
data.append(1);
sequence.append(TensorTrait::new(shape.span(), data.span()));
let mut data = ArrayTrait::new();
data.append(3);
sequence.append(TensorTrait::new(shape.span(), data.span()));
// Prepare input tensor
let mut data = ArrayTrait::new();
data.append(2);
let tensor = TensorTrait::new(shape.span(), data.span());
// Prepare position
let mut shape = ArrayTrait::<usize>::new();
let mut data = ArrayTrait::<i32>::new();
data.append(1);
let position = TensorTrait::<i32>::new(shape.span(), data.span())
let sequence = self.sequence_insert(tensor, Option::Some(position));
return sequence;
}
>>> [[1], [2], [3]]