Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong results when slicing a symmetric sparse tensor in python lib #132

Open
nickirk opened this issue Nov 30, 2021 · 0 comments
Open

Wrong results when slicing a symmetric sparse tensor in python lib #132

nickirk opened this issue Nov 30, 2021 · 0 comments

Comments

@nickirk
Copy link

nickirk commented Nov 30, 2021

Dear Edgar,

As the title suggests, I provide a minimal example to reproduce it. I am using the latest commit on master: commit c4f89dc

import ctf
import numpy as np
print(ctf.__file__)
vals = [1,2,3,4,5,6]
indices = [0,1,3,4,5,7]

s = ctf.tensor([2,2,2,2], sym=[1,0,1,0], sp=1)
s.write(indices, vals)
d = ctf.tensor([2,2,2,2], sym=[1,0,1,0], sp=0)
d.write(indices, vals)

print(s)
print(d)
assert(np.array_equal(s.to_nparray(),d.to_nparray()))

d_1 = d[:,:,:,:1]
print(d_1)
s_1 = s[:,:,:,:1]
print(s_1)
assert(np.array_equal(s_1.to_nparray(),d_1.to_nparray()))

One can see that d_1 is as intended, while s_1 is wrong. One can also test that as long as we don't use symmetries in the tensor, the slicing works fine for both dense and sparse tensors:

d_ns = ctf.tensor([2,2,2,2], sym=[0,0,0,0], sp=0)
d_ns.write(indices, vals)

d_ns_1 = d_ns[:,:,:,:1]
print(d_ns)
print(d_ns_1)

s_ns = ctf.tensor([2,2,2,2], sym=[0,0,0,0], sp=1)
s_ns.write(indices, vals)

s_ns_1 = s_ns[:,:,:,:1]
print(s_ns)
print(s_ns_1)

I ran the examples on 1 core only.

If you need further information, please let me know.

Thanks in advance,
Ke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant