pytorch

Форк
0
/
_compile.py 
30 строк · 1001.0 Байт
1
"""
2
APIs related to torch.compile which lazily import torch._dynamo to avoid
3
circular dependencies.
4
"""
5
import functools
6

7

8
def _disable_dynamo(fn=None, recursive=True):
9
    """
10
    This API should be only used inside torch, external users should still use
11
    torch._dynamo.disable. The main goal of this API is to avoid circular
12
    imports issues that is common while using _dynamo.disable inside torch
13
    itself.
14

15
    This API avoids it by lazily importing torch._dynamo from the import time to
16
    the invocation of the decorated function.
17
    """
18
    if fn is not None:
19

20
        @functools.wraps(fn)
21
        def inner(*args, **kwargs):
22
            import torch._dynamo
23

24
            return torch._dynamo.disable(fn, recursive)(*args, **kwargs)
25

26
        return inner
27
    else:
28
        # decorator usage like @_disable_dynamo(recursive=False). The resulting
29
        # object expects the original decorated function as the arg.
30
        return functools.partial(_disable_dynamo, recursive=recursive)
31

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.