pub struct PushBackOperation<'c> { /* private fields */ }
Expand description

A push_back operation. Pushes a value to the back of a given buffer.

Pushes value to the end of the given sparse tensor storage buffer inBuffer as indicated by the value of curSize and returns the new size of the buffer in newSize (newSize = curSize + n). The capacity of the buffer is recorded in the memref type of inBuffer. If the current buffer is full, then inBuffer.realloc is called before pushing the data to the buffer. This is similar to std::vector push_back.

The optional input n specifies the number of times to repeately push the value to the back of the tensor. When n is a compile-time constant, its value can’t be less than 1. If n is a runtime value that is less than 1, the behavior is undefined. Although using input n is semantically equivalent to calling push_back n times, it gives compiler more chances to to optimize the memory reallocation and the filling of the memory with the same value.

The inbounds attribute tells the compiler that the insertion won’t go beyond the current storage buffer. This allows the compiler to not generate the code for capacity check and reallocation. The typical usage will be for “dynamic” sparse tensors for which a capacity can be set beforehand.

Note that this operation is “impure” in the sense that even though the result is modeled through an SSA value, referencing the memref through the old SSA value after this operation is undefined behavior.

Example:

%buf, %newSize = sparse_tensor.push_back %curSize, %buffer, %val
   : index, memref<?xf64>, f64
%buf, %newSize = sparse_tensor.push_back inbounds %curSize, %buffer, %val
   : xindex, memref<?xf64>, f64
%buf, %newSize = sparse_tensor.push_back inbounds %curSize, %buffer, %val, %n
   : xindex, memref<?xf64>, f64

Implementations§

source§

impl<'c> PushBackOperation<'c>

source

pub fn name() -> &'static str

Returns a name.

source

pub fn as_operation(&self) -> &Operation<'c>

Returns a generic operation.

source

pub fn builder( context: &'c Context, location: Location<'c> ) -> PushBackOperationBuilder<'c, Unset, Unset, Unset, Unset, Unset>

Creates a builder.

source

pub fn out_buffer(&self) -> Result<OperationResult<'c, '_>, Error>

source

pub fn new_size(&self) -> Result<OperationResult<'c, '_>, Error>

source

pub fn cur_size(&self) -> Result<Value<'c, '_>, Error>

source

pub fn in_buffer(&self) -> Result<Value<'c, '_>, Error>

source

pub fn value(&self) -> Result<Value<'c, '_>, Error>

source

pub fn n(&self) -> Result<Value<'c, '_>, Error>

source

pub fn inbounds(&self) -> Result<Attribute<'c>, Error>

source

pub fn set_inbounds(&mut self, value: Attribute<'c>)

source

pub fn remove_inbounds(&mut self) -> Result<(), Error>

Trait Implementations§

source§

impl<'c> From<PushBackOperation<'c>> for Operation<'c>

source§

fn from(operation: PushBackOperation<'c>) -> Self

Converts to this type from the input type.
source§

impl<'c> TryFrom<Operation<'c>> for PushBackOperation<'c>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(operation: Operation<'c>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'c> RefUnwindSafe for PushBackOperation<'c>

§

impl<'c> !Send for PushBackOperation<'c>

§

impl<'c> !Sync for PushBackOperation<'c>

§

impl<'c> Unpin for PushBackOperation<'c>

§

impl<'c> UnwindSafe for PushBackOperation<'c>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.