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

Function NewRecord

caffe2/python/schema.py:1189–1210  ·  view source on GitHub ↗

Given a record of np.arrays, create a BlobReference for each one of them, returning a record containing BlobReferences. The name of each returned blob is NextScopedBlob(field_name), which guarantees unique name in the current net. Use NameScope explicitly to avoid name conflictions

(net, schema)

Source from the content-addressed store, hash-verified

1187
1188
1189def NewRecord(net, schema):
1190 """
1191 Given a record of np.arrays, create a BlobReference for each one of them,
1192 returning a record containing BlobReferences. The name of each returned blob
1193 is NextScopedBlob(field_name), which guarantees unique name in the current
1194 net. Use NameScope explicitly to avoid name conflictions between different
1195 nets.
1196 """
1197 if isinstance(schema, Scalar):
1198 result = schema.clone()
1199 result.set_value(
1200 blob=net.NextScopedBlob('unnamed_scalar'),
1201 unsafe=True,
1202 )
1203 return result
1204
1205 assert isinstance(schema, Field), 'Record must be a schema.Field instance.'
1206 blob_refs = [
1207 net.NextScopedBlob(prefix=name)
1208 for name in schema.field_names()
1209 ]
1210 return from_blob_list(schema, blob_refs)
1211
1212
1213def ConstRecord(net, array_record):

Callers 12

test_dequeue_manyMethod · 0.90
proc1Method · 0.90
proc2Method · 0.90
test_local_sessionMethod · 0.90
proc1Method · 0.90
proc2Method · 0.90
make_source_datasetFunction · 0.90
test_pack_unpackMethod · 0.90
test_dataset_opsMethod · 0.90
test_record_queueMethod · 0.90
ConstRecordFunction · 0.85
InitEmptyRecordFunction · 0.85

Calls 6

isinstanceFunction · 0.85
from_blob_listFunction · 0.85
NextScopedBlobMethod · 0.80
cloneMethod · 0.45
set_valueMethod · 0.45
field_namesMethod · 0.45

Tested by 10

test_dequeue_manyMethod · 0.72
proc1Method · 0.72
proc2Method · 0.72
test_local_sessionMethod · 0.72
proc1Method · 0.72
proc2Method · 0.72
make_source_datasetFunction · 0.72
test_pack_unpackMethod · 0.72
test_dataset_opsMethod · 0.72
test_record_queueMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…