-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerate_factorisation.py
More file actions
66 lines (57 loc) · 1.73 KB
/
generate_factorisation.py
File metadata and controls
66 lines (57 loc) · 1.73 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import sys
sys.path.append("src/")
from formal.formal_cfg import get_IR_for_formal
from formal.factorisation_builder import FactorisationBuilder
import time
filenames = [
"aircraft.jl",
"bayesian_network.jl",
"captcha.jl",
"dirichlet_process.jl",
"geometric.jl",
"gmm_fixed_numclust.jl",
"gmm_variable_numclust.jl",
"hmm.jl",
"hurricane.jl",
"lda_fixed_numtopic.jl",
"lda_variable_numtopic.jl",
"linear_regression.jl",
"marsaglia.jl",
"pcfg.jl",
"pedestrian.jl",
"urn.jl"
]
build_resume = set([
"dirichlet_process.jl",
"gmm_fixed_numclust.jl",
"gmm_variable_numclust.jl",
"hmm.jl",
"lda_fixed_numtopic.jl",
"lda_variable_numtopic.jl"
])
from pathlib import Path
Path("evaluation/benchmark/generated/").mkdir(parents=True, exist_ok=True)
Path("evaluation/unrolled/generated/").mkdir(parents=True, exist_ok=True)
t0 = time.time()
for i, filename in enumerate(filenames):
print(i+1, filename)
ir = get_IR_for_formal("evaluation/benchmark/" + filename)
pw = FactorisationBuilder(filename, ir, True, filename in build_resume)
pw.write_program()
with open("evaluation/benchmark/generated/" + filename, "w") as f:
f.write(pw.out)
filenames = [
# "gmm_fixed_numclust.jl",
"hmm.jl",
# "lda_fixed_numtopic.jl",
# "linear_regression.jl",
]
for i, filename in enumerate(filenames):
print(i+1, filename)
ir = get_IR_for_formal("evaluation/unrolled/" + filename, unroll_loops=True)
pw = FactorisationBuilder(filename, ir, True, filename in build_resume)
pw.write_program()
with open("evaluation/unrolled/generated/" + filename, "w") as f:
f.write(pw.out)
t1 = time.time()
print(f"Finished in {t1-t0:.3f} seconds")