tensor-compiler / taco

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

More sparse format support? #108

Open jermainewang opened 7 years ago

jermainewang commented 7 years ago

Hi Tacoers,

I am from MXNet team. We are working on sparse tensor operation support and we found that your project is really interesting. I really like your idea that can unify all different kinds of sparse formats in one representation. I can see this lays a foundation for easy extension to different sparse formats and even code generation like what you guys try to solve. We've also been discussing about using your representation as our sparse format (https://github.com/apache/incubator-mxnet/pull/7082). Here, we have some questions:

Look forward to your reply and I'd like to appreciate your cool project once again!

-Minjie

fredrikbk commented 7 years ago

Hi! Great to hear!

We have a new and much improved version of that paper that will appear at OOPSLA (assuming they accept some changes). One of the new things in that paper is parallelism. I'll look into sharing a preprint.

Have you considered using our library in your project instead of re-creating it? For example, @peterahrens in the Julia research group is currently working on building tensor support in Julia on top of taco and we're working on integrating with tensorflow. If you take that route we'd certainly work with you on taco-related problems you encounter. For example, we are considering C (and Python) bindings to make taco easier to use from other languages.

As to your questions:

Finally, a question from me: what are the driving applications that caused you to work on sparse tensor operations in MXNet?

-Fred

fredrikbk commented 7 years ago

I looked through the discussion at https://github.com/apache/incubator-mxnet/pull/7082 and I think I understand now. You can express, at runtime, tensors of any rank/order. For example, a kRowSparseStorage for a 3-order tensor in your notation is [<0, sparse>, <1, dense>, <2, dense>], a 4-order kRowSparseStorage is [<0, sparse>, <1, dense>, <2, dense>, <2, dense>], etc. In our C++ library you can provide these descriptors as dynamic (not fixed size) std::vectors so it's not a compile time thing.

jermainewang commented 7 years ago

CC @tqchen @mli @piiswrong

Thanks for the quick reply! It is great to know that you are looking into DL frameworks. I think the reason why MXNet needs sparse operations is the same as Tensorflow. From my bare understandings, they are quite useful for data pre-processings and result post-processings for speech and NLP tasks. @piiswrong @eric-haibin-lin should know more about this.

I'd love to see using taco as the sparse tensor library in MXNet. I think what we can think about is adding taco's sparse tensor format in DLPack project. This is the proposed tensor data structure and tensor operator interface shared by DL frameworks. Currently, it is only for dense tensors. By adapting to this interface, it will also benefit taco to be adopted by other DL frameworks like Caffe2 and Pytorch.

eric-haibin-lin commented 7 years ago

To add some context, we're using sparse tensor feature in mxnet for machine learning models for search/computational ads/recommender system/factorization machine/nlp problems.

fredrikbk commented 7 years ago

I have made a preprint of the rewritten paper available at http://people.csail.mit.edu/fred/tensor-compiler-preprint.pdf. It is clearer, more complete, and includes parallelism.

fredrikbk commented 7 years ago

@jermainewang @eric-haibin-lin Thanks for the information! We're happy to learn as much as we can about sparse tensor use cases in ml as we're coming from compilers.

There's also documentation for our library on our webpage http://tensor-compiler.org/docs, and a demo if you want to play with it http://tensor-compiler.org/codegen.

stephenchouca commented 7 years ago

As @fredrikbk mentioned, I'm currently working on extending taco to support additional formats like the coordinate format and DIA. It is still very much a work in progress (and unsupported for now), but if you'd like feel free to check out the prototype on this branch and play around with it. (As an example for reference, the following taco tool command generates code that computes the tensor-times-vector operation with an order-3 COO tensor as input and an order-2 COO tensor as output: taco "A(i,j) = B(i,j,k) * c(k)" -f=B:ucq -f=A:uq -c)

jermainewang commented 7 years ago

@stephenchouca that's really cool! Another question from our side, have you guys thought about generating GPU codes?

fredrikbk commented 7 years ago

@jermainewang yes that is something we're interested in. In fact, @Lugatod is looking into generating code for distributed machines/supercomputers and we believe some of those ideas may apply to GPU code generation too.