MCPcopy Index your code
hub / github.com/pytorch/pytorch / as_record

Function as_record

caffe2/python/schema.py:1126–1141  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

1124
1125
1126def as_record(value):
1127 if isinstance(value, Field):
1128 return value
1129 elif isinstance(value, list) or isinstance(value, tuple):
1130 is_field_list = all(
1131 f is tuple and len(f) == 2 and isinstance(f[0], basestring)
1132 for f in value
1133 )
1134 if is_field_list:
1135 return Struct(* [(k, as_record(v)) for k, v in value])
1136 else:
1137 return Tuple(* [as_record(f) for f in value])
1138 elif isinstance(value, dict):
1139 return Struct(* [(k, as_record(v)) for k, v in value.items()])
1140 else:
1141 return _normalize_field(value)
1142
1143
1144def FetchRecord(blob_record, ws=None, throw_on_type_mismatch=False):

Callers 2

__init__Method · 0.90
schema_checkFunction · 0.85

Calls 6

isinstanceFunction · 0.85
StructClass · 0.85
TupleFunction · 0.85
_normalize_fieldFunction · 0.85
allFunction · 0.50
itemsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…