Skip to content

Commit

Permalink
Add back tensor map test
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova committed Oct 10, 2024
1 parent 1c43e3f commit 7a0f77c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/utils/tensor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ describe("Tensor operations", () => {
});
});

describe("map", () => {
it("should double", async () => {
const original = new Tensor("float32", [1, 2, 3, 4, 5, 6], [2, 3]);
const target = new Tensor("float32", [2, 4, 6, 8, 10, 12], [2, 3]);

const doubled = original.map((x) => x * 2);
compare(doubled, target, 1e-3);
});
});

describe("mean", () => {
it("should calculate mean", async () => {
const t1 = new Tensor("float32", [1, 2, 3, 4, 5, 6], [2, 3, 1]);
Expand Down

0 comments on commit 7a0f77c

Please sign in to comment.