Skip to content

Commit

Permalink
Update pytorch.js (#842)
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Dec 24, 2024
1 parent 6e52cf0 commit a305d5a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
8 changes: 8 additions & 0 deletions source/python.js
Original file line number Diff line number Diff line change
Expand Up @@ -8753,42 +8753,49 @@ python.Execution = class {
}
s_(name, value) {
this._values.set(name, [value, 's']);
return this;
}
s(name) {
return this._values.get(name)[0];
}
ss_(name, value) {
this._values.set(name, [value, 'ss']);
return this;
}
ss(name) {
return this._values.get(name)[0];
}
i_(name, value) {
this._values.set(name, [value, 'i']);
return this;
}
i(name) {
return this._values.get(name)[0];
}
f_(name, value) {
this._values.set(name, [value, 'f']);
return this;
}
f(name) {
return this._values.get(name)[0];
}
t_(name, value) {
this._values.set(name, [value, 't']);
return this;
}
t(name) {
return this._values.get(name)[0];
}
tys_(name, value) {
this._values.set(name, [value, 'tys']);
return this;
}
tys(name) {
return this._values.get(name)[0];
}
ival_(name, value) {
this._values.set(name, [value, 'ival']);
return this;
}
ival(name) {
return this._values.get(name)[0];
Expand Down Expand Up @@ -9234,6 +9241,7 @@ python.Execution = class {
return convertObject(obj);
}
LEGACY_deserialize() {
// https://github.com/pytorch/pytorch/blob/5e69e11d098a2cfccc8a59377c431e9c71cab9a8/torch/csrc/jit/serialization/import_legacy.cpp#L88
const execution = this._compilation_unit.execution;
const caffe2 = execution.proto.caffe2;
const torch = execution.import('torch');
Expand Down
5 changes: 2 additions & 3 deletions source/pytorch.js
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,7 @@ pytorch.Container.Zip = class extends pytorch.Container {
constructor(entries) {
super();
this.type = 'pytorch.zip';
// https://github.com/pytorch/pytorch/blob/main/torch/csrc/jit/OVERVIEW.md
// https://github.com/pytorch/pytorch/blob/master/torch/csrc/jit/docs/serialization.md
this._entries = entries;
}
Expand Down Expand Up @@ -1286,9 +1287,7 @@ pytorch.Container.ModelJson = class extends pytorch.Container {
}

async read(metadata) {
if (this._entries.has('model.json')) {
pytorch.proto = await this._context.require('./pytorch-proto');
}
pytorch.proto = await this._context.require('./pytorch-proto');
const keys = [
'attributes.pkl',
'version',
Expand Down
8 changes: 4 additions & 4 deletions test/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -5629,7 +5629,7 @@
"target": "fasterrcnn_resnet50_fpn.pt",
"source": "https://github.com/lutzroeder/netron/files/7677467/fasterrcnn_resnet50_fpn.pt.zip[fasterrcnn_resnet50_fpn.pt]",
"format": "TorchScript v1.7",
"link": "https://github.com/lutzroeder/netron/issues/1061"
"link": "https://github.com/lutzroeder/netron/issues/842"
},
{
"type": "pytorch",
Expand Down Expand Up @@ -5786,7 +5786,7 @@
"target": "m4-sWE-0.1B.script.pt",
"source": "https://github.com/user-attachments/files/17967188/m4-sWE-0.1B.script.pt.zip[m4-sWE-0.1B.script.pt]",
"format": "TorchScript v1.6",
"link": "https://github.com/lutzroeder/netron/issues/1061"
"link": "https://github.com/lutzroeder/netron/issues/842"
},
{
"type": "pytorch",
Expand Down Expand Up @@ -5815,7 +5815,7 @@
"target": "mask_rcnn.pt",
"source": "https://github.com/user-attachments/files/17966950/mask_rcnn.pt.zip[mask_rcnn.pt]",
"format": "TorchScript v1.7",
"link": "https://github.com/lutzroeder/netron/issues/1061"
"link": "https://github.com/lutzroeder/netron/issues/842"
},
{
"type": "pytorch",
Expand Down Expand Up @@ -6749,7 +6749,7 @@
"target": "v1_lj_8000.jit",
"source": "https://github.com/user-attachments/files/16041474/v1_lj_8000.jit.zip[v1_lj_8000.jit]",
"format": "TorchScript v1.6",
"link": "https://github.com/lutzroeder/netron/issues/1061"
"link": "https://github.com/lutzroeder/netron/issues/842"
},
{
"type": "pytorch",
Expand Down

0 comments on commit a305d5a

Please sign in to comment.