(obj)
| 14162 | } |
| 14163 | const obj = this.readArchive('data'); |
| 14164 | const convertObject = (obj) => { |
| 14165 | if (obj.__class__) { |
| 14166 | const name = `${obj.__class__.__module__}.${obj.__class__.__name__}`; |
| 14167 | const type = this._source_importer.loadType(new torch._C.QualifiedName(name)); |
| 14168 | const module = type.is_module() ? new torch.ScriptModule(type, this._compilation_unit) : new torch.ScriptObject(type); |
| 14169 | for (let i = 0; i < type.numAttributes(); i++) { |
| 14170 | const k = type.getAttributeName(i); |
| 14171 | const t = type.getAttribute(i); |
| 14172 | const v = obj[k]; |
| 14173 | if (t instanceof torch.ClassType) { |
| 14174 | module.__setattr__(k, convertObject(v)); |
| 14175 | } else { |
| 14176 | if (t instanceof torch.TensorType && v && v.__class__ && v instanceof torch.Tensor === false && v.__class__.__module__ === '__torch__.torch.classes.quantized') { |
| 14177 | const name = `${v.__class__.__module__}.${v.__class__.__name__}`; |
| 14178 | type._attributes[i].type = this._source_importer.resolveType(name); |
| 14179 | } |
| 14180 | module.__setattr__(k, obj[k]); |
| 14181 | } |
| 14182 | } |
| 14183 | for (const [key, value] of Object.entries(Object.getPrototypeOf(obj))) { |
| 14184 | if (value && value.__class__ === builtins.method) { |
| 14185 | module[key] = value; |
| 14186 | } |
| 14187 | } |
| 14188 | return module; |
| 14189 | } |
| 14190 | throw new python.Error('Module class not found.'); |
| 14191 | }; |
| 14192 | return convertObject(obj); |
| 14193 | } |
| 14194 | LEGACY_deserialize() { |
nothing calls this directly
no test coverage detected