Skip to main content

recognize_elementwise_map

Function recognize_elementwise_map 

Source
pub fn recognize_elementwise_map(ops: &[MicroOp]) -> Option<MapPlan>
Expand description

Returns Some(MapPlan) iff ops is a pure element-wise map region in the top-tested while shape that adapt_region produces:

  [0]          Branch { cmp(Lt|LtEq), lhs:i, rhs:n, .. }   // loop guard (exit when cmp FALSE)
  [1..j-2]     body: ArrLoad{idx==i,checked:false} / float arith / ArrStore{idx==i,checked:false}
  [j-2]        LoadConst { dst:step, value:1 }
  [j-1]        Add { dst:i, lhs:i, rhs:step }              // increment
  [j]          Jump { target:0 }                           // back-edge to head
  [j+1..]      exit (Return)

Any reduction (loop-carried operand), cross-index access, bounds-checked access, non-unit stride, call, or other op makes it None — the conservative, sound side.