PyTorch 1.5 Updates C++ API

PyTorch, an optimized tensor library for deep learning using GPUs and CPUs, has been updated with several major new API additions and improvements, along with new and updated libraries.

PyTorch aims to offer a replacement for NumPy that make suse of the power of GPUs, while providing a deep learning research platform that provides maximum flexibility and speed.

The new release, PyTorch 1.5, includes a significant update to the C++ frontend, ‘channels last’ memory format for computer vision models, and a stable release of the distributed RPC framework used for model-parallel training. The release also has new APIs for autograd for hessians and jacobians, and an API that allows the creation of Custom C++ Classes that was inspired by pybind.

The C++ frontend API means users can translate their model from Python API to C++ API, making the model authoring experience much smoother. The work overcame problems including differences between the way optimizers behaved in C++ and Python. Another problem was the lack of tensor multi-dim indexing API in C++, which can now be achieved without a workaround. 

This release also adds a new API for binding custom C++ classes into TorchScript and Python simultaneously. The developers say this API is almost identical in syntax to pybind11. It allows users to expose their C++ class and its methods to the TorchScript type system and runtime system such that they can instantiate and manipulate arbitrary C++ objects from TorchScript and Python.

Elsewhere, the new ‘channels last’ memory layout provides a way to use performance efficient convolution algorithms and hardware such as Nvidia’s Tensor Cores, FBGEMM and QNNPACK.

More Information