Closed asraa closed 1 year ago
In regard of assembly format for SameOperandsAndResultType
ops.
@asraa , @j2kun could you please comment on the options, propose new ones ?
// Current:
%z = bgv.mul(%x, %y) : !bgv.ciphertext<rings=#rings> -> !bgv.ciphertext<rings=#rings, dim=3>
%q = bgv.modulus_switch(%x) {from_level = 1, to_level=0} : (!bgv.ciphertext<rings=#rings>) -> !bgv.ciphertext<rings=#rings, dim=2, level=0>
// Option 1. Render `rings` spec before the ciphertext first operand,
// render all ciphertext operands without `rings` attribute
%z = bgv.mul(%x, %y) : <rings=#rings> !bgv.ciphertext -> !bgv.ciphertext<dim=3>
%q = bgv.modulus_switch(%x) {from_level = 1, to_level=0} : <rings=#rings> !bgv.ciphertext -> !bgv.ciphertext<dim=2, level=0>
// Option 2. Do not render `rings` at all,
// assuming that in most cases within block all operation will be done on the same rings, so no disambiguation is needed.
%z = bgv.mul(%x, %y) : !bgv.ciphertext -> !bgv.ciphertext<dim=3>
%q = bgv.modulus_switch(%x) {from_level = 1, to_level=0} : !bgv.ciphertext -> !bgv.ciphertext<dim=2, level=0>
In all of these cases the type actually legitimately changes, though, right? So we can't use a type constraint that asserts equality to simplify the assembly format. In that case I don't mind keeping the more verbose syntax, at least to promote consistency.
[!NOTE] Re-commenting because this issue was closed with unresolved TODOs.
This issue has 1 outstanding TODOs:
This comment was autogenerated by todo-backlinks
Most of our ops do not utilize Constrains which can be used to verify operations.
For example, it may enforce that for BGV mul ops, that their ring parameter must be the same across inputs and outputs, or that the inputs size must be the same, while their output size is predicatable one greater.
These also allow simplification of the assembly format.