Skip to content

Commit afe9c82

Browse files
tmp
1 parent 6b3aabc commit afe9c82

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from egglog.exp.array_api import *
2+
3+
v = NDArray.matrix([[0.0, 5.0, 0.0], [0.0, 0.0, 10.0], [0.0, 6.0, 8.0]])
4+
n = NDArray.vector([0.0, 0.6, 0.8])
5+
res = vecdot(v, n)
6+
# This fails with EggSmolError: Panic: Illegal merge attempted for function egglog_exp_array_api_Int_to_i64
7+
# assert str(res.eval_numpy("float64")) == "array([ 3., 8., 10.])"
8+
9+
# Trying to debug by inlining the code for eval
10+
11+
12+
egraph = EGraph()
13+
egraph.register(res.shape)
14+
egraph.run(array_api_schedule)
15+
assert eq(egraph.extract(res.shape)).to(TupleInt(Vec(Int(3))))
16+
idxed = res.index((0,))
17+
egraph.register(res.index((0,)))
18+
19+
# This is what fails
20+
# egraph.run(array_api_schedule)
21+
# print(egraph.extract(res.index((0,))))
22+
# Trying to debug by running step by step
23+
24+
i = 0
25+
while (report := egraph.run(array_api_combined_ruleset + run())).updated:
26+
print(f"Step {i}:")
27+
# If we want to look at which rules were applied:
28+
# matches = [k for k, v in report.num_matches_per_rule.items() if v > 0]
29+
# print(f"Step {i}: applied rules: {matches}")
30+
31+
# If we want to see the current extraction:
32+
# print(egraph.extract(res.index((0,))))
33+
34+
# If we want to look at e-graph json:
35+
# print(egraph._serialize().to_json())
36+
i += 1

0 commit comments

Comments
 (0)