Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
* Changed to a clearer and more robust way to compare `MLContextOption`s
  • Loading branch information
egalli committed Oct 23, 2024
1 parent 3d45e5b commit 96e116b
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions js/web/lib/wasm/jsep/backend-webnn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,9 @@ const compareMLContextOptions = (a?: MLContextOptions, b?: MLContextOptions): bo
if (a === undefined || b === undefined) {
return false;
}
const aKeys = Object.keys(a).sort();
const bKeys = Object.keys(b).sort();
if (aKeys.length !== bKeys.length) {
return false;
}
type GeneticObject = { [key: string]: object };
for (const key of aKeys) {
if ((a as GeneticObject)[key] !== (b as GeneticObject)[key]) {
return false;
}
}
return true;
const aKeys = Object.keys(a).sort() as Array<keyof typeof a>;
const bKeys = Object.keys(b).sort() as Array<keyof typeof b>;
return aKeys.length === bKeys.length && aKeys.every((key, index) => key === bKeys[index] && a[key] === b[key]);
};

/**
Expand Down

0 comments on commit 96e116b

Please sign in to comment.