pub struct SelectOperation<'c> { /* private fields */ }
Expand description
A select
operation. Select operation.
The arith.select
operation chooses one value based on a binary condition
supplied as its first operand. If the value of the first operand is 1
,
the second operand is chosen, otherwise the third operand is chosen.
The second and the third operand must have the same type.
The operation applies to vectors and tensors elementwise given the shape of all operands is identical. The choice is made for each element individually based on the value at the same position as the element in the condition operand. If an i1 is provided as the condition, the entire vector or tensor is chosen.
Example:
// Custom form of scalar selection.
%x = arith.select %cond, %true, %false : i32
// Generic form of the same operation.
%x = "arith.select"(%cond, %true, %false) : (i1, i32, i32) -> i32
// Element-wise vector selection.
%vx = arith.select %vcond, %vtrue, %vfalse : vector<42xi1>, vector<42xf32>
// Full vector selection.
%vx = arith.select %cond, %vtrue, %vfalse : vector<42xf32>
Implementations§
source§impl<'c> SelectOperation<'c>
impl<'c> SelectOperation<'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>
) -> SelectOperationBuilder<'c, Unset, Unset, Unset, Unset>
pub fn builder( context: &'c Context, location: Location<'c> ) -> SelectOperationBuilder<'c, Unset, Unset, Unset, Unset>
Creates a builder.
pub fn result(&self) -> Result<OperationResult<'c, '_>, Error>
pub fn condition(&self) -> Result<Value<'c, '_>, Error>
pub fn true_value(&self) -> Result<Value<'c, '_>, Error>
pub fn false_value(&self) -> Result<Value<'c, '_>, Error>
Trait Implementations§
source§impl<'c> From<SelectOperation<'c>> for Operation<'c>
impl<'c> From<SelectOperation<'c>> for Operation<'c>
source§fn from(operation: SelectOperation<'c>) -> Self
fn from(operation: SelectOperation<'c>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<'c> RefUnwindSafe for SelectOperation<'c>
impl<'c> !Send for SelectOperation<'c>
impl<'c> !Sync for SelectOperation<'c>
impl<'c> Unpin for SelectOperation<'c>
impl<'c> UnwindSafe for SelectOperation<'c>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more