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

A with_shape operation. Returns ValueShape with given shape.

Returns ValueShape with the shape updated to match the shape operand. That is a new ValueShape tuple is created with value equal to operand’s value and shape equal to shape. If the ValueShape and given shape are non-conformant, then the returned ValueShape will represent an error of this mismatch. Similarly if either inputs are in an error state, then an error is propagated.

Usage: %0 = shape.with_shape %1, %2 : tensor<…>, !shape.shape

This is used, for example, where one combines shape function calculations and/or call one shape function from another. E.g.,

func.func @shape_foobah(%a: !shape.value_shape,
                   %b: !shape.value_shape,
                   %c: !shape.value_shape) -> !shape.shape {
  %0 = call @shape_foo(%a, %b) :
    (!shape.value_shape, !shape.value_shape) -> !shape.shape
  %1 = shape.with_shape %b, %0 : !shape.value_shape, !shape.shape
  %2 = call @shape_bah(%c, %1) :
    (!shape.value_shape, !shape.value_shape) -> !shape.shape
  return %2 : !shape.shape
}

This op need not be a refinement of the shape. In non-error cases the input ValueShape’s value and shape are conformant and so too for the output, but the result may be less specified than operand’s shape as shape is merely used to construct the new ValueShape. If join behavior is desired then a join op should be used.

Implementations§

source§

impl<'c> WithOperation<'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> ) -> WithOperationBuilder<'c, Unset, Unset, Unset>

Creates a builder.

source

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

source

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

source

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

Trait Implementations§

source§

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

source§

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

Converts to this type from the input type.
source§

impl<'c> TryFrom<Operation<'c>> for WithOperation<'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 WithOperation<'c>

§

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

§

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

§

impl<'c> Unpin for WithOperation<'c>

§

impl<'c> UnwindSafe for WithOperation<'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.