{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/automatic-differentiation-for-tensor-algebras","title":"Automatic Differentiation for Tensor Algebras","arxiv_id":"1711.01348","date":"2017-11-03","proceeding":null,"authors":["Sebastian Urban","Patrick van der Smagt"],"abstract":"Kjolstad et. al. proposed a tensor algebra compiler. It takes expressions\nthat define a tensor element-wise, such as $f_{ij}(a,b,c,d) =\n\\exp\\left[-\\sum_{k=0}^4 \\left((a_{ik}+b_{jk})^2\\, c_{ii} + d_{i+k}^3 \\right)\n\\right]$, and generates the corresponding compute kernel code.\n  For machine learning, especially deep learning, it is often necessary to\ncompute the gradient of a loss function $l(a,b,c,d)=l(f(a,b,c,d))$ with respect\nto parameters $a,b,c,d$. If tensor compilers are to be applied in this field,\nit is necessary to derive expressions for the derivatives of element-wise\ndefined tensors, i.e. expressions for $(da)_{ik}=\\partial l/\\partial a_{ik}$.\n  When the mapping between function indices and argument indices is not 1:1,\nspecial attention is required. For the function $f_{ij} (x) = x_i^2$, the\nderivative of the loss is $(dx)_i=\\partial l/\\partial x_i=\\sum_j\n(df)_{ij}2x_i$; the sum is necessary because index $j$ does not appear in the\nindices of $f$. Another example is $f_{i}(x)=x_{ii}^2$, where $x$ is a matrix;\nhere we have $(dx)_{ij}=\\delta_{ij}(df)_i2x_{ii}$; the Kronecker delta is\nnecessary because the derivative is zero for off-diagonal elements. Another\nindexing scheme is used by $f_{ij}(x)=\\exp x_{i+j}$; here the correct\nderivative is $(dx)_{k}=\\sum_i (df)_{i,k-i} \\exp x_{k}$, where the range of the\nsum must be chosen appropriately.\n  In this publication we present an algorithm that can handle any case in which\nthe indices of an argument are an arbitrary linear combination of the indices\nof the function, thus all the above examples can be handled. Sums (and their\nranges) and Kronecker deltas are automatically inserted into the derivatives as\nnecessary. Additionally, the indices are transformed, if required (as in the\nlast example). The algorithm outputs a symbolic expression that can be\nsubsequently fed into a tensor algebra compiler.\n  Source code is provided.","url_abs":"http://arxiv.org/abs/1711.01348v1","url_pdf":"http://arxiv.org/pdf/1711.01348v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/surban/TensorAlgDiff","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"none","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/Arima-Kawori/CPProject","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/Ir1d/CompilerProject","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/NeverGiveUuuuuuup/Compiler_Project","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/beizai/CompilerProject2","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/bling666/CompilerProject-2020Spring","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/gosicksky/CompilerPorject","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/guoyuqi020/CompilerProject","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/gurry30/compiler","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/handar423/project2","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/hzw649/CompilerProject-Part1","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/idodra/Compile-project","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/magic3007/AutoGrad","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/natianxing/CompilerProject","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/pku-compiler-design-spring/CompilerProject-2020Spring","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/quackson/Project2","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/shibizhao/compiler_proj_final","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"automatic-differentiation-for-tensor-algebras","repo_url":"https://github.com/xjc-kk/CompilerProject","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"tensor-algebra","task_name":"tensor algebra"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":null,"mcp":null,"developers":"https://syntology.ai/developers"},"arxiv_metadata":null,"syntology_extracted_results":null}