{"id":16705032,"url":"https://github.com/mcabbott/tensortrack.jl","last_synced_at":"2026-03-17T08:39:40.266Z","repository":{"id":117871525,"uuid":"201619128","full_name":"mcabbott/TensorTrack.jl","owner":"mcabbott","description":null,"archived":false,"fork":false,"pushed_at":"2020-02-08T17:17:43.000Z","size":7,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-01T01:50:38.817Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcabbott.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-10T11:11:49.000Z","updated_at":"2022-12-12T13:34:07.000Z","dependencies_parsed_at":"2023-04-07T13:23:14.584Z","dependency_job_id":null,"html_url":"https://github.com/mcabbott/TensorTrack.jl","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"315c645abd45746cadd780c6b65e9a8304253345"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mcabbott/TensorTrack.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcabbott%2FTensorTrack.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcabbott%2FTensorTrack.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcabbott%2FTensorTrack.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcabbott%2FTensorTrack.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcabbott","download_url":"https://codeload.github.com/mcabbott/TensorTrack.jl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcabbott%2FTensorTrack.jl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30619218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T08:10:05.930Z","status":"ssl_error","status_checked_at":"2026-03-17T08:10:04.972Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T19:28:24.640Z","updated_at":"2026-03-17T08:39:40.236Z","avatar_url":"https://github.com/mcabbott.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TensorTrack.jl\n\n[![Build Status](https://travis-ci.org/mcabbott/TensorTrack.jl.svg?branch=master)](https://travis-ci.org/mcabbott/TensorTrack.jl)\n\nThis package is one approach to adding gradient definitions to [TensorOperations.jl](https://github.com/Jutho/TensorOperations.jl)\nfor reverse-mode auto-differentiation. Originally for [Tracker.jl](https://github.com/FluxML/Tracker.jl), \nnow also for [Zygote.jl](https://github.com/FluxML/Zygote.jl).\n\nEverything `TensorOperations` calculates comes down to three basic functions: \n`contract!` (generalised matrix multiplication) `trace!` (traces!) and `add!` (index permutations, and addition).\nThis package simply overloads each of them to compute the sensitivities of their inputs \nin terms of other such functions. Here's the simplest one:\n```julia\nTracker.@grad function add!(α, A, conjA, β, C, indCinA)\n    add!(data(α), data(A), conjA, data(β), data(C), indCinA),\n    Δ -\u003e ∇add(Δ, α, A, conjA, β, C, indCinA)\nend\n\nfunction ∇add(Δ, α::Tα, A::TA, conjA, β::Tβ, C::TC, indCinA) where {Tα,TA,Tβ,TC}\n    ∇A = TA\u003c:TrackedArray ? add∇A(data(Δ), data(α), A, conjA, β, C, indCinA) : nothing\n    ∇C = TC\u003c:TrackedArray ? data(β) .* data(Δ) : nothing\n    ∇α = 0\n    ∇β = 0\n    return (∇α, ∇A, nothing, ∇β, ∇C, nothing)\nend\n\nfunction add∇A(Δ, α, A::TA, conjA, β, C::TC, indCinA) where {TA,TC}\n    add!(α, Δ, conjA, 0, similar(data(A)), invperm(indCinA))\nend\n```\nThe only hard part of this is getting all the things like `invperm(indCinA)` straight.\n\n### Limitations:\n1. It will tend to compute too many gradients\n  (especially with Zygote where it cannot ask `TA\u003c:TrackedArray ?` before calculating).\n2. It does not handle constants like `α * B[i,j]` at all (hence `∇α = 0` above).\n3. Since this is entirely within TensorOperations.jl, it cannot handle non-Einstein contractions\n  such as `A[i,k] * B[j,k] * C[l,k]`. \n4. It depends on many internal details of TensorOperations.jl, so will break if that package changes.\n\nSee also [TensorGrad.jl](https://github.com/mcabbott/TensorGrad.jl) for another approach, \nat the level of the macro not the functions. \n\n--- Michael Abbott, January 2019\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcabbott%2Ftensortrack.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcabbott%2Ftensortrack.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcabbott%2Ftensortrack.jl/lists"}