MCPcopy
hub / github.com/lutzroeder/netron / parseObject

Method parseObject

source/python.js:18973–18994  ·  view source on GitHub ↗
(ivalue)

Source from the content-addressed store, hash-verified

18971 return tensor;
18972 }
18973 parseObject(ivalue) {
18974 const object = ivalue.val;
18975 const obj_type = this._module.object_types[object.type_index];
18976 const cls = this.getOrCreateClassTypeForObject(object);
18977 switch (obj_type.type) {
18978 case torch.mobile.serialization.TypeType.CLASS_WITH_FIELD: {
18979 const torch = this._torch;
18980 const obj = torch.ScriptObject.create(cls);
18981 for (let i = 0; i < object.attrs.length; i++) {
18982 const attr_name = obj_type.attr_names[i];
18983 const val = this._all_ivalues[object.attrs[i]];
18984 obj.__setattr__(attr_name, val);
18985 }
18986 return obj;
18987 }
18988 case torch.mobile.serialization.TypeType.CUSTOM_CLASS:
18989 case torch.mobile.serialization.TypeType.CLASS_WITH_SETSTATE:
18990 default: {
18991 throw new python.Error(`Unknown object type type '${obj_type.type}'.`);
18992 }
18993 }
18994 }
18995 getOrCreateClassTypeForObject(object) {
18996 let cls = this._all_types[object.type_index];
18997 const obj_type = this._module.object_types[object.type_index];

Callers 1

constructorMethod · 0.80

Calls 3

__setattr__Method · 0.80
createMethod · 0.45

Tested by

no test coverage detected