joelberkeley / spidr

Accelerated machine learning with dependent types
Apache License 2.0
72 stars 4 forks source link

Support not-sharing #399

Closed joelberkeley closed 1 month ago

joelberkeley commented 3 months ago

By adding a Var : Nat -> Expr constructor to Expr, we can support both sharing and not-sharing in our graph. If we also make not-sharing the default it could drastically simplify client code as most function results aren't shared, and likely more performant as we'd do away with most of the monadic function calls.

We might be able to prevent accidental re-use of uncached tensors by using linearity. All tensors are linear until they're shared, at which point they have unrestricted quantity.

It's possible that with much less sharing, we could use linearity and do away entirely with monads, giving us a significant performance boost.