(ivalue)
| 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]; |
no test coverage detected