joelberkeley / spidr

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

Implement observable sharing #343

Closed joelberkeley closed 1 year ago

joelberkeley commented 1 year ago

As a user, I want spidr to reuse values I reuse in code, so that the graph faithfully represents what I have written, and doesn't recalculate values.

We could do this via observable sharing, which is likely to require introducing monadic code to the main tensor API. See this post for more info

https://stackoverflow.com/q/74347734/5986907

With an intelligent use of fromDouble etc. and overloaded APIs, we could reduce the amount of monadic syntax in user code. Such overloads could be placed in a separate module so that users can opt in to the possibility to accidentally write code that doesn't reuse values.

joelberkeley commented 1 year ago

done in #347