Adding support for pytorch tensors in CPU/GPU #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Dear maintainers,
the current code is based on numpy, which makes it difficult and slow to use with pytorch tensors. I have implemented the algorithms in pure pytorch (code actually requires less lines) which has the advantage of supporting tensors in GPU, potentially increasing the speed of execution. I have also added a short benchmark script that returns the following:
as can be seen in this example the torch code computes the exact same values, and the computation on GPU (Nvidia V100) is 20x faster. The CPU in this example is Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz
On my macbook pro laptop (2.9 GHz Quad-Core Intel Core i7) I get the following
which shows that the pytorch CPU code can be faster than numpy, in some cases.
Hopefully this addition will be helpful to you and the community.