You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that you must specify ``py_limited_api=True`` both within ``setup``
85
+
It is necessary to specify ``py_limited_api=True`` both within ``setup``
96
86
and also as an option to the ``"bdist_wheel"`` command with the minimal supported
97
87
Python version (in this case, 3.9). This ``setup`` would build one wheel that could
98
-
be installed across multiple Python versions ``python>=3.9``. Please see
99
-
`torchao <https://github.com/pytorch/ao>`_ for an example.
88
+
be installed across multiple Python versions ``python>=3.9``.
100
89
101
90
.. note::
102
91
@@ -105,7 +94,7 @@ be installed across multiple Python versions ``python>=3.9``. Please see
105
94
to build a wheel that looks Python agnostic but will crash, or worse, be silently
106
95
incorrect, in another Python environment. Take care to avoid using unstable CPython
107
96
APIs, for example APIs from libtorch_python (in particular pytorch/python bindings,)
108
-
and to only use APIs from libtorch (aten objects, operators and the dispatcher).
97
+
and to only use APIs from libtorch (ATen objects, operators and the dispatcher).
109
98
For example, to give access to custom ops from Python, the library should register
110
99
the ops through the dispatcher (covered below!).
111
100
@@ -255,13 +244,43 @@ first load the C++ library that holds the custom operator definition
255
244
and then call the ``torch.library`` registration APIs. This can happen in one
256
245
of two ways:
257
246
258
-
1. If you're following this tutorial, importing the Python C extension module
259
-
we created will load the C++ custom operator definitions.
260
-
2. If your C++ custom operator is located in a shared library object, you can
261
-
also use ``torch.ops.load_library("/path/to/library.so")`` to load it. This
262
-
is the blessed path for Python agnosticism, as you will not have a Python C
263
-
extension module to import. See `torchao __init__.py <https://github.com/pytorch/ao/blob/881e84b4398eddcea6fee4d911fc329a38b5cd69/torchao/__init__.py#L26-L28>`_
264
-
for an example.
247
+
248
+
1. In this tutorial, our C++ custom operator is located in a shared library object,
249
+
and we use ``torch.ops.load_library("/path/to/library.so")`` to load it. This
250
+
is the blessed path for Python agnosticism, and you will not have a Python C
251
+
extension module to import. See our `extension_cpp/__init__.py <https://github.com/pytorch/extension-cpp/blob/e4c4eb822889ea67f191071fa627d750e04bf047/extension_cpp/__init__.py>`_
0 commit comments