tensorflowjs-string-weight-dos-poc / source /tf-core-node-decodeweight-string-loop.txt
hacnho's picture
Upload folder using huggingface_hub
32810b6 verified
Raw
History Blame Contribute Delete
957 Bytes
6740 else {
6741 throw new Error("Unsupported dtype in weight '".concat(name, "': ").concat(dtype));
6742 }
6743 offset += size * quantizationSizeFactor;
6744 }
6745 else if (dtype === 'string') {
6746 var size_1 = sizeFromShape(spec.shape);
6747 values = [];
6748 for (var i = 0; i < size_1; i++) {
6749 var byteLength = new Uint32Array(byteBuffer.slice(offset, offset + NUM_BYTES_STRING_LENGTH))[0];
6750 offset += NUM_BYTES_STRING_LENGTH;
6751 var bytes = new Uint8Array(byteBuffer.slice(offset, offset + byteLength));
6752 values.push(bytes);
6753 offset += byteLength;
6754 }
6755 }
6756 else {
6757 var dtypeFactor = DTYPE_VALUE_SIZE_MAP[dtype];
6758 if (dtype === 'float32') {
6759 values = new Float32Array(byteBuffer);
6760 }