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

Sparse*Dense to Sparse Contraction yields wrong results #77

Open
ryanlevy opened this issue Oct 23, 2019 · 0 comments
Open

Sparse*Dense to Sparse Contraction yields wrong results #77

ryanlevy opened this issue Oct 23, 2019 · 0 comments

Comments

@ryanlevy
Copy link
Contributor

The following minimal code seems to not produce correct results:

vector<int64_t> res_sizes = {1,3,2,2,8};
vector<int64_t> R_sizes   = {3,8,3};
vector<int64_t> ans_sizes = {1,2,2,3};
CTF::Tensor<> res(5,res_sizes.data()); res.fill_sp_random(0.,1.,0.25);
CTF::Tensor<> R(3,R_sizes.data()); R.fill_sp_random(0.,1.,0.25);
{
      perr<<"Dense = Dense*Dense"<<endl;
      CTF::Tensor<> ans(4,ans_sizes.data()); ans.set_name("Dense=DenseDense");
      ans["acdf"] = res["abcde"]*R["feb"];
      ans.print();
}
{
      perr<<"Sparse = Dense*Dense"<<endl;
      CTF::Tensor<> ans(4,true,ans_sizes.data()); ans.set_name("Sparse=DenseDense");
      ans["acdf"] = res["abcde"]*R["feb"];
      ans.print();
}
{
      perr<<"Sparse = Sparse*Dense"<<endl;
      res.sparsify();
      CTF::Tensor<> ans(4,true,ans_sizes.data()); ans.set_name("Sparse=SparseDense");
      ans["acdf"] = res["abcde"]*R["feb"];
      ans.print();
}

And for my particular set of random numbers

Dense = Dense*Dense
...
[0][0][0][2](8, <8.59462E-01>)
[0][1][0][2](9, <5.53183E-03>)
[0][1][1][2](11, <5.09581E-01>)
Sparse = Dense*Dense
...
[0][0][0][2](8, <8.59462E-01>)
[0][1][0][2](9, <5.53183E-03>)
[0][0][1][2](10, <0.00000E+00>)
[0][1][1][2](11, <5.09581E-01>)
Sparse=SparseDense
...
[0][0][0][2](8, <3.51847E-01>)
[0][1][0][2](9, <5.53183E-03>)
[0][1][1][2](11, <4.72762E-01>)

Where elements 8 and 11 are incorrect

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