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):
| Name | Static Name Identifier | Type |
|---|---|---|
| builtin_operand_segment_sizes | ATTR_KEY_OPERAND_SEGMENT_SIZES | OperandSegmentSizesAttr |
Required Methods§
Provided Methods§
Sourcefn compute_segment_sizes(
operands: Vec<Vec<Value>>,
) -> (Vec<Value>, OperandSegmentSizesAttr)where
Self: Sized,
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.
Sourcefn segment_range(&self, ctx: &Context, seg_idx: usize) -> Range<usize> ⓘ
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.
Sourcefn get_segment(&self, ctx: &Context, seg_idx: usize) -> Vec<Value>
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.
Sourcefn segment_size(&self, ctx: &Context, seg_idx: usize) -> u32
fn segment_size(&self, ctx: &Context, seg_idx: usize) -> u32
Get the length of the seg_idxth segment.
Sourcefn num_segments(&self, ctx: &Context) -> usize
fn num_segments(&self, ctx: &Context) -> usize
Get the number of segments.
Sourcefn set_operand_segment_sizes(
&self,
ctx: &Context,
sizes: OperandSegmentSizesAttr,
)
fn set_operand_segment_sizes( &self, ctx: &Context, sizes: OperandSegmentSizesAttr, )
Set the operand_segment_sizes attribute for this operation.
Sourcefn get_operand_segment_sizes(&self, ctx: &Context) -> OperandSegmentSizesAttr
fn get_operand_segment_sizes(&self, ctx: &Context) -> OperandSegmentSizesAttr
Get the operand_segment_sizes attribute for this operation.
Sourcefn push_to_segment(
&self,
ctx: &mut Context,
seg_idx: usize,
operand: Value,
) -> usize
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.
Sourcefn pop_from_segment(&self, ctx: &mut Context, seg_idx: usize) -> Value
fn pop_from_segment(&self, ctx: &mut Context, seg_idx: usize) -> Value
Pop and return the last operand in the seg_idxth segment.
Trait Implementations§
impl OpInterfaceMarker for dyn OperandSegmentInterface
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".