tensor-compiler / taco

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

Complex numbers #116

Closed fwinter closed 6 years ago

fwinter commented 6 years ago

Hi! We are looking for a sparse tensor framework just like yours. However we rely on computations on complex numbers and a first attempt with the current taco code didn't quite succeed. I.e. I couldn't do

Tensor<std::complex<double> > A({2,2}, sm);

Is it already possible to define tensors on complex numbers? If not, would this represent a major feature addition (and thus will not be available for some time to come)?

fredrikbk commented 6 years ago

Hi @fwinter! I hope taco can help you.

We don't support anything except doubles yet, but I think it will be easy for us to add (hours/days, not weeks). We are, however, completely committed until the end of November. It is a clear hole in taco though, so I would like to fix it sometime in either December or early next year.

If this is the only thing blocking you from using taco, then I will make an effort to implement it next month.

fwinter commented 6 years ago

I believe if taco would support tensors of complex numbers and would expose the complex conjugation of a tensor (i.e. conjugate all elements) then we could use it in our contraction framework right away.

If I can iterate over references of the values (be it inside sparse or dense dimension) then I can complex conjugate each element that way. So, I think we're good with just the complex number multiplication/addition of the regular tensor contractions.

quaxquax commented 6 years ago

Want to second fwinter's request. TACO could be a great fit for Quantum Computing software (e.g. compilers for universal quantum gate sets) if it could handle complex numbers.

fwinter commented 6 years ago

Since @quaxquax mentioned his field.. Our application involves Nuclear Physics calculations and we believe taco would be of great use.

fredrikbk commented 6 years ago

Those are really cool applications! Based on this I’ll try to prioritize complex numbers next month or January. Is the complex conjugation you refer to a component-wise per-non-zero conjugation?

fwinter commented 6 years ago

OK! For us, the earlier the better. Yes, it's an element-wise complex conjugation. Only the non-zero elements require an actual operation since zero is it's own complex conjugate.

RSenApps commented 6 years ago

@fwinter @quaxquax Complex numbers should now be supported. I am still working on adding complex literals as well as cleaning up some things in the code, but for your use case, it should be good to use. Please reach out if you run into any issues or have any feedback, we are very interested to see what you use taco to build.

fredrikbk commented 6 years ago

Great job!

As @rsenapps said, let us know if there’s anything else you need for your applications. We hope to hear more about what you do!

quaxquax commented 6 years ago

Thanks! Much appreciated.