Skip to content

Commit

Permalink
Add PyTorch test file (#720)
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Nov 2, 2024
1 parent 56fc168 commit c278ada
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
16 changes: 5 additions & 11 deletions source/pytorch.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,14 +695,6 @@ pytorch.Node = class {
const value = metadata.type(key);
this.type = value ? { ...value } : { name: type };
this.type.identifier = type;
if (this.type.name.indexOf('(') !== -1) {
throw new Error();
}
if (this.type.name.indexOf('::') !== -1) {
throw new Error();
}
// [name] = this.type.name.split('(');
// this.type.name = name.indexOf('::') === -1 ? name : name.split('::').pop().split('.')[0];
}
stack = stack || new Set();
const weights = pytorch.Utility.weights(obj);
Expand All @@ -729,6 +721,8 @@ pytorch.Node = class {
continue;
} else if (pytorch.Utility.isInstance(value, 'builtins.list') && Array.isArray(value) && value.length === 0) {
continue;
} else if (pytorch.Utility.isInstance(value, 'torch.Size') && Array.isArray(value) && value.length === 0) {
continue;
}
const parameters = new Map();
if ((name === '_parameters' || name === '_buffers') && value instanceof Map && value.size > 0) {
Expand Down Expand Up @@ -3492,9 +3486,9 @@ pytorch.Utility = class {
if (obj instanceof Map) {
const entries = Array.from(obj).filter(([name]) => name !== '_metadata');
const names = entries.filter(([name]) => typeof name === 'string' && (name.indexOf('.') !== -1 || name.indexOf('|') !== -1));
if (names.length > 1 &&
(names.length / entries.length) >= 0.8 &&
entries.every(([, value]) => !pytorch.Utility.isInstance(value, 'builtins.dict') || Array.from(value.values()).every((value) => !pytorch.Utility.isTensor(value)))) {
if (names.length > 1 && (names.length / entries.length) >= 0.8 &&
(entries.every(([, value]) => !pytorch.Utility.isInstance(value, 'builtins.dict')) || Array.from(value.values()).every((value) => !pytorch.Utility.isTensor(value))) &&

Check failure on line 3490 in source/pytorch.js

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

'value' is not defined

Check failure on line 3490 in source/pytorch.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

'value' is not defined
(!entries.every(([, value]) => Array.isArray(value)))) {
const modules = new Map();
for (const [name, value] of entries) {
const separator = name.indexOf('.') === -1 && name.indexOf('|') !== -1 ? '|' : '.';
Expand Down
7 changes: 7 additions & 0 deletions test/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -5429,6 +5429,13 @@
"format": "PyTorch v1.6",
"link": "https://github.com/lutzroeder/netron/issues/133"
},
{
"type": "pytorch",
"target": "InternVideo2-stage2_1b-224p-f4.pt",
"source": "https://github.com/user-attachments/files/17607734/InternVideo2-stage2_1b-224p-f4.pt.zip[InternVideo2-stage2_1b-224p-f4.pt]",
"format": "PyTorch v1.6",
"link": "https://github.com/lutzroeder/netron/issues/720"
},
{
"type": "pytorch",
"target": "iv3_pertensor.pt",
Expand Down

0 comments on commit c278ada

Please sign in to comment.