Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
PyTorch Deep Learning Hands-On

You're reading from   PyTorch Deep Learning Hands-On Build CNNs, RNNs, GANs, reinforcement learning, and more, quickly and easily

Arrow left icon
Product type Paperback
Published in Apr 2019
Publisher Packt
ISBN-13 9781788834131
Length 250 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Sherin Thomas Sherin Thomas
Author Profile Icon Sherin Thomas
Sherin Thomas
Sudhanshu Passi Sudhanshu Passi
Author Profile Icon Sudhanshu Passi
Sudhanshu Passi
Arrow right icon
View More author details
Toc

Efficiency with TorchScript

We have set up the simple Flask application server to serve our model and we have implemented the same model using the MXNet model server, but if we need to go away from the Python world and make a highly efficient server in C++ or Go, or in other efficient languages, PyTorch came up with TorchScript, which can generate the most efficient form your model, which is readable in C++.

Now the question is: isn't this what we did with ONNX; that is, creating another IR from the PyTorch model? Yes, the processes are similar, but the difference here is that ONNX creates the optimized IR using tracing; that is, it passes a dummy input through the model and while the model is being executed, it records the PyTorch operation and then converts those operations to intermediate IR.

There is a problem with this approach: if the model is data-dependent, like loops in RNNs, or if the if/else condition is based on the input, then tracing can't really get that right...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image