• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1r"""
2Decorator used in test_decorator.py. We define it in a
3separate file on purpose to test that the names in different modules
4are resolved correctly.
5"""
6
7import functools
8
9
10def my_decorator(func):
11    """Dummy decorator that removes itself when torchscripting"""
12
13    @functools.wraps(func)
14    def wrapped_func(*args, **kwargs):
15        return func(*args, **kwargs)
16
17    # torch.jit.script() uses __prepare_scriptable__ to remove the decorator
18    wrapped_func.__prepare_scriptable__ = lambda: func
19
20    return wrapped_func
21