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/** @import { Source } from '#client' */2import { DEV } from 'esm-env';3import {4 get,5 active_effect,6 update_version,7 active_reaction,8 set_update_version,9 set_active_reaction10} from './runtime.js';11import {12 array_prototype,13 get_descriptor,14 get_prototype_of,15 is_array,16 object_prototype17} from '../shared/utils.js';18import {19 state as source,20 set,21 increment,22 flush_eager_effects,23 set_eager_effects_deferred24} from './reactivity/sources.js';25import { PROXY_PATH_SYMBOL, STATE_SYMBOL } from '#client/constants';26import { UNINITIALIZED } from '../../constants.js';27import * as e from './errors.js';28import { tag } from './dev/tracing.js';29import { get_error } from '../shared/dev.js';30import { tracing_mode_flag } from '../flags/index.js';31 32// TODO move all regexes into shared module?33const regex_is_valid_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;34 35/**36 * @template T37 * @param {T} value38 * @returns {T}39 */40export function proxy(value) {41 // if non-proxyable, or is already a proxy, return `value`42 if (typeof value !== 'object' || value === null || STATE_SYMBOL in value) {43 return value;44 }45 46 const prototype = get_prototype_of(value);47 48 if (prototype !== object_prototype && prototype !== array_prototype) {49 return value;50 }51 52 /** @type {Map<any, Source<any>>} */53 var sources = new Map();54 var is_proxied_array = is_array(value);55 var version = source(0);56 57 var stack = DEV && tracing_mode_flag ? get_error('created at') : null;58 var parent_version = update_version;59 60 /**61 * Executes the proxy in the context of the reaction it was originally created in, if any62 * @template T63 * @param {() => T} fn64 */65 var with_parent = (fn) => {66 if (update_version === parent_version) {67 return fn();68 }69 70 // child source is being created after the initial proxy —71 // prevent it from being associated with the current reaction72 var reaction = active_reaction;73 var version = update_version;74 75 set_active_reaction(null);76 set_update_version(parent_version);77 78 var result = fn();79 80 set_active_reaction(reaction);81 set_update_version(version);82 83 return result;84 };85 86 if (is_proxied_array) {87 // We need to create the length source eagerly to ensure that88 // mutations to the array are properly synced with our proxy89 sources.set('length', source(/** @type {any[]} */ (value).length, stack));90 if (DEV) {91 value = /** @type {any} */ (inspectable_array(/** @type {any[]} */ (value)));92 }93 }94 95 /** Used in dev for $inspect.trace() */96 var path = '';97 let updating = false;98 /** @param {string} new_path */99 function update_path(new_path) {100 if (updating) return;101 updating = true;102 path = new_path;103 104 tag(version, `${path} version`);105 106 // rename all child sources and child proxies107 for (const [prop, source] of sources) {108 tag(source, get_label(path, prop));109 }110 updating = false;111 }112 113 return new Proxy(/** @type {any} */ (value), {114 defineProperty(_, prop, descriptor) {115 if (116 !('value' in descriptor) ||117 descriptor.configurable === false ||118 descriptor.enumerable === false ||119 descriptor.writable === false120 ) {121 // we disallow non-basic descriptors, because unless they are applied to the122 // target object — which we avoid, so that state can be forked — we will run123 // afoul of the various invariants124 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/getOwnPropertyDescriptor#invariants125 e.state_descriptors_fixed();126 }127 var s = sources.get(prop);128 if (s === undefined) {129 with_parent(() => {130 var s = source(descriptor.value, stack);131 sources.set(prop, s);132 if (DEV && typeof prop === 'string') {133 tag(s, get_label(path, prop));134 }135 return s;136 });137 } else {138 set(s, descriptor.value, true);139 }140 141 return true;142 },143 144 deleteProperty(target, prop) {145 var s = sources.get(prop);146 147 if (s === undefined) {148 if (prop in target) {149 const s = with_parent(() => source(UNINITIALIZED, stack));150 sources.set(prop, s);151 increment(version);152 153 if (DEV) {154 tag(s, get_label(path, prop));155 }156 }157 } else {158 set(s, UNINITIALIZED);159 increment(version);160 }161 162 return true;163 },164 165 get(target, prop, receiver) {166 if (prop === STATE_SYMBOL) {167 return value;168 }169 170 if (DEV && prop === PROXY_PATH_SYMBOL) {171 return update_path;172 }173 174 var s = sources.get(prop);175 var exists = prop in target;176 177 // create a source, but only if it's an own property and not a prototype property178 if (s === undefined && (!exists || get_descriptor(target, prop)?.writable)) {179 s = with_parent(() => {180 var p = proxy(exists ? target[prop] : UNINITIALIZED);181 var s = source(p, stack);182 183 if (DEV) {184 tag(s, get_label(path, prop));185 }186 187 return s;188 });189 190 sources.set(prop, s);191 }192 193 if (s !== undefined) {194 var v = get(s);195 return v === UNINITIALIZED ? undefined : v;196 }197 198 return Reflect.get(target, prop, receiver);199 },200 201 getOwnPropertyDescriptor(target, prop) {202 var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);203 204 if (descriptor && 'value' in descriptor) {205 var s = sources.get(prop);206 if (s) descriptor.value = get(s);207 } else if (descriptor === undefined) {208 var source = sources.get(prop);209 var value = source?.v;210 211 if (source !== undefined && value !== UNINITIALIZED) {212 return {213 enumerable: true,214 configurable: true,215 value,216 writable: true217 };218 }219 }220 221 return descriptor;222 },223 224 has(target, prop) {225 if (prop === STATE_SYMBOL) {226 return true;227 }228 229 var s = sources.get(prop);230 var has = (s !== undefined && s.v !== UNINITIALIZED) || Reflect.has(target, prop);231 232 if (233 s !== undefined ||234 (active_effect !== null && (!has || get_descriptor(target, prop)?.writable))235 ) {236 if (s === undefined) {237 s = with_parent(() => {238 var p = has ? proxy(target[prop]) : UNINITIALIZED;239 var s = source(p, stack);240 241 if (DEV) {242 tag(s, get_label(path, prop));243 }244 245 return s;246 });247 248 sources.set(prop, s);249 }250 251 var value = get(s);252 if (value === UNINITIALIZED) {253 return false;254 }255 }256 257 return has;258 },259 260 set(target, prop, value, receiver) {261 var s = sources.get(prop);262 var has = prop in target;263 264 // variable.length = value -> clear all signals with index >= value265 if (is_proxied_array && prop === 'length') {266 for (var i = value; i < /** @type {Source<number>} */ (s).v; i += 1) {267 var other_s = sources.get(i + '');268 if (other_s !== undefined) {269 set(other_s, UNINITIALIZED);270 } else if (i in target) {271 // If the item exists in the original, we need to create an uninitialized source,272 // else a later read of the property would result in a source being created with273 // the value of the original item at that index.274 other_s = with_parent(() => source(UNINITIALIZED, stack));275 sources.set(i + '', other_s);276 277 if (DEV) {278 tag(other_s, get_label(path, i));279 }280 }281 }282 }283 284 // If we haven't yet created a source for this property, we need to ensure285 // we do so otherwise if we read it later, then the write won't be tracked and286 // the heuristics of effects will be different vs if we had read the proxied287 // object property before writing to that property.288 if (s === undefined) {289 if (!has || get_descriptor(target, prop)?.writable) {290 s = with_parent(() => source(undefined, stack));291 292 if (DEV) {293 tag(s, get_label(path, prop));294 }295 set(s, proxy(value));296 297 sources.set(prop, s);298 }299 } else {300 has = s.v !== UNINITIALIZED;301 302 var p = with_parent(() => proxy(value));303 set(s, p);304 }305 306 var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);307 308 // Set the new value before updating any signals so that any listeners get the new value309 if (descriptor?.set) {310 descriptor.set.call(receiver, value);311 }312 313 if (!has) {314 // If we have mutated an array directly, we might need to315 // signal that length has also changed. Do it before updating metadata316 // to ensure that iterating over the array as a result of a metadata update317 // will not cause the length to be out of sync.318 if (is_proxied_array && typeof prop === 'string') {319 var ls = /** @type {Source<number>} */ (sources.get('length'));320 var n = Number(prop);321 322 if (Number.isInteger(n) && n >= ls.v) {323 set(ls, n + 1);324 }325 }326 327 increment(version);328 }329 330 return true;331 },332 333 ownKeys(target) {334 get(version);335 336 var own_keys = Reflect.ownKeys(target).filter((key) => {337 var source = sources.get(key);338 return source === undefined || source.v !== UNINITIALIZED;339 });340 341 for (var [key, source] of sources) {342 if (source.v !== UNINITIALIZED && !(key in target)) {343 own_keys.push(key);344 }345 }346 347 return own_keys;348 },349 350 setPrototypeOf() {351 e.state_prototype_fixed();352 }353 });354}355 356/**357 * @param {string} path358 * @param {string | symbol} prop359 */360function get_label(path, prop) {361 if (typeof prop === 'symbol') return `${path}[Symbol(${prop.description ?? ''})]`;362 if (regex_is_valid_identifier.test(prop)) return `${path}.${prop}`;363 return /^\d+$/.test(prop) ? `${path}[${prop}]` : `${path}['${prop}']`;364}365 366/**367 * @param {any} value368 */369export function get_proxied_value(value) {370 try {371 if (value !== null && typeof value === 'object' && STATE_SYMBOL in value) {372 return value[STATE_SYMBOL];373 }374 } catch {375 // the above if check can throw an error if the value in question376 // is the contentWindow of an iframe on another domain, in which377 // case we want to just return the value (because it's definitely378 // not a proxied value) so we don't break any JavaScript interacting379 // with that iframe (such as various payment companies client side380 // JavaScript libraries interacting with their iframes on the same381 // domain)382 }383 384 return value;385}386 387/**388 * @param {any} a389 * @param {any} b390 */391export function is(a, b) {392 return Object.is(get_proxied_value(a), get_proxied_value(b));393}394 395const ARRAY_MUTATING_METHODS = new Set([396 'copyWithin',397 'fill',398 'pop',399 'push',400 'reverse',401 'shift',402 'sort',403 'splice',404 'unshift'405]);406 407/**408 * Wrap array mutating methods so $inspect is triggered only once and409 * to prevent logging an array in intermediate state (e.g. with an empty slot)410 * @param {any[]} array411 */412function inspectable_array(array) {413 return new Proxy(array, {414 get(target, prop, receiver) {415 var value = Reflect.get(target, prop, receiver);416 if (!ARRAY_MUTATING_METHODS.has(/** @type {string} */ (prop))) {417 return value;418 }419 420 /**421 * @this {any[]}422 * @param {any[]} args423 */424 return function (...args) {425 set_eager_effects_deferred();426 var result = value.apply(this, args);427 flush_eager_effects();428 return result;429 };430 }431 });432}433 