Hey,
I tried to use torch.jit.script
on code that used OrderedDict
's move_to_end
, and got an error that suggested it was interpreted as a Dict
. Am I doing something wrong, or are OrderedDicts
not quite fully supported in TorchScript?
I’m on PyTorch 1.6.0.
The instantiation looks like this:
self.cache:typing.OrderedDict[str,Tensor] = OrderedDict()
Here’s the error:
RuntimeError:
Tried to access nonexistent attribute or method 'move_to_end' of type 'Dict[str, Tensor]'.:
File "/home/strawvulcan/lad/lad/util.py", line 162
return -1
else:
self.cache.move_to_end(key)
~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
return self.cache[key]
'LRUCache.get' is being compiled since it was called from 'LRUCache.__getitem__'
File "/home/strawvulcan/lad/lad/util.py", line 175
def __getitem__(self, key:str):
return self.get(key)
~~~ <--- HERE
'LRUCache.__getitem__' is being compiled since it was called from '__torch__.lad.util.LRUCache'
File "/home/strawvulcan/lad/lad/util.py", line 188
"`batch` is a list of strings"
if not hasattr(self, 'item_cache'):
self.item_cache = LRUCache(max_cache_size)
~~~~~~~~ <--- HERE
hit_idxs = []
hits = []
'__torch__.lad.util.LRUCache' is being compiled since it was called from 'Autoencoder.forward'
File "/home/strawvulcan/lad/lad/util.py", line 188
"`batch` is a list of strings"
if not hasattr(self, 'item_cache'):
self.item_cache = LRUCache(max_cache_size)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
hit_idxs = []
hits = []