mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
This is a big bang PR, merge conflicts are probably expected and will be addressed at merge. Pull Request resolved: https://github.com/pytorch/pytorch/pull/81643 Approved by: https://github.com/ezyang
31 lines
657 B
Python
31 lines
657 B
Python
"""
|
|
This makes the functions in torch._C._VariableFunctions available as
|
|
torch._VF.<funcname>
|
|
without mypy being able to find them.
|
|
|
|
A subset of those functions are mapped to ATen functions in
|
|
torch/jit/_builtins.py
|
|
|
|
See https://github.com/pytorch/pytorch/issues/21478 for the reason for
|
|
introducing torch._VF
|
|
|
|
"""
|
|
import sys
|
|
import types
|
|
|
|
import torch
|
|
|
|
|
|
class VFModule(types.ModuleType):
|
|
vf: types.ModuleType
|
|
|
|
def __init__(self, name):
|
|
super(VFModule, self).__init__(name)
|
|
self.vf = torch._C._VariableFunctions
|
|
|
|
def __getattr__(self, attr):
|
|
return getattr(self.vf, attr)
|
|
|
|
|
|
sys.modules[__name__] = VFModule(__name__)
|