joelberkeley / spidr

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

Support not-sharing #399

Closed joelberkeley closed 4 months ago

joelberkeley commented 6 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.