Skip to content

Commit

Permalink
Cleanup bert unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova committed Dec 19, 2024
1 parent 2c3ab0d commit 637b92c
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions tests/models/bert/test_modeling_bert.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,9 @@ export default () => {
async () => {
const inputs = tokenizer("hello");
const { logits } = await model(inputs);
const target = [[0.00043986947275698185, -0.030218850821256638]].flat();
const target = [[0.00043986947275698185, -0.030218850821256638]];
expect(logits.dims).toEqual([1, 2]);
logits
.tolist()
.flat()
.forEach((item, i) => {
expect(item).toBeCloseTo(target[i], 5);
});
expect(logits.tolist()).toBeCloseToNested(target, 5);
},
MAX_TEST_EXECUTION_TIME,
);
Expand All @@ -120,14 +115,9 @@ export default () => {
const target = [
[0.00043986947275698185, -0.030218850821256638],
[0.0003853091038763523, -0.03022204339504242],
].flat();
];
expect(logits.dims).toEqual([2, 2]);
logits
.tolist()
.flat()
.forEach((item, i) => {
expect(item).toBeCloseTo(target[i], 5);
});
expect(logits.tolist()).toBeCloseToNested(target, 5);
},
MAX_TEST_EXECUTION_TIME,
);
Expand Down

0 comments on commit 637b92c

Please sign in to comment.