MCPcopy Create free account
hub / github.com/pytorch/pytorch / namedtupledict

Function namedtupledict

caffe2/python/functional.py:14–26  ·  view source on GitHub ↗
(typename, field_names, *args, **kwargs)

Source from the content-addressed store, hash-verified

12
13
14def namedtupledict(typename, field_names, *args, **kwargs):
15 field_names_map = {n: i for i, n in enumerate(field_names)}
16 # Some output names are invalid python identifier, e.g. "0"
17 kwargs.setdefault('rename', True)
18 data = namedtuple(typename, field_names, *args, **kwargs)
19
20 def getitem(self, key):
21 if isinstance(key, str):
22 key = field_names_map[key]
23 return super(type(self), self).__getitem__(key)
24
25 data.__getitem__ = getitem
26 return data
27
28
29class _Functional:

Callers 10

op_funcMethod · 0.85
_test_relu_graphMethod · 0.85
_test_onnx_importerMethod · 0.85
test_resnet50_coreMethod · 0.85
test_resnet50_coreMethod · 0.85
run_nodeMethod · 0.85
runMethod · 0.85
c2_native_run_opFunction · 0.85
c2_native_run_netFunction · 0.85
runMethod · 0.85

Calls 1

setdefaultMethod · 0.45

Tested by 4

_test_relu_graphMethod · 0.68
_test_onnx_importerMethod · 0.68
test_resnet50_coreMethod · 0.68
test_resnet50_coreMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…