From 9c5934b6207a8d8593fc6b02c7fb366671ca92f0 Mon Sep 17 00:00:00 2001 From: Joshua Lochner Date: Wed, 10 Apr 2024 13:23:15 +0200 Subject: [PATCH] Update src/utils/tensor.js --- src/utils/tensor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/tensor.js b/src/utils/tensor.js index 87461f45c..469054cac 100644 --- a/src/utils/tensor.js +++ b/src/utils/tensor.js @@ -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