mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
Summary: The existing RemoteCacheBackend classes were a bit haphazard - some of them accepted bytes only, some accepted objects, some returned different types of objects than were passed in. Update them to be more consistent: 1. RemoteCacheBackend is an implementation of a backend: Redis, Memcache, Manifold, LocalFile 2. RemoteCacheSerde is an implementation of a serde protocol - to turn structured objects (dict, list, etc) into bytes: RemoteCacheJsonSerde (json encoding), RemoteCachePassthroughSerde (strictly bytes only) 3. RemoteCache is the cache implementation itself, mixing a RemoteCacheBackend along with an RemoteCacheSerde to provide structured caching. Other than simply reorganizing the existing cache code this also fixes the Redis autotune caching for OSS. Test Plan: unit tests Reviewed By: oulgen Differential Revision: D61178859 Pull Request resolved: https://github.com/pytorch/pytorch/pull/134032 Approved by: https://github.com/oulgen, https://github.com/bhack
32 lines
664 B
Python
32 lines
664 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: str):
|
|
super().__init__(name)
|
|
self.vf = torch._C._VariableFunctions
|
|
|
|
def __getattr__(self, name: str) -> object:
|
|
return getattr(self.vf, name)
|
|
|
|
|
|
sys.modules[__name__] = VFModule(__name__)
|