Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--optimize-relinearization fails for multiple return values #1298

Open
AlexanderViand-Intel opened this issue Jan 23, 2025 · 0 comments
Open
Assignees
Labels
dialect: mgmt Issues concerning the mgmt dialect

Comments

@AlexanderViand-Intel
Copy link
Collaborator

// heir-opt --mlir-to-bgv
func.func @foo(%x: i16 {secret.secret}, %y: i16 {secret.secret}) -> (i16, i16) {
  %0 = arith.addi %x, %y : i16
  return %0, %0: i16, i16
}

fails with

Error solving the problem: INVALID_ARGUMENT: duplicate name inserted: RequireLinearized_secret.yield_1; ModelProto.linear_constraints are invalid
/home/aviand/code/heir/tests/Emitter/heracles/emit_heracles_bgv.mlir:11:1: error: Failed to solve the optimization problem
func.func @foo(%x: i16 {secret.secret}, %y: i16 {secret.secret}) -> (i16, i16) {
^
/home/aviand/code/heir/tests/Emitter/heracles/emit_heracles_bgv.mlir:11:1: note: see current operation: 
%0:2 = "secret.generic"(%arg0, %arg1) ({
^bb0(%arg2: i16, %arg3: i16):
  %1 = "arith.addi"(%arg2, %arg3) <{overflowFlags = #arith.overflow<none>}> {mgmt.mgmt = #mgmt.mgmt<level = 0>} : (i16, i16) -> i16
  "secret.yield"(%1, %1) : (i16, i16) -> ()
}) {arg0 = {mgmt.mgmt = #mgmt.mgmt<level = 0>}, arg1 = {mgmt.mgmt = #mgmt.mgmt<level = 0>}} : (!secret.secret<i16>, !secret.secret<i16>) -> (!secret.secret<i16>, !secret.secret<i16>)

This also occurs when the return values aren't duplicates:

// heir-opt --mlir-to-bgv
func.func @foo(%x: i16 {secret.secret}, %y: i16 {secret.secret}) -> (i16, i16) {
  %0 = arith.addi %x, %y : i16
  %1 = arith.addi %x, %x : i16
  return %0, %1: i16, i16
}

fails with

Error solving the problem: INVALID_ARGUMENT: duplicate name inserted: RequireLinearized_secret.yield_2; ModelProto.linear_constraints are invalid
/home/aviand/code/heir/tests/Emitter/heracles/emit_heracles_bgv.mlir:11:1: error: Failed to solve the optimization problem
func.func @foo(%x: i16 {secret.secret}, %y: i16 {secret.secret}) -> (i16, i16) {
^
/home/aviand/code/heir/tests/Emitter/heracles/emit_heracles_bgv.mlir:11:1: note: see current operation: 
%0:2 = "secret.generic"(%arg0, %arg1) ({
^bb0(%arg2: i16, %arg3: i16):
  %1 = "arith.addi"(%arg2, %arg3) <{overflowFlags = #arith.overflow<none>}> {mgmt.mgmt = #mgmt.mgmt<level = 0>} : (i16, i16) -> i16
  %2 = "arith.addi"(%arg2, %arg2) <{overflowFlags = #arith.overflow<none>}> {mgmt.mgmt = #mgmt.mgmt<level = 0>} : (i16, i16) -> i16
  "secret.yield"(%1, %2) : (i16, i16) -> ()
}) {arg0 = {mgmt.mgmt = #mgmt.mgmt<level = 0>}, arg1 = {mgmt.mgmt = #mgmt.mgmt<level = 0>}} : (!secret.secret<i16>, !secret.secret<i16>) -> (!secret.secret<i16>, !secret.secret<i16>)

Unlike the previous issue, this seems like it's actually be a bug/ intended limitation of the relin solver 😉

@AlexanderViand-Intel AlexanderViand-Intel added the dialect: mgmt Issues concerning the mgmt dialect label Jan 23, 2025
@AlexanderViand-Intel AlexanderViand-Intel changed the title --insert-relinearization fails for multiple return values --optimize-relinearization fails for multiple return values Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialect: mgmt Issues concerning the mgmt dialect
Projects
None yet
Development

No branches or pull requests

2 participants