The Tensor Algebra Compiler
tensor-compiler.org
tensor-compiler.org
http://news.mit.edu/2017/faster-big-data-analysis-tensor-alg...
The code is available at:
https://github.com/tensor-compiler/taco/issues
I’m happy to discuss the project and to answer any questions :)
The tensor contraction engine is great work, and focuses on dense tensor. We currently optimize for sparse tensors so TCE will do better than us for pure dense expressions. We want to bridge this gap next semester though.
The cyclops framework is also great. We discuss it in our related work, but we did not directly compare to it in our evaluation. The first version of it, like TCE, focused on dense tensors, and their main focus is on distributed computing, which we don't support yet (we do shared memory parallel execution at the moment). They have some followup work on sparse computations. The difference to our work is that they, if I read their paper correctly, transposes the data until they can call pre-existing matrix multiplication routines. This causes data movement overheads. Our work compiles expressions to work at the data at hand, without moving it.
It seems like a strange thing that no one thought of doing this before! Nice that you identified a cool problem and solved it :)
https://github.com/amzn/amazon-dsstne
But this library is clearly more thorough.
We believe our contribution is being able to generate kernels for all the expressions.
Thanks for the reference though! We’re trying to learn where sparsity may be important in neural networks.
Is this intentional? (if so, why)
The C compilers dead code elimination should remove those though.
Ps: excellent name
taco does not target GPUs yet, and we want to work on it this spring. It’s clearly needed, for example for neural networks
I'm hoping that you can (at some point) write a language-agnostic library, so that your work can be used in many other development tools (which are not using C++). I suppose it would amount to publishing the documentation of the intermediate code you are already using. This would also save you the trouble of writing and maintaining a GPU back-end because other people could do that using your library.
Anyway, great work!
https://github.com/surban/TensorAlgDiff/raw/master/elemdiff....
Our system takes a tensor algebra (we call it element-wise defined tensor) and outputs expressions for the derivatives w.r.t. all of its arguments. The expression may contain sums and the indices of the argument tensors can be any linear combination of the function indices (see our example for more details). It correctly handles the cases where an index does not appear in an argument, appears twice, appears as (i+j) etc.
Code to play with at https://github.com/surban/TensorAlgDiff
For example if you have f_{i,j} = (x_i)^2, then the derivative (of some loss) w.r.t. x will be: dx_i = \sum_j df_{i,j} 2 x_i. The sum is needed because the argument x does not depend on the index j and thus x_i is affected by all j elements of df_{i,j}.
Another example would be: f_i = (x_ii)^2, i.e. taking the squares of the diagonal of the matrix x. Here the derivative is x_{i,j} = kronecker_{i=j} 2 df_i x_ii because off-diagonal elements have zero derivatives.
For such simple expressions it's trivial, but for complex expressions it's error-prone when you do it by hand.
I made something similar recently, a GLSL code printer for for SymPy. I use it for generating GLSL out of Clifford algebras. I'm using it to do higher dimensional & conformal geometry.
Is there a similar story for sparse matrices ever?
Because of the lack of random access, some algorithm like linear combination matrix-matrix multiplication benefits from adding a dense workspace that gives you a view into one row. Then you can scatter into it and when you’re done copy the nonzeroes to the sparse result matrix. This algorithm is sometimes called Gustavson’s algorithm after the person who published it first). We have worked out this optimization within the taco framework, it applies to other kernels too, and are now writing it up for publication.