-
-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
autodiff
: re-structure to avoid lifetimes.
#72
Comments
The variable struct has a member Graph, maybe can be wrapped inside a Box? |
I tried |
Hello. I discovered this project due to the latest TWIR and was looking through this issue. Can't EDIT: sorry, I went trough the other files and realized this won't do. Boxing and using an rc would be fine since you are only cloning the pointer so there are no performance losses. |
Hi thanks for your interest :) Rc works (after a lot of refactoring), but it's very annoying for the user. Long mathematical formulas become filled with .clone() which is annoying to write and doesn't look very good. I think the actual logic of the module needs to change tbh. |
I am not familiar with automatic differentiation so I was reading the Wikipedia page about it and stumbled upon the cpp implementation of the reverse accumulation procedure, where they use a hashmap to store state. So... I think that rewriting the |
So store the |
Has this been addressed? |
Not yet, it's quite a task. But it would be nice to get a more flexible AD implementation that can be used to compute Greeks more easily, for example. |
The
Variable
struct has a reference to theGraph
struct. This is causing a lot of issues, namely it prevents:ndarray
andnalgebra
.#[pyclass]
is incompatible with lifetimes.It also makes it somewhat non-user-friendly since the user also has to annotate functions they want to differentiate with lifetimes.
Need to find a better solution than
&'v Graph
(basically re-structure the module).Edit:
Ideally, I want to implement num-traits for the
Variable
type, and allow it to be'static
, since bothndarray
andnalgebra
require array/matrix elements to be:ndarray
:pub trait LinalgScalar: 'static + Copy + Zero + One + Add + Sub + Mul + Div<Output = Self> { }
nalgebra
:T: Scalar + Zero + ClosedAdd + ClosedMul
pub trait Scalar: 'static + Clone + PartialEq + Debug { }
The text was updated successfully, but these errors were encountered: