Description
PennyLaneAI/jeff-mlir#20 (comment) has led to a discussion about whether jeff regions should be strictly isolated from above.
Currently, any value used within a region must first be explicitly passed to it as an argument. This is not limited to linear types (i.e., qubits and quregs) but also holds for classical types. For example, the (somewhat arbitrary MLIR) program below is invalid because the inner for loop does not have access to %start, %stop, and %step.
func.func @example(%start: i32, %stop: i32, %s: %step) {
jeff.for %i = %start to %stop step %step : i32 {
jeff.for %j = %start to %stop step %step : i32 {}
}
return
}
Considerations
- Impact on optimization: If regions are fully isolated from above, classical constants defined outside a loop cannot be used directly inside the loop body. This could limit or complicate standard optimizations like constant folding and propagation, as pulling/sinking constants into regions would require explicitly adding them to the loop arguments.
- Conversion complexity: Enforcing strict isolation complicates the generation of
jeff programs from source languages or intermediate representations that do not treat these concepts as strictly. Any conversion or serialization tool must scan entire regions to identify all outside values required within the scope and map them to arguments.
Description
PennyLaneAI/jeff-mlir#20 (comment) has led to a discussion about whether
jeffregions should be strictly isolated from above.Currently, any value used within a region must first be explicitly passed to it as an argument. This is not limited to linear types (i.e., qubits and quregs) but also holds for classical types. For example, the (somewhat arbitrary MLIR) program below is invalid because the inner for loop does not have access to
%start,%stop, and%step.Considerations
jeffprograms from source languages or intermediate representations that do not treat these concepts as strictly. Any conversion or serialization tool must scan entire regions to identify all outside values required within the scope and map them to arguments.