Skip to content

Commit d0b7505

Browse files
committed
light dusting on grammar
1 parent 53aed84 commit d0b7505

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

advanced_source/cpp_custom_ops.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,15 @@ CPython version through setuptools' ``py_limited_api`` flag, like so:
7878
7979
setup(name="extension_cpp",
8080
ext_modules=[
81-
cpp_extension.CppExtension("extension_cpp", ["muladd.cpp"], py_limited_api=True)],
81+
cpp_extension.CppExtension(
82+
"extension_cpp",
83+
["python_agnostic_code.cpp"],
84+
py_limited_api=True)],
8285
cmdclass={'build_ext': cpp_extension.BuildExtension},
8386
options={"bdist_wheel": {"py_limited_api": "cp39"}}
8487
)
8588
86-
Note that you must specify ``py_limited_api=True`` both within ``setup``:
89+
Note that you must specify ``py_limited_api=True`` both within ``setup``
8790
and also as an option to the ``"bdist_wheel"`` command with the minimal supported
8891
Python version (in this case, 3.9). This ``setup`` would build one wheel that could
8992
be installed across multiple Python versions ``python>=3.9``. Please see
@@ -95,9 +98,9 @@ be installed across multiple Python versions ``python>=3.9``. Please see
9598
Specifying ``py_limited_api`` does not check for any guarantees, so it is possible
9699
to build a wheel that looks Python agnostic but will crash, or worse, be silently
97100
incorrect, in another Python environment. Take care to avoid using unstable CPython
98-
APIs, for example APIs from libtorch_python (in particular pytorch/python bindings)
101+
APIs, for example APIs from libtorch_python (in particular pytorch/python bindings,)
99102
and to only use APIs from libtorch (aten objects, operators and the dispatcher).
100-
For example, to give access to custom ops from python, the library should register
103+
For example, to give access to custom ops from Python, the library should register
101104
the ops through the dispatcher (covered below!).
102105

103106
Defining the custom op and adding backend implementations
@@ -251,7 +254,7 @@ of two ways:
251254
2. If your C++ custom operator is located in a shared library object, you can
252255
also use ``torch.ops.load_library("/path/to/library.so")`` to load it. This
253256
is the blessed path for Python agnosticism, as you will not have a Python C
254-
extension module to import. See `torchao __init__.py <https://github.com/pytorch/ao/blob/881e84b4398eddcea6fee4d911fc329a38b5cd69/torchao/__init__.py#L26-L28>`
257+
extension module to import. See `torchao __init__.py <https://github.com/pytorch/ao/blob/881e84b4398eddcea6fee4d911fc329a38b5cd69/torchao/__init__.py#L26-L28>`_
255258
for an example.
256259

257260

0 commit comments

Comments
 (0)