coreylowman / dfdx

Deep learning in Rust, with shape checked tensors and neural networks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

impl `Merge` for `NoneTape` for `OwnedTape` and `Arc<Mutex<OwnedTape>>`

emchristiansen opened this issue · comments

We can currently write tracked_tensor.op(untracked_tensor), but not untracked_tensor.op(tracked_tensor).
If we want to do the latter we have to surgically remove the tape from tracked_tensor and transplant it into untracked_tensor, which is annoying.

Thus, it would nice to have impls like this:

impl<E, D: Storage<E>> Merge<Arc<Mutex<OwnedTape<E, D>>>> for NoneTape {
    fn merge(self, other: Arc<Mutex<OwnedTape<E, D>>>) -> Arc<Mutex<OwnedTape<E, D>>> {
        other
    }
}

But we can't currently write this because merge returns Self.
Maybe we should define type Output in the trait and have merge return Output?

This was done in #835