tensor-compiler / taco

The Tensor Algebra Compiler (taco) computes sparse tensor expressions on CPUs and GPUs
http://tensor-compiler.org
Other
1.26k stars 189 forks source link

Output Tensor Generated by TACO might be Incorrect for Certain Tensor Computation #309

Open jiawen11 opened 4 years ago

jiawen11 commented 4 years ago

Hi,

I used TACO for tensor contraction following the "Library Example" shown on the official page https://github.com/tensor-compiler/taco. I found that the final results generated by TACO are incorrect.

Does it mean TACO does not support tensor contraction or are there issues within TACO for tensor contraction? In addition, does TACO support sorting the output tensor?

Any comments are welcome!

Thanks!


Code:

include

include "taco.h"

include <sys/time.h>

include

include

include

using namespace taco;

int main(int argc, char argv[]) { IndexVar i, j, k, l, m; Tensor X = read("x.tns", Format({Sparse, Sparse, Sparse})); Tensor Y = read("y.tns", Format({Sparse, Sparse, Sparse})); Tensor Z("Z", {4, 3, 4, 3}, Format({Sparse, Sparse, Sparse, Sparse})); X.pack(); Y.pack(); Z(j, k, l, m) = X(i,j,k) Y(i,l,m); Z.compile(); Z.assemble(); Z.compute(); write("output.tns", Z); }

Input tensor (x.tns is the same as y.tns): 0 0 0 1.000000 0 1 0 2.000000 0 3 0 10.00000 1 0 1 7.000000 1 1 0 8.000000 1 2 0 6.000000 2 0 2 3.000000 2 2 0 4.000000 3 0 1 5.000000

Incorrect output tensor (output.tns): 1 1 1 1 1 1 1 2 1 2 1 1 4 1 10 2 1 1 1 2 2 1 2 1 4 (should be accumulated with "2 1 2 1 64") 2 1 4 1 20 4 1 1 1 10 4 1 2 1 20 4 1 4 1 100 1 2 1 2 49 (should be accumulated with "1 2 1 2 25") 1 2 2 1 56 1 2 3 1 42 2 1 1 2 56 2 1 2 1 64 2 1 3 1 48 3 1 1 2 42 3 1 2 1 48 3 1 3 1 36 (should be accumulated with "3 1 3 1 16") 1 3 1 3 9 1 3 3 1 12 3 1 1 3 12 3 1 3 1 16 1 2 1 2 25

Infinoid commented 4 years ago

Hi,

Taco does support tensor contraction. But there are issues with sparse outputs at the moment. See issues #184, #297. I think that's what's happening here.