MCPcopy Index your code
hub / github.com/lutzroeder/netron / parseTensorFromMetadata

Method parseTensorFromMetadata

source/python.js:18957–18972  ·  view source on GitHub ↗
(metadata)

Source from the content-addressed store, hash-verified

18955 return this.parseTensorFromMetadata(ivalue.val);
18956 }
18957 parseTensorFromMetadata(metadata) {
18958 if (metadata.quantized_schema) {
18959 throw new torch.Error('Quantized schema not implemented.');
18960 }
18961 const index = metadata.storage_location_index;
18962 const data = this._module.storage_data[index].data;
18963 const dtype = this._dtypes.get(metadata.scalar_type);
18964 const size = data.length / dtype.itemsize();
18965 const storage = new torch.storage.TypedStorage(size, dtype);
18966 storage._set_cdata(data);
18967 const tensor = new torch.Tensor();
18968 const shape = Array.from(metadata.sizes);
18969 const stride = Array.from(metadata.strides);
18970 tensor.__setstate__([storage, metadata.storage_offset, shape, stride]);
18971 return tensor;
18972 }
18973 parseObject(ivalue) {
18974 const object = ivalue.val;
18975 const obj_type = this._module.object_types[object.type_index];

Callers 1

parseTensorMethod · 0.80

Calls 4

itemsizeMethod · 0.80
_set_cdataMethod · 0.80
getMethod · 0.45
__setstate__Method · 0.45

Tested by

no test coverage detected