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.
03.1k
1/**2 * Like `Array#splice`, but smarter for giant arrays.3 *4 * `Array#splice` takes all items to be inserted as individual argument which5 * causes a stack overflow in V8 when trying to insert 100k items for instance.6 *7 * Otherwise, this does not return the removed items, and takes `items` as an8 * array instead of rest parameters.9 *10 * @template {unknown} T11 * Item type.12 * @param {Array<T>} list13 * List to operate on.14 * @param {number} start15 * Index to remove/insert at (can be negative).16 * @param {number} remove17 * Number of items to remove.18 * @param {Array<T>} items19 * Items to inject into `list`.20 * @returns {undefined}21 * Nothing.22 */23export function splice(list, start, remove, items) {24 const end = list.length;25 let chunkStart = 0;26 /** @type {Array<unknown>} */27 let parameters;28 29 // Make start between zero and `end` (included).30 if (start < 0) {31 start = -start > end ? 0 : end + start;32 } else {33 start = start > end ? end : start;34 }35 remove = remove > 0 ? remove : 0;36 37 // No need to chunk the items if there’s only a couple (10k) items.38 if (items.length < 10000) {39 parameters = Array.from(items);40 parameters.unshift(start, remove);41 // @ts-expect-error Hush, it’s fine.42 list.splice(...parameters);43 } else {44 // Delete `remove` items starting from `start`45 if (remove) list.splice(start, remove);46 47 // Insert the items in chunks to not cause stack overflows.48 while (chunkStart < items.length) {49 parameters = items.slice(chunkStart, chunkStart + 10000);50 parameters.unshift(start, 0);51 // @ts-expect-error Hush, it’s fine.52 list.splice(...parameters);53 chunkStart += 10000;54 start += 10000;55 }56 }57}58 59/**60 * Append `items` (an array) at the end of `list` (another array).61 * When `list` was empty, returns `items` instead.62 *63 * This prevents a potentially expensive operation when `list` is empty,64 * and adds items in batches to prevent V8 from hanging.65 *66 * @template {unknown} T67 * Item type.68 * @param {Array<T>} list69 * List to operate on.70 * @param {Array<T>} items71 * Items to add to `list`.72 * @returns {Array<T>}73 * Either `list` or `items`.74 */75export function push(list, items) {76 if (list.length > 0) {77 splice(list, list.length, 0, items);78 return list;79 }80 return items;81}