mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
xpu: support py_limited_api with SyclExtension
Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
This commit is contained in:
parent
1df103e823
commit
05193ab582
1 changed files with 12 additions and 1 deletions
|
|
@ -1329,6 +1329,15 @@ def SyclExtension(name, sources, *args, **kwargs):
|
|||
All arguments are forwarded to the :class:`setuptools.Extension`
|
||||
constructor.
|
||||
|
||||
.. note::
|
||||
The PyTorch python API (as provided in libtorch_python) cannot be built
|
||||
with the flag ``py_limited_api=True``. When this flag is passed, it is
|
||||
the user's responsibility in their library to not use APIs from
|
||||
libtorch_python (in particular pytorch/python bindings) and to only use
|
||||
APIs from libtorch (aten objects, operators and the dispatcher). For
|
||||
example, to give access to custom ops from python, the library should
|
||||
register the ops through the dispatcher.
|
||||
|
||||
Example:
|
||||
>>> # xdoctest: +SKIP
|
||||
>>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_CPP_EXT)
|
||||
|
|
@ -1367,7 +1376,9 @@ def SyclExtension(name, sources, *args, **kwargs):
|
|||
libraries.append("c10_xpu")
|
||||
libraries.append("torch")
|
||||
libraries.append("torch_cpu")
|
||||
libraries.append("torch_python")
|
||||
if not kwargs.get('py_limited_api', False):
|
||||
# torch_python uses more than the python limited api
|
||||
libraries.append("torch_python")
|
||||
libraries.append("torch_xpu")
|
||||
kwargs["libraries"] = libraries
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue