Skip to content

Latest commit

 

History

History
43 lines (33 loc) · 1.72 KB

library.rst

File metadata and controls

43 lines (33 loc) · 1.72 KB

torch.library

.. py:module:: torch.library
.. currentmodule:: torch.library

torch.library is a collection of APIs for extending PyTorch's core library of operators. It contains utilities for creating new custom operators as well as extending operators defined with PyTorch's C++ operator registration APIs (e.g. aten operators).

For a detailed guide on effectively using these APIs, please see this gdoc

Use :func:`torch.library.define` to define new custom operators. Use the impl methods, such as :func:`torch.library.impl` and func:torch.library.impl_abstract, to add implementations for any operators (they may have been created using :func:`torch.library.define` or via PyTorch's C++ operator registration APIs).

.. autofunction:: define
.. autofunction:: impl
.. autofunction:: impl_abstract
.. autofunction:: get_ctx

Low-level APIs

The following APIs are direct bindings to PyTorch's C++ low-level operator registration APIs.

Warning

The low-level operator registration APIs and the PyTorch Dispatcher are a complicated PyTorch concept. We recommend you use the higher level APIs above (that do not require a torch.library.Library object) when possible. This blog post <http://blog.ezyang.com/2020/09/lets-talk-about-the-pytorch-dispatcher/>`_ is a good starting point to learn about the PyTorch Dispatcher.

A tutorial that walks you through some examples on how to use this API is available on Google Colab.

.. autoclass:: torch.library.Library
  :members:

.. autofunction:: fallthrough_kernel