palle-k / DL4S

Accelerated tensor operations and dynamic neural networks based on reverse mode automatic differentiation for every device that can run Swift - from watchOS to Linux
https://palle-k.github.io/DL4S/
MIT License
102 stars 13 forks source link

Very cool! :) #1

Closed dynamicwebpaige closed 5 years ago

dynamicwebpaige commented 5 years ago

Love this project, as well as your Seq2Seq implementation and RL library!

Have you considered integrating with Swift for TensorFlow? 😄

palle-k commented 5 years ago

Swift for TensorFlow includes its own Tensor library, which you can read about in the TensorFlow documentation, so if you want to work with TensorFlow, this is probably the better way to go. This library provides an alternative implementation of automatic differentiation, similar to how PyTorch and TensorFlow work differently.

RahulBhalley commented 5 years ago

Basically it means both can't be integrated together because of the basic structure they use i.e. their own Tensor internal implementation, right? S4TF have different design principle and ur library have different. Am I correct?

palle-k commented 5 years ago

S4TF has two parts:

DL4S follows a very similar approach. It provides a Tensor library with a similar set of operations (though TensorFlow supports a much wider selection of operators). It also provides a way of computing derivatives of operations. S4TF and DL4S use a similar approach for computing derivatives. Each "atomic" operation specifies a way to compute its derivative given its inputs and the result of the operation. The derivative of a sequence of operations is computed by packpropagating through the compute graph of those operations.

So, both features that S4TF provides, are also implemented by DL4S. Using S4TF's method of differentiation would solve an issue that is already solved in DL4S. Also, replacing DL4S' method of differentiation with @differentiable will not magically add support for TPUs and other hardware accelerators.

It would be possible to add an additional S4TF engine to DL4S, similar to how a CPU engine is provided already and a GPU engine is in the works. This would then use S4TF's Tensor implementation. But I don't see a point in doing that. It would make more sense to use S4TF directly then.

RahulBhalley commented 5 years ago

It would be possible to add an additional S4TF engine to DL4S, similar to how a CPU engine is provided already and a GPU engine is in the works. This would then use S4TF's Tensor implementation. But I don't see a point in doing that. It would make more sense to use S4TF directly then.

Yup. That's right.