-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from jellevos/more-experiments
More experiments
- Loading branch information
Showing
13 changed files
with
183 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,5 @@ instructions.txt | |
.sphinx_build/ | ||
/dist | ||
*.svg | ||
*.pyc | ||
oraqle/addchain_cache.db |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
oraqle/experiments/depth_aware_arithmetization/execution/bench_cardio_circuits.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import random | ||
import time | ||
from typing import Dict | ||
|
||
from galois import GF | ||
|
||
from oraqle.circuits.cardio import ( | ||
construct_cardio_elevated_risk_circuit, | ||
construct_cardio_risk_circuit, | ||
) | ||
from oraqle.compiler.circuit import Circuit | ||
|
||
|
||
def gen_params() -> Dict[str, int]: | ||
params = {} | ||
|
||
params["man"] = random.randint(0, 1) | ||
params["smoking"] = random.randint(0, 1) | ||
params["diabetic"] = random.randint(0, 1) | ||
params["hbp"] = random.randint(0, 1) | ||
|
||
params["age"] = random.randint(0, 100) | ||
params["cholesterol"] = random.randint(0, 60) | ||
params["weight"] = random.randint(40, 150) | ||
params["height"] = random.randint(80, 210) | ||
params["activity"] = random.randint(0, 250) | ||
params["alcohol"] = random.randint(0, 5) | ||
|
||
return params | ||
|
||
|
||
if __name__ == "__main__": | ||
gf = GF(257) | ||
iterations = 10 | ||
|
||
for cost_of_squaring in [0.75]: | ||
print(f"--- Cardio risk assessment ({cost_of_squaring}) ---") | ||
circuit = Circuit([construct_cardio_risk_circuit(gf)]) | ||
|
||
start = time.monotonic() | ||
front = circuit.arithmetize_depth_aware(cost_of_squaring=cost_of_squaring) | ||
print("Compile time:", time.monotonic() - start, "s") | ||
|
||
for depth, cost, arithmetic_circuit in front: | ||
print(depth, cost) | ||
run_time = arithmetic_circuit.run_using_helib(iterations, True, False, **gen_params()) | ||
print("Run time:", run_time) | ||
|
||
print(f"--- Cardio elevated risk assessment ({cost_of_squaring}) ---") | ||
circuit = Circuit([construct_cardio_elevated_risk_circuit(gf)]) | ||
|
||
start = time.monotonic() | ||
front = circuit.arithmetize_depth_aware(cost_of_squaring=cost_of_squaring) | ||
print("Compile time:", time.monotonic() - start, "s") | ||
|
||
for depth, cost, arithmetic_circuit in front: | ||
print(depth, cost) | ||
run_time = arithmetic_circuit.run_using_helib(iterations, True, False, **gen_params()) | ||
print("Run time:", run_time) |
22 changes: 22 additions & 0 deletions
22
oraqle/experiments/depth_aware_arithmetization/execution/bench_equality.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from galois import GF | ||
|
||
from oraqle.compiler.circuit import Circuit | ||
from oraqle.compiler.nodes.leafs import Input | ||
|
||
|
||
if __name__ == "__main__": | ||
iterations = 10 | ||
|
||
for p in [29, 43, 61, 101, 131]: | ||
gf = GF(p) | ||
|
||
x = Input("x", gf) | ||
y = Input("y", gf) | ||
|
||
circuit = Circuit([x == y]) | ||
|
||
for d, c, arith in circuit.arithmetize_depth_aware(0.75): | ||
print(d, c, arith.run_using_helib(10, True, False, x=13, y=19)) | ||
|
||
arith = circuit.arithmetize('naive') | ||
print('square and multiply', arith.multiplicative_depth(), arith.multiplicative_size(), arith.multiplicative_cost(0.75), arith.run_using_helib(10, True, False, x=13, y=19)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Template containing all the things to build an HElib program.""" |
Oops, something went wrong.