Skip to content

Commit

Permalink
Update src/utils/tensor.js
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova authored Apr 10, 2024
1 parent 183f2ee commit 9c5934b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/tensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1210,13 +1210,13 @@ export function quantize_embeddings(tensor, precision) {
if (!['binary', 'ubinary'].includes(precision)) {
throw new Error("The precision must be either 'binary' or 'ubinary'");
}
const inputData = tensor.data;

const signed = precision === 'binary';
const dtype = signed ? 'int8' : 'uint8';
const cls = signed ? Int8Array : Uint8Array;

// Create a typed array to store the packed bits
const cls = signed ? Int8Array : Uint8Array;
const inputData = tensor.data;
const outputData = new cls(inputData.length / 8);

// Iterate over each number in the array
Expand Down

0 comments on commit 9c5934b

Please sign in to comment.