variable.py 391 B

123456789101112131415
  1. # mypy: allow-untyped-defs
  2. import torch
  3. from torch._C import _ImperativeEngine as ImperativeEngine
  4. __all__ = ["VariableMeta", "Variable"]
  5. class VariableMeta(type):
  6. def __instancecheck__(cls, other):
  7. return isinstance(other, torch.Tensor)
  8. class Variable(torch._C._LegacyVariableBase, metaclass=VariableMeta): # type: ignore[misc]
  9. _execution_engine = ImperativeEngine()