Team Ai
Datasetpublic

Brunobkr/llama.cpp_AlgMor24_github

ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
valueToFloat16Bytes.js74 linesDownload Raw Back to helpers
1'use strict';2 3var $abs = require('math-intrinsics/abs');4var $floor = require('math-intrinsics/floor');5var $pow = require('math-intrinsics/pow');6 7var isFinite = require('math-intrinsics/isFinite');8var isNaN = require('math-intrinsics/isNaN');9var isNegativeZero = require('math-intrinsics/isNegativeZero');10 11var maxFiniteFloat16 = 65504; // 2**16 - 2**512 13module.exports = function valueToFloat16Bytes(value, isLittleEndian) {14	// NaN → exponent=all-ones, mantissa MSB=1 → 0x7e0015	if (isNaN(value)) {16		return isLittleEndian17			? [0x00, 0x7e]18			: [0x7e, 0x00];19	}20 21	var leastSig;22 23	// ±0 → just the sign bit24	if (value === 0) {25		leastSig = isNegativeZero(value) ? 0x80 : 0x00;26		return isLittleEndian27			? [0x00, leastSig]28			: [leastSig, 0x00];29	}30 31	// ±∞ → exponent=all-ones, mantissa=0 → 0x7c00 or 0xfc0032	if ($abs(value) > maxFiniteFloat16 || !isFinite(value)) {33		leastSig = value < 0 ? 0xfc : 0x7c;34		return isLittleEndian35			? [0x00, leastSig]36			: [leastSig, 0x00];37	}38 39	var sign = value < 0 ? 1 : 0;40	value = $abs(value); // eslint-disable-line no-param-reassign41 42	// normalize to [1,2)43	var exponent = 0;44	while (value >= 2) {45		exponent += 1;46		value /= 2; // eslint-disable-line no-param-reassign47	}48	while (value < 1) {49		exponent -= 1;50		value *= 2; // eslint-disable-line no-param-reassign51	}52 53	// build mantissa (10 bits)54	var mantissa = value - 1;55	mantissa *= $pow(2, 10) + 0.5;56	mantissa = $floor(mantissa);57 58	// apply bias (15) and shift into place59	exponent += 15;60	exponent <<= 10;61 62	// pack sign, exponent, mantissa63	var result = (sign << 15) | exponent | mantissa;64 65	// split into two bytes66	var byte0 = result & 0xFF;67	result >>= 8;68	var byte1 = result & 0xFF;69 70	return isLittleEndian71		? [byte0, byte1]72		: [byte1, byte0];73};74 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai