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
util.js439 linesDownload Raw Back to lib
1/* -*- Mode: js; js-indent-level: 2; -*- */2/*3 * Copyright 2011 Mozilla Foundation and contributors4 * Licensed under the New BSD license. See LICENSE or:5 * http://opensource.org/licenses/BSD-3-Clause6 */7 8const URL = require("./url");9 10/**11 * This is a helper function for getting values from parameter/options12 * objects.13 *14 * @param args The object we are extracting values from15 * @param name The name of the property we are getting.16 * @param defaultValue An optional value to return if the property is missing17 * from the object. If this is not specified and the property is missing, an18 * error will be thrown.19 */20function getArg(aArgs, aName, aDefaultValue) {21  if (aName in aArgs) {22    return aArgs[aName];23  } else if (arguments.length === 3) {24    return aDefaultValue;25  }26    throw new Error('"' + aName + '" is a required argument.');27 28}29exports.getArg = getArg;30 31const supportsNullProto = (function() {32  const obj = Object.create(null);33  return !("__proto__" in obj);34}());35 36function identity(s) {37  return s;38}39 40/**41 * Because behavior goes wacky when you set `__proto__` on objects, we42 * have to prefix all the strings in our set with an arbitrary character.43 *44 * See https://github.com/mozilla/source-map/pull/31 and45 * https://github.com/mozilla/source-map/issues/3046 *47 * @param String aStr48 */49function toSetString(aStr) {50  if (isProtoString(aStr)) {51    return "$" + aStr;52  }53 54  return aStr;55}56exports.toSetString = supportsNullProto ? identity : toSetString;57 58function fromSetString(aStr) {59  if (isProtoString(aStr)) {60    return aStr.slice(1);61  }62 63  return aStr;64}65exports.fromSetString = supportsNullProto ? identity : fromSetString;66 67function isProtoString(s) {68  if (!s) {69    return false;70  }71 72  const length = s.length;73 74  if (length < 9 /* "__proto__".length */) {75    return false;76  }77 78  /* eslint-disable no-multi-spaces */79  if (s.charCodeAt(length - 1) !== 95  /* '_' */ ||80      s.charCodeAt(length - 2) !== 95  /* '_' */ ||81      s.charCodeAt(length - 3) !== 111 /* 'o' */ ||82      s.charCodeAt(length - 4) !== 116 /* 't' */ ||83      s.charCodeAt(length - 5) !== 111 /* 'o' */ ||84      s.charCodeAt(length - 6) !== 114 /* 'r' */ ||85      s.charCodeAt(length - 7) !== 112 /* 'p' */ ||86      s.charCodeAt(length - 8) !== 95  /* '_' */ ||87      s.charCodeAt(length - 9) !== 95  /* '_' */) {88    return false;89  }90  /* eslint-enable no-multi-spaces */91 92  for (let i = length - 10; i >= 0; i--) {93    if (s.charCodeAt(i) !== 36 /* '$' */) {94      return false;95    }96  }97 98  return true;99}100 101function strcmp(aStr1, aStr2) {102  if (aStr1 === aStr2) {103    return 0;104  }105 106  if (aStr1 === null) {107    return 1; // aStr2 !== null108  }109 110  if (aStr2 === null) {111    return -1; // aStr1 !== null112  }113 114  if (aStr1 > aStr2) {115    return 1;116  }117 118  return -1;119}120 121/**122 * Comparator between two mappings with inflated source and name strings where123 * the generated positions are compared.124 */125function compareByGeneratedPositionsInflated(mappingA, mappingB) {126  let cmp = mappingA.generatedLine - mappingB.generatedLine;127  if (cmp !== 0) {128    return cmp;129  }130 131  cmp = mappingA.generatedColumn - mappingB.generatedColumn;132  if (cmp !== 0) {133    return cmp;134  }135 136  cmp = strcmp(mappingA.source, mappingB.source);137  if (cmp !== 0) {138    return cmp;139  }140 141  cmp = mappingA.originalLine - mappingB.originalLine;142  if (cmp !== 0) {143    return cmp;144  }145 146  cmp = mappingA.originalColumn - mappingB.originalColumn;147  if (cmp !== 0) {148    return cmp;149  }150 151  return strcmp(mappingA.name, mappingB.name);152}153exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;154 155/**156 * Strip any JSON XSSI avoidance prefix from the string (as documented157 * in the source maps specification), and then parse the string as158 * JSON.159 */160function parseSourceMapInput(str) {161  return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ""));162}163exports.parseSourceMapInput = parseSourceMapInput;164 165// We use 'http' as the base here because we want URLs processed relative166// to the safe base to be treated as "special" URLs during parsing using167// the WHATWG URL parsing. This ensures that backslash normalization168// applies to the path and such.169const PROTOCOL = "http:";170const PROTOCOL_AND_HOST = `${PROTOCOL}//host`;171 172/**173 * Make it easy to create small utilities that tweak a URL's path.174 */175function createSafeHandler(cb) {176  return input => {177    const type = getURLType(input);178    const base = buildSafeBase(input);179    const url = new URL(input, base);180 181    cb(url);182 183    const result = url.toString();184 185    if (type === "absolute") {186      return result;187    } else if (type === "scheme-relative") {188      return result.slice(PROTOCOL.length);189    } else if (type === "path-absolute") {190      return result.slice(PROTOCOL_AND_HOST.length);191    }192 193    // This assumes that the callback will only change194    // the path, search and hash values.195    return computeRelativeURL(base, result);196  };197}198 199function withBase(url, base) {200  return new URL(url, base).toString();201}202 203function buildUniqueSegment(prefix, str) {204  let id = 0;205  do {206    const ident = prefix + (id++);207    if (str.indexOf(ident) === -1) return ident;208  } while (true);209}210 211function buildSafeBase(str) {212  const maxDotParts = str.split("..").length - 1;213 214  // If we used a segment that also existed in `str`, then we would be unable215  // to compute relative paths. For example, if `segment` were just "a":216  //217  //   const url = "../../a/"218  //   const base = buildSafeBase(url); // http://host/a/a/219  //   const joined = "http://host/a/";220  //   const result = relative(base, joined);221  //222  // Expected: "../../a/";223  // Actual: "a/"224  //225  const segment = buildUniqueSegment("p", str);226 227  let base = `${PROTOCOL_AND_HOST}/`;228  for (let i = 0; i < maxDotParts; i++) {229    base += `${segment}/`;230  }231  return base;232}233 234const ABSOLUTE_SCHEME = /^[A-Za-z0-9\+\-\.]+:/;235function getURLType(url) {236  if (url[0] === "/") {237    if (url[1] === "/") return "scheme-relative";238    return "path-absolute";239  }240 241  return ABSOLUTE_SCHEME.test(url) ? "absolute" : "path-relative";242}243 244/**245 * Given two URLs that are assumed to be on the same246 * protocol/host/user/password build a relative URL from the247 * path, params, and hash values.248 *249 * @param rootURL The root URL that the target will be relative to.250 * @param targetURL The target that the relative URL points to.251 * @return A rootURL-relative, normalized URL value.252 */253function computeRelativeURL(rootURL, targetURL) {254  if (typeof rootURL === "string") rootURL = new URL(rootURL);255  if (typeof targetURL === "string") targetURL = new URL(targetURL);256 257  const targetParts = targetURL.pathname.split("/");258  const rootParts = rootURL.pathname.split("/");259 260  // If we've got a URL path ending with a "/", we remove it since we'd261  // otherwise be relative to the wrong location.262  if (rootParts.length > 0 && !rootParts[rootParts.length - 1]) {263    rootParts.pop();264  }265 266  while (267    targetParts.length > 0 &&268    rootParts.length > 0 &&269    targetParts[0] === rootParts[0]270  ) {271    targetParts.shift();272    rootParts.shift();273  }274 275  const relativePath = rootParts276    .map(() => "..")277    .concat(targetParts)278    .join("/");279 280  return relativePath + targetURL.search + targetURL.hash;281}282 283/**284 * Given a URL, ensure that it is treated as a directory URL.285 *286 * @param url287 * @return A normalized URL value.288 */289const ensureDirectory = createSafeHandler(url => {290  url.pathname = url.pathname.replace(/\/?$/, "/");291});292 293/**294 * Given a URL, strip off any filename if one is present.295 *296 * @param url297 * @return A normalized URL value.298 */299const trimFilename = createSafeHandler(url => {300  url.href = new URL(".", url.toString()).toString();301});302 303/**304 * Normalize a given URL.305 * * Convert backslashes.306 * * Remove any ".." and "." segments.307 *308 * @param url309 * @return A normalized URL value.310 */311const normalize = createSafeHandler(url => {});312exports.normalize = normalize;313 314/**315 * Joins two paths/URLs.316 *317 * All returned URLs will be normalized.318 *319 * @param aRoot The root path or URL. Assumed to reference a directory.320 * @param aPath The path or URL to be joined with the root.321 * @return A joined and normalized URL value.322 */323function join(aRoot, aPath) {324  const pathType = getURLType(aPath);325  const rootType = getURLType(aRoot);326 327  aRoot = ensureDirectory(aRoot);328 329  if (pathType === "absolute") {330    return withBase(aPath, undefined);331  }332  if (rootType === "absolute") {333    return withBase(aPath, aRoot);334  }335 336  if (pathType === "scheme-relative") {337    return normalize(aPath);338  }339  if (rootType === "scheme-relative") {340    return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(PROTOCOL.length);341  }342 343  if (pathType === "path-absolute") {344    return normalize(aPath);345  }346  if (rootType === "path-absolute") {347    return withBase(aPath, withBase(aRoot, PROTOCOL_AND_HOST)).slice(PROTOCOL_AND_HOST.length);348  }349 350  const base = buildSafeBase(aPath + aRoot);351  const newPath = withBase(aPath, withBase(aRoot, base));352  return computeRelativeURL(base, newPath);353}354exports.join = join;355 356/**357 * Make a path relative to a URL or another path. If returning a358 * relative URL is not possible, the original target will be returned.359 * All returned URLs will be normalized.360 *361 * @param aRoot The root path or URL.362 * @param aPath The path or URL to be made relative to aRoot.363 * @return A rootURL-relative (if possible), normalized URL value.364 */365function relative(rootURL, targetURL) {366  const result = relativeIfPossible(rootURL, targetURL);367 368  return typeof result === "string" ? result : normalize(targetURL);369}370exports.relative = relative;371 372function relativeIfPossible(rootURL, targetURL) {373  const urlType = getURLType(rootURL);374  if (urlType !== getURLType(targetURL)) {375    return null;376  }377 378  const base = buildSafeBase(rootURL + targetURL);379  const root = new URL(rootURL, base);380  const target = new URL(targetURL, base);381 382  try {383    new URL("", target.toString());384  } catch (err) {385    // Bail if the URL doesn't support things being relative to it,386    // For example, data: and blob: URLs.387    return null;388  }389 390  if (391    target.protocol !== root.protocol ||392    target.user !== root.user ||393    target.password !== root.password ||394    target.hostname !== root.hostname ||395    target.port !== root.port396  ) {397    return null;398  }399 400  return computeRelativeURL(root, target);401}402 403/**404 * Compute the URL of a source given the the source root, the source's405 * URL, and the source map's URL.406 */407function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {408  // The source map spec states that "sourceRoot" and "sources" entries are to be appended. While409  // that is a little vague, implementations have generally interpreted that as joining the410  // URLs with a `/` between then, assuming the "sourceRoot" doesn't already end with one.411  // For example,412  //413  //   sourceRoot: "some-dir",414  //   sources: ["/some-path.js"]415  //416  // and417  //418  //   sourceRoot: "some-dir/",419  //   sources: ["/some-path.js"]420  //421  // must behave as "some-dir/some-path.js".422  //423  // With this library's the transition to a more URL-focused implementation, that behavior is424  // preserved here. To acheive that, we trim the "/" from absolute-path when a sourceRoot value425  // is present in order to make the sources entries behave as if they are relative to the426  // "sourceRoot", as they would have if the two strings were simply concated.427  if (sourceRoot && getURLType(sourceURL) === "path-absolute") {428    sourceURL = sourceURL.replace(/^\//, "");429  }430 431  let url = normalize(sourceURL || "");432 433  // Parsing URLs can be expensive, so we only perform these joins when needed.434  if (sourceRoot) url = join(sourceRoot, url);435  if (sourceMapURL) url = join(trimFilename(sourceMapURL), url);436  return url;437}438exports.computeSourceURL = computeSourceURL;439