Skip to content

Commit

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

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

// Create a typed array to store the packed bits
const outputData = new cls(inputData.length / 8);

// Iterate over each number in the array
Expand Down

0 comments on commit 183f2ee

Please sign in to comment.