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

Function from_column_list

caffe2/python/schema.py:1061–1105  ·  view source on GitHub ↗

Given a list of names, types, and optionally values, construct a Schema.

(
    col_names, col_types=None,
    col_blobs=None, col_metadata=None
)

Source from the content-addressed store, hash-verified

1059
1060
1061def from_column_list(
1062 col_names, col_types=None,
1063 col_blobs=None, col_metadata=None
1064):
1065 """
1066 Given a list of names, types, and optionally values, construct a Schema.
1067 """
1068 if col_types is None:
1069 col_types = [None] * len(col_names)
1070 if col_metadata is None:
1071 col_metadata = [None] * len(col_names)
1072 if col_blobs is None:
1073 col_blobs = [None] * len(col_names)
1074 assert len(col_names) == len(col_types), (
1075 'col_names and col_types must have the same length.'
1076 )
1077 assert len(col_names) == len(col_metadata), (
1078 'col_names and col_metadata must have the same length.'
1079 )
1080 assert len(col_names) == len(col_blobs), (
1081 'col_names and col_blobs must have the same length.'
1082 )
1083 root = _SchemaNode('root', 'Struct')
1084 for col_name, col_type, col_blob, col_md in zip(
1085 col_names, col_types, col_blobs, col_metadata
1086 ):
1087 columns = col_name.split(FIELD_SEPARATOR)
1088 current = root
1089 for i in range(len(columns)):
1090 name = columns[i]
1091 type_str = ''
1092 field = None
1093 if i == len(columns) - 1:
1094 type_str = col_type
1095 field = Scalar(
1096 dtype=col_type,
1097 blob=col_blob,
1098 metadata=col_md
1099 )
1100 next = current.add_child(name, type_str)
1101 if field is not None:
1102 next.field = field
1103 current = next
1104
1105 return root.get_field()
1106
1107
1108def from_blob_list(schema, values, throw_on_type_mismatch=False):

Callers 3

__init__Method · 0.90
__init__Method · 0.90
_init_reader_schemaMethod · 0.90

Calls 6

_SchemaNodeClass · 0.85
ScalarClass · 0.85
get_fieldMethod · 0.80
rangeFunction · 0.50
splitMethod · 0.45
add_childMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…