1
1
Autoloading Out-of-Tree Extension
2
- ===========================================
2
+ =================================
3
3
4
- **Author: ** `Yuanhao Ji <www. github.com/shink >`__
4
+ **Author: ** `Yuanhao Ji <https:// github.com/shink >`__
5
5
6
6
The extension autoloading mechanism enables PyTorch to automatically
7
7
load out-of-tree backend extensions without explicit import statements. This
8
- feature is beneficial for users as it enhances their
8
+ feature is beneficial for users as it enhances their
9
9
experience and enables them to follow the familiar PyTorch device
10
10
programming model without having to explicitly load or import device-specific
11
11
extensions. Additionally, it facilitates effortless
@@ -25,6 +25,7 @@ out-of-tree devices. For further details, refer to the
25
25
:class-card: card-prerequisites
26
26
27
27
* PyTorch v2.5 or later
28
+
28
29
.. note ::
29
30
30
31
This feature is enabled by default and can be disabled by using
@@ -42,7 +43,7 @@ your package is compatible with PyTorch 2.5 or later and includes the following
42
43
.. code-block :: python
43
44
44
45
def _autoload ():
45
- print (" No need to import torch_foo anymore! Check things are working with `torch.foo.is_available()`." )
46
+ print (" Check things are working with `torch.foo.is_available()`." )
46
47
47
48
Then, the only thing you need to do is define an entry point within your Python package:
48
49
@@ -177,5 +178,7 @@ See the implementation in this pull request: `[RFC] Add support for device exten
177
178
Conclusion
178
179
----------
179
180
180
- This tutorial has guided you through the out-of-tree extension autoloading
181
- mechanism, including its usage and implementation.
181
+ In this tutorial, we learned about the out-of-tree extension autoloading mechanism in PyTorch, which automatically
182
+ loads backend extensions eliminating the need to add additional import statements. We also learned how to apply
183
+ this mechanism to out-of-tree extensions by defining an entry point and how to prevent circular imports.
184
+ We also reviewed an example on how to use the autoloading mechanism with Intel Gaudi HPU and Huawei Ascend NPU.
0 commit comments