Skip to main content

OperandSegmentInterface

Trait OperandSegmentInterface 

Source
pub trait OperandSegmentInterface: Op {
    // Required method
    fn expected_num_segments(&self, ctx: &Context) -> Option<usize>;

    // Provided methods
    fn compute_segment_sizes(
        operands: Vec<Vec<Value>>,
    ) -> (Vec<Value>, OperandSegmentSizesAttr)
       where Self: Sized { ... }
    fn segment_range(&self, ctx: &Context, seg_idx: usize) -> Range<usize> ⓘ { ... }
    fn get_segment(&self, ctx: &Context, seg_idx: usize) -> Vec<Value> { ... }
    fn segment_size(&self, ctx: &Context, seg_idx: usize) -> u32 { ... }
    fn num_segments(&self, ctx: &Context) -> usize { ... }
    fn set_operand_segment_sizes(
        &self,
        ctx: &Context,
        sizes: OperandSegmentSizesAttr,
    ) { ... }
    fn get_operand_segment_sizes(
        &self,
        ctx: &Context,
    ) -> OperandSegmentSizesAttr { ... }
    fn push_to_segment(
        &self,
        ctx: &mut Context,
        seg_idx: usize,
        operand: Value,
    ) -> usize { ... }
    fn pop_from_segment(&self, ctx: &mut Context, seg_idx: usize) -> Value { ... }
    fn insert_into_segment(
        &self,
        ctx: &mut Context,
        seg_idx: usize,
        seg_opd_idx: usize,
        operand: Value,
    ) { ... }
    fn remove_from_segment(
        &self,
        ctx: &mut Context,
        seg_idx: usize,
        seg_opd_idx: usize,
    ) -> Value { ... }
}
Expand description

Interface for operations whose operands are grouped into segments.

In the case of variadic operands, sometimes it makes sense to group contiguous operands together into a segment. This interface aids doing that. MLIR achieves this by having ODS (tablegen)’ AttrSizedOperandSegments generate getODSOperands() based on the operandSegmentSizes attribute.

§Attribute(s):

NameStatic Name IdentifierType
builtin_operand_segment_sizesATTR_KEY_OPERAND_SEGMENT_SIZESOperandSegmentSizesAttr

Required Methods§

Source

fn expected_num_segments(&self, ctx: &Context) -> Option<usize>

The number of operand segments that this Op must have, or None if any number of segments is valid.

Provided Methods§

Source

fn compute_segment_sizes( operands: Vec<Vec<Value>>, ) -> (Vec<Value>, OperandSegmentSizesAttr)
where Self: Sized,

Given a list of segmented operands, compute the segment sizes and flatten the operands (ready for use in constructing an operation). Call set_operand_segment_sizes with the computed segment sizes to set the attribute.

Source

fn segment_range(&self, ctx: &Context, seg_idx: usize) -> Range<usize> ⓘ

Return the index range of operands in segment seg_idx of this Op. Panics if seg_idx is out of bounds.

Source

fn get_segment(&self, ctx: &Context, seg_idx: usize) -> Vec<Value>

Get the seg_idxth segment of operands. Panics if seg_idx is out of bounds.

Source

fn segment_size(&self, ctx: &Context, seg_idx: usize) -> u32

Get the length of the seg_idxth segment.

Source

fn num_segments(&self, ctx: &Context) -> usize

Get the number of segments.

Source

fn set_operand_segment_sizes( &self, ctx: &Context, sizes: OperandSegmentSizesAttr, )

Set the operand_segment_sizes attribute for this operation.

Source

fn get_operand_segment_sizes(&self, ctx: &Context) -> OperandSegmentSizesAttr

Get the operand_segment_sizes attribute for this operation.

Source

fn push_to_segment( &self, ctx: &mut Context, seg_idx: usize, operand: Value, ) -> usize

Push a new operand at the end of the seg_idxth segment. Returns the index of the inserted operand within that segment.

Source

fn pop_from_segment(&self, ctx: &mut Context, seg_idx: usize) -> Value

Pop and return the last operand in the seg_idxth segment.

Source

fn insert_into_segment( &self, ctx: &mut Context, seg_idx: usize, seg_opd_idx: usize, operand: Value, )

Insert an operand at seg_opd_idx within the seg_idxth segment.

Source

fn remove_from_segment( &self, ctx: &mut Context, seg_idx: usize, seg_opd_idx: usize, ) -> Value

Remove and return the operand at seg_opd_idx in the seg_idxth segment.

Trait Implementations§

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§