ankane / torch.rb

Deep learning for Ruby, powered by LibTorch
Other
704 stars 30 forks source link

Wrap functions returning Tensor Lists in Arrays #14

Closed mib32 closed 4 years ago

mib32 commented 4 years ago

As discussed in #13. Big thanks for the directions! Will be happy to hear feedback and iterate.

This is a contribution from @riboseinc.

mib32 commented 4 years ago

Thanks for the valuable feedback. Hope it looks better now. Also added a test for #unbind, because it's the other method that became wrapped in this PR.

ankane commented 4 years ago

Awesome, looks really great. Thanks @mib32!

ankane commented 3 years ago

Hey @mib32, just fyi, I recently profiled the library and found a significant amount of time was being spent deciding which LibTorch C++ function to call from Ruby. That logic's been moved to C++ (like PyTorch) on master, so you may want to see if it speeds up your training.

A rough micro benchmark calling add 1,000,000 times:

Version Time (sec) Note
0.3.6 20.3
0.3.7 12.3 Ruby optimizations, released today
master 4.4 C++ version
mib32 commented 3 years ago

@ankane Aha! Yes, I will update right now. That's so very kind of you to notify 🌟