Skip to content

Commit

Permalink
Update pytorch.js
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Aug 27, 2024
1 parent 19e4d48 commit c42091a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions source/pytorch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3490,14 +3490,15 @@ pytorch.Utility = class {
const modules = new Map();
const entries = obj instanceof Map ? Array.from(obj) : Object.entries(obj);
if (entries.length > 0 && entries) {
for (const [name, value] of entries) {
for (const [key, value] of entries) {
const name = key.toString();
if (!value || Object(value) !== value || pytorch.Utility.isTensor(value) || ArrayBuffer.isView(value)) {
return null;
}
if (!modules.has(name)) {
modules.set(name, {});
}
const layer = modules.get(name);
const module = modules.get(name);
let tensor = false;
const entries = value instanceof Map ? value : new Map(Object.entries(value));
for (const [name, value] of entries) {
Expand All @@ -3511,12 +3512,12 @@ pytorch.Utility = class {
continue;
}
if (typeof value === 'string' || typeof value === 'number') {
layer[name] = value;
module[name] = value;
continue;
}
if (pytorch.Utility.isTensor(value)) {
value.__name__ = name;
layer[name] = value;
module[name] = value;
tensor = true;
}
}
Expand Down

0 comments on commit c42091a

Please sign in to comment.