Thread local tensor caches.
| 151 | |
| 152 | |
| 153 | class _TensorCaches(threading.local): |
| 154 | """Thread local tensor caches.""" |
| 155 | |
| 156 | def __init__(self): |
| 157 | super(_TensorCaches, self).__init__() |
| 158 | self._ones_rank_cache = None |
| 159 | self._zeros_cache = None |
| 160 | |
| 161 | @property |
| 162 | def ones_rank_cache(self): |
| 163 | if not self._ones_rank_cache: |
| 164 | self._ones_rank_cache = _EagerTensorCache() |
| 165 | return self._ones_rank_cache |
| 166 | |
| 167 | @property |
| 168 | def zeros_cache(self): |
| 169 | if not self._zeros_cache: |
| 170 | self._zeros_cache = _EagerTensorCache() |
| 171 | return self._zeros_cache |
| 172 | |
| 173 | |
| 174 | class _ThreadLocalData(threading.local): |