-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathir.py
More file actions
executable file
·52 lines (46 loc) · 1.86 KB
/
ir.py
File metadata and controls
executable file
·52 lines (46 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from circuzz.common.field import CurvePrime
from circuzz.common.helper import generate_random_circuit
from circuzz.ir.config import GeneratorKind, IRConfig
config_dict = { \
"rewrite" : {
"weakening_probability" : 0,
"min_rewrites" : 0,
"max_rewrites" : 0,
"rules" : {
"equivalence" : [],
"weakening" :[]
}
},
"generation": {
"generator": GeneratorKind.ARITHMETIC,
"constant_probability_weight" : 1,
"variable_probability_weight" : 1,
"unary_probability_weight" : 1,
"binary_probability_weight" : 1,
"relation_probability_weight" : 1,
"ternary_probability_weight" : 1,
"max_expression_depth" : 2,
"min_number_of_assertions" : 1,
"max_number_of_assertions" : 2,
"min_number_of_input_variables" : 1,
"max_number_of_input_variables" : 2,
"min_number_of_output_variables" : 1,
"max_number_of_output_variables" : 2,
"max_exponent_value" : 2,
"boundary_value_probability" : 0.5
},
"operators" : {
"relations" : ["<", ">", "<=", ">=", "==", "!="],
"boolean_unary_operators" : ["!"],
"boolean_binary_operators" : ["&&", "||", "^^"],
"arithmetic_unary_operators" : ["-", "~"],
"arithmetic_binary_operators" : ["+", "-", "*", "**", "/", "%", "^", "&", "|"],
"is_arithmetic_ternary_supported" : True,
"is_boolean_ternary_supported" : False
}
}
def test_ir_generator(seed: int):
irConfig = IRConfig.from_dict(config_dict)
circuit = generate_random_circuit(CurvePrime.BN128, False, irConfig, seed)
print(circuit)
print()