-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't working
Description
leading to OOB errors in the SparseLinAlg backend on programs like:
main:
p <~ uniform([1]:[int])
x <~ bernoulli(1/2)
y <~ bernoulli(1/2)
return x
which produces output:
TREE:
VDist Tree: Leaf EVal VInteger 1
VDist Tree: Split (Just 1) (Leaf EVal VBool True) (Leaf EVal VBool False)
VDist Tree: Split (Just 2) (Leaf EVal VBool True) (Leaf EVal VBool False)
VDist Tree: Split (Just 3) (Leaf EVal VBool True) (Leaf EVal VBool False)
(0 (2 (EVal VBool True) (EVal VBool True)) (3 (EVal VBool False) (EVal VBool False)))
size: 7
TREE SAMPLING INFERENCE:
[(EVal VBool True,0.494),(EVal VBool False,0.506)]
0.5
eqs: [{ 3 = [] },{ 2 = [(1 % 2,Nothing),(1 % 2,Nothing)] },{ 0 = [(1 % 2,Just 2),(1 % 2,Just 3)] }]
mateqs: [([(1 % 1,3)],0 % 1),([(1 % 1,2)],1 % 1),([(1 % 1,0),((-1) % 2,2),((-1) % 2,3)],0 % 1)]
ltree: (0 (2 (True) (True)) (3 (False) (False)))
eqs: [([(1 % 1,3)],0 % 1),([(1 % 1,2)],1 % 1),([(1 % 1,0),((-1) % 2,2),((-1) % 2,3)],0 % 1)]
n: 3
l: [(0,3,1.0),(1,2,1.0),(2,0,1.0),(2,2,-0.5),(2,3,-0.5)]
zar-exe: insertSpMatrix : index out of bounds
CallStack (from HasCallStack):
error, called at src/Data/Sparse/SpMatrix.hs:208:17 in sparse-linear-algebra-0.3.1-60PEPJsn9866VHk9xIHXYW:Data.Sparse.SpMatrix
The main issue is the use of out-of-bounds label 3 in the generated matrix equations.
The following version of the program (where p is sampled from uniform[1,2]) produces no error:
main:
p <~ uniform([1, 2]:[int])
x <~ bernoulli(1/2)
y <~ bernoulli(1/2)
return x
My working hypothesis is that there's a label generated for uniform[1] but no corresponding equation (because uniform[1] is essentially p <- 1), leading to the OOB error. This violates an assumption of the SparseLinAlg backend, that the highest occurring label is less than the total number of subtrees.
Two possible solutions:
- Do alpha-renaming of labels before generating equations.
- Desugar
x <~ uniform([c])tox <- c.
Solution 2 is easier but doesn't solve the more general issue (the assumption on labels made by the SparseLinAlg backend).
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working