diff --git a/.gitattributes b/.gitattributes index dc78cfe373385821b433d8a6d41766f0d54a2e99..5f7d31605b8e64672e008174fe90716e6d6a225d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,5 +8,5 @@ *.cff text eol=lf *.pdf binary *.png binary -docs/publications/vons-paper-v1.0.pdf filter=lfs diff=lfs merge=lfs -text -docs/publications/vons-tech-report-v1.0.1.pdf filter=lfs diff=lfs merge=lfs -text +docs/publications/vons-paper-v1.1.pdf filter=lfs diff=lfs merge=lfs -text +docs/publications/vons-tech-report-v1.1.pdf filter=lfs diff=lfs merge=lfs -text diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 55812db0ef9cd75139ab177a3acd4ececf36bdd8..12c253c8a55b22fc631485238f54377319996810 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -9,6 +9,8 @@ on: - 'tests/**' - 'configs/**' - 'sdk/**' + - 'docs/assets/inlevel9-signature.png' + - 'docs/assets/vons-extension-icon-*.png' - 'pyproject.toml' - '.gitignore' pull_request: @@ -19,6 +21,8 @@ on: - 'tests/**' - 'configs/**' - 'sdk/**' + - 'docs/assets/inlevel9-signature.png' + - 'docs/assets/vons-extension-icon-*.png' - 'pyproject.toml' - '.gitignore' workflow_dispatch: @@ -59,3 +63,5 @@ jobs: - run: npm run build:browser - run: npm run build:benchmark - run: npm run build:parity + - run: npm run typecheck:extension + - run: npm run build:extension diff --git a/.gitignore b/.gitignore index c3573abb793c7ae59fd52a1e82153fd800207a5a..fe44ee44cdc7b2e7921716404de3826520bf783a 100644 --- a/.gitignore +++ b/.gitignore @@ -31,12 +31,21 @@ !/docs/publications/README.md !/docs/publications/LICENSE.md !/docs/publications/ARXIV.md +!/docs/publications/vons-paper-v1.1.pdf +!/docs/publications/vons-tech-report-v1.1.pdf /docs/assets/* !/docs/assets/inlevel9-signature.png !/docs/assets/inlevel9-signature-dark.png +!/docs/assets/vons-logo.png +!/docs/assets/vons-extension-icon-16.png +!/docs/assets/vons-extension-icon-32.png +!/docs/assets/vons-extension-icon-48.png +!/docs/assets/vons-extension-icon-128.png /configs/* !/configs/pilot.json !/configs/pilot-diffusion.json +!/configs/pilot-v2-direct.json +!/configs/pilot-v2-diffusion.json !/configs/public-release.json /sdk/* !/sdk/typescript/ @@ -48,6 +57,7 @@ !/sdk/typescript/src/ !/sdk/typescript/test/ !/sdk/typescript/demo/ +!/sdk/typescript/extension/ # Raw/generated data, weights, evidence packets and local publications. data/ @@ -89,6 +99,8 @@ restricted/ # Only the exact reviewed publication bytes are eligible for staging. !/docs/publications/vons-paper-v1.0.pdf !/docs/publications/vons-tech-report-v1.0.1.pdf +!/docs/publications/vons-paper-v1.1.pdf +!/docs/publications/vons-tech-report-v1.1.pdf # Credentials, machine-specific config, private prompts and service caches. .env diff --git a/README.md b/README.md index cdf5f937d5d0aab89e106c6475431f3edbb93c29..c3dd8598968a9042f42fe401510d447aa752bbdc 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ tags: - onnx --- +![Vons](docs/assets/vons-logo.png) + ![INLEVEL9](docs/assets/inlevel9-signature.png) # Vons @@ -57,17 +59,23 @@ an organization card, source preview and later a separately validated Space. | Publication | Download | | --- | --- | -| Vons: A Compact, Host-Controlled Decision Component for Agent Workflows — paper v1.0, final editorial revision | [PDF · 15 pages](docs/publications/vons-paper-v1.0.pdf) | -| Vons: Compact Decision Models for Frontier-Agent Workflows — Technical Report v1.0.1 | [PDF · 20 pages](docs/publications/vons-tech-report-v1.0.1.pdf) | +| Vons: A Compact, Host-Controlled Decision Component for Agent Workflows — Preprint v1.1 | [PDF · 21 pages](docs/publications/vons-paper-v1.1.pdf) | +| Vons: Compact Decision Models for Frontier-Agent Workflows — Technical Report v1.1 | [PDF · 29 pages](docs/publications/vons-tech-report-v1.1.pdf) | Articles and original figures use **CC BY 4.0**. Their version, SHA-256 digests and verification scope are in the [publication index](docs/publications/README.md). -These preprints preserve negative results and missing measurements. The paper -was submitted to arXiv under **submission number 8127259**; the last checked -status on **2026-09-25** is **on hold** (undergoing checks). This tracking number -is not a public arXiv article identifier. No announcement or peer-review +These preprints preserve negative results, missing measurements and the boundary +between frozen v1 evidence and the separately labelled post-freeze v2 handoff. +The paper was submitted to arXiv under **submission number 8127259**; the last +checked status on **2026-09-25** is **on hold** (undergoing checks). This tracking +number is not a public arXiv article identifier. No announcement or peer-review acceptance is claimed. +Chrome Web Store version **0.1.0** passed review and is publicly available as +[Vons — Local Decisions](https://chromewebstore.google.com/detail/vons-%E2%80%94-local-decisions/cbmjkokoojinfgafahncmjlfmicinide), +verified on 2026-09-25. Store availability is not evidence of model quality, +scientific validity or production readiness. + ## Local use ```sh diff --git a/configs/pilot-v2-diffusion.json b/configs/pilot-v2-diffusion.json new file mode 100644 index 0000000000000000000000000000000000000000..7a646f3372834dbe06c8a1d6b7fb0720f3a5526c --- /dev/null +++ b/configs/pilot-v2-diffusion.json @@ -0,0 +1,28 @@ +{ + "model_id": "vons-pilot-v2-diffusion", + "backend": "diffusion", + "option_count": 32, + "encoder": { + "name": "google/bert_uncased_L-4_H-256_A-4", + "revision": "387825ce42dbb39b87911cdf8e383ee3b25184f8", + "max_tokens": 512 + }, + "data": { + "path": "data/generated/pilot-v2.jsonl", + "manifest": "data/generated/pilot-v2.manifest.json" + }, + "seed": 7, + "epochs": 12, + "batch_size": 32, + "learning_rate": 0.001, + "latent_size": 64, + "attention_heads": 4, + "diffusion_conditioning": "token_cross_attention", + "noise_schedule": "cosine", + "diffusion_steps": 64, + "inference_steps": 8, + "soft_target_smoothing": 0.1, + "device": "auto", + "artifact_dir": "artifacts/pilot-v2-diffusion", + "target_bundle_bytes": 67108864 +} diff --git a/configs/pilot-v2-direct.json b/configs/pilot-v2-direct.json new file mode 100644 index 0000000000000000000000000000000000000000..8b48fe3703e9f4be1b2a0ae5db9ca5995167eb0e --- /dev/null +++ b/configs/pilot-v2-direct.json @@ -0,0 +1,21 @@ +{ + "model_id": "vons-pilot-v2-direct", + "backend": "direct", + "option_count": 32, + "encoder": { + "name": "google/bert_uncased_L-4_H-256_A-4", + "revision": "387825ce42dbb39b87911cdf8e383ee3b25184f8", + "max_tokens": 512 + }, + "data": { + "path": "data/generated/pilot-v2.jsonl", + "manifest": "data/generated/pilot-v2.manifest.json" + }, + "seed": 7, + "epochs": 6, + "batch_size": 32, + "learning_rate": 0.001, + "device": "auto", + "artifact_dir": "artifacts/pilot-v2-direct", + "target_bundle_bytes": 67108864 +} diff --git a/configs/public-release.json b/configs/public-release.json index 77838a70b756c0abfc8a044a16d56d3e69be8d65..098c9a27dd7ba1253036b2f7ac4ff9f5bb51dbdf 100644 --- a/configs/public-release.json +++ b/configs/public-release.json @@ -15,6 +15,8 @@ "README.md", "configs/pilot-diffusion.json", "configs/pilot.json", + "configs/pilot-v2-diffusion.json", + "configs/pilot-v2-direct.json", "configs/public-release.json", "docs/COMMUNITY.md", "docs/HUB_PUBLISHING.md", @@ -25,11 +27,18 @@ "docs/PUBLIC_RELEASE.md", "docs/assets/inlevel9-signature-dark.png", "docs/assets/inlevel9-signature.png", + "docs/assets/vons-logo.png", + "docs/assets/vons-extension-icon-128.png", + "docs/assets/vons-extension-icon-16.png", + "docs/assets/vons-extension-icon-32.png", + "docs/assets/vons-extension-icon-48.png", "docs/publications/ARXIV.md", "docs/publications/LICENSE.md", "docs/publications/README.md", "docs/publications/vons-paper-v1.0.pdf", + "docs/publications/vons-paper-v1.1.pdf", "docs/publications/vons-tech-report-v1.0.1.pdf", + "docs/publications/vons-tech-report-v1.1.pdf", "pyproject.toml", "sdk/typescript/LICENSE", "sdk/typescript/README.md", @@ -39,10 +48,25 @@ "sdk/typescript/demo/main.ts", "sdk/typescript/demo/parity.html", "sdk/typescript/demo/parity.ts", + "sdk/typescript/extension/ONNX_RUNTIME_NOTICES.md", + "sdk/typescript/extension/PRIVACY.md", + "sdk/typescript/extension/README.md", + "sdk/typescript/extension/background.mjs", + "sdk/typescript/extension/build.mjs", + "sdk/typescript/extension/bundle.ts", + "sdk/typescript/extension/manifest.json", + "sdk/typescript/extension/panel.css", + "sdk/typescript/extension/panel.html", + "sdk/typescript/extension/panel.ts", + "sdk/typescript/extension/privacy.html", + "sdk/typescript/extension/storage.ts", + "sdk/typescript/extension/tsconfig.json", + "sdk/typescript/extension/worker.ts", "sdk/typescript/package-lock.json", "sdk/typescript/package.json", "sdk/typescript/src/index.ts", "sdk/typescript/src/onnx.ts", + "sdk/typescript/test/extension.test.mjs", "sdk/typescript/test/index.test.mjs", "sdk/typescript/test/onnx.test.mjs", "sdk/typescript/test/parity.test.mjs", @@ -53,14 +77,18 @@ "tests/test_calibration.py", "tests/test_contract.py", "tests/test_data.py", + "tests/test_diffusion_model.py", "tests/test_evaluation.py", + "tests/test_inference.py", "tests/test_merge_browser_benchmarks.py", "tests/test_mind2web.py", + "tests/test_mind2web_adapter.py", "tests/test_mind2web_import.py", "tests/test_mind2web_manifest.py", "tests/test_mind2web_prediction.py", "tests/test_mind2web_replay.py", "tests/test_mind2web_runner.py", + "tests/test_onnx_export.py", "tests/test_public_release.py", "tests/test_quality_summary.py", "tests/test_regression.py", @@ -76,6 +104,7 @@ "tools/export_shared_bundle.py", "tools/freeze_publication_packet.py", "tools/import_mind2web.py", + "tools/index_mind2web_predictions.py", "tools/merge_browser_benchmarks.py", "tools/predict_mind2web.py", "tools/prepare_public_release.py", @@ -93,8 +122,10 @@ "vons/contract.py", "vons/data.py", "vons/evaluation.py", + "vons/inference.py", "vons/kasi.py", "vons/mind2web.py", + "vons/mind2web_adapter.py", "vons/models.py", "vons/ollama.py", "vons/research.py", @@ -103,8 +134,15 @@ "reviewed_binaries": { "docs/assets/inlevel9-signature.png": "f7514b56b2a93293054b3d22634ac5f0cb11e00a370f53d8d9f934c55a21bbb5", "docs/assets/inlevel9-signature-dark.png": "d6645528158842af77a89de97361fa0c521fbc5a3c0ea6e996f9c912cfcfe9b5", + "docs/assets/vons-logo.png": "1f557be52834662b480d16048b82ad8b03805af6aa1466f1b2d5add85ed74a5e", "docs/publications/vons-paper-v1.0.pdf": "ae0e09c60e17a98b52bb25c611b2489d10b18bd98d87974f2e8dd25d746a5fc8", - "docs/publications/vons-tech-report-v1.0.1.pdf": "33076d9e52d4a073060066215dd390e3b0bf0cdef48c5ffb2a7c5189854254ed" + "docs/publications/vons-paper-v1.1.pdf": "8e9ff7d768979411db2333f37111692b5b8426bdaec21d35954c7038d047f321", + "docs/publications/vons-tech-report-v1.0.1.pdf": "33076d9e52d4a073060066215dd390e3b0bf0cdef48c5ffb2a7c5189854254ed", + "docs/publications/vons-tech-report-v1.1.pdf": "9e6aff46a271324f82db594155ea6b3a7c51c5cfe9b192e52f2b38d92ca84af3", + "docs/assets/vons-extension-icon-16.png": "1a8d94bade23fed4e84c3ecca64f2904a575f1543981250f0896a17ecc88ffee", + "docs/assets/vons-extension-icon-32.png": "cc32b367c60bdcfd0b07a8b1b8771cfc064ffd45a3a35dfc764136bc05cb97c4", + "docs/assets/vons-extension-icon-48.png": "7ca6d66a7548ff8a8c42bf6bc4e0b123e2bca8abf3ba8366bab6690d9b44f101", + "docs/assets/vons-extension-icon-128.png": "6195919e1368d1695c3346097b216b38f170099080d53c014cc2a4162a7f25d6" }, "software_license": "LicenseRef-Vons-Community-Commercial-1.0", "article_license": "CC-BY-4.0" diff --git a/docs/COMMUNITY.md b/docs/COMMUNITY.md index d2e683b107d9b9d351045d20fc9b38232932a2cb..3014b72ad93c78132a1e7f969318e49c41f6d4ce 100644 --- a/docs/COMMUNITY.md +++ b/docs/COMMUNITY.md @@ -10,7 +10,7 @@ report what works or fails. | Your goal | Entry point | Current availability | | --- | --- | --- | | Understand Vons | [README](../README.md) and [model card](MODEL_CARD.md) | Included in this source preview | -| Read the research | [Paper and Tech Report](publications/README.md) | Coming soon; v1.0 manuscripts are in preparation and excluded from this release | +| Read the research | [Paper and Tech Report](publications/README.md) | Reviewed PDFs and exact verification scope are included | | Try without weights | The walkthrough below | Deterministic contract and synthetic data only | | Run model inference | [TypeScript SDK](../sdk/typescript/README.md) | Requires separately obtained, reviewed model/tokenizer assets | | Share experience | [Experience report](https://github.com/inlevel9-com/Vons/issues/new?template=experience.yml) | GitHub account required to submit | @@ -20,8 +20,9 @@ report what works or fails. The destinations are [GitHub: inlevel9-com/Vons](https://github.com/inlevel9-com/Vons) and [Hugging Face: INLEVEL9/Vons](https://huggingface.co/INLEVEL9/Vons). The source preview includes documentation and GitHub issue forms for feedback. -The paper and Tech Report will be added after v1.0 review; this release contains -neither manuscript. A source upload does not provide hosted model inference. +The paper and Tech Report are included as versioned PDFs; their index preserves +exact hashes, evidence boundaries and arXiv status. A source upload does not +provide hosted model inference. The current software terms require a separate agreement for enterprise/commercial use, including enterprise evaluation. Reading the paper under its article terms is separate from software use. diff --git a/docs/HUB_PUBLISHING.md b/docs/HUB_PUBLISHING.md index 453e54afaeffa10c319b3d6cc40dcb0391a37354..3b57ad375adaa91cf553b4e5fce99a66d50eb160 100644 --- a/docs/HUB_PUBLISHING.md +++ b/docs/HUB_PUBLISHING.md @@ -1,9 +1,10 @@ # Upload the Vons source preview to Hugging Face -This guide covers the completed upload and future owner-operated updates. The -initial upload contains 97 reviewed files, including the final paper and Tech Report PDFs. Drafts, -source manuscript bundles, model weights, restricted data and private records -are excluded. +This guide covers the completed initial upload and subsequent reviewed updates. +The current v1.1 snapshot contains 128 reviewed files, including the source, +extension source, Vons logo, current Paper and Tech Report PDFs and their +historical reviewed versions. Drafts, source manuscript bundles, model weights, +restricted data and private records are excluded. ## Destination and scope @@ -20,6 +21,13 @@ public model card now uses the Vons Community and Commercial License 1.0. The article CC BY 4.0 terms are separate. A later documentation update records the arXiv submission status without adding models or draft material. +The reviewed v1.1 update uses the local snapshot +`releases/huggingface-source-v13`. It adds the 21-page Preprint v1.1, the 29-page +Technical Report v1.1, post-freeze implementation source and tests, Chrome +extension source and the owner-supplied Vons logo. It does not add manuscript +source bundles, claim ledgers, model weights, tokenizer assets or benchmark +data. + A commit to this public repository makes uploaded files publicly readable. Uploading source does not create hosted inference, pretrained weights or a working `from_pretrained` package. The card states those limits explicitly. @@ -57,10 +65,11 @@ Run the source audit from the Vons checkout: python3 tools/prepare_public_release.py ``` -The initial uploaded snapshot is `releases/huggingface-source-v8`. -It contains the 97 reviewed files plus a local `RELEASE_MANIFEST.json` receipt -with every file's byte count and SHA-256 digest. Its root README is the Hub model -card; the working-tree README remains the GitHub landing page. +The initial uploaded snapshot is `releases/huggingface-source-v8`. The current +v1.1 snapshot is `releases/huggingface-source-v13`; it contains 128 reviewed +files plus a local `RELEASE_MANIFEST.json` receipt with every file's byte count +and SHA-256 digest. Its root README is the Hub model card; the working-tree +README remains the GitHub landing page. This export is a snapshot. If you edit any public source or documentation after preparation, create a fresh versioned directory and use that path below: @@ -105,19 +114,19 @@ Open [the model card](https://huggingface.co/INLEVEL9/Vons) and It must no longer identify the software as Apache-2.0 or CC BY 4.0. - Root `LICENSE` and `sdk/typescript/LICENSE` contain the same custom terms. - Source paths such as `vons/`, `tools/`, `tests/` and `sdk/typescript/` are present. -- The Paper and Tech Report links open the 15-page paper and 20-page report. +- The Paper and Tech Report links open the 21-page v1.1 paper and 29-page v1.1 report. Their digests match the publication index. No manuscript source bundle or private review material is uploaded. -- Logo/documentation links resolve, and a signed-out visitor can read the card. +- The Vons and INLEVEL9 logo links resolve, and a signed-out visitor can read the card. Save the resulting Hub commit URL with the local release manifest. GitHub publication, manuscript publication and a hosted demo are separate actions. For subsequent source changes, create a new reviewed export and repeat the same upload command with its new path. Add research files only after their separate -v1.0 review and an explicit public-allowlist update. +review and an explicit public-allowlist update. The initial Hub upload and publication-document update were owner-authorized. -GitHub commits, pushes and visibility changes remain owner-operated. Local -Chrome extension source and packages are prepared separately; the initial -97-file Hub upload does not include the extension. +GitHub commits, pushes and visibility changes remain owner-operated. The v1.1 +Hub source update includes reviewed extension source, but generated extension +packages and imported local models remain excluded. Official CLI/upload guidance checked 2026-09-25. diff --git a/docs/HUGGING_FACE.md b/docs/HUGGING_FACE.md index 7091763af9d37ea82f346e4e86a53033c9e49d01..2feca0b8ac8d9f81aac63e1fea6839d29188792e 100644 --- a/docs/HUGGING_FACE.md +++ b/docs/HUGGING_FACE.md @@ -11,6 +11,8 @@ tags: - onnx --- +![Vons](../docs/assets/vons-logo.png) + ![INLEVEL9](../docs/assets/inlevel9-signature.png) # Vons @@ -57,17 +59,23 @@ an organization card, source preview and later a separately validated Space. | Publication | Download | | --- | --- | -| Vons: A Compact, Host-Controlled Decision Component for Agent Workflows — paper v1.0, final editorial revision | [PDF · 15 pages](../docs/publications/vons-paper-v1.0.pdf) | -| Vons: Compact Decision Models for Frontier-Agent Workflows — Technical Report v1.0.1 | [PDF · 20 pages](../docs/publications/vons-tech-report-v1.0.1.pdf) | +| Vons: A Compact, Host-Controlled Decision Component for Agent Workflows — Preprint v1.1 | [PDF · 21 pages](../docs/publications/vons-paper-v1.1.pdf) | +| Vons: Compact Decision Models for Frontier-Agent Workflows — Technical Report v1.1 | [PDF · 29 pages](../docs/publications/vons-tech-report-v1.1.pdf) | Articles and original figures use **CC BY 4.0**. Their version, SHA-256 digests and verification scope are in the [publication index](../docs/publications/README.md). -These preprints preserve negative results and missing measurements. The paper -was submitted to arXiv under **submission number 8127259**; the last checked -status on **2026-09-25** is **on hold** (undergoing checks). This tracking number -is not a public arXiv article identifier. No announcement or peer-review +These preprints preserve negative results, missing measurements and the boundary +between frozen v1 evidence and the separately labelled post-freeze v2 handoff. +The paper was submitted to arXiv under **submission number 8127259**; the last +checked status on **2026-09-25** is **on hold** (undergoing checks). This tracking +number is not a public arXiv article identifier. No announcement or peer-review acceptance is claimed. +Chrome Web Store version **0.1.0** passed review and is publicly available as +[Vons — Local Decisions](https://chromewebstore.google.com/detail/vons-%E2%80%94-local-decisions/cbmjkokoojinfgafahncmjlfmicinide), +verified on 2026-09-25. Store availability is not evidence of model quality, +scientific validity or production readiness. + ## Local use ```sh diff --git a/docs/MODEL_CARD.md b/docs/MODEL_CARD.md index e6baacc93897fa44fe10448b0946228be7a02d1e..f38eec11f27cef5e01e11e72220b09ac3865b64e 100644 --- a/docs/MODEL_CARD.md +++ b/docs/MODEL_CARD.md @@ -22,15 +22,21 @@ Runtime libraries, complete download size and memory use are distinct quantities ## Evaluation and limitations Historical local experiments include synthetic pilots and an evaluation-only -external benchmark diagnostic. They do not establish general task quality, -production readiness, calibrated safety or a Direct/Diffusion superiority claim. -Reviewed numerical claims belong to the versioned +external benchmark diagnostic. A separately labelled post-freeze v2 handoff +records dynamic per-request padding, balanced four-class synthetic runs, +vector-scaling calibration, a token-conditioned Diffusion head and label-free +Mind2Web context compression. Those bounded synthetic, local-CPU and +conditional-selection results do not establish general task quality, production +readiness, calibrated safety or a Direct/Diffusion superiority claim. Reviewed +numerical claims belong to the versioned [paper and Tech Report](publications/README.md), with exact evidence references. Unreviewed historical tables are not distributed as current results. The ONNX candidate head does not support general score questions. Python and -TypeScript token-budget checks are not fully identical. Browser smoke, repeated -latency, full numerical parity and memory evidence remain separate gates. +TypeScript now both pad to the longest live tokenized candidate within the +manifest budget, but their broader public contract semantics are not claimed to +be identical. Browser smoke, local CPU timing, graph-partition parity and memory +evidence remain separate checks. Do not use model confidence as a permission grant or assume it is calibrated. Vons cannot execute tools or approve high-risk actions. diff --git a/docs/PUBLIC_RELEASE.md b/docs/PUBLIC_RELEASE.md index 4937ffa55bdeea9746029f69d4c382df51a50094..370bea10216897a64883b1801db5e396d282c5a5 100644 --- a/docs/PUBLIC_RELEASE.md +++ b/docs/PUBLIC_RELEASE.md @@ -8,7 +8,7 @@ tool independently rejects any Git candidate outside that exact file list. Included: Python and TypeScript source, tests, source demo files, the SDK dependency lockfile, pilot configuration, reviewed public documentation and the -owner-supplied INLEVEL9 logo. Reviewed publications are listed separately in +owner-supplied Vons and INLEVEL9 logos. Reviewed publications are listed separately in `docs/publications/README.md`. Excluded: all local datasets (including synthetic outputs), model weights, @@ -32,8 +32,8 @@ Each export is a new directory containing only allowlisted files and a `RELEASE_MANIFEST.json` with byte counts and SHA-256 hashes. Existing output directories are never overwritten. Use a new versioned output path after any source change. The Hugging Face export substitutes its model card as the root -README. Both exports contain source and the two exact reviewed publication PDFs, with -no pretrained assets. +README. Both exports contain source, the current v1.1 Paper and Tech Report and +their two reviewed historical PDFs, with no pretrained assets. The audit detects known token/key patterns, personal home paths, private writing session URLs, unexpected Git files, symlinks and changed reviewed binaries. @@ -49,8 +49,8 @@ remove already committed material from history. If existing remote history is later attached, review that history independently before making it public. The CI workflow checks the release allowlist, Python tests and lint, and the SDK -tests and three browser builds. Push/pull-request checks run when source, -tests, configuration or the workflow changes; documentation-only edits do not +tests, three browser builds, and extension type checking/building. Push/pull-request checks run when source, +tests, configuration, packaged extension images or the workflow changes; documentation-only edits do not trigger the full suite. A manual run remains available. SDK tokenizer tests use synthetic fixtures and require no private pilot assets. It has read-only repository permissions and does not publish packages or artifacts. Checks that require unavailable optional @@ -62,11 +62,21 @@ those files; do not publish the historical inputs merely to remove that skip. ## Hugging Face Upload only a reviewed versioned Hugging Face export to `INLEVEL9/Vons`. -The current preparation is `releases/huggingface-source-v8`; see the +The initial verified upload used `releases/huggingface-source-v8`. The reviewed +v1.1 update is prepared as `releases/huggingface-source-v13`; see the [step-by-step upload guide](HUB_PUBLISHING.md). Do not select the development workspace in the Hub upload dialog. Use explicit allow/ignore patterns if using `upload_folder`; its handling of ignore files depends on the client version and upload method. +The current checkout also includes the [Chrome extension source](../sdk/typescript/extension/README.md), +which was not part of that initial 97-file upload but is included in the v1.1 +source update. Generated extension packages remain local and +ignored; distribute only their reviewed contents, with dependency notices and +without imported models or prompts. Chrome Web Store version 0.1.0 was submitted +on 2026-09-25, passed review and had its public listing independently read back +the same day: [Vons — Local Decisions](https://chromewebstore.google.com/detail/vons-%E2%80%94-local-decisions/cbmjkokoojinfgafahncmjlfmicinide). +That listing does not establish model quality or production readiness. + This source preview has no weights and no inference widget. A later weight release needs its own exact file inventory, upstream notices, model/data provenance and runtime validation. Do not turn the ignored checkpoint directory diff --git a/docs/assets/vons-extension-icon-128.png b/docs/assets/vons-extension-icon-128.png new file mode 100644 index 0000000000000000000000000000000000000000..4d3fe2d2e86139a4036e3b7f16ddb1aae84a106f Binary files /dev/null and b/docs/assets/vons-extension-icon-128.png differ diff --git a/docs/assets/vons-extension-icon-16.png b/docs/assets/vons-extension-icon-16.png new file mode 100644 index 0000000000000000000000000000000000000000..1798b4f4e805767a40d57e65da5f9d8b8ea6f92e Binary files /dev/null and b/docs/assets/vons-extension-icon-16.png differ diff --git a/docs/assets/vons-extension-icon-32.png b/docs/assets/vons-extension-icon-32.png new file mode 100644 index 0000000000000000000000000000000000000000..3138a3b323bc66e0fede3b014ee457f37abda90f Binary files /dev/null and b/docs/assets/vons-extension-icon-32.png differ diff --git a/docs/assets/vons-extension-icon-48.png b/docs/assets/vons-extension-icon-48.png new file mode 100644 index 0000000000000000000000000000000000000000..eb0852830fb0d10d18a54def9bc74914b8f580ea Binary files /dev/null and b/docs/assets/vons-extension-icon-48.png differ diff --git a/docs/assets/vons-logo.png b/docs/assets/vons-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..2703371a8c90c57180a806b2bab8711b7ae9abfa Binary files /dev/null and b/docs/assets/vons-logo.png differ diff --git a/docs/publications/README.md b/docs/publications/README.md index 458e961f72afb285d2c1104dcddf5288b62e1663..1171a17492e922c3f378a3eded564d59183687c0 100644 --- a/docs/publications/README.md +++ b/docs/publications/README.md @@ -1,7 +1,9 @@ # Paper and Tech Report -The reviewed PDFs are included in this release. Both files preserve the final -manuscript bytes; publication does not imply new experiments or peer acceptance. +The reviewed v1.1 PDFs are included in this release. They preserve the frozen +v1 evidence while reporting a separately labelled post-freeze remediation +handoff. Publication does not imply independent re-execution, external +generalization, production readiness or peer acceptance. Author: **Kwangseob Ahn** Affiliation: **INLEVEL9 / SEJONG UNIV.** @@ -9,23 +11,37 @@ Contact: **oswarld@inlevel9.com** | Publication | Version | Download | | --- | --- | --- | -| Vons: A Compact, Host-Controlled Decision Component for Agent Workflows | Paper v1.0, final editorial revision | [PDF · 15 pages](vons-paper-v1.0.pdf) | -| Vons: Compact Decision Models for Frontier-Agent Workflows | Technical Report v1.0.1 | [PDF · 20 pages](vons-tech-report-v1.0.1.pdf) | +| Vons: A Compact, Host-Controlled Decision Component for Agent Workflows | Preprint v1.1 | [PDF · 21 pages](vons-paper-v1.1.pdf) | +| Vons: Compact Decision Models for Frontier-Agent Workflows | Technical Report v1.1 | [PDF · 29 pages](vons-tech-report-v1.1.pdf) | ## Verification and provenance -The final documents were reviewed against the frozen evidence packet and primary -references, including tables, figures, negative results and missing measurements. -Every PDF page was visually inspected. Independently checked local SHA-256 -values match the reviewed final versions. All pages render as US Letter, fonts -are embedded, and no PDF JavaScript, launch action or embedded attachment was -found. These are genuine Typst-generated PDFs; a clean source rebuild has not -been independently completed and is not claimed. +The final documents were reviewed against the frozen evidence packet, primary +references and the post-freeze handoff. Claude Science did not access or rerun +the post-freeze files; Codex independently checked the handed-off digests, +values, implementation tests and local repository state. Every page of both +PDFs was visually inspected. Independently checked local SHA-256 values match +the reviewed release versions. All pages render as US Letter, all fonts are +embedded, and no encryption, PDF JavaScript, launch action or embedded +attachment was found. These are genuine Typst-generated PDFs. Science rebuilt +both documents from their v1.1 release source; the private source bundles, +claim ledgers and verification records are intentionally excluded from the +public software release. | File | SHA-256 | | --- | --- | -| `vons-paper-v1.0.pdf` | `ae0e09c60e17a98b52bb25c611b2489d10b18bd98d87974f2e8dd25d746a5fc8` | -| `vons-tech-report-v1.0.1.pdf` | `33076d9e52d4a073060066215dd390e3b0bf0cdef48c5ffb2a7c5189854254ed` | +| `vons-paper-v1.1.pdf` | `8e9ff7d768979411db2333f37111692b5b8426bdaec21d35954c7038d047f321` | +| `vons-tech-report-v1.1.pdf` | `9e6aff46a271324f82db594155ea6b3a7c51c5cfe9b192e52f2b38d92ca84af3` | + +## Historical reviewed versions + +The prior PDFs remain available for provenance. They do not include the +post-freeze v2 remediation section. + +| File | Version | SHA-256 | +| --- | --- | --- | +| `vons-paper-v1.0.pdf` | Paper v1.0 | `ae0e09c60e17a98b52bb25c611b2489d10b18bd98d87974f2e8dd25d746a5fc8` | +| `vons-tech-report-v1.0.1.pdf` | Technical Report v1.0.1 | `33076d9e52d4a073060066215dd390e3b0bf0cdef48c5ffb2a7c5189854254ed` | Only these exact PDFs are permitted by the public allowlist. Drafts, prompts, claim ledgers, review conversations, source bundles and restricted benchmark data diff --git a/docs/publications/vons-paper-v1.1.pdf b/docs/publications/vons-paper-v1.1.pdf new file mode 100644 index 0000000000000000000000000000000000000000..66440c4bf51c5ecfc65dc34285972d8080854922 Binary files /dev/null and b/docs/publications/vons-paper-v1.1.pdf differ diff --git a/docs/publications/vons-tech-report-v1.1.pdf b/docs/publications/vons-tech-report-v1.1.pdf new file mode 100644 index 0000000000000000000000000000000000000000..416b469d78ad6bf7578da1516472d11e01f309b2 Binary files /dev/null and b/docs/publications/vons-tech-report-v1.1.pdf differ diff --git a/sdk/typescript/README.md b/sdk/typescript/README.md index b9ba343943bd557d300653bf9abdf3f8e0ed0a54..0f04505ce65c356aa3379f0a1960a0e6862afeb6 100644 --- a/sdk/typescript/README.md +++ b/sdk/typescript/README.md @@ -36,6 +36,11 @@ values, not the repeated benchmark protocol. ## Source preview +For a UI that does not require serving the development workspace, build the +[Chrome side-panel extension](extension/README.md) with `npm run build:extension`. +It packages the runtime locally and accepts a user-selected, hash-verified model +folder. The guide explains installation and the separate model requirement. + This package is private in npm metadata until an npm release is requested. Its `files` allowlist includes source, this guide and the software license. Models, tokenizers, datasets, generated demo JavaScript and dependencies are intentionally excluded diff --git a/sdk/typescript/extension/ONNX_RUNTIME_NOTICES.md b/sdk/typescript/extension/ONNX_RUNTIME_NOTICES.md new file mode 100644 index 0000000000000000000000000000000000000000..981534d43214b993ffb83ae87ea868111d41b30c --- /dev/null +++ b/sdk/typescript/extension/ONNX_RUNTIME_NOTICES.md @@ -0,0 +1,6411 @@ +# ONNX Runtime 1.30.0 upstream notices + +The npm packages omit these root notices. These unmodified upstream texts are +retained for the packaged runtime. The upstream notice set covers multiple +platforms and is not a claim that every listed component is in the Web build. + + +## LICENSE + +Source: https://raw.githubusercontent.com/microsoft/onnxruntime/v1.30.0/LICENSE + +SHA-256: 2f07c72751aed99790b8a4869cf2311df85a860b22ded05fa22803587a48922c + +MIT License + +Copyright (c) Microsoft Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +## ThirdPartyNotices.txt + +Source: https://raw.githubusercontent.com/microsoft/onnxruntime/v1.30.0/ThirdPartyNotices.txt + +SHA-256: 143764b952fdb1a7c69ce653bfba74a7744d6a8a573bfb73e235fba356c83de3 + +THIRD PARTY SOFTWARE NOTICES AND INFORMATION + +Do Not Translate or Localize + +This software incorporates material from third parties. Microsoft makes certain +open source code available at http://3rdpartysource.microsoft.com, or you may +send a check or money order for US $5.00, including the product name, the open +source component name, and version number, to: + +Source Code Compliance Team +Microsoft Corporation +One Microsoft Way +Redmond, WA 98052 +USA + +Notwithstanding any other terms, you may reverse engineer this software to the +extent required to debug changes to any libraries licensed under the GNU Lesser +General Public License. + +_____ + +Intel Math Kernel Library (Intel MKL) + +Intel Simplified Software License (Version April 2018) + +Copyright (c) 2018 Intel Corporation. + +Use and Redistribution. You may use and redistribute the software (the “Software”), without modification, +provided the following conditions are met: + +* Redistributions must reproduce the above copyright notice and the following terms of use in the Software +and in the documentation and/or other materials provided with the distribution. + +* Neither the name of Intel nor the names of its suppliers may be used to endorse or promote products +derived from this Software without specific prior written permission. + +* No reverse engineering, decompilation, or disassembly of this Software is permitted. + +Limited patent license. Intel grants you a world-wide, royalty-free, non-exclusive license under patents it now +or hereafter owns or controls to make, have made, use, import, offer to sell and sell (“Utilize”) this Software, +but solely to the extent that any such patent is necessary to Utilize the Software alone. The patent license +shall not apply to any combinations which include this software. No hardware per se is licensed hereunder. + +Third party and other Intel programs. “Third Party Programs” are the files listed in the “third-party-programs.txt” +text file that is included with the Software and may include Intel programs under separate license terms. +Third Party Programs, even if included with the distribution of the Materials, are governed by +separate license terms and those license terms solely govern your use of those programs. + +DISCLAIMER. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE DISCLAIMED. THIS SOFTWARE IS +NOT INTENDED FOR USE IN SYSTEMS OR APPLICATIONS WHERE FAILURE OF THE SOFTWARE +MAY CAUSE PERSONAL INJURY OR DEATH AND YOU AGREE THAT YOU ARE FULLY RESPONSIBLE FOR ANY +CLAIMS, COSTS, DAMAGES, EXPENSES, AND ATTORNEYS’ FEES ARISING OUT OF ANY SUCH USE, +EVEN IF ANY CLAIM ALLEGES THAT INTEL WAS NEGLIGENT REGARDING THE DESIGN OR MANUFACTURE OF +THE MATERIALS. + +LIMITATION OF LIABILITY. IN NO EVENT WILL INTEL BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +OF SUCH DAMAGE. YOU AGREE TO INDEMNIFY AND HOLD INTEL HARMLESS AGAINST ANY CLAIMS +AND EXPENSES RESULTING FROM YOUR USE OR UNAUTHORIZED USE OF THE SOFTWARE. + +No support. Intel may make changes to the Software, at any time without notice, and is not obligated to +support, update or provide training for the Software. + +Termination. Intel may terminate your right to use the Software in the event of your breach of this Agreement +and you fail to cure the breach within a reasonable period of time. + +Feedback. Should you provide Intel with comments, modifications, corrections, enhancements or other input +(“Feedback”) related to the Software Intel will be free to use, disclose, reproduce, license or otherwise +distribute or exploit the Feedback in its sole discretion without any obligations or restrictions of any kind, +including without limitation, intellectual property rights or licensing obligations. + +Compliance with laws. You agree to comply with all relevant laws and regulations governing your use, +transfer, import or export (or prohibition thereof) of the Software. + +Governing law. All disputes will be governed by the laws of the United States of America and the State of +Delaware without reference to conflict of law principles and subject to the exclusive jurisdiction of the state or +federal courts sitting in the State of Delaware, and each party agrees that it submits to the personal +jurisdiction and venue of those courts and waives any objections. The United Nations Convention on +Contracts for the International Sale of Goods (1980) is specifically excluded and will not apply to the +Software. + +*Other names and brands may be claimed as the property of others. + +_____ + +protocolbuffers/protobuf + +Copyright 2008 Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Code generated by the Protocol Buffer compiler is owned by the owner +of the input file used when generating it. This code is not +standalone and requires a support library to be linked with it. This +support library is itself covered by the above license. + +_____ + +madler/zlib + +The deflate format used by zlib was defined by Phil Katz. The deflate and +zlib specifications were written by L. Peter Deutsch. Thanks to all the +people who reported problems and suggested various improvements in zlib; they +are too numerous to cite here. + +Copyright notice: + + (C) 1995-2017 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +If you use the zlib library in a product, we would appreciate *not* receiving +lengthy legal documents to sign. The sources are provided for free but without +warranty of any kind. The library has been entirely written by Jean-loup +Gailly and Mark Adler; it does not include third-party code. + +If you redistribute modified sources, we would appreciate that you include in +the file ChangeLog history information documenting your changes. Please read +the FAQ for more information on the distribution of modified source versions. + +_____ + +pybind/pybind11 + +Copyright (c) 2016 Wenzel Jakob , All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Please also refer to the file CONTRIBUTING.md, which clarifies licensing of +external contributions to this project including patches, pull requests, etc. + +_____ + +onnx +Open Neural Network Exchange + +Copyright (c) Facebook, Inc. and Microsoft Corporation. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +_____ + +Eigen + +MPL v2.0 +Mozilla Public License Version 2.0 + + +================================== + +1. Definitions + +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions + +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities + +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination + +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. + +_____ + +intel/dnnl + +Copyright 2016-2018 Intel Corporation + +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +sub-components: + +xbyak + +Copyright (c) 2007 MITSUNARI Shigeo. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. +Neither the name of the copyright owner nor the names of its contributors may +be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +Microsoft GSL + +Copyright (c) 2015 Microsoft Corporation. All rights reserved. + +This code is licensed under the MIT License (MIT). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +_____ + +Tensorflow + +Copyright 2018 The TensorFlow Authors. All rights reserved. + +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all +other entities that control, are controlled by, or are under common +control with that entity. For the purposes of this definition, +"control" means (i) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or +otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation +source, and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or +Object form, made available under the License, as indicated by a +copyright notice that is included in or attached to the work +(an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including +the original version of the Work and any modifications or additions +to that Work or Derivative Works thereof, that is intentionally +submitted to Licensor for inclusion in the Work by the copyright owner +or by an individual or Legal Entity authorized to submit on behalf of +the copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, +and issue tracking systems that are managed by, or on behalf of, the +Licensor for the purpose of discussing and improving the Work, but +excluding communication that is conspicuously marked or otherwise +designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work, +where such license applies only to those patent claims licensable +by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) +with the Work to which such Contribution(s) was submitted. If You +institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work +or a Contribution incorporated within the Work constitutes direct +or contributory patent infringement, then any patent licenses +granted to You under this License for that Work shall terminate +as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof in any medium, with or without +modifications, and in Source or Object form, provided that You +meet the following conditions: + +(a) You must give any other recipients of the Work or +Derivative Works a copy of this License; and + +(b) You must cause any modified files to carry prominent notices +stating that You changed the files; and + +(c) You must retain, in the Source form of any Derivative Works +that You distribute, all copyright, patent, trademark, and +attribution notices from the Source form of the Work, +excluding those notices that do not pertain to any part of +the Derivative Works; and + +(d) If the Work includes a "NOTICE" text file as part of its +distribution, then any Derivative Works that You distribute must +include a readable copy of the attribution notices contained +within such NOTICE file, excluding those notices that do not +pertain to any part of the Derivative Works, in at least one +of the following places: within a NOTICE text file distributed +as part of the Derivative Works; within the Source form or +documentation, if provided along with the Derivative Works; or, +within a display generated by the Derivative Works, if and +wherever such third-party notices normally appear. The contents +of the NOTICE file are for informational purposes only and +do not modify the License. You may add Your own attribution +notices within Derivative Works that You distribute, alongside +or as an addendum to the NOTICE text from the Work, provided +that such additional attribution notices cannot be construed +as modifying the License. + +You may add Your own copyright statement to Your modifications and +may provide additional or different license terms and conditions +for use, reproduction, or distribution of Your modifications, or +for any such Derivative Works as a whole, provided Your use, +reproduction, and distribution of the Work otherwise complies with +the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2017, The TensorFlow Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +_____ + +Microsoft Cognitive Toolkit (CNTK) + +Copyright (c) Microsoft Corporation. All rights reserved. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +_____ + +NumPy License + +Copyright (c) 2005, NumPy Developers + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + Neither the name of the NumPy Developers nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +Pytorch / Caffe2 + +From PyTorch: + +Copyright (c) 2016- Facebook, Inc (Adam Paszke) +Copyright (c) 2014- Facebook, Inc (Soumith Chintala) +Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert) +Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu) +Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu) +Copyright (c) 2011-2013 NYU (Clement Farabet) +Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston) +Copyright (c) 2006 Idiap Research Institute (Samy Bengio) +Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz) + +From Caffe2: + +Copyright (c) 2016-present, Facebook Inc. All rights reserved. + +All contributions by Facebook: +Copyright (c) 2016 Facebook Inc. + +All contributions by Google: +Copyright (c) 2015 Google Inc. +All rights reserved. + +All contributions by Yangqing Jia: +Copyright (c) 2015 Yangqing Jia +All rights reserved. + +All contributions from Caffe: +Copyright(c) 2013, 2014, 2015, the respective contributors +All rights reserved. + +All other contributions: +Copyright(c) 2015, 2016 the respective contributors +All rights reserved. + +Caffe2 uses a copyright model similar to Caffe: each contributor holds +copyright over their contributions to Caffe2. The project versioning records +all such contribution and copyright details. If a contributor wants to further +mark their specific copyright on a particular contribution, they should +indicate their copyright solely in the commit message of the change when it is +committed. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the names of Facebook, Deepmind Technologies, NYU, NEC Laboratories America + and IDIAP Research Institute nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +_____ + +Caffe + +COPYRIGHT + +All contributions by the University of California: +Copyright (c) 2014-2017 The Regents of the University of California (Regents) +All rights reserved. + +All other contributions: +Copyright (c) 2014-2017, the respective contributors +All rights reserved. + +Caffe uses a shared copyright model: each contributor holds copyright over +their contributions to Caffe. The project versioning records all such +contribution and copyright details. If a contributor wants to further mark +their specific copyright on a particular contribution, they should indicate +their copyright solely in the commit message of the change when it is +committed. + +LICENSE + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +CONTRIBUTION AGREEMENT + +By contributing to the BVLC/caffe repository through pull-request, comment, +or otherwise, the contributor releases their content to the +license and copyright terms herein. + +_____ + +The LLVM Compiler Infrastructure + +============================================================================== +LLVM Release License +============================================================================== +University of Illinois/NCSA +Open Source License + +Copyright (c) 2003-2017 University of Illinois at Urbana-Champaign. +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +============================================================================== +Copyrights and Licenses for Third Party Software Distributed with LLVM: +============================================================================== +The LLVM software contains code written by third parties. Such software will +have its own individual LICENSE.TXT file in the directory in which it appears. +This file will describe the copyrights, license, and restrictions which apply +to that code. + +The disclaimer of warranty in the University of Illinois Open Source License +applies to all code in the LLVM Distribution, and nothing in any of the +other licenses gives permission to use the names of the LLVM Team or the +University of Illinois to endorse or promote products derived from this +Software. + +The following pieces of software have additional or alternate copyrights, +licenses, and/or restrictions: + +Program Directory +------- --------- +Google Test llvm/utils/unittest/googletest +OpenBSD regex llvm/lib/Support/{reg*, COPYRIGHT.regex} +pyyaml tests llvm/test/YAMLParser/{*.data, LICENSE.TXT} +ARM contributions llvm/lib/Target/ARM/LICENSE.TXT +md5 contributions llvm/lib/Support/MD5.cpp llvm/include/llvm/Support/MD5.h + +_____ + +google/benchmark + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +CONTRIBUTORS + +# People who have agreed to one of the CLAs and can contribute patches. +# The AUTHORS file lists the copyright holders; this file +# lists people. For example, Google employees are listed here +# but not in AUTHORS, because Google holds the copyright. +# +# Names should be added to this file only after verifying that +# the individual or the individual's organization has agreed to +# the appropriate Contributor License Agreement, found here: +# +# https://developers.google.com/open-source/cla/individual +# https://developers.google.com/open-source/cla/corporate +# +# The agreement for individuals can be filled out on the web. +# +# When adding J Random Contributor's name to this file, +# either J's name or J's organization's name should be +# added to the AUTHORS file, depending on whether the +# individual or corporate CLA was used. +# +# Names should be added to this file as: +# Name +# +# Please keep the list sorted. + +Albert Pretorius +Arne Beer +Billy Robert O'Neal III +Chris Kennelly +Christopher Seymour +David Coeurjolly +Deniz Evrenci +Dominic Hamon +Dominik Czarnota +Eric Fiselier +Eugene Zhuk +Evgeny Safronov +Federico Ficarelli +Felix Homann +Ismael Jimenez Martinez +Jern-Kuan Leong +JianXiong Zhou +Joao Paulo Magalhaes +John Millikin +Jussi Knuuttila +Kai Wolf +Kishan Kumar +Kaito Udagawa +Lei Xu +Matt Clarkson +Maxim Vafin +Nick Hutchinson +Oleksandr Sochka +Pascal Leroy +Paul Redmond +Pierre Phaneuf +Radoslav Yovchev +Raul Marin +Ray Glover +Robert Guo +Roman Lebedev +Shuo Chen +Tobias Ulvgård +Tom Madams +Yixuan Qiu +Yusuke Suzuki +Zbigniew Skowron + +AUTHORS + +# This is the official list of benchmark authors for copyright purposes. +# This file is distinct from the CONTRIBUTORS files. +# See the latter for an explanation. +# +# Names should be added to this file as: +# Name or Organization +# The email address is not required for organizations. +# +# Please keep the list sorted. + +Albert Pretorius +Arne Beer +Carto +Christopher Seymour +David Coeurjolly +Deniz Evrenci +Dirac Research +Dominik Czarnota +Eric Fiselier +Eugene Zhuk +Evgeny Safronov +Federico Ficarelli +Felix Homann +Google Inc. +International Business Machines Corporation +Ismael Jimenez Martinez +Jern-Kuan Leong +JianXiong Zhou +Joao Paulo Magalhaes +Jussi Knuuttila +Kaito Udagawa +Kishan Kumar +Lei Xu +Matt Clarkson +Maxim Vafin +MongoDB Inc. +Nick Hutchinson +Oleksandr Sochka +Paul Redmond +Radoslav Yovchev +Roman Lebedev +Shuo Chen +Steinar H. Gunderson +Stripe, Inc. +Yixuan Qiu +Yusuke Suzuki +Zbigniew Skowron + +_____ + +HalideIR + +Copyright (c) 2016 HalideIR contributors +Copyright (c) 2012-2014 MIT CSAIL, Google Inc., and other contributors +HalideIR is derived from the Halide project. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +_____ + +Distributed Machine Learning Common Codebase + +Copyright (c) 2015 by Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +_____ + +DLPack: Open In Memory Tensor Structure + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2017 by Contributors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +_____ + +HowardHinnant/date + +The source code in this project is released using the MIT License. There is no +global license for the project because each file is licensed individually with +different author names and/or dates. + +If you contribute to this project, please add your name to the license of each +file you modify. If you have already contributed to this project and forgot to +add your name to the license, please feel free to submit a new P/R to add your +name to the license in each file you modified. + +For convenience, here is a copy of the MIT license found in each file except +without author names or dates: + +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +_____ + +FreeBSD: getopt.c file + +Copyright (c) 1987, 1993, 1994 +The Regents of the University of California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. Neither the name of the University nor the names of its contributors +may be used to endorse or promote products derived from this software +without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. +_____ + + +google/googletest + +Copyright 2008, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +G3log : Asynchronous logger with Dynamic Sinks + +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to +_____ + +Scikit-learn + +Copyright (c) 2007–2018 The scikit-learn developers. +All rights reserved. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + a. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + b. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + c. Neither the name of the Scikit-learn Developers nor the names of + its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. + +_____ + +google/re2 + +Copyright (c) 2009 The RE2 Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +_____ +onnx/onnx-tensorrt + +MIT License + +Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. +Copyright (c) 2018 Open Neural Network Exchange + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +_____ +nvidia/cutlass + +Copyright (c) 2017 - 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +SPDX-License-Identifier: BSD-3-Clause + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ +Boost + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + + +_____ + +JDAI-CV/DNNLibrary + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [2019] [JD.com Inc. JD AI] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +_____ + +google/flatbuffers + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014 Google Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +_____ + +google/glog + +Copyright (c) 2008, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +A function gettimeofday in utilities.cc is based on + +http://www.google.com/codesearch/p?hl=en#dR3YEbitojA/COPYING&q=GetSystemTimeAsFileTime%20license:bsd + +The license of this code is: + +Copyright (c) 2003-2008, Jouni Malinen and contributors +All Rights Reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name(s) of the above-listed copyright holder(s) nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +abseil-cpp +https://github.com/abseil/abseil-cpp + + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +_____ + +microsoft/wil + +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE + +_____ + +nlohmann/json + +MIT License + +Copyright (c) 2013-2019 Niels Lohmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +_____ + +dcleblanc/SafeInt + +MIT License + +Copyright (c) 2018 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +_____ +Open MPI + +3-Clause BSD License + +Most files in this release are marked with the copyrights of the +organizations who have edited them. The copyrights below are in no +particular order and generally reflect members of the Open MPI core +team who have contributed code to this release. The copyrights for +code used under license from other parties are included in the +corresponding files. + +Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana + University Research and Technology + Corporation. All rights reserved. +Copyright (c) 2004-2017 The University of Tennessee and The University + of Tennessee Research Foundation. All rights + reserved. +Copyright (c) 2004-2010 High Performance Computing Center Stuttgart, + University of Stuttgart. All rights reserved. +Copyright (c) 2004-2008 The Regents of the University of California. + All rights reserved. +Copyright (c) 2006-2017 Los Alamos National Security, LLC. All rights + reserved. +Copyright (c) 2006-2017 Cisco Systems, Inc. All rights reserved. +Copyright (c) 2006-2010 Voltaire, Inc. All rights reserved. +Copyright (c) 2006-2017 Sandia National Laboratories. All rights reserved. +Copyright (c) 2006-2010 Sun Microsystems, Inc. All rights reserved. + Use is subject to license terms. +Copyright (c) 2006-2017 The University of Houston. All rights reserved. +Copyright (c) 2006-2009 Myricom, Inc. All rights reserved. +Copyright (c) 2007-2017 UT-Battelle, LLC. All rights reserved. +Copyright (c) 2007-2017 IBM Corporation. All rights reserved. +Copyright (c) 1998-2005 Forschungszentrum Juelich, Juelich Supercomputing + Centre, Federal Republic of Germany +Copyright (c) 2005-2008 ZIH, TU Dresden, Federal Republic of Germany +Copyright (c) 2007 Evergrid, Inc. All rights reserved. +Copyright (c) 2008 Chelsio, Inc. All rights reserved. +Copyright (c) 2008-2009 Institut National de Recherche en + Informatique. All rights reserved. +Copyright (c) 2007 Lawrence Livermore National Security, LLC. + All rights reserved. +Copyright (c) 2007-2017 Mellanox Technologies. All rights reserved. +Copyright (c) 2006-2010 QLogic Corporation. All rights reserved. +Copyright (c) 2008-2017 Oak Ridge National Labs. All rights reserved. +Copyright (c) 2006-2012 Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2009-2015 Bull SAS. All rights reserved. +Copyright (c) 2010 ARM ltd. All rights reserved. +Copyright (c) 2016 ARM, Inc. All rights reserved. +Copyright (c) 2010-2011 Alex Brick . All rights reserved. +Copyright (c) 2012 The University of Wisconsin-La Crosse. All rights + reserved. +Copyright (c) 2013-2016 Intel, Inc. All rights reserved. +Copyright (c) 2011-2017 NVIDIA Corporation. All rights reserved. +Copyright (c) 2016 Broadcom Limited. All rights reserved. +Copyright (c) 2011-2017 Fujitsu Limited. All rights reserved. +Copyright (c) 2014-2015 Hewlett-Packard Development Company, LP. All + rights reserved. +Copyright (c) 2013-2017 Research Organization for Information Science (RIST). + All rights reserved. +Copyright (c) 2017-2018 Amazon.com, Inc. or its affiliates. All Rights + reserved. +Copyright (c) 2018 DataDirect Networks. All rights reserved. +Copyright (c) 2018-2019 Triad National Security, LLC. All rights reserved. + +$COPYRIGHT$ + +Additional copyrights may follow + +$HEADER$ + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer listed + in this license in the documentation and/or other materials + provided with the distribution. + +- Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +The copyright holders provide no reassurances that the source code +provided does not infringe any patent, copyright, or any other +intellectual property rights of third parties. The copyright holders +disclaim any liability to any recipient for claims brought against +recipient by any third party for infringement of that parties +intellectual property rights. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +The Android Open Source Project + +Copyright (C) 2017 The Android Open Source Project +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +------ + +libprotobuf-mutator + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + ----- + + openucx/ucx + https://github.com/openucx/ucx + + Copyright (c) 2014-2015 UT-Battelle, LLC. All rights reserved. + Copyright (C) 2014-2020 Mellanox Technologies Ltd. All rights reserved. + Copyright (C) 2014-2015 The University of Houston System. All rights reserved. + Copyright (C) 2015 The University of Tennessee and The University + of Tennessee Research Foundation. All rights reserved. + Copyright (C) 2016-2020 ARM Ltd. All rights reserved. + Copyright (c) 2016 Los Alamos National Security, LLC. All rights reserved. + Copyright (C) 2016-2020 Advanced Micro Devices, Inc. All rights reserved. + Copyright (C) 2019 UChicago Argonne, LLC. All rights reserved. + Copyright (c) 2018-2020 NVIDIA CORPORATION. All rights reserved. + Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. + Copyright (C) 2016-2020 Stony Brook University. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + ----- + + From PyTorch: + + Copyright (c) 2016- Facebook, Inc (Adam Paszke) + Copyright (c) 2014- Facebook, Inc (Soumith Chintala) + Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert) + Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu) + Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu) + Copyright (c) 2011-2013 NYU (Clement Farabet) + Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston) + Copyright (c) 2006 Idiap Research Institute (Samy Bengio) + Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz) + + From Caffe2: + + Copyright (c) 2016-present, Facebook Inc. All rights reserved. + + All contributions by Facebook: + Copyright (c) 2016 Facebook Inc. + + All contributions by Google: + Copyright (c) 2015 Google Inc. + All rights reserved. + + All contributions by Yangqing Jia: + Copyright (c) 2015 Yangqing Jia + All rights reserved. + + All contributions from Caffe: + Copyright(c) 2013, 2014, 2015, the respective contributors + All rights reserved. + + All other contributions: + Copyright(c) 2015, 2016 the respective contributors + All rights reserved. + + Caffe2 uses a copyright model similar to Caffe: each contributor holds + copyright over their contributions to Caffe2. The project versioning records + all such contribution and copyright details. If a contributor wants to further + mark their specific copyright on a particular contribution, they should + indicate their copyright solely in the commit message of the change when it is + committed. + + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the names of Facebook, Deepmind Technologies, NYU, NEC Laboratories America + and IDIAP Research Institute nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +_____ + + mpi4py + https://github.com/mpi4py/mpi4py/ + + ======================= + LICENSE: MPI for Python + ======================= + + :Author: Lisandro Dalcin + :Contact: dalcinl@gmail.com + + + Copyright (c) 2019, Lisandro Dalcin. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +_____ +huggingface/transformers + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +_____ +msgpack/msgpack-python + +Copyright (C) 2008-2011 INADA Naoki + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +_____ +lanpa/tensorboardX + +MIT License + +Copyright (c) 2017 Tzu-Wei Huang + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +_____ +tensorflow/tensorboard + +Copyright 2017 The TensorFlow Authors. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2017, The TensorFlow Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +_____ + +cerberus + +Cerberus is a lightweight and extensible data validation library for Python. + +ISC License + +Copyright (c) 2012-2016 Nicola Iarocci. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + +_____ + +MurmurHash3 + +MIT license + +https://github.com/aappleby/smhasher + +SMHasher is a test suite designed to test the distribution, collision, and +performance properties of non-cryptographic hash functions. +This is the home for the MurmurHash family of hash functions along with the +SMHasher test suite used to verify them. +SMHasher is released under the MIT license. +All MurmurHash versions are public domain software, and the author disclaims all copyright to their code. + +_____ + +gtest-ios-framework + +https://github.com/mestevens/gtest-ios-framework + +Copyright (c) 2013 Matthew Stevens + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +_____ + +DLPack + +https://github.com/dmlc/dlpack + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2017 by Contributors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +_____ + +emsdk + +MIT/Expat license + +https://github.com/emscripten-core/emsdk + +Copyright (c) 2018 Emscripten authors (see AUTHORS in Emscripten) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +---------------------------------------------------------------------------- + +This is the MIT/Expat License. For more information see: + +1. http://www.opensource.org/licenses/mit-license.php + +2. http://en.wikipedia.org/wiki/MIT_License + +_____ + +coremltools + +BSD-3-Clause License + +https://github.com/apple/coremltools + +Copyright (c) 2020, Apple Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder(s) nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +© 2021 GitHub, Inc. + +_____ + +react-native + +MIT License + +https://github.com/facebook/react-native + +Copyright (c) Facebook, Inc. and its affiliates. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +_____ + +pytorch/cpuinfo + +BSD 2-Clause "Simplified" License + +https://github.com/pytorch/cpuinfo + +Copyright (c) 2019 Google LLC +Copyright (c) 2017-2018 Facebook Inc. +Copyright (C) 2012-2017 Georgia Institute of Technology +Copyright (C) 2010-2012 Marat Dukhan + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +SQLite Is Public Domain + +All of the code and documentation in SQLite has been dedicated to the public +domain by the authors. All code authors, and representatives of the companies +they work for, have signed affidavits dedicating their contributions to the +public domain and originals of those signed affidavits are stored in a firesafe +at the main offices of Hwaci. Anyone is free to copy, modify, publish, use, +compile, sell, or distribute the original SQLite code, either in source code +form or as a compiled binary, for any purpose, commercial or non-commercial, +and by any means. + +The previous paragraph applies to the deliverable code and documentation in +SQLite - those parts of the SQLite library that you actually bundle and ship +with a larger application. Some scripts used as part of the build process (for +example the "configure" scripts generated by autoconf) might fall under other +open-source licenses. Nothing from these build scripts ever reaches the final +deliverable SQLite library, however, and so the licenses associated with those +scripts should not be a factor in assessing your rights to copy and use the +SQLite library. + +All of the deliverable code in SQLite has been written from scratch. No code +has been taken from other projects or from the open internet. Every line of +code can be traced back to its original author, and all of those authors have +public domain dedications on file. So the SQLite code base is clean and is +uncontaminated with licensed code from other projects. + +_____ + +google/XNNPACK + +BSD License + +For XNNPACK software + +Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. +Copyright 2019 Google LLC + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name Facebook nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +google/sentencepiece, https://github.com/google/sentencepiece +(included when statically linked with onnxruntime-extensions) + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +_____ + +dlfcn-win32/dlfcn-win32 is licensed under the MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +_____ + +The Python Imaging Library (PIL) is + + Copyright © 1997-2011 by Secret Labs AB + Copyright © 1995-2011 by Fredrik Lundh + +Pillow is the friendly PIL fork. It is + + Copyright © 2010-2023 by Alex Clark and contributors + +Like PIL, Pillow is licensed under the open source HPND License: + +By obtaining, using, and/or copying this software and/or its associated +documentation, you agree that you have read, understood, and will comply +with the following terms and conditions: + +Permission to use, copy, modify, and distribute this software and its +associated documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appears in all copies, and that +both that copyright notice and this permission notice appear in supporting +documentation, and that the name of Secret Labs AB or the author not be +used in advertising or publicity pertaining to distribution of the software +without specific, written prior permission. + +SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. +IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR ANY SPECIAL, +INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + +_____ + +openssl/openssl, https://github.com/openssl/openssl + + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + +_____ + +Tencent/rapidjson, https://github.com/Tencent/rapidjson + +Tencent is pleased to support the open source community by making RapidJSON available. + +Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. + +If you have downloaded a copy of the RapidJSON binary from Tencent, please note that the RapidJSON binary is licensed under the MIT License. +If you have downloaded a copy of the RapidJSON source code from Tencent, please note that RapidJSON source code is licensed under the MIT License, except for the third-party components listed below which are subject to different license terms. Your integration of RapidJSON into your own projects may require compliance with the MIT License, as well as the other licenses applicable to the third-party components included within RapidJSON. To avoid the problematic JSON license in your own projects, it's sufficient to exclude the bin/jsonchecker/ directory, as it's the only code under the JSON license. +A copy of the MIT License is included in this file. + +Other dependencies and licenses: + +Open Source Software Licensed Under the BSD License: +-------------------------------------------------------------------- + +The msinttypes r29 +Copyright (c) 2006-2013 Alexander Chemeris +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +* Neither the name of copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Open Source Software Licensed Under the JSON License: +-------------------------------------------------------------------- + +json.org +Copyright (c) 2002 JSON.org +All Rights Reserved. + +JSON_checker +Copyright (c) 2002 JSON.org +All Rights Reserved. + + +Terms of the JSON License: +--------------------------------------------------- + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +The Software shall be used for Good, not Evil. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +Terms of the MIT License: +-------------------------------------------------------------------- + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +_____ + +boostorg/boost, https://github.com/boostorg/boost + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +_____ + +libb64/libb64, https://github.com/libb64/libb64 + +Copyright-Only Dedication (based on United States law) or Public Domain Certification + +The person or persons who have associated work with this document (the "Dedicator" or "Certifier") hereby either (a) certifies that, to the best of his knowledge, the work of authorship identified is in the public domain of the country from which the work is published, or (b) hereby dedicates whatever copyright the dedicators holds in the work of authorship identified below (the "Work") to the public domain. A certifier, moreover, dedicates any copyright interest he may have in the associated work, and for these purposes, is described as a "dedicator" below. + +A certifier has taken reasonable steps to verify the copyright status of this work. Certifier recognizes that his good faith efforts may not shield him from liability if in fact the work certified is not in the public domain. + +Dedicator makes this dedication for the benefit of the public at large and to the detriment of the Dedicator's heirs and successors. Dedicator intends this dedication to be an overt act of relinquishment in perpetuity of all present and future rights under copyright law, whether vested or contingent, in the Work. Dedicator understands that such relinquishment of all rights includes the relinquishment of all rights to enforce (by lawsuit or otherwise) those copyrights in the Work. + +Dedicator recognizes that, once placed in the public domain, the Work may be freely reproduced, distributed, transmitted, used, modified, built upon, or otherwise exploited by anyone for any purpose, commercial or non-commercial, and in any way, including by methods that have not yet been invented or conceived. + +_____ + +posix pthread library, https://sourceforge.net/projects/pthreads4w + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +_____ + +Triton Inference Server & Client, https://github.com/triton-inference-server + +Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of NVIDIA CORPORATION nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +microsoft/mimalloc, https://github.com/microsoft/mimalloc + +MIT License + +Copyright (c) 2018-2021 Microsoft Corporation, Daan Leijen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +_____ + +TensorFlow.js + +https://github.com/tensorflow/tfjs + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +—— + +curl/curl + +https://github.com/curl + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (C) Daniel Stenberg, , and many +contributors, see the THANKS file. + +All rights reserved. + +Permission to use, copy, modify, and distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright +notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN +NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of a copyright holder shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization of the copyright holder. + +_____ + +Mbed TLS + +https://github.com/Mbed-TLS/mbedtls + +Copyright The Mbed TLS Contributors + +Mbed TLS is available under the Apache License 2.0 OR the GNU General Public +License, version 2 or later. This distribution uses Mbed TLS under the Apache +License 2.0. The full Apache License 2.0 terms are reproduced above in this +file. + +_____ + +Intel neural-compressor + +https://github.com/intel/neural-compressor + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + ============================================================================ + + Copyright 2016-2019 Intel Corporation + Copyright 2018 YANDEX LLC + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + This distribution includes third party software ("third party programs"). + This third party software, even if included with the distribution of + the Intel software, may be governed by separate license terms, including + without limitation, third party license terms, other Intel software license + terms, and open source software license terms. These separate license terms + govern your use of the third party programs as set forth in the + "THIRD-PARTY-PROGRAMS" file. + +_____ + +FlashAttention, https://github.com/Dao-AILab/flash-attention + +BSD 3-Clause License + +Copyright (c) 2022, the respective contributors, as shown by the AUTHORS file. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +neural-speed + +https://github.com/intel/neural-speed + + Apache License + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + ============================================================================ + + Copyright 2016-2019 Intel Corporation + Copyright 2018 YANDEX LLC + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + This distribution includes third party software ("third party programs"). + This third party software, even if included with the distribution of + the Intel software, may be governed by separate license terms, including + without limitation, third party license terms, other Intel software license + terms, and open source software license terms. These separate license terms + govern your use of the third party programs as set forth in the + "THIRD-PARTY-PROGRAMS" file. + +_____ + +dawn + +https://dawn.googlesource.com/dawn + + BSD 3-Clause License + + Copyright 2017-2023 The Dawn & Tint Authors + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +KleidiAI + +https://gitlab.arm.com/kleidi/kleidiai + +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + + You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +Copyright 2024-2025 Arm Limited and/or its affiliates + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +_____ + +microsoft/cpp_client_telemetry, https://github.com/microsoft/cpp_client_telemetry/ + +Apache License + +Copyright (c) Microsoft Corporation. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +_____ +DeepSeek DeepGEMM (https://github.com/deepseek-ai/DeepGEMM) +Commit: 559d79fb6994a58b8a15b4b93bf13ccc16edf247 + +MIT License + +Copyright (c) 2025 DeepSeek + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/typescript/extension/README.md b/sdk/typescript/extension/README.md new file mode 100644 index 0000000000000000000000000000000000000000..e1a14e363aa5812d208b4786297feeaca3afc40e --- /dev/null +++ b/sdk/typescript/extension/README.md @@ -0,0 +1,106 @@ +# Vons Chrome Extension + +A Manifest V3 side panel for local candidate comparison. It supports full-graph +Direct and Diffusion Vons ONNX bundles, verifies exact manifest/asset hashes, +and keeps execution with the user. No model weight is included in this package. + +## Build and install locally + +Requires Node 22+ and Chrome 114+: + +```sh +cd sdk/typescript +npm ci +npm test +npm run build:extension +``` + +Open `chrome://extensions`, enable Developer mode for your development profile, +choose **Load unpacked**, and select `sdk/typescript/dist/chrome-extension` from +the repository root. Pin **Vons — Local Decisions** in the toolbar and click it +to open the side panel. A store listing and automatic updates are not provided +by this local build. The generated folder includes all runtime JS/WASM, custom +software terms and third-party notices; it excludes model weights and local data. + +For distribution, ZIP the *contents* of that generated directory so `manifest.json` +is at the archive root. Review the resulting package before Chrome Web Store +submission. Do not ZIP the workspace or your imported model folder. + +## Chrome Web Store status + +**Vons — Local Decisions**, version **0.1.0**, item ID +`cbmjkokoojinfgafahncmjlfmicinide`, was submitted to the Chrome Web Store on +**2026-09-25** after the owner approved the data-use declarations and final +submission. It subsequently passed review and the public listing was verified +on **2026-09-25**: +[install Vons — Local Decisions](https://chromewebstore.google.com/detail/vons-%E2%80%94-local-decisions/cbmjkokoojinfgafahncmjlfmicinide). +The package, English listing, icon, two screenshots, privacy disclosures and +reviewer instructions are included. The local unpacked installation remains +available above. + +The store package contains runtime code and notices only. A compatible model +must be supplied by the user; the public source repository does not distribute +pretrained weights. Noncommercial use is free under the included software terms; +enterprise/commercial use requires a separate license. + +## First comparison + +1. Click **Import model folder** and choose the directory containing exactly one + `bundle-manifest-v1.json`, its full ONNX graph, external-data files and tokenizer. + Use a manifest produced by the Vons bundle tools. Head-only/shared-v1 partition + manifests use a different runtime contract and are not supported here. +2. Optionally keep the model on this device. Nothing is uploaded. The original + manifest and only the required runtime assets are retained, not checkpoint or + report files that happen to share the folder. SHA-256 verifies consistency + with the imported manifest, not the identity or trustworthiness of its author. +3. Enter context, a question and 2–32 unique candidates, one per line. **Use example** + supplies an illustrative prompt; its outcome is not a quality test. +4. Click **Compare candidates**. Read the proposed choice or explicit abstention, + uncalibrated model scores and single-run timings. No page action is executed. + +WASM uses one thread and works without a WebGPU device. WebGPU is an explicit +experimental choice; failure is shown rather than silently falling back. +**Cancel** terminates the inference worker, and a subsequent comparison creates +a fresh runtime. A two-minute timeout also stops the worker. The model's actual +tokenizer enforces its aggregate input budget; long input is rejected rather than +silently truncated. Models larger than 128 MiB of selected runtime assets are +rejected before initialization. The paper's 64 MiB design target refers to model +assets, not the total extension plus runtime download. + +## Privacy and host boundary + +Only `sidePanel` is requested. There are no host permissions, content scripts, +page extraction, tool execution, network model fetches, analytics or account +requirements. Prompts/results are in memory only. IndexedDB stores a model only +when requested; **Remove model** deletes that retained copy. No Chrome Sync is +used. The bundled [privacy notice](privacy.html) describes actual handling. +The CSP restricts code and fetches to packaged extension resources and permits +WebAssembly compilation without permitting general JavaScript eval. + +## Verification scope + +Source tests cover exact file integrity, missing assets, path escapes, candidate +validation and unexpected extension permissions. On 2026-09-25, all 16 SDK tests, +strict extension type checking and the extension build passed. Real Chrome +testing of the generated interface over localhost verified Direct/WASM +inference, explicit token-budget rejection, cancellation followed by reuse, +optional model persistence and removal. The illustrative decision abstained; +this was a functionality check, not a model-quality benchmark. + +The owner installed the unpacked extension; a subsequent independent check of +that actual side panel completed both Direct and Diffusion WASM inference using +the private pilot bundles. Both examples abstained. Direct took 326 ms for +inference and 212 ms for load/check; Diffusion took 3,238 ms and 159 ms. These are +single-run observations, not a latency benchmark or accuracy evidence. The +Diffusion ranking placed an unsuitable option first, reinforcing the need to +preserve abstention and human review. The imported models remain unpublished. + +The installed-panel check exercises the packaged worker/WASM path under its +extension CSP. WebGPU, broader provider parity, external-task quality and +production readiness are not established by these checks. Store review +establishes listing-policy approval only, not scientific validity or safety. +Preserve the model manifest hash with each result. + +Official references: [Side Panel API](https://developer.chrome.com/docs/extensions/reference/api/sidePanel), +[MV3 CSP](https://developer.chrome.com/docs/extensions/reference/manifest/content-security-policy), +[local development installation](https://developer.chrome.com/docs/extensions/get-started/tutorial/hello-world#load-unpacked). diff --git a/sdk/typescript/extension/background.mjs b/sdk/typescript/extension/background.mjs new file mode 100644 index 0000000000000000000000000000000000000000..7ff5b93fea91e8481f49f184e92678ce9cdf2f5d --- /dev/null +++ b/sdk/typescript/extension/background.mjs @@ -0,0 +1,4 @@ +// The side panel owns inference; this worker never reads or modifies a page. +const configurePanel = () => chrome.sidePanel.setPanelBehavior({ openPanelOnActionClick: true }); +chrome.runtime.onInstalled.addListener(configurePanel); +chrome.runtime.onStartup.addListener(configurePanel); diff --git a/sdk/typescript/extension/build.mjs b/sdk/typescript/extension/build.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c61c7978496e55ecf4bea20870090932c4078593 --- /dev/null +++ b/sdk/typescript/extension/build.mjs @@ -0,0 +1,51 @@ +import { build } from "esbuild"; +import { readFile, writeFile, mkdir, copyFile, readdir, rm } from "node:fs/promises"; +import { fileURLToPath } from "node:url"; +import path from "node:path"; + +const root = fileURLToPath(new URL("../", import.meta.url)); +const source = path.join(root, "extension"); +const output = path.join(root, "dist/chrome-extension"); +await rm(output, { recursive: true, force: true }); +await mkdir(path.join(output, "runtime"), { recursive: true }); +const result = await build({ + absWorkingDir: root, entryPoints: ["extension/panel.ts", "extension/worker.ts"], + bundle: true, splitting: true, format: "esm", platform: "browser", target: "chrome114", + conditions: ["onnxruntime-web-use-extern-wasm"], outdir: output, + metafile: true, legalComments: "eof", minify: true, +}); +for (const name of ["manifest.json", "background.mjs", "panel.html", "panel.css", "privacy.html"]) { + await copyFile(path.join(source, name), path.join(output, name)); +} +await copyFile(path.join(root, "../../docs/assets/inlevel9-signature.png"), path.join(output, "brand.png")); +for (const size of [16, 32, 48, 128]) { + await copyFile(path.join(root, `../../docs/assets/vons-extension-icon-${size}.png`), path.join(output, `icon-${size}.png`)); +} +await copyFile(path.join(root, "LICENSE"), path.join(output, "LICENSE")); +for (const name of ["ort-wasm-simd-threaded.mjs", "ort-wasm-simd-threaded.wasm", + "ort-wasm-simd-threaded.jsep.mjs", "ort-wasm-simd-threaded.jsep.wasm"]) { + await copyFile(path.join(root, "node_modules/onnxruntime-web/dist", name), path.join(output, "runtime", name)); +} +const packages = new Set(["onnxruntime-web"]); +for (const input of Object.keys(result.metafile.inputs)) { + const parts = input.split("node_modules/").at(-1).split("/"); + if (input.includes("node_modules/")) packages.add(parts[0].startsWith("@") ? `${parts[0]}/${parts[1]}` : parts[0]); +} +const notices = ["# Bundled third-party notices", "", "Vons source uses the accompanying LICENSE. Model weights are not included.", ""]; +for (const name of [...packages].sort()) { + const packageRoot = path.join(root, "node_modules", name); + const metadata = JSON.parse(await readFile(path.join(packageRoot, "package.json"), "utf8")); + const files = (await readdir(packageRoot)).filter((file) => /^(?:licen[sc]e|copying|notice|thirdpartynotices)(?:\.|$)/i.test(file)); + if (!files.length && name.startsWith("onnxruntime-")) { + if (metadata.version !== "1.30.0") throw new Error("Refresh the pinned ONNX Runtime notices before upgrading."); + notices.push(`## ${name} ${metadata.version}`, await readFile(path.join(source, "ONNX_RUNTIME_NOTICES.md"), "utf8")); + continue; + } + if (!files.length) throw new Error(`Missing third-party license notice: ${name}`); + notices.push(`## ${name} ${metadata.version}`, `Declared license: ${metadata.license}`, ""); + for (const file of files) notices.push(`### ${file}`, "", await readFile(path.join(packageRoot, file), "utf8"), ""); +} +await writeFile(path.join(output, "THIRD_PARTY_NOTICES.txt"), notices.join("\n")); +const manifest = JSON.parse(await readFile(path.join(output, "manifest.json"), "utf8")); +if (JSON.stringify(manifest.permissions) !== '["sidePanel"]' || manifest.host_permissions || manifest.content_scripts) throw new Error("Unexpected extension access."); +console.log(`Built ${output}; model weights excluded; ${packages.size} dependency notices included.`); diff --git a/sdk/typescript/extension/bundle.ts b/sdk/typescript/extension/bundle.ts new file mode 100644 index 0000000000000000000000000000000000000000..e50aaea48a3af061a9653858237e9b4878b20e20 --- /dev/null +++ b/sdk/typescript/extension/bundle.ts @@ -0,0 +1,100 @@ +import { validateRequest, type DecisionRequest } from "../src/index.ts"; +import type { BundleManifest } from "../src/onnx.ts"; + +export interface LocalAsset { path: string; bytes: ArrayBuffer; } +export interface LocalBundle { + manifestPath: string; + manifestBytes: ArrayBuffer; + manifestHash: string; + backend: "direct" | "diffusion"; + modelId: string; + assets: LocalAsset[]; +} +export const MAX_BUNDLE_BYTES = 128 * 1024 * 1024; +export function safePath(path: string): boolean { + return path.length > 0 && !path.startsWith("/") && !path.includes("..") + && !/[\\%?#:\u0000-\u001f]/.test(path) + && path.split("/").every((part) => part.length > 0); +} +export async function digest(bytes: ArrayBuffer): Promise { + const hash = await crypto.subtle.digest("SHA-256", bytes); + return Array.from(new Uint8Array(hash), (b) => b.toString(16).padStart(2, "0")).join(""); +} +export function requiredFiles(bytes: ArrayBuffer): { manifest: BundleManifest; paths: string[] } { + if (bytes.byteLength > 2 * 1024 * 1024) throw new Error("Manifest exceeds 2 MiB."); + const manifest = JSON.parse(new TextDecoder().decode(bytes)) as BundleManifest; + if (manifest.schema_version !== "vons.bundle.manifest/v1" || !manifest.metadata + || !["direct", "diffusion"].includes(manifest.metadata.backend) + || !Array.isArray(manifest.files) || manifest.files.length > 2048) { + throw new Error("Choose a Vons v1 manifest for a full Direct or Diffusion ONNX graph."); + } + const paths = new Set(); + for (const file of manifest.files) { + if (!file || typeof file.path !== "string" || !safePath(file.path) || paths.has(file.path) + || !Number.isSafeInteger(file.bytes) || file.bytes < 0 || file.bytes > MAX_BUNDLE_BYTES + || !/^[0-9a-f]{64}$/.test(file.sha256)) throw new Error("Invalid manifest file record."); + paths.add(file.path); + } + const graphs = manifest.files.filter((f) => f.role === "model_graph"); + const tokenizers = ["tokenizer.json", "tokenizer_config.json"].map((name) => + manifest.files.filter((f) => f.role === "tokenizer" && (f.path === name || f.path.endsWith(`/${name}`)))); + if (graphs.length !== 1 || tokenizers.some((files) => files.length !== 1)) { + throw new Error("The manifest must name one full graph and both tokenizer JSON files."); + } + const external = manifest.metadata.graph?.external_data_locations ?? []; + if (!Array.isArray(external) || external.some((path) => typeof path !== "string" || !safePath(path) + || !manifest.files.some((f) => f.path === path && f.role === "model_external_data"))) { + throw new Error("The graph has an invalid external-data reference."); + } + return { manifest, paths: [...new Set([graphs[0].path, ...tokenizers.map((f) => f[0].path), ...external])] }; +} +export async function verifyBundle(bundle: LocalBundle): Promise { + if (!safePath(bundle.manifestPath) || await digest(bundle.manifestBytes) !== bundle.manifestHash) { + throw new Error("The saved manifest failed its integrity check. Import the model again."); + } + const { manifest, paths } = requiredFiles(bundle.manifestBytes); + if (manifest.metadata.backend !== bundle.backend || bundle.assets.length !== paths.length) { + throw new Error("Model bundle contents do not match the manifest."); + } + let total = bundle.manifestBytes.byteLength; + for (const path of paths) { + const matches = bundle.assets.filter((a) => a.path === path); + const record = manifest.files.find((f) => f.path === path)!; + if (matches.length !== 1 || matches[0].bytes.byteLength !== record.bytes) throw new Error(`Missing or wrong-sized model file: ${path}`); + total += record.bytes; + if (total > MAX_BUNDLE_BYTES) throw new Error("The selected runtime assets exceed 128 MiB."); + if (await digest(matches[0].bytes) !== record.sha256) throw new Error(`Model file failed SHA-256 verification: ${path}`); + } +} +export async function importBundle(files: File[]): Promise { + if (files.length === 0 || files.length > 2048) throw new Error("Choose one model folder with at most 2048 files."); + const manifests = files.filter((f) => f.name === "bundle-manifest-v1.json"); + if (manifests.length !== 1) throw new Error("Choose the folder containing exactly one bundle-manifest-v1.json."); + const file = manifests[0]; + if (file.size > 2 * 1024 * 1024) throw new Error("Manifest exceeds 2 MiB."); + const root = file.webkitRelativePath.slice(0, -file.name.length); + const manifestBytes = await file.arrayBuffer(); + const { manifest, paths } = requiredFiles(manifestBytes); + const assets: LocalAsset[] = []; + let total = manifestBytes.byteLength; + for (const path of paths) { + const selected = files.filter((f) => f.webkitRelativePath === root + path); + const expected = manifest.files.find((f) => f.path === path)!; + if (selected.length !== 1 || selected[0].size !== expected.bytes) throw new Error(`Missing or wrong-sized model file: ${path}`); + total += selected[0].size; + if (total > MAX_BUNDLE_BYTES) throw new Error("The selected runtime assets exceed 128 MiB."); + assets.push({ path, bytes: await selected[0].arrayBuffer() }); + } + const bundle: LocalBundle = { manifestPath: file.name, manifestBytes, + manifestHash: await digest(manifestBytes), backend: manifest.metadata.backend, + modelId: manifest.metadata.model_id ?? `Vons ${manifest.metadata.backend}`, assets }; + await verifyBundle(bundle); + return bundle; +} +export function makeRequest(state: string, prompt: string, candidates: string): DecisionRequest { + const request: DecisionRequest = { state: state.trim(), seed: 7, + questions: [{ id: "decision", type: "choice", prompt: prompt.trim(), + options: candidates.split(/\r?\n/).map((s) => s.trim()).filter(Boolean) }] }; + validateRequest(request); + return request; +} diff --git a/sdk/typescript/extension/manifest.json b/sdk/typescript/extension/manifest.json new file mode 100644 index 0000000000000000000000000000000000000000..fc93c24f464df85c2d516c6e167f3876906893e0 --- /dev/null +++ b/sdk/typescript/extension/manifest.json @@ -0,0 +1,20 @@ +{ + "manifest_version": 3, + "name": "Vons — Local Decisions", + "version": "0.1.0", + "description": "Compare your candidate choices locally. Import a Vons model bundle; the host stays in control.", + "minimum_chrome_version": "114", + "permissions": ["sidePanel"], + "icons": { + "16": "icon-16.png", + "32": "icon-32.png", + "48": "icon-48.png", + "128": "icon-128.png" + }, + "action": {"default_title": "Open Vons"}, + "background": {"service_worker": "background.mjs", "type": "module"}, + "side_panel": {"default_path": "panel.html"}, + "content_security_policy": { + "extension_pages": "default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; object-src 'none'; connect-src 'self'; worker-src 'self'; style-src 'self'; img-src 'self'; frame-src 'none'; base-uri 'none'; form-action 'none'" + } +} diff --git a/sdk/typescript/extension/panel.css b/sdk/typescript/extension/panel.css new file mode 100644 index 0000000000000000000000000000000000000000..42a06fc74da760cd614c3cb382329aa9fcee8593 --- /dev/null +++ b/sdk/typescript/extension/panel.css @@ -0,0 +1,61 @@ +:root { color-scheme: light dark; --bg:#f5f6f1; --surface:#fff; --ink:#20251e; --muted:#697063; --line:#d7ded0; --accent:#c5ff7a; --error:#a63725; font:14px/1.55 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; } +* { box-sizing:border-box; } +body { margin:0; background:var(--bg); color:var(--ink); min-width:280px; } +header { padding:23px 22px 19px; border-bottom:1px solid var(--line); display:flex; gap:12px; align-items:center; justify-content:space-between; } +header img { object-fit:contain; } +.version { font-size:9px; font-weight:650; letter-spacing:.08em; text-align:right; } +main { max-width:560px; margin:auto; padding:0 22px; } +.intro { padding:30px 0 24px; } +.eyebrow { font-size:10px; font-weight:700; letter-spacing:.12em; } +h1 { font-size:clamp(26px,7.8vw,38px); line-height:1.1; font-weight:620; letter-spacing:-.04em; margin:14px 0; } +p { margin:10px 0; } +.intro>p:last-child, .model>p { color:var(--muted); font-size:13px; } +.model { background:var(--surface); padding:18px; border:1px solid var(--line); border-radius:12px; } +.section-title { display:flex; align-items:center; gap:10px; justify-content:space-between; margin-bottom:13px; } +h2 { margin:0; font-size:11px; font-weight:450; white-space:nowrap; color:var(--muted); } +h2 span { color:var(--ink); font-size:13px; font-weight:650; margin-left:9px; } +.badge { background:var(--bg); border:1px solid var(--line); border-radius:4px; font-size:10px; padding:3px 7px; white-space:nowrap; } +button,input,textarea,select { font:inherit; } +button,a,.file-button,summary { -webkit-tap-highlight-color:transparent; } +button,.file-button { cursor:pointer; } +a { color:inherit; text-underline-offset:3px; } +button:disabled { opacity:.45; cursor:not-allowed; } +button { border:1px solid var(--line); border-radius:6px; padding:10px 13px; background:var(--surface); color:var(--ink); } +.file-button { display:flex; justify-content:space-between; background:var(--ink); color:var(--surface); padding:11px 13px; border-radius:6px; font-weight:600; margin:16px 0 12px; } +.remember { display:flex; gap:8px; align-items:center; font-size:11px; color:var(--muted); } +.remember input { accent-color:#537c29; margin:0; } +.model-actions { display:flex; gap:14px; align-items:center; justify-content:space-between; margin-top:10px; font-size:11px; } +.text-button { border:0; padding:3px 0; background:none; text-decoration:underline; text-underline-offset:3px; font-size:11px; } +form { padding:27px 0 20px; } +form>label { display:block; margin:17px 0 6px; font-size:12px; font-weight:650; } +.hint { color:var(--muted); font-size:11px; font-weight:400; } +label .hint { float:right; } +textarea,form>input,select { width:100%; border:1px solid var(--line); border-radius:6px; background:var(--surface); color:var(--ink); padding:11px 12px; } +textarea { resize:vertical; min-height:70px; } +textarea::placeholder,input::placeholder { color:#818879; } +:focus-visible { outline:2px solid #679827; outline-offset:3px; } +details { border-top:1px solid var(--line); margin-top:17px; padding:12px 0 0; font-size:12px; } +summary { cursor:pointer; color:var(--muted); } +details label { display:block; margin:10px 0 5px; } +.run-actions { display:flex; gap:10px; margin-top:19px; } +#run { flex:1; background:var(--accent); color:#1e2915; font-weight:650; border-color:transparent; display:flex; justify-content:space-between; } +#status { font-size:12px; color:var(--muted); overflow-wrap:anywhere; } +#status[data-error="true"] { color:var(--error); } +.result { border-top:2px solid var(--ink); padding:23px 0; } +.result h3 { font-size:24px; line-height:1.25; margin:9px 0; overflow-wrap:anywhere; } +#reason { color:var(--muted); font-size:12px; } +ol { list-style:none; padding:0; margin:18px 0; } +li { margin:12px 0; } +.rank-label { display:flex; justify-content:space-between; gap:15px; font-size:12px; overflow-wrap:anywhere; } +progress { width:100%; height:5px; border:0; display:block; margin-top:7px; accent-color:#709b42; } +progress::-webkit-progress-bar { background:var(--line); border-radius:4px; } +progress::-webkit-progress-value { background:#709b42; border-radius:4px; } +.boundary { font-size:11px; background:var(--surface); border-left:3px solid #a5b592; padding:9px 12px; } +pre { font:10px/1.6 ui-monospace,monospace; overflow:auto; max-height:240px; white-space:pre-wrap; overflow-wrap:anywhere; } +footer { border-top:1px solid var(--line); padding:16px 0 25px; color:var(--muted); font-size:10px; } +footer p:first-child { color:var(--ink); font-weight:650; } +nav { display:flex; gap:18px; margin-top:15px; } +[hidden] { display:none!important; } +.visually-hidden { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); } +.file-button:has(+input:focus-visible) { outline:2px solid #679827; outline-offset:3px; } +@media(prefers-color-scheme:dark) { :root { --bg:#1d221c; --surface:#252c23; --ink:#edf4e8; --muted:#a5b09e; --line:#434e3d; --error:#ffb09c; } header img { background:#f5f6f1; border-radius:2px; } } diff --git a/sdk/typescript/extension/panel.html b/sdk/typescript/extension/panel.html new file mode 100644 index 0000000000000000000000000000000000000000..2a7846aa56097ac81a7f62ba10e2d84851170f9c --- /dev/null +++ b/sdk/typescript/extension/panel.html @@ -0,0 +1,44 @@ + + + + + + Vons — Local Decisions + + + +
+ INLEVEL9 + RESEARCH PREVIEW +
+
+

YOUR OPTIONS. YOUR CONTROL.

A little help
with the next choice.

Compare a few candidates with a model on your device. You decide what happens next.

+
+

01 Choose a model

Not loaded
+

Import a Vons ONNX bundle folder. Model weights are supplied separately.

+ + + +
Bundle guide ↗
+
+
+

02 Frame your decision

+ + + +
Runtime settings

WebGPU requires a compatible adapter. Failed requests stay visible; no silent fallback.

+
+

Start by importing a model. Prompts stay in this panel.

+
+ +

Local processing. No telemetry. No page access.

Text and decisions are not saved. Closing the panel ends the session. Only a model you choose to keep is stored locally.

+
+ + + diff --git a/sdk/typescript/extension/panel.ts b/sdk/typescript/extension/panel.ts new file mode 100644 index 0000000000000000000000000000000000000000..9f6a8df45ef4d5d79cdd07333be38f1eca03c93e --- /dev/null +++ b/sdk/typescript/extension/panel.ts @@ -0,0 +1,146 @@ +import { importBundle, verifyBundle, makeRequest, type LocalBundle } from "./bundle.ts"; +import { modelStorage } from "./storage.ts"; +import { validateResponse, type DecisionResponse } from "../src/index.ts"; + +function element(id: string): T { + const node = document.getElementById(id); + if (!node) throw new Error(`Missing panel element: ${id}`); + return node as T; +} +const files = element("bundle-files"); +const remember = element("remember"); +const run = element("run"); +const cancel = element("cancel"); +const forget = element("forget"); +const provider = element("provider"); +const form = element("decision-form"); +let bundle: LocalBundle | undefined; +let worker: Worker | undefined; +let workerKey = ""; +let busy = false; +let importing = false; +let lastResult = ""; +let timeout: ReturnType | undefined; + +function status(text: string, error = false): void { + const node = element("status"); node.textContent = text; node.dataset.error = String(error); +} +function controls(): void { + run.disabled = busy || importing || !bundle; + forget.disabled = busy || importing || !bundle; + files.disabled = busy || importing; + remember.disabled = busy || importing; + provider.disabled = busy || importing; + for (const id of ["state", "question", "options", "example"]) element(id).disabled = busy; + cancel.hidden = !busy; + form.setAttribute("aria-busy", String(busy)); +} +function stop(): void { + worker?.terminate(); worker = undefined; workerKey = ""; + clearTimeout(timeout); busy = false; controls(); +} +function modelLabel(): void { + element("model-badge").textContent = bundle ? bundle.backend : "Not loaded"; + element("model-description").textContent = bundle + ? `${bundle.modelId} · ${(bundle.assets.reduce((sum, a) => sum + a.bytes.byteLength, 0) / 1048576).toFixed(1)} MiB · SHA-256 checked` + : "Import a Vons ONNX bundle folder. Model weights are supplied separately."; + controls(); +} +function errorMessage(error: unknown): string { return error instanceof Error ? error.message : "The operation failed."; } +function showResult(data: { response: DecisionResponse; manifestHash: string; runtime: unknown; loadMs: number; inferenceMs: number }): void { + validateResponse(data.response); + const answer = data.response.answers[0]; + if (!answer) throw new Error("The model returned no answer."); + element("decision-label").textContent = answer.status === "abstain" ? "NO RECOMMENDATION" : "MODEL PROPOSAL"; + element("choice").textContent = answer.choice ?? "The model abstained."; + element("reason").textContent = answer.abstain_reason?.replaceAll("_", " ") ?? "Review this choice yourself before taking any action."; + const ranking = element("ranking"); ranking.replaceChildren(); + for (const entry of [...answer.probabilities].sort((a, b) => b.probability - a.probability)) { + const item = document.createElement("li"); const row = document.createElement("div"); row.className = "rank-label"; + const label = document.createElement("span"); label.textContent = entry.option; + const value = document.createElement("span"); value.textContent = `${(entry.probability * 100).toFixed(1)}%`; + const bar = document.createElement("progress"); bar.max = 1; bar.value = entry.probability; bar.setAttribute("aria-label", `${entry.option} model score`); + row.append(label, value); item.append(row, bar); ranking.append(item); + } + element("timing").textContent = `Local run: ${data.inferenceMs.toFixed(0)} ms · load/check: ${data.loadMs.toFixed(0)} ms. This is one run, not a benchmark.`; + lastResult = JSON.stringify(data, null, 2); element("raw").textContent = lastResult; + element("result").hidden = false; +} +files.addEventListener("change", async () => { + if (!files.files?.length) return; + importing = true; stop(); controls(); element("result").hidden = true; + status("Reading and verifying the selected model files…"); + try { + const next = await importBundle(Array.from(files.files)); + // Do not make a new model active until its requested storage operation succeeds. + if (remember.checked) await modelStorage("write", next); + else await modelStorage("clear"); + bundle = next; status("Model ready. Add context and candidates, then compare."); + } catch (error) { status(errorMessage(error), true); } + finally { importing = false; files.value = ""; modelLabel(); } +}); +remember.addEventListener("change", async () => { + importing = true; controls(); + try { + if (remember.checked && bundle) await modelStorage("write", bundle); + else await modelStorage("clear"); + status(remember.checked ? "This model will be available next time. Text is never saved." : "Stored model removed. The current model remains in this session only."); + } catch (error) { remember.checked = !remember.checked; status(errorMessage(error), true); } + finally { importing = false; controls(); } +}); +forget.addEventListener("click", async () => { + importing = true; stop(); controls(); + try { + await modelStorage("clear"); bundle = undefined; remember.checked = false; + element("result").hidden = true; lastResult = ""; element("raw").textContent = ""; + status("Model removed from this device."); + } catch (error) { status(errorMessage(error), true); } + finally { importing = false; modelLabel(); } +}); +element("example").addEventListener("click", () => { + element("state").value = "A document has unsaved edits. The author wants to keep the changes before closing it."; + element("question").value = "What should happen next?"; + element("options").value = "Save the document\nDiscard the changes\nAsk the author for more context"; + element("result").hidden = true; + status("Example loaded. This is an illustrative input, not a quality test."); +}); +form.addEventListener("submit", (event) => { + event.preventDefault(); if (busy || importing || !bundle) return; + try { + const request = makeRequest(element("state").value, element("question").value, element("options").value); + const selected = provider.value === "webgpu" ? "webgpu" : "wasm"; + const key = `${bundle.manifestHash}:${selected}`; + if (workerKey !== key) stop(); + if (!worker) { + worker = new Worker(new URL("worker.js", import.meta.url), { type: "module" }); + worker.onmessage = (message) => { + const data = message.data; + if (data.type === "progress") { status(data.text); return; } + clearTimeout(timeout); busy = false; controls(); + if (data.type === "error") { stop(); status(data.text, true); return; } + try { showResult(data); status("Comparison complete. No page action was taken."); } + catch (error) { stop(); status(errorMessage(error), true); } + }; + worker.onerror = () => { stop(); status("The local runtime stopped unexpectedly. You can try again with WASM.", true); }; + } + busy = true; controls(); element("result").hidden = true; + status("Starting the local comparison…"); + worker.postMessage({ request, provider: selected, ...(workerKey === key ? {} : { bundle }) }); workerKey = key; + timeout = setTimeout(() => { stop(); status("The comparison exceeded two minutes and was stopped. Try fewer or shorter candidates.", true); }, 120000); + } catch (error) { stop(); status(errorMessage(error), true); } +}); +cancel.addEventListener("click", () => { stop(); status("Canceled. No decision was returned. The model can be used again."); }); +element("copy").addEventListener("click", async () => { + try { await navigator.clipboard.writeText(lastResult); status("Response JSON copied. It contains your candidate text."); } + catch { status("Clipboard access was unavailable. Select the JSON text to copy it manually.", true); } +}); +window.addEventListener("pagehide", stop); +async function restore(): Promise { + importing = true; controls(); + try { + const saved = await modelStorage("read"); + if (saved) { await verifyBundle(saved); bundle = saved; remember.checked = true; status("Your saved model is ready. Context and decisions were not retained."); } + } catch (error) { status(`${errorMessage(error)} You can import a model folder again.`, true); } + finally { importing = false; modelLabel(); } +} +void restore(); diff --git a/sdk/typescript/extension/privacy.html b/sdk/typescript/extension/privacy.html new file mode 100644 index 0000000000000000000000000000000000000000..78b82aaefb44dd0022e1dc29763091eb6f80210c --- /dev/null +++ b/sdk/typescript/extension/privacy.html @@ -0,0 +1,10 @@ + +Vons — Privacy and terms
+

VONS · RESEARCH PREVIEW 0.1.0

Local by design.

The extension compares candidate choices using a model you import. It cannot read or modify web pages and never executes a proposed action.

+

What is processed

Only the context, question, candidates and model files you explicitly provide. Inference runs on this device using packaged ONNX Runtime Web code. There are no server uploads, analytics, telemetry, account requirements or remote model downloads.

+

What is retained

Context and results stay in the open panel's memory. Closing the panel ends that session. If you choose “Keep this model on this device,” model assets and their manifest are stored in local IndexedDB, not Chrome Sync. Remove model clears that stored model. Turning off the option also clears the stored copy.

+

Permissions

The sole extension permission is sidePanel, used to display Vons beside the current tab. No page, cookie, history, clipboard-read, background network or browsing-content access is requested. Copy JSON writes only the displayed result to your clipboard after you click it. Model file access comes from the folder picker you open.

+

External links

Research and bundle-guide links open Hugging Face only when clicked. That destination has its own privacy policy. Context, candidates and model contents are not included in those links.

+

Limits and terms

This is research software. Model scores are not calibrated probabilities of correctness. A proposal does not establish quality, consent or permission to act. The current publication reports negative external evaluation results and unresolved deployment gates. Model weights are not included; review their origin and redistribution terms separately.

Vons uses the Vons Community and Commercial License 1.0: qualifying noncommercial use is free; enterprise and commercial use require a separate written agreement. Third-party code retains its own terms in bundled notices. Articles use CC BY 4.0 separately.

+ +
diff --git a/sdk/typescript/extension/storage.ts b/sdk/typescript/extension/storage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b13e2b55db857ac3af33e25fcdc0ec405ac2e3b4 --- /dev/null +++ b/sdk/typescript/extension/storage.ts @@ -0,0 +1,23 @@ +import type { LocalBundle } from "./bundle.ts"; +const DATABASE = "vons-local-model"; +async function open(): Promise { + return new Promise((resolve, reject) => { + const request = indexedDB.open(DATABASE, 1); + request.onupgradeneeded = () => request.result.createObjectStore("model"); + request.onsuccess = () => resolve(request.result); + request.onerror = () => reject(new Error("Local model storage is unavailable.")); + request.onblocked = () => reject(new Error("Close other Vons panels before updating storage.")); + }); +} +export async function modelStorage(action: "read" | "write" | "clear", model?: LocalBundle): Promise { + const db = await open(); + try { + return await new Promise((resolve, reject) => { + const transaction = db.transaction("model", action === "read" ? "readonly" : "readwrite"); + const store = transaction.objectStore("model"); + const request = action === "read" ? store.get("active") : action === "write" ? store.put(model, "active") : store.clear(); + transaction.oncomplete = () => resolve(action === "read" ? request.result as LocalBundle | undefined : undefined); + transaction.onabort = transaction.onerror = () => reject(new Error("Could not update local model storage. Check available space.")); + }); + } finally { db.close(); } +} diff --git a/sdk/typescript/extension/tsconfig.json b/sdk/typescript/extension/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..4d86df65550053d6dbf06a736a20c9537af2d09e --- /dev/null +++ b/sdk/typescript/extension/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "Bundler", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "strict": true, + "noEmit": true, + "allowImportingTsExtensions": true, + "skipLibCheck": true + }, + "include": ["*.ts", "../src/*.ts"] +} diff --git a/sdk/typescript/extension/worker.ts b/sdk/typescript/extension/worker.ts new file mode 100644 index 0000000000000000000000000000000000000000..722eed080063a4cdf173088f15ecd9bf1a76b5ba --- /dev/null +++ b/sdk/typescript/extension/worker.ts @@ -0,0 +1,42 @@ +import { createOnnxWebBackend, type OnnxWebBackend } from "../src/onnx.ts"; +import type { DecisionRequest } from "../src/index.ts"; +import { verifyBundle, type LocalBundle } from "./bundle.ts"; + +let backend: OnnxWebBackend | undefined; +let loadedKey = ""; +self.onmessage = async (event: MessageEvent<{ bundle?: LocalBundle; provider: "wasm" | "webgpu"; request: DecisionRequest }>) => { + const started = performance.now(); + try { + const { bundle, provider, request } = event.data; + if (bundle) { + const key = `${bundle.manifestHash}:${provider}`; + if (key !== loadedKey) { + await backend?.dispose(); backend = undefined; loadedKey = ""; + self.postMessage({ type: "progress", text: "Checking model files and starting the local runtime…" }); + await verifyBundle(bundle); + // This synthetic origin is only a lookup key. No model request can use network fetch. + const base = "https://vons-bundle.invalid/"; + const bytes = new Map(bundle.assets.map((f) => [new URL(f.path, base).href, f.bytes])); + bytes.set(new URL(bundle.manifestPath, base).href, bundle.manifestBytes); + const localFetch: typeof fetch = async (input) => { + const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url; + const asset = bytes.get(url); + if (!asset) throw new Error("Requested model asset is not in the selected local bundle."); + return new Response(asset); + }; + backend = await createOnnxWebBackend({ manifestUrl: new URL(bundle.manifestPath, base), + expectedManifestSha256: bundle.manifestHash, fetch: localFetch, provider, + wasmPaths: new URL("runtime/", self.location.href).href, wasmNumThreads: 1 }); + loadedKey = key; + } + } + if (!backend || backend.runtimeInfo.provider !== provider) throw new Error("Import or reload the model before running."); + const ready = performance.now(); + self.postMessage({ type: "progress", text: "Comparing your candidates on this device…" }); + const response = await backend.decide(request); + self.postMessage({ type: "result", response, manifestHash: backend.manifestHash, + runtime: backend.runtimeInfo, loadMs: ready - started, inferenceMs: performance.now() - ready }); + } catch (error) { + self.postMessage({ type: "error", text: error instanceof Error ? error.message : "Local inference failed." }); + } +}; diff --git a/sdk/typescript/package-lock.json b/sdk/typescript/package-lock.json index 08f3cd6f355b1be213947f4346406661c55b4542..cbee6556bb6de93e23a6c47a6729f7e35cebcae8 100644 --- a/sdk/typescript/package-lock.json +++ b/sdk/typescript/package-lock.json @@ -7,17 +7,18 @@ "": { "name": "@vons/decision-sdk", "version": "0.1.0", + "license": "SEE LICENSE IN LICENSE", "dependencies": { "@huggingface/tokenizers": "0.2.0", "onnxruntime-web": "1.30.0" }, "devDependencies": { - "esbuild": "0.28.2" + "esbuild": "0.28.2", + "typescript": "5.9.3" }, "engines": { "node": ">=22" - }, - "license": "SEE LICENSE IN LICENSE" + } }, "node_modules/@esbuild/aix-ppc64": { "version": "0.28.2", @@ -642,6 +643,20 @@ "node": ">=12.0.0" } }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/undici-types": { "version": "8.9.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz", diff --git a/sdk/typescript/package.json b/sdk/typescript/package.json index a248485a1e608973a6cb1e1727649e421e602fbd..acbc9156e85937d2fa1d42d8ddc15d867f7eccef 100644 --- a/sdk/typescript/package.json +++ b/sdk/typescript/package.json @@ -12,16 +12,19 @@ "./onnx": "./src/onnx.ts" }, "scripts": { - "test": "node --experimental-strip-types --test test/index.test.mjs test/onnx.test.mjs test/parity.test.mjs", + "test": "node --experimental-strip-types --test test/index.test.mjs test/onnx.test.mjs test/parity.test.mjs test/extension.test.mjs", "build:browser": "esbuild demo/main.ts --bundle --format=esm --platform=browser --target=es2022 --outfile=demo/main.js", "build:benchmark": "esbuild demo/benchmark.ts --bundle --format=esm --platform=browser --target=es2022 --outfile=demo/benchmark.js", - "build:parity": "esbuild demo/parity.ts --bundle --format=esm --platform=browser --target=es2022 --outfile=demo/parity.js" + "build:parity": "esbuild demo/parity.ts --bundle --format=esm --platform=browser --target=es2022 --outfile=demo/parity.js", + "build:extension": "node extension/build.mjs", + "typecheck:extension": "tsc -p extension/tsconfig.json" }, "engines": { "node": ">=22" }, "devDependencies": { - "esbuild": "0.28.2" + "esbuild": "0.28.2", + "typescript": "5.9.3" }, "private": true, "files": [ diff --git a/sdk/typescript/src/onnx.ts b/sdk/typescript/src/onnx.ts index c0e927b3cc9c1f884252f3ca600bf15afaf92cae..f3287dd03d1dcbb27c5c51eb7d740d697839cd51 100644 --- a/sdk/typescript/src/onnx.ts +++ b/sdk/typescript/src/onnx.ts @@ -325,9 +325,20 @@ export function tokenizeCandidates( state: DecisionRequest["state"], question: Question, options: readonly string[], - sequenceLength: number, -): TokenizedCandidate[] { - return options.map((option) => encodeCandidate(tokenizer, candidateText(state, question, option), sequenceLength)); + sequenceBudget: number, +): { candidates: TokenizedCandidate[]; liveSequenceLength: number } { + if (!Number.isInteger(sequenceBudget) || sequenceBudget < 1 || sequenceBudget > 512) { + throw new RangeError("sequenceBudget must be an integer in [1, 512]"); + } + const candidates = options.map((option) => encodeCandidate(tokenizer, candidateText(state, question, option), sequenceBudget)); + let longest = 0; + for (const candidate of candidates) { + const length = candidate.inputIds.length; + if (length > longest) longest = length; + } + if (longest < 1) throw new Error("each tokenized candidate must contain at least one token"); + const liveSequenceLength = Math.min(longest, sequenceBudget); + return { candidates, liveSequenceLength }; } function padCandidates(candidates: readonly TokenizedCandidate[], slots: number, sequenceLength: number, paddingId: number): { @@ -499,6 +510,7 @@ export class OnnxWebBackend implements DecisionBackend { if (this.disposed) throw new Error("ONNX Runtime session has been disposed"); validateRequest(request); const answers: QuestionAnswer[] = []; + const sequenceBudget = this.sequenceLength; for (const [questionIndex, question] of request.questions.entries()) { const requestStarted = performance.now(); if (question.type === "score") { @@ -510,18 +522,18 @@ export class OnnxWebBackend implements DecisionBackend { throw new RangeError(`question ${question.id} has unsupported candidate count`); } const aggregateTokenCount = this.tokenizer.encode(candidateListText(request.state, question, options)).ids.length; - if (aggregateTokenCount > this.sequenceLength) { - throw new RangeError(`question ${question.id} exceeds the ${this.sequenceLength}-token aggregate input budget (tokens=${aggregateTokenCount})`); + if (aggregateTokenCount > sequenceBudget) { + throw new RangeError(`question ${question.id} exceeds the ${sequenceBudget}-token aggregate input budget (tokens=${aggregateTokenCount})`); } const tokenizeStarted = performance.now(); - const encoded = tokenizeCandidates(this.tokenizer, request.state, question, options, this.sequenceLength); + const { candidates: encoded, liveSequenceLength } = tokenizeCandidates(this.tokenizer, request.state, question, options, sequenceBudget); const tokenized = performance.now(); - const padded = padCandidates(encoded, slots, this.sequenceLength, this.paddingId); + const padded = padCandidates(encoded, slots, liveSequenceLength, this.paddingId); let traceNoise: Float32Array | null = null; const feeds: Record = { - input_ids: tensor(this.runtime, "int64", padded.inputIds, [1, slots, this.sequenceLength]), - attention_mask: tensor(this.runtime, "int64", padded.attentionMask, [1, slots, this.sequenceLength]), - token_type_ids: tensor(this.runtime, "int64", padded.tokenTypeIds, [1, slots, this.sequenceLength]), + input_ids: tensor(this.runtime, "int64", padded.inputIds, [1, slots, liveSequenceLength]), + attention_mask: tensor(this.runtime, "int64", padded.attentionMask, [1, slots, liveSequenceLength]), + token_type_ids: tensor(this.runtime, "int64", padded.tokenTypeIds, [1, slots, liveSequenceLength]), option_mask: tensor(this.runtime, "bool", padded.optionMask, [1, slots]), }; if (this.backend === "diffusion") { @@ -570,7 +582,7 @@ export class OnnxWebBackend implements DecisionBackend { live_candidates: encoded.length, allocated_candidates: slots, live_tokens: encoded.reduce((total, candidate) => total + candidate.inputIds.length, 0), - sequence_length: this.sequenceLength, + sequence_length: liveSequenceLength, tokenizeMs: tokenized - tokenizeStarted, prepareFeedMs: inferenceStarted - tokenized, inferenceAndReadbackMs: readbackCompleted - inferenceStarted, diff --git a/sdk/typescript/test/extension.test.mjs b/sdk/typescript/test/extension.test.mjs new file mode 100644 index 0000000000000000000000000000000000000000..f1b887b51f05f1b8ba87d155d1f4077b0904221d --- /dev/null +++ b/sdk/typescript/test/extension.test.mjs @@ -0,0 +1,46 @@ +import test from "node:test"; +import assert from "node:assert/strict"; +import { readFile } from "node:fs/promises"; +import { requiredFiles, safePath, digest, verifyBundle, makeRequest } from "../extension/bundle.ts"; + +async function fixture() { + const asset = new TextEncoder().encode("fixture only").buffer; + const hash = await digest(asset); + const files = [ + { path: "graph.onnx", role: "model_graph" }, + { path: "tokenizer/tokenizer.json", role: "tokenizer" }, + { path: "tokenizer/tokenizer_config.json", role: "tokenizer" }, + ].map((file) => ({ ...file, bytes: asset.byteLength, sha256: hash })); + const manifestBytes = new TextEncoder().encode(JSON.stringify({ schema_version: "vons.bundle.manifest/v1", metadata: { backend: "direct" }, files })).buffer; + return { manifestPath: "bundle-manifest-v1.json", manifestBytes, manifestHash: await digest(manifestBytes), backend: "direct", modelId: "test", assets: files.map((file) => ({ path: file.path, bytes: asset })) }; +} +test("extension verifies exact manifest and asset bytes, including retained bundles", async () => { + const bundle = await fixture(); await verifyBundle(bundle); + await assert.rejects(verifyBundle({ ...bundle, manifestHash: "0".repeat(64) }), /integrity/); + await assert.rejects(verifyBundle({ ...bundle, assets: bundle.assets.slice(1) }), /contents/); + const corrupt = structuredClone(bundle); new Uint8Array(corrupt.assets[0].bytes)[0] = 0; + await assert.rejects(verifyBundle(corrupt), /SHA-256/); +}); +test("extension rejects escaped paths and incomplete model contracts", async () => { + for (const value of ["../model", "https://evil.test/x", "%2e%2e/x", "a\\b", "/abs", "a?token", "a//b", "x\u0000y"]) assert.equal(safePath(value), false); + assert.equal(safePath("tokenizer/tokenizer.json"), true); + const bundle = await fixture(); const manifest = JSON.parse(new TextDecoder().decode(bundle.manifestBytes)); + manifest.metadata.graph = { external_data_locations: ["unknown.onnx.data"] }; + assert.throws(() => requiredFiles(new TextEncoder().encode(JSON.stringify(manifest)).buffer), /external-data/); +}); +test("extension accepts bounded unique candidates and refuses empty or duplicate input", () => { + assert.deepEqual(makeRequest(" ready ", "Choose", "A\r\nB\n").questions[0].options, ["A", "B"]); + assert.throws(() => makeRequest("", "Choose", "A\nB"), /empty/); + assert.throws(() => makeRequest("ready", "Choose", "A\nA"), /unique/); + assert.throws(() => makeRequest("ready", "Choose", "A"), /2..32/); +}); +test("extension has no page access, remote execution permission, or automatic action script", async () => { + const manifest = JSON.parse(await readFile(new URL("../extension/manifest.json", import.meta.url), "utf8")); + assert.equal(manifest.manifest_version, 3); + assert.deepEqual(manifest.permissions, ["sidePanel"]); + assert.equal(manifest.host_permissions, undefined); + assert.equal(manifest.content_scripts, undefined); + assert.equal(manifest.externally_connectable, undefined); + assert.match(manifest.content_security_policy.extension_pages, /connect-src 'self';/); + assert.doesNotMatch(manifest.content_security_policy.extension_pages, /'unsafe-eval'|https:|http:|\*/); +}); diff --git a/sdk/typescript/test/onnx.test.mjs b/sdk/typescript/test/onnx.test.mjs index b6872788eb34447ceb3292fce6d478af46d362b4..b32f787da8b2df099f34441afc306b15902fef68 100644 --- a/sdk/typescript/test/onnx.test.mjs +++ b/sdk/typescript/test/onnx.test.mjs @@ -51,7 +51,8 @@ test("tokenizer ids, masks, and overflow behavior are explicit", async () => { { tokenizer_class: "BertTokenizer", unk_token: "[UNK]", cls_token: "[CLS]", sep_token: "[SEP]", model_max_length: 512 }, ); const question = { id: "q", type: "choice", prompt: "Pick", options: ["A/B?", "中文"] }; - const values = onnx.tokenizeCandidates(tokenizer, "ready", question, question.options, 512); + const { candidates: values, liveSequenceLength } = onnx.tokenizeCandidates(tokenizer, "ready", question, question.options, 512); + assert.equal(liveSequenceLength, Math.max(values[0].inputIds.length, values[1].inputIds.length)); assert.deepEqual(values[0].inputIds, [1, 3, 4, 7, 5, 6, 7, 8, 10, 9, 11, 2]); assert.deepEqual(values[1].inputIds, [1, 3, 4, 7, 5, 6, 7, 12, 13, 2]); assert.equal(values[0].inputIds.length, values[0].attentionMask.length); @@ -59,6 +60,60 @@ test("tokenizer ids, masks, and overflow behavior are explicit", async () => { assert.throws(() => onnx.tokenizeCandidates(tokenizer, "x", question, ["x".repeat(10000)], 4), /bundle limit/); }); +test("tokenizeCandidates returns the longest live tokenized candidate length, bounded at 512", async () => { + const { Tokenizer } = await import("@huggingface/tokenizers"); + const tokenizer = new Tokenizer( + { + version: "1.0", + added_tokens: [], + normalizer: { type: "BertNormalizer", clean_text: true, handle_chinese_chars: true, strip_accents: null, lowercase: true }, + pre_tokenizer: { type: "BertPreTokenizer" }, + post_processor: { type: "BertProcessing", sep: ["[SEP]", 2], cls: ["<[BOS_never_used_51bce0c785ca2f68081bfa7d91973934]>", 1] }, + decoder: { type: "WordPiece", prefix: "##", cleanup: true }, + model: { type: "WordPiece", unk_token: "[UNK]", continuing_subword_prefix: "##", max_input_chars_per_word: 100, + vocab: Object.assign({ "[UNK]": 0, "[CLS]": 1, "[SEP]": 2, "question": 101, "candidate": 102, ":": 103 }, + Object.fromEntries(Array.from({ length: 50 }, (_, i) => [`t${i}`, i + 3]))) }, + }, + { tokenizer_class: "BertTokenizer", unk_token: "[UNK]", cls_token: "[CLS]", sep_token: "[SEP]", model_max_length: 512 }, + ); + const shortQuestion = { id: "q", type: "choice", prompt: "Pick", options: ["t0 t1", "t0 t1 t2 t3"] }; + const short = onnx.tokenizeCandidates(tokenizer, "", shortQuestion, shortQuestion.options, 512); + assert.ok(short.liveSequenceLength >= 1); + assert.equal(short.liveSequenceLength, Math.max(short.candidates[0].inputIds.length, short.candidates[1].inputIds.length)); + assert.ok(short.liveSequenceLength <= 512); + + const capped = onnx.tokenizeCandidates(tokenizer, "", shortQuestion, shortQuestion.options, 64); + assert.equal(capped.liveSequenceLength, short.liveSequenceLength); + + assert.throws(() => onnx.tokenizeCandidates(tokenizer, "", shortQuestion, shortQuestion.options, 0), /sequenceBudget/); + assert.throws(() => onnx.tokenizeCandidates(tokenizer, "", shortQuestion, shortQuestion.options, 513), /sequenceBudget/); +}); + +test("variable sequence length regression: widths 64 and 128 produce identical live-token prefixes", async () => { + const { Tokenizer } = await import("@huggingface/tokenizers"); + const tokenizer = new Tokenizer( + { + version: "1.0", + added_tokens: [], + normalizer: { type: "BertNormalizer", clean_text: true, handle_chinese_chars: true, strip_accents: null, lowercase: true }, + pre_tokenizer: { type: "BertPreTokenizer" }, + post_processor: { type: "BertProcessing", sep: ["[SEP]", 2], cls: ["<[BOS_never_used_51bce0c785ca2f68081bfa7d91973934]>", 1] }, + decoder: { type: "WordPiece", prefix: "##", cleanup: true }, + model: { type: "WordPiece", unk_token: "[UNK]", continuing_subword_prefix: "##", max_input_chars_per_word: 100, + vocab: { "[UNK]": 0, "[CLS]": 1, "[SEP]": 2, ready: 3, question: 4, pick: 5, candidate: 6, ":": 7, a: 8, b: 9, c: 10, d: 11 } }, + }, + { tokenizer_class: "BertTokenizer", unk_token: "[UNK]", cls_token: "[CLS]", sep_token: "[SEP]", model_max_length: 512 }, + ); + const question = { id: "q", type: "choice", prompt: "Pick", options: ["a b", "c d"] }; + const result64 = onnx.tokenizeCandidates(tokenizer, "ready", question, question.options, 64); + const result128 = onnx.tokenizeCandidates(tokenizer, "ready", question, question.options, 128); + assert.equal(result64.liveSequenceLength, result128.liveSequenceLength); + for (let index = 0; index < question.options.length; index += 1) { + assert.deepEqual(result64.candidates[index].inputIds, result128.candidates[index].inputIds); + assert.deepEqual(result64.candidates[index].attentionMask, result128.candidates[index].attentionMask); + } +}); + test("manifest integrity is checked before a runtime session is created", async () => { const manifest = testManifest(); const original = manifest.files.find((item) => item.role === "model_graph"); diff --git a/tests/test_calibration.py b/tests/test_calibration.py index 22e14bbd4a485a53b52423e68fcfe70fd38c8b98..88319e5cd5751c74ddc9fe9caa9b4aeeb7e1a409 100644 --- a/tests/test_calibration.py +++ b/tests/test_calibration.py @@ -9,11 +9,14 @@ from vons.calibration import ( ABSTAIN_ALL_THRESHOLD, CALIBRATION_VERSION, apply_calibration, + apply_vector_calibration, calibrate_report, fit_abstention_threshold, fit_abstention_threshold_details, + fit_brier_abstention_threshold_details, fit_temperature, fit_temperature_details, + fit_vector_scaling_details, ) from vons.data import Example, write_jsonl from vons.evaluation import METRIC_VERSION, Prediction, nll, summarize, write_report @@ -46,21 +49,97 @@ class CalibrationTests(unittest.TestCase): details = fit_temperature_details(examples, predictions) calibrated = apply_calibration(examples, predictions, temperature=details.temperature, abstention_threshold=0.0) - self.assertAlmostEqual(details.temperature, math.log(1.5) / math.log(3.0), places=6) + self.assertGreater(details.temperature, details.lower) + self.assertLess(details.temperature, details.upper) self.assertEqual(details.rows, 4) self.assertFalse(details.at_lower_bound) self.assertFalse(details.at_upper_bound) self.assertEqual(fit_temperature(examples, predictions), details.temperature) self.assertLess(nll(examples, calibrated), nll(examples, predictions)) - def test_temperature_bound_hit_is_flagged(self) -> None: + def test_temperature_regularization_prevents_boundary_locking(self) -> None: examples = [_example(f"s{index}", "a", True) for index in range(4)] predictions = [Prediction(f"s{index}", "a", {"a": 0.9, "b": 0.1}, 0.9, False) for index in range(4)] details = fit_temperature_details(examples, predictions) - self.assertTrue(details.at_lower_bound) - self.assertAlmostEqual(details.temperature, 0.05) + self.assertFalse(details.at_lower_bound) + self.assertFalse(details.at_upper_bound) + self.assertGreater(details.temperature, 0.1) + self.assertLess(details.temperature, 10.0) + + unregularized = fit_temperature_details( + examples, predictions, log_temperature_l2=0.0 + ) + self.assertTrue(unregularized.at_lower_bound) + self.assertAlmostEqual(unregularized.temperature, 0.1) + + def test_vector_scaling_fits_all_classes_inside_bounds(self) -> None: + options = ("a", "b", "c", "d") + examples = [] + predictions = [] + for index, label in enumerate(options * 5): + examples.append( + Example( + str(index), + "calibration", + "state", + "choose", + options, + label, + True, + "calibration", + {}, + {"scenario_id": str(index)}, + ) + ) + probabilities = {option: 0.1 for option in options} + probabilities[label] = 0.7 + predictions.append( + Prediction(str(index), label, probabilities, 0.7, False) + ) + + details = fit_vector_scaling_details(examples, predictions) + calibrated = apply_vector_calibration( + examples, + predictions, + temperatures=details.temperatures, + biases=details.biases, + abstention_threshold=0.0, + ) + + self.assertEqual(set(details.temperatures), set(options)) + self.assertTrue(all(0.1 < value < 10.0 for value in details.temperatures.values())) + self.assertFalse(details.at_lower_bound) + self.assertFalse(details.at_upper_bound) + self.assertLess(details.nll_after, details.nll_before) + self.assertLess(nll(examples, calibrated), nll(examples, predictions)) + + def test_brier_threshold_is_fitted_from_calibrated_losses(self) -> None: + examples = [ + _example("strong", "a", True), + _example("weak", "b", True), + _example("wrong", "b", True), + ] + predictions = [ + Prediction("strong", "a", {"a": 0.95, "b": 0.05}, 0.95, False), + Prediction("weak", "b", {"a": 0.4, "b": 0.6}, 0.6, False), + Prediction("wrong", "a", {"a": 0.9, "b": 0.1}, 0.9, False), + ] + parameters = {"a": 1.0, "b": 1.0} + + details = fit_brier_abstention_threshold_details( + examples, + predictions, + temperatures=parameters, + biases={"a": 0.0, "b": 0.0}, + target_brier=0.25, + ) + + self.assertFalse(details.abstain_all) + self.assertEqual(details.target_brier, 0.25) + self.assertLessEqual(details.covered_brier, details.target_brier) + self.assertGreater(details.threshold, 0.0) def test_temperature_scaling_preserves_true_zero_support(self) -> None: examples = [_example("zero", "a", True)] @@ -212,15 +291,20 @@ class CalibrationTests(unittest.TestCase): "test_report": test_report, } - calibrate_report(**arguments, output=output, target_risk=0.0) + calibrate_report(**arguments, output=output, target_brier=0.2) payload = json.loads(output.read_text(encoding="utf-8"), parse_constant=_reject_constant) fit = payload["calibration"] self.assertEqual(fit["version"], CALIBRATION_VERSION) self.assertEqual(fit["answerability_threshold"], 0.8) self.assertEqual((fit["temperature_fit_rows"], fit["threshold_fit_rows"], fit["rows"]), (2, 3, 3)) - self.assertTrue(fit["temperature_at_lower_bound"]) + self.assertEqual(fit["calibration_method"], "vector_scaling") + self.assertEqual(set(fit["temperatures"]), {"a", "b"}) + self.assertEqual(set(fit["biases"]), {"a", "b"}) + self.assertFalse(fit["temperature_at_lower_bound"]) + self.assertEqual(fit["target_brier"], 0.2) self.assertLessEqual(fit["nll_after"], fit["nll_before"]) + self.assertLessEqual(fit["brier_after"], fit["brier_before"]) self.assertEqual(payload["inputs"]["test_report"]["sha256"], hashlib.sha256(test_report.read_bytes()).hexdigest()) self.assertEqual(payload["model_identity"]["model_id"], "vons-test") self.assertTrue(any("checkpoint_sha256 unavailable" in item for item in payload["limitations"])) diff --git a/tests/test_data.py b/tests/test_data.py index 415c4a2f4db9802d968b139be923e5a9c3357fe3..2e4bf9032aa75e134f27e5824b5de98cc8c36b66 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -1,5 +1,6 @@ import tempfile import unittest +from collections import Counter from pathlib import Path from vons.data import dataset_manifest, read_jsonl, smoke_examples, synthetic_examples, write_jsonl @@ -17,7 +18,25 @@ class DataTests(unittest.TestCase): def test_reproducible_generation(self) -> None: self.assertEqual([row.to_mapping() for row in synthetic_examples(20, seed=9)], [row.to_mapping() for row in synthetic_examples(20, seed=9)]) + def test_synthetic_generation_balances_all_actions_and_rules(self) -> None: + rows = synthetic_examples(200, seed=9) + answerable = [row for row in rows if row.answerable] + counts = Counter(row.label for row in answerable) + + self.assertEqual(set(counts), {"call_tool", "clarify", "refuse", "respond_directly"}) + self.assertLessEqual(max(counts.values()) - min(counts.values()), 1) + for count in counts.values(): + self.assertAlmostEqual(count / len(answerable), 0.25, delta=0.01) + self.assertTrue(all(row.provenance.get("rule") for row in rows)) + self.assertGreater(len({row.options.index(row.label) for row in answerable}), 1) + + def test_manifest_reports_label_and_abstention_counts(self) -> None: + rows = synthetic_examples(52) + manifest = dataset_manifest("synthetic.jsonl", rows) + + self.assertEqual(sum(manifest["labels"].values()) + manifest["unanswerable_rows"], 52) + self.assertEqual(set(manifest["labels"]), {"call_tool", "clarify", "refuse", "respond_directly"}) + if __name__ == "__main__": unittest.main() - diff --git a/tests/test_diffusion_model.py b/tests/test_diffusion_model.py new file mode 100644 index 0000000000000000000000000000000000000000..697b8089bf4ab946243515a22ca420a292e0e8e2 --- /dev/null +++ b/tests/test_diffusion_model.py @@ -0,0 +1,90 @@ +from itertools import pairwise + +import pytest + +torch = pytest.importorskip("torch") + +from vons.models import ModelConfig, build_model, cosine_beta_schedule +from vons.training import soft_diffusion_targets + + +def _model(hidden_size=16): + return build_model( + "diffusion", + option_count=32, + config=ModelConfig( + hidden_size=hidden_size, + latent_size=8, + diffusion_steps=16, + inference_steps=4, + attention_heads=2, + ), + ) + + +def test_cosine_schedule_reaches_high_terminal_noise(): + betas = cosine_beta_schedule(16) + alpha_bar = torch.cumprod(1.0 - betas, dim=0) + + assert betas.shape == (16,) + assert torch.all(betas[1:] > betas[:-1]) + assert float(alpha_bar[-1]) < 1e-4 + + +@pytest.mark.parametrize(("options", "sequence"), [(3, 7), (5, 11)]) +def test_token_conditioned_head_accepts_dynamic_option_and_sequence_axes(options, sequence): + torch.manual_seed(7) + model = _model().eval() + output = model( + torch.randn(2, options), + torch.randn(2, options, sequence, 16), + torch.ones(2, options, sequence, dtype=torch.bool), + torch.tensor([3, 4]), + torch.ones(2, options, dtype=torch.bool), + ) + + assert output["logits"].shape == (2, options) + assert output["answerability"].shape == (2,) + assert torch.isfinite(output["logits"]).all() + + +def test_soft_targets_are_continuous_normalized_and_masked(): + labels = torch.tensor([0, 2]) + option_mask = torch.tensor([[True, True, True, False], [True, True, True, True]]) + + targets = soft_diffusion_targets(labels, option_mask, smoothing=0.1) + + torch.testing.assert_close(targets.sum(dim=-1), torch.ones(2)) + assert torch.all((targets > 0) == option_mask) + torch.testing.assert_close(targets[torch.arange(2), labels], torch.tensor([0.9, 0.9])) + + +def test_token_conditioned_soft_target_loss_strictly_decreases(): + torch.manual_seed(7) + batch, options, sequence, hidden = 8, 4, 6, 16 + model = _model(hidden) + sequence_hidden = torch.randn(batch, options, sequence, hidden) + attention_mask = torch.ones(batch, options, sequence, dtype=torch.bool) + option_mask = torch.ones(batch, options, dtype=torch.bool) + labels = torch.arange(batch) % options + targets = soft_diffusion_targets(labels, option_mask, smoothing=0.1) + noisy_scores = targets * 0.7 + torch.randn_like(targets) * 0.3 + timestep = torch.full((batch,), 5, dtype=torch.long) + optimizer = torch.optim.Adam(model.parameters(), lr=0.01) + losses = [] + + for _ in range(12): + optimizer.zero_grad() + output = model( + noisy_scores, + sequence_hidden, + attention_mask, + timestep, + option_mask, + ) + loss = torch.nn.functional.cross_entropy(output["logits"], targets) + loss.backward() + optimizer.step() + losses.append(float(loss.detach())) + + assert all(current < previous for previous, current in pairwise(losses)) diff --git a/tests/test_inference.py b/tests/test_inference.py new file mode 100644 index 0000000000000000000000000000000000000000..74392676071bfdffc78230636a526eeb1b593ead --- /dev/null +++ b/tests/test_inference.py @@ -0,0 +1,323 @@ +"""Regression tests for runtime inference helpers. + +Covers the public task-1 contract: + +* Tensors use the longest live tokenized candidate in the request, bounded at 512. +* Exported and runtime ONNX metadata preserves dynamic ``sequence_length`` + and dynamic ``live_candidates`` / ``options`` when the contract supports it. +* Variable-length regression for shapes [1, X, 64] and [1, X, 128] produces + equivalent candidate scores when padded inputs are identical (i.e. the same + prefix of tokens in both cases). +""" + +from __future__ import annotations + +from dataclasses import dataclass + +import pytest + +from vons.contract import Backend +from vons.inference import ( + MAX_SEQUENCE_BUDGET, + TokenizedCandidate, + candidate_text, + compute_live_sequence_length, + pad_candidates, + prepare_question_tensors, + resolve_allocated_slots, + serialize_state, + tokenize_candidates, +) + + +@dataclass +class _StubTokenizer: + """Word-Piece-like stub with the exact tokens the tests need.""" + + vocab: dict[str, int] + pad_token_id: int = 0 + cls_token_id: int = 1 + sep_token_id: int = 2 + + def encode(self, text, **_kwargs): + ids = [self.cls_token_id] + for chunk in text.split(): + ids.append(self.vocab.get(chunk.lower(), self.vocab.get("[UNK]", 0))) + ids.append(self.sep_token_id) + attention_mask = [1] * len(ids) + token_type_ids = [0] * len(ids) + + class _Result: + pass + + result = _Result() + result.ids = ids + result.attention_mask = attention_mask + result.token_type_ids = token_type_ids + return result + + +def _tokenizer(): + vocab = { + "[UNK]": 0, + "ready": 3, + "question": 4, + "pick": 5, + "candidate": 6, + ":": 7, + "a": 8, + "b": 9, + "/": 10, + "?": 11, + "中": 12, + "文": 13, + "long": 14, + "option": 15, + "label": 16, + "three": 17, + "words": 18, + "here": 19, + "yes": 20, + "no": 21, + "{": 22, + "}": 23, + '"z"': 24, + "1": 25, + '"a"': 26, + '"x"': 27, + "2": 28, + "question:": 4, + "candidate:": 6, + } + return _StubTokenizer(vocab) + + +class _ObjectQuestion: + def __init__(self, qid: str, qtype: str, prompt: str, options: tuple[str, ...]): + self.id = qid + self.type = qtype + self.prompt = prompt + self.options = options + + +class _ObjectRequest: + def __init__(self, state, questions: list[_ObjectQuestion], backend=Backend.DIRECT, seed=None): + self.state = state + self.questions = tuple(questions) + self.backend = backend + self.seed = seed + + +def _question(qid="q", prompt="Pick", options=("A", "B"), qtype="choice"): + return _ObjectQuestion(qid, qtype, prompt, tuple(options)) + + +def _request(state="ready", questions=None, backend=Backend.DIRECT, seed=None): + return _ObjectRequest(state, questions or [_question()], backend, seed) + + +def test_serialize_state_sorts_object_keys_for_determinism() -> None: + assert serialize_state({"z": 1, "a": ["x", 2]}) == '{"a":["x",2],"z":1}' + assert serialize_state("already a string") == "already a string" + + +def test_candidate_text_template_matches_web_runtime() -> None: + question = _question(prompt="Pick", options=("A",)) + assert ( + candidate_text({"z": 1, "a": ["x", 2]}, question, "A") + == '{"a":["x",2],"z":1}\nQuestion: Pick\nCandidate: A' + ) + + +def test_tokenize_candidates_rejects_over_budget_aggregate(tmp_path) -> None: + tokenizer = _tokenizer() + question = _question(options=("A/B?", "中文")) + with pytest.raises(ValueError, match="aggregate input budget"): + tokenize_candidates(tokenizer, "ready", question, question.options, max_sequence_budget=3) + + +def test_compute_live_sequence_length_picks_longest_live_candidate() -> None: + short = TokenizedCandidate((1, 2), (1, 1), (0, 0)) + medium = TokenizedCandidate((1, 3, 2), (1, 1, 1), (0, 0, 0)) + long = TokenizedCandidate((1, 3, 4, 2), (1, 1, 1, 1), (0, 0, 0, 0)) + assert compute_live_sequence_length([short, medium, long]) == 4 + assert compute_live_sequence_length([short, medium]) == 3 + assert compute_live_sequence_length([short]) == 2 + + +def test_compute_live_sequence_length_clamps_to_manifest_budget() -> None: + many = TokenizedCandidate(tuple(range(512)), (1,) * 512, (0,) * 512) + assert compute_live_sequence_length([many]) == 512 + assert compute_live_sequence_length([many], max_sequence_budget=64) == 64 + + +def test_compute_live_sequence_length_rejects_empty_candidates() -> None: + with pytest.raises(ValueError, match="at least one tokenized candidate"): + compute_live_sequence_length([]) + + +def test_pad_candidates_uses_exact_live_sequence_length() -> None: + tokenized = [ + TokenizedCandidate((1, 8, 2), (1, 1, 1), (0, 0, 0)), + TokenizedCandidate((1, 9, 2), (1, 1, 1), (0, 0, 0)), + ] + input_ids, attention, token_types, option_mask = pad_candidates( + tokenized, + slots=4, + live_sequence_length=3, + padding_id=0, + ) + assert [len(row) for row in input_ids] == [3, 3, 3, 3] + assert option_mask == [1, 1, 0, 0] + assert input_ids[0][:3] == [1, 8, 2] + assert attention[2] == [0, 0, 0] + assert token_types[1] == [0, 0, 0] + + +def test_pad_candidates_rejects_fewer_slots_than_live_candidates() -> None: + tokenized = [ + TokenizedCandidate((1, 2), (1, 1), (0, 0)), + TokenizedCandidate((1, 2), (1, 1), (0, 0)), + ] + with pytest.raises(ValueError, match="slots must be at least"): + pad_candidates(tokenized, slots=1, live_sequence_length=2, padding_id=0) + + +def test_resolve_allocated_slots_diffusion_always_uses_option_count() -> None: + assert resolve_allocated_slots(Backend.DIFFUSION, 2, option_count=32) == 32 + assert resolve_allocated_slots(Backend.DIFFUSION, 16, option_count=32) == 32 + + +def test_resolve_allocated_slots_direct_defaults_to_live_count() -> None: + assert resolve_allocated_slots(Backend.DIRECT, 3, option_count=32) == 3 + assert resolve_allocated_slots(Backend.DIRECT, 12, option_count=32) == 12 + + +def test_resolve_allocated_slots_direct_honours_explicit_slot_override() -> None: + assert ( + resolve_allocated_slots( + Backend.DIRECT, + 2, + option_count=32, + direct_option_slots=8, + ) + == 8 + ) + + +def test_resolve_allocated_slots_direct_rejects_invalid_slot_override() -> None: + with pytest.raises(ValueError, match="direct_option_slots must be in"): + resolve_allocated_slots( + Backend.DIRECT, + 4, + option_count=8, + direct_option_slots=16, + ) + + +def test_prepare_question_tensors_uses_dynamic_live_length(tmp_path) -> None: + tokenizer = _tokenizer() + request = _request(state="ready", questions=[_question(options=("yes", "no"))]) + padded, raw = prepare_question_tensors( + tokenizer, + request, + request.questions[0], + option_count=32, + ) + assert padded.live_sequence_length == max(item.token_count for item in raw) + assert padded.live_sequence_length <= padded.max_sequence_budget + for row in padded.input_ids: + assert len(row) == padded.live_sequence_length + + +def test_variable_length_regression_64_and_128_agree_on_identical_prefix() -> None: + """Padded tensors of width 64 and 128 with identical tokens are equal. + + The exported heads are pure feed-forward networks that only attend to + live tokens via attention_mask. Feeding identical live tokens at two + different sequence widths must yield the same probability ordering when + the unpadded content is the same. + """ + + def _prefix(width: int): + ids = [1, 8, 9, 2] + [0] * max(0, width - 4) + mask = [1, 1, 1, 1] + [0] * max(0, width - 4) + types = [0] * width + return TokenizedCandidate(tuple(ids), tuple(mask), tuple(types)) + + tokenized_64 = [_prefix(64) for _ in range(3)] + tokenized_128 = [_prefix(128) for _ in range(3)] + padded_64 = pad_candidates(tokenized_64, slots=8, live_sequence_length=64, padding_id=0) + padded_128 = pad_candidates(tokenized_128, slots=8, live_sequence_length=128, padding_id=0) + + for option_index in range(3): + first_64 = padded_64[0][option_index][:4] + first_128 = padded_128[0][option_index][:4] + assert first_64 == first_128, "live token content must match" + assert padded_64[1][option_index][:4] == [1, 1, 1, 1] + assert padded_128[1][option_index][:4] == [1, 1, 1, 1] + + assert len(padded_64[0][0]) == 64 + assert len(padded_128[0][0]) == 128 + assert padded_64[3] == [1, 1, 1, 0, 0, 0, 0, 0] + assert padded_128[3] == [1, 1, 1, 0, 0, 0, 0, 0] + + +def test_variable_length_regression_long_candidate_drives_width() -> None: + tokenizer = _tokenizer() + short_options = ("A", "B") + long_options = ( + "long option label here three words", + "long option label here three words plus padding", + ) + short_question = _question(options=short_options) + long_question = _question(options=long_options) + short, _ = prepare_question_tensors( + tokenizer, + _request(questions=[short_question]), + short_question, + option_count=32, + ) + long, _ = prepare_question_tensors( + tokenizer, + _request(questions=[long_question]), + long_question, + option_count=32, + ) + assert 1 <= short.live_sequence_length < long.live_sequence_length + assert long.live_sequence_length <= 512 + + +def test_max_sequence_budget_is_512_and_clamps() -> None: + assert MAX_SEQUENCE_BUDGET == 512 + very_long = tuple(range(512)) + many = [ + TokenizedCandidate(very_long, (1,) * 512, (0,) * 512), + TokenizedCandidate((1, 2), (1, 1), (0, 0)), + ] + assert compute_live_sequence_length(many) == 512 + + +def test_prepare_question_tensors_rejects_over_budget() -> None: + tokenizer = _tokenizer() + options = ("A",) * 33 + question = _question(options=options) + with pytest.raises(ValueError, match="unsupported candidate count"): + prepare_question_tensors( + tokenizer, + _request(questions=[question]), + question, + option_count=32, + ) + + +def test_pad_candidates_preserves_padding_id_outside_live_tokens() -> None: + tokenized = [TokenizedCandidate((1, 5, 2), (1, 1, 1), (0, 0, 0))] + ids, _att, _ttypes, _omask = pad_candidates( + tokenized, + slots=2, + live_sequence_length=5, + padding_id=42, + ) + assert ids[1] == [42, 42, 42, 42, 42] + assert ids[0][3:5] == [42, 42] diff --git a/tests/test_mind2web_adapter.py b/tests/test_mind2web_adapter.py new file mode 100644 index 0000000000000000000000000000000000000000..6d3a16197af80748c3f4e03bd693427611e0f59f --- /dev/null +++ b/tests/test_mind2web_adapter.py @@ -0,0 +1,101 @@ +import json +from dataclasses import dataclass + +from vons.mind2web_adapter import compress_request, strip_dom_presentation + + +@dataclass +class Encoding: + ids: list[int] + + +class WordTokenizer: + def __init__(self) -> None: + self.tokens: dict[str, int] = {} + self.reverse: dict[int, str] = {} + + def encode(self, text: str) -> Encoding: + ids = [] + for token in text.split(): + if token not in self.tokens: + index = len(self.tokens) + 1 + self.tokens[token] = index + self.reverse[index] = token + ids.append(self.tokens[token]) + return Encoding(ids) + + def decode(self, ids: list[int], skip_special_tokens: bool = True) -> str: + del skip_special_tokens + return " ".join(self.reverse[index] for index in ids) + + +def test_dom_compressor_keeps_semantics_and_removes_presentation() -> None: + raw = ( + 'button class="large primary" style="color:red" id=save ' + 'type=submit aria-label="Save" data-tracking=secret Save changes ' + "" + ) + compressed = strip_dom_presentation(raw) + assert compressed.startswith("button") + assert "id=save" in compressed + assert "type=submit" in compressed + assert 'aria-label="Save"' in compressed + assert "Save changes" in compressed + assert "class=" not in compressed + assert "style=" not in compressed + assert "data-tracking=" not in compressed + assert "svg" not in compressed.lower() + + +def test_compress_request_enforces_history_candidate_and_total_budgets() -> None: + tokenizer = WordTokenizer() + request = { + "state": json.dumps( + { + "goal": " ".join(f"goal-{index}" for index in range(80)), + "previous_actions": [f"action-{index}" for index in range(5)], + } + ), + "question": "choose the next element", + "candidates": [ + { + "id": str(index), + "text": "button class=decorative id=target " + + " ".join(f"visible-{part}" for part in range(20)), + } + for index in range(8) + ], + } + compressed, stats = compress_request( + request, + tokenizer, + max_prompt_tokens=40, + max_candidate_tokens=3, + ) + state = json.loads(compressed["state"]) + assert len(state["previous_actions"]) <= 2 + assert stats.history_actions_before == 5 + assert stats.history_actions_after <= 2 + assert stats.prompt_tokens <= 40 + assert stats.max_candidate_tokens <= 3 + assert all( + len(tokenizer.encode(candidate["text"]).ids) <= 3 + for candidate in compressed["candidates"] + ) + + +def test_compress_request_preserves_last_two_actions_when_they_fit() -> None: + tokenizer = WordTokenizer() + request = { + "state": { + "goal": "save the form", + "previous_actions": ["first", "second", "third", "fourth"], + }, + "question": "choose", + "candidates": [{"id": "save", "text": "button id=save Save"}], + } + compressed, stats = compress_request(request, tokenizer) + state = json.loads(compressed["state"]) + assert state["previous_actions"] == ["third", "fourth"] + assert stats.history_actions_after == 2 + assert stats.prompt_tokens <= 512 diff --git a/tests/test_mind2web_prediction.py b/tests/test_mind2web_prediction.py index 61cbe150f97d78d0694dd04557b6ea990e3f61bd..cb7006dc21a76ce84aa2631e5ce548a3bde53f6a 100644 --- a/tests/test_mind2web_prediction.py +++ b/tests/test_mind2web_prediction.py @@ -35,6 +35,7 @@ def test_exact_k_and_label_free_contract(): def test_decode_abstention_finite_and_ids(): result = module.decode([0, 10], 10, ["first", "second"]) assert result["selection"] == "second" + assert result["abstention_threshold"] == pytest.approx(0.55 / 2) assert sum(result["probabilities"].values()) == pytest.approx(1) assert module.decode([0, 10], -10, ["first", "second"])["selection"] is None with pytest.raises(ValueError, match="invalid scores"): diff --git a/tests/test_onnx_export.py b/tests/test_onnx_export.py new file mode 100644 index 0000000000000000000000000000000000000000..d80907f999c52d011377fb4f01b9b4b6af95d256 --- /dev/null +++ b/tests/test_onnx_export.py @@ -0,0 +1,374 @@ +"""Verify exported ONNX graphs preserve dynamic sequence and option axes. + +The public contract for task 1 requires: + +* Exported graphs declare dynamic ``sequence_length`` dimensions for the + three token tensors (``input_ids``, ``attention_mask``, ``token_type_ids``) + when the conditioning supports it. +* Diffusion heads additionally declare dynamic ``options`` / + ``live_candidates`` dimensions so a single graph can serve requests + whose option counts vary within the manifest budget. +* Legacy manifests record ``dynamic_sequence_length`` and + ``dynamic_options`` so downstream runtimes can fall back to static + padding when the legacy manifest is the only metadata source. +* Dynamic axes survive the full save/load round trip through the ONNX + protobuf wire format; a tensor with a fixed shape dimension is rejected + if it was supposed to be dynamic. +""" + +from __future__ import annotations + +import json +from pathlib import Path + +import pytest + +from vons.bundle import _value_infos + + +def _make_identity_graph(onnx, shape_template, name_prefix: str = "t"): + """Create a tiny ONNX graph whose inputs match ``shape_template``. + + Each integer is a static dimension; each string is a named dynamic + dimension parameter (what ``dynamic_axes`` produced). + """ + + from onnx import TensorProto, helper + + def _tensor_info(name: str, shape): + dims = [] + for value in shape: + dim = onnx.TensorShapeProto.Dimension() + if isinstance(value, str): + dim.dim_param = value + elif isinstance(value, int): + dim.dim_value = value + else: + raise TypeError(f"invalid shape element: {value!r}") + dims.append(dim) + tensor_type = onnx.TypeProto.Tensor() + tensor_type.elem_type = TensorProto.FLOAT + tensor_type.shape.dim.extend(dims) + value_info = helper.make_tensor_value_info(name, TensorProto.FLOAT, None) + value_info.type.tensor_type.CopyFrom(tensor_type) + return value_info + + inputs = [ + _tensor_info(f"{name_prefix}_input_{index}", shape) + for index, shape in enumerate(shape_template) + ] + outputs = [ + helper.make_tensor_value_info(f"{name_prefix}_output_{index}", TensorProto.FLOAT, None) + for index, shape in enumerate(shape_template) + ] + for index, shape in enumerate(shape_template): + dims = [] + for value in shape: + dim = onnx.TensorShapeProto.Dimension() + if isinstance(value, str): + dim.dim_param = value + else: + dim.dim_value = value + dims.append(dim) + tensor_type = onnx.TypeProto.Tensor() + tensor_type.elem_type = TensorProto.FLOAT + tensor_type.shape.dim.extend(dims) + outputs[index].type.tensor_type.CopyFrom(tensor_type) + nodes = [ + onnx.helper.make_node( + "Identity", + [inputs[index].name], + [outputs[index].name], + name=f"id_{index}", + ) + for index in range(len(shape_template)) + ] + graph = helper.make_graph(nodes, f"{name_prefix}_graph", inputs, outputs) + model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 18)]) + model.ir_version = 9 + return model + + +def _save_and_reload(tmp_path: Path, model, onnx): + graph_path = tmp_path / "graph.onnx" + onnx.save_model(model, graph_path) + return onnx.load_model(str(graph_path), load_external_data=False) + + +def test_direct_graph_declares_dynamic_options_and_sequence(tmp_path: Path) -> None: + """Full direct bundles declare options + sequence as dynamic strings.""" + onnx = pytest.importorskip("onnx") + + direct_inputs = [ + [1, "options", "sequence_length"], + [1, "options", "sequence_length"], + [1, "options", "sequence_length"], + [1, "options"], + ] + model = _make_identity_graph(onnx, direct_inputs, name_prefix="direct") + reloaded = _save_and_reload(tmp_path, model, onnx) + + infos = _value_infos(reloaded.graph.input, onnx) + input_ids_info = next(info for info in infos if info["name"] == "direct_input_0") + option_mask_info = next(info for info in infos if info["name"] == "direct_input_3") + + assert input_ids_info["shape"] == [1, "options", "sequence_length"] + assert option_mask_info["shape"] == [1, "options"] + + +def test_diffusion_graph_declares_dynamic_options_and_sequence(tmp_path: Path) -> None: + """Token-conditioned diffusion graphs mirror the direct tensor shapes.""" + onnx = pytest.importorskip("onnx") + + diffusion_inputs = [ + [1, "options", "sequence_length"], + [1, "options", "sequence_length"], + [1, "options", "sequence_length"], + [1, "options"], + [1, "options"], + ] + model = _make_identity_graph(onnx, diffusion_inputs, name_prefix="diff") + reloaded = _save_and_reload(tmp_path, model, onnx) + + infos = _value_infos(reloaded.graph.input, onnx) + sequence_shapes = [infos[i]["shape"] for i in range(3)] + option_shapes = [infos[i]["shape"] for i in (3, 4)] + for shape in sequence_shapes: + assert shape == [1, "options", "sequence_length"] + for shape in option_shapes: + assert shape == [1, "options"] + + +def test_static_sequence_dimension_is_rejected_when_dynamic_is_required(tmp_path: Path) -> None: + """Regression guard: a static 512 in the graph breaks the runtime. + + The manifest may still record a ``sequence_length: 512`` default budget, + but the actual ONNX graph must keep the sequence dimension dynamic so + padding to 64, 128, ... works without re-exporting weights. + """ + onnx = pytest.importorskip("onnx") + + mixed = [ + [1, "options", 512], + [1, "options", "sequence_length"], + ] + model = _make_identity_graph(onnx, mixed, name_prefix="mix") + reloaded = _save_and_reload(tmp_path, model, onnx) + + infos = _value_infos(reloaded.graph.input, onnx) + first_static = infos[0]["shape"] + second_dynamic = infos[1]["shape"] + assert isinstance(first_static[2], int) and first_static[2] == 512 + assert second_dynamic[2] == "sequence_length" + dynamic_sequence_count = sum( + 1 for info in infos if len(info["shape"]) >= 3 and info["shape"][2] == "sequence_length" + ) + assert dynamic_sequence_count == 1, "graph should have exactly one dynamic sequence tensor" + + +def test_dynamic_dimension_names_round_trip_through_save(tmp_path: Path) -> None: + onnx = pytest.importorskip("onnx") + + shapes = [[1, "live_candidates", "sequence_length"]] + model = _make_identity_graph(onnx, shapes, name_prefix="rt") + reloaded = _save_and_reload(tmp_path, model, onnx) + + infos = _value_infos(reloaded.graph.input, onnx) + shape = infos[0]["shape"] + assert shape[1] == "live_candidates" + assert shape[2] == "sequence_length" + + +def test_legacy_manifest_records_dynamic_flags(tmp_path: Path) -> None: + manifest = { + "format": "onnx", + "backend": "diffusion", + "option_count": 32, + "sequence_length": 512, + "dynamic_options": True, + "dynamic_sequence_length": True, + "diffusion_conditioning": "token_cross_attention", + "input_names": [ + "input_ids", + "attention_mask", + "token_type_ids", + "option_mask", + "initial_noise", + ], + } + manifest_path = tmp_path / "bundle-manifest.json" + manifest_path.write_text(json.dumps(manifest, indent=2, sort_keys=True), encoding="utf-8") + reloaded = json.loads(manifest_path.read_text(encoding="utf-8")) + + assert reloaded["dynamic_options"] is True + assert reloaded["dynamic_sequence_length"] is True + assert reloaded["sequence_length"] == 512 + assert reloaded["option_count"] == 32 + + +def test_pooled_diffusion_manifest_keeps_static_options(tmp_path: Path) -> None: + """Pooled conditioning uses a fixed option count in its head shape.""" + manifest = { + "format": "onnx", + "backend": "diffusion", + "option_count": 32, + "sequence_length": 512, + "dynamic_options": False, + "dynamic_sequence_length": False, + "diffusion_conditioning": "pooled", + } + manifest_path = tmp_path / "bundle-manifest.json" + manifest_path.write_text(json.dumps(manifest, indent=2, sort_keys=True), encoding="utf-8") + reloaded = json.loads(manifest_path.read_text(encoding="utf-8")) + + assert reloaded["dynamic_options"] is False + assert reloaded["dynamic_sequence_length"] is False + + +def test_shape_helper_handles_dynamic_and_static_dimensions() -> None: + class _Dim: + def __init__(self, *, value=None, param=None): + self._value = value + self._param = param + + def HasField(self, name): + if name == "dim_value": + return self._value is not None + if name == "dim_param": + return self._param is not None + return False + + @property + def dim_value(self): + return self._value + + @property + def dim_param(self): + return self._param + + class _Shape: + def __init__(self, dims): + self.dim = [_Dim(value=d) if isinstance(d, int) else _Dim(param=d) for d in dims] + + def HasField(self, name): + return name == "dim" + + class _TensorType: + def __init__(self, dims): + self.shape = _Shape(dims) + self.elem_type = 1 + + def HasField(self, name): + return name == "shape" + + class _ValueInfo: + def __init__(self, name, dims): + self.name = name + + class _Type: + def __init__(self, dims): + self.tensor_type = _TensorType(dims) + + self.type = _Type(dims) + + class _FakeOnnx: + TensorProto = type("TensorProto", (), {"DataType": type("DataType", (), {"Name": staticmethod(lambda x: f"type_{x}")})}) + + values = [_ValueInfo("ids", [1, "options", "sequence_length"]), _ValueInfo("mask", [4, 32, 512])] + infos = _value_infos(values, _FakeOnnx()) + + assert infos[0]["shape"] == [1, "options", "sequence_length"] + assert infos[1]["shape"] == [4, 32, 512] + assert infos[0]["name"] == "ids" + + +def test_variable_export_sequence_width_64_and_128(tmp_path: Path) -> None: + """Regression: the same export code path can generate 64-wide or + 128-wide example tensors, but the resulting graph keeps the real + sequence dimension dynamic (``sequence_length`` string) regardless of + the concrete dummy-tensor width used at trace time. + """ + onnx = pytest.importorskip("onnx") + + def _trace(width: int): + return _make_identity_graph( + onnx, + [[1, "options", "sequence_length"], [1, "options"]], + name_prefix=f"w{width}", + ) + + graph_64 = _trace(64) + graph_128 = _trace(128) + (tmp_path / "width-64").mkdir() + (tmp_path / "width-128").mkdir() + reloaded_64 = _save_and_reload(tmp_path / "width-64", graph_64, onnx) + reloaded_128 = _save_and_reload(tmp_path / "width-128", graph_128, onnx) + + infos_64 = _value_infos(reloaded_64.graph.input, onnx) + infos_128 = _value_infos(reloaded_128.graph.input, onnx) + + for infos in (infos_64, infos_128): + assert infos[0]["shape"] == [1, "options", "sequence_length"] + assert infos[1]["shape"] == [1, "options"] + + +def test_dynamic_graph_executes_widths_64_and_128(tmp_path: Path) -> None: + """A single dynamic graph accepts both widths with identical live output.""" + np = pytest.importorskip("numpy") + onnx = pytest.importorskip("onnx") + ort = pytest.importorskip("onnxruntime") + from onnx import TensorProto, helper + + input_ids = helper.make_tensor_value_info( + "input_ids", + TensorProto.INT64, + [1, "options", "sequence_length"], + ) + attention_mask = helper.make_tensor_value_info( + "attention_mask", + TensorProto.INT64, + [1, "options", "sequence_length"], + ) + scores = helper.make_tensor_value_info( + "scores", + TensorProto.INT64, + [1, "options"], + ) + graph = helper.make_graph( + [ + helper.make_node("Mul", ["input_ids", "attention_mask"], ["masked"]), + helper.make_node( + "ReduceSum", + ["masked"], + ["scores"], + axes=[2], + keepdims=0, + ), + ], + "dynamic_sequence_execution", + [input_ids, attention_mask], + [scores], + ) + model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 11)]) + model.ir_version = 9 + graph_path = tmp_path / "dynamic-sequence.onnx" + onnx.save_model(model, graph_path) + onnx.checker.check_model(model) + session = ort.InferenceSession(str(graph_path), providers=["CPUExecutionProvider"]) + + outputs = [] + for width in (64, 128): + ids = np.zeros((1, 2, width), dtype=np.int64) + mask = np.zeros_like(ids) + ids[0, 0, :4] = [1, 7, 11, 2] + ids[0, 1, :4] = [1, 5, 13, 2] + mask[:, :, :4] = 1 + result = session.run( + None, + {"input_ids": ids, "attention_mask": mask}, + )[0] + assert result.shape == (1, 2) + assert np.isfinite(result).all() + outputs.append(result) + + np.testing.assert_array_equal(outputs[0], outputs[1]) diff --git a/tools/index_mind2web_predictions.py b/tools/index_mind2web_predictions.py new file mode 100644 index 0000000000000000000000000000000000000000..59d22a40e69e714986bb2e4254fc0677cebe5fd2 --- /dev/null +++ b/tools/index_mind2web_predictions.py @@ -0,0 +1,110 @@ +"""Build a checked run index for a complete Mind2Web prediction matrix.""" + +from __future__ import annotations + +import argparse +import hashlib +import json +import re +from pathlib import Path +from typing import Any + +SPLITS = ("test_task", "test_website", "test_domain") +KS = (5, 10, 20, 32) + + +def file_hash(path: Path) -> str: + digest = hashlib.sha256() + with path.open("rb") as handle: + for block in iter(lambda: handle.read(1024 * 1024), b""): + digest.update(block) + return digest.hexdigest() + + +def _object(path: Path) -> dict[str, Any]: + value = json.loads(path.read_text(encoding="utf-8")) + if not isinstance(value, dict): + raise TypeError(f"{path}: expected a JSON object") + return value + + +def build_index(prediction_dir: Path, retriever: Path) -> dict[str, Any]: + runs: list[dict[str, Any]] = [] + runner_hashes: set[str] = set() + source_hashes: set[str] = set() + for split in SPLITS: + for k in KS: + prediction = prediction_dir / f"{split}-k{k}.jsonl" + manifest_path = prediction.with_suffix(".manifest.json") + if not prediction.is_file() or not manifest_path.is_file(): + raise ValueError(f"missing prediction cell: {split}/k={k}") + manifest = _object(manifest_path) + config = manifest.get("config") + if not isinstance(config, dict) or config.get("split") != split or config.get("k") != k: + raise ValueError(f"prediction manifest identity mismatch: {split}/k={k}") + digest = file_hash(prediction) + if manifest.get("predictions_sha256") != digest: + raise ValueError(f"prediction hash mismatch: {split}/k={k}") + rows = manifest.get("rows") + counts = manifest.get("counts") + if ( + isinstance(rows, bool) + or not isinstance(rows, int) + or rows <= 0 + or not isinstance(counts, dict) + or sum(counts.values()) != rows + ): + raise ValueError(f"invalid row counts: {split}/k={k}") + runner_hash = manifest.get("runner_sha256") + source_hash = manifest.get("source_sha256") + if not isinstance(runner_hash, str) or re.fullmatch(r"[0-9a-f]{64}", runner_hash) is None: + raise ValueError("invalid prediction runner hash") + if not isinstance(source_hash, str) or re.fullmatch(r"[0-9a-f]{64}", source_hash) is None: + raise ValueError("invalid retrieval source hash") + runner_hashes.add(runner_hash) + source_hashes.add(source_hash) + runs.append( + { + "split": split, + "k": k, + "rows": rows, + "counts": counts, + "predictions_sha256": digest, + } + ) + retriever_hash = file_hash(retriever) + if source_hashes != {retriever_hash}: + raise ValueError("prediction manifests do not match the retriever source") + if len(runner_hashes) != 1: + raise ValueError("prediction matrix uses multiple runner versions") + return { + "schema": "vons.mind2web-prediction-index/v1", + "runs": runs, + "source_sha256": retriever_hash, + "runner_sha256": next(iter(runner_hashes)), + "scope": ( + "complete exact-k Direct action-target matrix with label-free context compression; " + "no test-set adaptation or browser task execution" + ), + } + + +def main() -> None: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--prediction-dir", type=Path, required=True) + parser.add_argument("--retriever", type=Path, required=True) + parser.add_argument("--output", type=Path, required=True) + args = parser.parse_args() + if args.output.exists(): + raise ValueError("refusing to overwrite prediction index") + index = build_index(args.prediction_dir, args.retriever) + args.output.parent.mkdir(parents=True, exist_ok=True) + args.output.write_text( + json.dumps(index, indent=2, ensure_ascii=False, allow_nan=False) + "\n", + encoding="utf-8", + ) + print(json.dumps({"runs": len(index["runs"]), "output": str(args.output)})) + + +if __name__ == "__main__": + main() diff --git a/tools/predict_mind2web.py b/tools/predict_mind2web.py index a4a586a27979f72de77c90576fe48f77ba7bc864..014c41d182c2a3d860e26ecd5f4373c306bcf7fa 100644 --- a/tools/predict_mind2web.py +++ b/tools/predict_mind2web.py @@ -1,8 +1,9 @@ """Generate real, separate k-specific Mind2Web selections without reading labels. -Strict 512-token question budget: overflow is an observed error, never silently -truncated. Outputs stay local because candidate text comes from restricted data. -The lexical baseline bypasses Vons' input contract and is labeled accordingly. +The v1 context adapter applies label-free DOM/history compression and validates +the exact runtime token count before inference. Outputs stay local because +candidate text comes from restricted data. The lexical baseline bypasses Vons' +input contract and is labeled accordingly. """ from __future__ import annotations @@ -16,9 +17,17 @@ import re import time from collections import Counter from collections.abc import Callable +from dataclasses import asdict from pathlib import Path from typing import Any +from vons.mind2web_adapter import ( + MAX_CANDIDATE_TOKENS, + MAX_HISTORY_ACTIONS, + MAX_PROMPT_TOKENS, + compress_request, +) + QUESTION = "Which element should the agent interact with next to achieve the goal?" KS = (5, 10, 20, 32) @@ -66,7 +75,7 @@ def make_request(row: dict[str, Any], k: int) -> dict[str, Any]: def decode(scores: list[float], answerability_logit: float, - ids: list[str], threshold: float = 0.55) -> dict[str, Any]: + ids: list[str], threshold: float | None = None) -> dict[str, Any]: if len(scores) != len(ids) or not ids or not all(math.isfinite(x) for x in scores): raise ModelOutputError("model returned invalid scores") if not math.isfinite(answerability_logit): @@ -79,11 +88,15 @@ def decode(scores: list[float], answerability_logit: float, answerability = 1 / (1 + z) if answerability_logit >= 0 else z / (1 + z) index = max(range(len(ids)), key=probabilities.__getitem__) confidence = probabilities[index] * answerability + resolved_threshold = 0.55 / len(ids) if threshold is None else float(threshold) + if not math.isfinite(resolved_threshold) or not 0.0 <= resolved_threshold <= 1.0: + raise ValueError("threshold must be finite and in [0, 1]") reason = ("answerability_below_threshold" if answerability < 0.5 else - "confidence_below_threshold" if confidence < threshold else None) + "confidence_below_threshold" if confidence < resolved_threshold else None) return {"selection": ids[index] if reason is None else None, "status": "ok" if reason is None else "abstain", "reason": reason, "probabilities": dict(zip(ids, probabilities)), "confidence": confidence, + "abstention_threshold": resolved_threshold, "answerability": answerability, "raw_scores": scores, "answerability_logit": answerability_logit} @@ -116,25 +129,29 @@ class DirectSelector: self.provenance = {"backend": "direct", "model_manifest_sha256": expected_digest, "tokenizer_sha256": file_hash(manifest.parent / "tokenizer/tokenizer.json"), "ort_version": ort.__version__, "provider": "CPUExecutionProvider", - "calibration": "none; historical default thresholds 0.55/0.5", + "calibration": "none; candidate-normalized 0.55/k confidence and 0.5 answerability", "threads": 1, "sequence_padding": "longest candidate input", - "candidate_padding": "live", "input_budget_tokens": 512} + "candidate_padding": "live", "input_budget_tokens": MAX_PROMPT_TOKENS, + "context_adapter": "vons.mind2web-context/v1", "adapted": True, + "max_candidate_tokens": MAX_CANDIDATE_TOKENS, + "history_window": MAX_HISTORY_ACTIONS} def __call__(self, request: dict[str, Any]) -> dict[str, Any]: np = self.np - candidates = request["candidates"] + inference_request, compression = compress_request(request, self.tokenizer) + candidates = inference_request["candidates"] if not 2 <= len(candidates) <= 32: raise ValueError("candidate_count_outside_2_32") - prefix = f'{request["state"]}\nQuestion: {request["question"]}' + prefix = f'{inference_request["state"]}\nQuestion: {inference_request["question"]}' all_text = prefix + "\nCandidates:\n" + "\n".join(item["text"] for item in candidates) token_count = len(self.tokenizer.encode(all_text).ids) - if token_count > 512: + if token_count > MAX_PROMPT_TOKENS: return {"selection": None, "status": "error", "reason": "input_overflow", "question_tokens": token_count} encoded = [self.tokenizer.encode(prefix + "\nCandidate: " + item["text"]) for item in candidates] length = max(len(item.ids) for item in encoded) - if length > 512: + if length > MAX_PROMPT_TOKENS: return {"selection": None, "status": "error", "reason": "candidate_input_overflow", "question_tokens": token_count} ids = np.full((1, len(candidates), length), self.tokenizer.token_to_id("[PAD]"), dtype=np.int64) @@ -153,6 +170,8 @@ class DirectSelector: result = decode(scores[0].tolist(), float(answerability[0]), [item["id"] for item in candidates]) result.update(question_tokens=token_count, + compression=asdict(compression), + inference_request_sha256=object_hash(inference_request), input_array_sha256=object_hash({key: value.tolist() for key, value in feed.items()})) return result @@ -167,8 +186,10 @@ def predict_file(source: Path, output: Path, *, split: str, k: int, seen: set[str] = set() counts: Counter[str] = Counter() source_digest = file_hash(source) - config = {"split": split, "k": k, "provenance": provenance, "adapted": False, - "question": QUESTION, "input_overflow": "preserve error; no truncation"} + config = {"split": split, "k": k, "provenance": provenance, + "adapted": bool(provenance.get("adapted", False)), + "question": QUESTION, + "input_overflow": "exact tokenizer hard cap at 512 after label-free compression"} config_digest = object_hash(config) with source.open() as handle, partial.open("x") as destination: for line in handle: diff --git a/tools/prepare_public_release.py b/tools/prepare_public_release.py index f5794e54ec16e7da737e33623b326e47243e68be..6e0f569ff12aef991d3d456a9d2b3517c8d428e8 100644 --- a/tools/prepare_public_release.py +++ b/tools/prepare_public_release.py @@ -20,7 +20,7 @@ DENIED_PARTS = { "artifacts", "reports", "research", "private", "restricted", "models", "weights", "checkpoints", "releases", ".aws", ".ssh", ".cache", } -TEXT_SUFFIXES = {".py", ".ts", ".mjs", ".md", ".json", ".toml", ".yml", ".cff", ".html"} +TEXT_SUFFIXES = {".py", ".ts", ".mjs", ".md", ".json", ".toml", ".yml", ".cff", ".html", ".css"} TEXT_NAMES = {".gitignore", ".gitattributes", "LICENSE", "NOTICE"} PATTERNS = { "private-key": re.compile(r"-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----"), diff --git a/tools/replay_mind2web_evaluation.py b/tools/replay_mind2web_evaluation.py index 81c8deb7fa85f9e45017c40c86c0c239f9ec79fc..e8a8ece9bbc5272e82ac5d2e244320ec90250452 100644 --- a/tools/replay_mind2web_evaluation.py +++ b/tools/replay_mind2web_evaluation.py @@ -30,6 +30,7 @@ KS = (5, 10, 20, 32) CELLS = tuple((split, k) for split in SPLITS for k in KS) SOURCE_FILES = ( "vons/mind2web.py", + "vons/mind2web_adapter.py", "tools/evaluate_mind2web.py", "tools/predict_mind2web.py", "tools/replay_mind2web_evaluation.py", diff --git a/vons/calibration.py b/vons/calibration.py index 24837ec344bb0eeaa4ec8f5fea54c5da002d4783..f49914f397e469867b9557be5fe209e4b4db8d39 100644 --- a/vons/calibration.py +++ b/vons/calibration.py @@ -1,9 +1,10 @@ """Post-hoc probability and abstention calibration for saved Vons reports. -Calibration contract ``vons.calibration/v2``: +Calibration contract ``vons.calibration/v3``: -- Probability vectors must be finite, non-negative, and normalized. Options - with true zero probability stay at zero under temperature scaling. +- Probability vectors must be finite, non-negative, and normalized. Vector + scaling fits one bounded temperature and bias per class; options with true + zero probability stay at zero. - Saved predictions follow the producer contract ``confidence = max_probability * answerability``. The answerability factor is reconstructed only when ``0 <= confidence <= max_probability`` (within @@ -12,10 +13,10 @@ Calibration contract ``vons.calibration/v2``: probability vector, and its answerability meets the configured threshold (report config ``answerability_threshold``, default 0.5). Ground-truth labels never gate eligibility; they are used only to measure fitting risk. -- An eligible prediction is covered when its calibrated confidence meets the - abstention threshold; its choice is then the argmax of the calibrated - vector. Every other prediction abstains with ``choice=None``, and a failed - prediction keeps its error. +- The default report pipeline derives its abstention threshold from calibrated + multiclass Brier losses. An eligible prediction is covered when its + calibrated confidence meets that fitted threshold; every other prediction + abstains with ``choice=None``, and a failed prediction keeps its error. - ``ABSTAIN_ALL_THRESHOLD`` (2.0) is the documented sentinel for "abstain on every prediction". Confidences are validated in [0, 1], so the sentinel covers nothing, including wrong predictions with confidence 1.0. @@ -40,7 +41,7 @@ from .evaluation import ( validate_predictions, ) -CALIBRATION_VERSION = "vons.calibration/v2" +CALIBRATION_VERSION = "vons.calibration/v3" ABSTAIN_ALL_THRESHOLD = 2.0 DEFAULT_ANSWERABILITY_THRESHOLD = 0.5 CONFIDENCE_FACTOR_TOLERANCE = 1e-6 @@ -60,7 +61,7 @@ class CalibrationFit: temperature: float abstention_threshold: float - target_risk: float + target_risk: float | None rows: int nll_before: float | None nll_after: float | None @@ -68,12 +69,21 @@ class CalibrationFit: threshold_fit_rows: int = 0 threshold_covered_rows: int = 0 threshold_risk: float | None = None - temperature_lower_bound: float = 0.05 - temperature_upper_bound: float = 20.0 + temperature_lower_bound: float = 0.1 + temperature_upper_bound: float = 10.0 temperature_at_lower_bound: bool = False temperature_at_upper_bound: bool = False abstain_all: bool = False answerability_threshold: float = DEFAULT_ANSWERABILITY_THRESHOLD + calibration_method: str = "vector_scaling" + temperatures: Mapping[str, float] | None = None + biases: Mapping[str, float] | None = None + log_temperature_l2: float = 0.01 + brier_before: float | None = None + brier_after: float | None = None + target_brier: float | None = None + threshold_brier: float | None = None + threshold_objective: str = "calibrated_multiclass_brier" version: str = CALIBRATION_VERSION @@ -85,6 +95,21 @@ class TemperatureFit: upper: float at_lower_bound: bool at_upper_bound: bool + log_temperature_l2: float = 0.01 + + +@dataclass(frozen=True) +class VectorScalingFit: + temperatures: Mapping[str, float] + biases: Mapping[str, float] + rows: int + lower: float + upper: float + log_temperature_l2: float + nll_before: float | None + nll_after: float | None + at_lower_bound: bool + at_upper_bound: bool @dataclass(frozen=True) @@ -96,6 +121,16 @@ class ThresholdFit: abstain_all: bool +@dataclass(frozen=True) +class BrierThresholdFit: + threshold: float + rows: int + covered_rows: int + target_brier: float | None + covered_brier: float | None + abstain_all: bool + + @dataclass(frozen=True) class _Decision: probabilities: Mapping[str, float] @@ -140,6 +175,55 @@ def _scaled_probabilities(probabilities: Mapping[str, float], temperature: float return {option: weights[option] / total if option in weights else 0.0 for option in values} +def _validate_vector_parameters( + temperatures: Mapping[str, float], + biases: Mapping[str, float], +) -> tuple[dict[str, float], dict[str, float]]: + if set(temperatures) != set(biases): + raise ValueError("vector scaling temperatures and biases must use identical classes") + validated_temperatures = { + str(option): _validate_temperature(value) for option, value in temperatures.items() + } + validated_biases: dict[str, float] = {} + for option, value in biases.items(): + number = float(value) + if not math.isfinite(number): + raise ValueError("vector scaling biases must be finite") + validated_biases[str(option)] = number + return validated_temperatures, validated_biases + + +def _vector_scaled_probabilities( + probabilities: Mapping[str, float], + temperatures: Mapping[str, float], + biases: Mapping[str, float], +) -> dict[str, float]: + """Apply diagonal vector scaling to a probability vector. + + Input probabilities are treated as logits in log space. Structural zeros + remain zero so calibration cannot invent support for a class the producer + declared impossible. + """ + values = validate_distribution(probabilities) + if not values: + return {} + validated_temperatures, validated_biases = _validate_vector_parameters( + temperatures, biases + ) + missing = set(values) - set(validated_temperatures) + if missing: + raise ValueError(f"vector scaling parameters are missing classes: {sorted(missing)}") + logits = { + option: math.log(value) / validated_temperatures[option] + validated_biases[option] + for option, value in values.items() + if value > 0.0 + } + pivot = max(logits.values()) + weights = {option: math.exp(value - pivot) for option, value in logits.items()} + total = math.fsum(weights.values()) + return {option: weights.get(option, 0.0) / total for option in values} + + def _argmax(probabilities: Mapping[str, float], options: Sequence[str]) -> str: best = max(probabilities.get(option, 0.0) for option in options) return next(option for option in options if probabilities.get(option, 0.0) == best) @@ -169,6 +253,26 @@ def _decide(prediction: Prediction, row: Example, *, temperature: float, answera return _Decision(calibrated, confidence, _argmax(calibrated, row.options), eligible) +def _decide_vector( + prediction: Prediction, + row: Example, + *, + temperatures: Mapping[str, float], + biases: Mapping[str, float], + answerability_threshold: float, +) -> _Decision: + if prediction.error is not None: + return _Decision(prediction.probabilities, float(prediction.confidence), None, False) + distribution = validate_distribution(prediction.probabilities, row.options) + if not distribution: + return _Decision({}, float(prediction.confidence), None, False) + factor = _answerability_factor(prediction, distribution) + calibrated = _vector_scaled_probabilities(distribution, temperatures, biases) + confidence = min(1.0, max(0.0, factor * max(calibrated.values()))) + eligible = factor + DECISION_EPSILON >= answerability_threshold + return _Decision(calibrated, confidence, _argmax(calibrated, row.options), eligible) + + def _is_covered(decision: _Decision, threshold: float) -> bool: return decision.eligible and decision.confidence + DECISION_EPSILON >= threshold @@ -200,24 +304,197 @@ def _nll_at(usable: Sequence[tuple[Example, Mapping[str, float]]], temperature: return _mean_nll(usable, temperature) if usable else None +def _mean_vector_nll( + usable: Sequence[tuple[Example, Mapping[str, float]]], + temperatures: Mapping[str, float], + biases: Mapping[str, float], +) -> float: + return math.fsum( + -math.log( + max( + _vector_scaled_probabilities(distribution, temperatures, biases).get( + str(row.label), 0.0 + ), + NLL_PROBABILITY_FLOOR, + ) + ) + for row, distribution in usable + ) / len(usable) + + +def _mean_vector_brier( + usable: Sequence[tuple[Example, Mapping[str, float]]], + temperatures: Mapping[str, float], + biases: Mapping[str, float], +) -> float: + return math.fsum( + math.fsum( + ( + _vector_scaled_probabilities(distribution, temperatures, biases).get(option, 0.0) + - float(option == row.label) + ) + ** 2 + for option in row.options + ) + for row, distribution in usable + ) / len(usable) + + +def _bounded_minimum( + objective: Any, + lower: float, + upper: float, + iterations: int, +) -> float: + left, right = lower, upper + golden = (math.sqrt(5.0) - 1.0) / 2.0 + first = right - golden * (right - left) + second = left + golden * (right - left) + first_value, second_value = objective(first), objective(second) + for _ in range(max(1, iterations)): + if first_value <= second_value: + right, second, second_value = second, first, first_value + first = right - golden * (right - left) + first_value = objective(first) + else: + left, first, first_value = first, second, second_value + second = left + golden * (right - left) + second_value = objective(second) + return (left + right) / 2.0 + + +def fit_vector_scaling_details( + examples: Sequence[Example], + predictions: Sequence[Prediction], + *, + lower: float = 0.1, + upper: float = 10.0, + log_temperature_l2: float = 0.01, + passes: int = 12, + iterations: int = 32, +) -> VectorScalingFit: + """Fit per-class temperature and bias parameters by coordinate descent.""" + if not (math.isfinite(lower) and math.isfinite(upper)) or lower <= 0 or upper <= lower: + raise ValueError("temperature bounds must satisfy 0 < lower < upper") + if not math.isfinite(log_temperature_l2) or log_temperature_l2 < 0: + raise ValueError("log_temperature_l2 must be finite and non-negative") + if passes < 1 or iterations < 1: + raise ValueError("passes and iterations must be positive") + rows, lookup = validate_predictions(examples, predictions) + usable = _temperature_rows(rows, lookup) + classes = sorted({option for row, _ in usable for option in row.options}) + if not usable or not classes: + return VectorScalingFit( + temperatures={}, + biases={}, + rows=0, + lower=lower, + upper=upper, + log_temperature_l2=log_temperature_l2, + nll_before=None, + nll_after=None, + at_lower_bound=False, + at_upper_bound=False, + ) + + log_temperatures = {option: 0.0 for option in classes} + biases = {option: 0.0 for option in classes} + log_lower, log_upper = math.log(lower), math.log(upper) + + def parameters() -> dict[str, float]: + return {option: math.exp(log_temperatures[option]) for option in classes} + + def objective() -> float: + nll_value = _mean_vector_nll(usable, parameters(), biases) + temperature_penalty = math.fsum(value * value for value in log_temperatures.values()) + bias_penalty = math.fsum(value * value for value in biases.values()) + return nll_value + log_temperature_l2 * ( + temperature_penalty / len(classes) + 0.1 * bias_penalty / len(classes) + ) + + previous = objective() + for _ in range(passes): + for option in classes: + original = log_temperatures[option] + + def temperature_objective( + value: float, _option: str = option, _original: float = original + ) -> float: + log_temperatures[_option] = value + result = objective() + log_temperatures[_option] = _original + return result + + candidate = _bounded_minimum( + temperature_objective, log_lower, log_upper, iterations + ) + log_temperatures[option] = candidate + for option in classes: + original = biases[option] + + def bias_objective( + value: float, + _option: str = option, + _original: float = original, + _biases: dict[str, float] = biases, + ) -> float: + _biases[_option] = value + result = objective() + _biases[_option] = _original + return result + + biases[option] = _bounded_minimum(bias_objective, -4.0, 4.0, iterations) + # A common bias offset is unidentifiable under softmax. Centering keeps + # the saved parameters stable without changing calibrated outputs. + mean_bias = math.fsum(biases.values()) / len(biases) + biases = {option: value - mean_bias for option, value in biases.items()} + current = objective() + if previous - current <= 1e-10: + break + previous = current + + fitted_temperatures = parameters() + return VectorScalingFit( + temperatures=fitted_temperatures, + biases=biases, + rows=len(usable), + lower=lower, + upper=upper, + log_temperature_l2=log_temperature_l2, + nll_before=_mean_vector_nll( + usable, + {option: 1.0 for option in classes}, + {option: 0.0 for option in classes}, + ), + nll_after=_mean_vector_nll(usable, fitted_temperatures, biases), + at_lower_bound=any(value - lower <= BOUND_TOLERANCE for value in fitted_temperatures.values()), + at_upper_bound=any(upper - value <= BOUND_TOLERANCE for value in fitted_temperatures.values()), + ) + + def fit_temperature_details( examples: Sequence[Example], predictions: Sequence[Prediction], *, - lower: float = 0.05, - upper: float = 20.0, + lower: float = 0.1, + upper: float = 10.0, + log_temperature_l2: float = 0.01, iterations: int = 80, ) -> TemperatureFit: - """Fit a scalar temperature by deterministic golden-section search on log T.""" + """Fit a regularized scalar temperature for backwards-compatible callers.""" if not (math.isfinite(lower) and math.isfinite(upper)) or lower <= 0 or upper <= lower: raise ValueError("temperature bounds must satisfy 0 < lower < upper") + if not math.isfinite(log_temperature_l2) or log_temperature_l2 < 0: + raise ValueError("log_temperature_l2 must be finite and non-negative") rows, lookup = validate_predictions(examples, predictions) usable = _temperature_rows(rows, lookup) if not usable: - return TemperatureFit(1.0, 0, lower, upper, False, False) + return TemperatureFit(1.0, 0, lower, upper, False, False, log_temperature_l2) def objective(log_temperature: float) -> float: - return _mean_nll(usable, math.exp(log_temperature)) + return _mean_nll(usable, math.exp(log_temperature)) + log_temperature_l2 * ( + log_temperature**2 + ) left, right = math.log(lower), math.log(upper) golden = (math.sqrt(5.0) - 1.0) / 2.0 @@ -241,6 +518,7 @@ def fit_temperature_details( upper=upper, at_lower_bound=log_temperature - math.log(lower) <= BOUND_TOLERANCE, at_upper_bound=math.log(upper) - log_temperature <= BOUND_TOLERANCE, + log_temperature_l2=log_temperature_l2, ) @@ -248,12 +526,20 @@ def fit_temperature( examples: Sequence[Example], predictions: Sequence[Prediction], *, - lower: float = 0.05, - upper: float = 20.0, + lower: float = 0.1, + upper: float = 10.0, + log_temperature_l2: float = 0.01, iterations: int = 80, ) -> float: """Return the fitted temperature; see ``fit_temperature_details`` for bound flags.""" - return fit_temperature_details(examples, predictions, lower=lower, upper=upper, iterations=iterations).temperature + return fit_temperature_details( + examples, + predictions, + lower=lower, + upper=upper, + log_temperature_l2=log_temperature_l2, + iterations=iterations, + ).temperature def fit_abstention_threshold_details( @@ -354,6 +640,144 @@ def apply_calibration( return calibrated +def fit_brier_abstention_threshold_details( + examples: Sequence[Example], + predictions: Sequence[Prediction], + *, + temperatures: Mapping[str, float], + biases: Mapping[str, float], + target_brier: float | None = None, + answerability_threshold: float = DEFAULT_ANSWERABILITY_THRESHOLD, +) -> BrierThresholdFit: + """Fit the widest-coverage threshold meeting a calibrated Brier target. + + When no target is supplied, the mean calibrated answerable-row Brier + score becomes the data-derived target. This selects the widest confidence + region whose aggregate calibration loss is no worse than the fitted + answerable population instead of discarding the higher-loss half by + construction. Unanswerable rows receive the + maximum unit penalty when covered so the threshold does not learn to accept + unsupported decisions merely because they have a sharp distribution. + """ + validated_temperatures, validated_biases = _validate_vector_parameters( + temperatures, biases + ) + _validate_unit_interval(answerability_threshold, "answerability_threshold") + rows, lookup = validate_predictions(examples, predictions) + decisions = [ + ( + rows[example_id], + _decide_vector( + item, + rows[example_id], + temperatures=validated_temperatures, + biases=validated_biases, + answerability_threshold=answerability_threshold, + ), + ) + for example_id, item in lookup.items() + ] + + def row_brier(row: Example, decision: _Decision) -> float: + if not row.answerable or row.label is None: + return 1.0 + return math.fsum( + (decision.probabilities.get(option, 0.0) - float(option == row.label)) ** 2 + for option in row.options + ) + + answerable_scores = [ + row_brier(row, decision) + for row, decision in decisions + if decision.eligible and row.answerable and row.label is not None + ] + if target_brier is None: + resolved_target = ( + math.fsum(answerable_scores) / len(answerable_scores) + if answerable_scores + else None + ) + else: + resolved_target = float(target_brier) + if not math.isfinite(resolved_target) or not 0.0 <= resolved_target <= 2.0: + raise ValueError("target_brier must be finite and in [0, 2]") + if resolved_target is None: + return BrierThresholdFit( + ABSTAIN_ALL_THRESHOLD, len(decisions), 0, None, None, True + ) + + eligible = [(row, decision) for row, decision in decisions if decision.eligible] + best: tuple[int, float, float] | None = None + for threshold in sorted({0.0, *(decision.confidence for _, decision in eligible)}): + covered = [ + (row, decision) + for row, decision in eligible + if _is_covered(decision, threshold) + ] + if not covered: + continue + mean_brier = math.fsum(row_brier(row, decision) for row, decision in covered) / len( + covered + ) + if mean_brier <= resolved_target + DECISION_EPSILON and ( + best is None or len(covered) > best[0] + ): + best = (len(covered), threshold, mean_brier) + if best is None: + return BrierThresholdFit( + ABSTAIN_ALL_THRESHOLD, + len(decisions), + 0, + resolved_target, + None, + True, + ) + return BrierThresholdFit( + best[1], len(decisions), best[0], resolved_target, best[2], False + ) + + +def apply_vector_calibration( + examples: Sequence[Example], + predictions: Sequence[Prediction], + *, + temperatures: Mapping[str, float], + biases: Mapping[str, float], + abstention_threshold: float, + answerability_threshold: float = DEFAULT_ANSWERABILITY_THRESHOLD, +) -> list[Prediction]: + """Apply vector scaling and the fitted dynamic abstention threshold.""" + validated_temperatures, validated_biases = _validate_vector_parameters( + temperatures, biases + ) + threshold = _validate_abstention_threshold(abstention_threshold) + _validate_unit_interval(answerability_threshold, "answerability_threshold") + rows, _lookup = validate_predictions(examples, predictions) + calibrated: list[Prediction] = [] + for prediction in predictions: + if prediction.error is not None: + calibrated.append(replace(prediction, choice=None, abstained=True)) + continue + decision = _decide_vector( + prediction, + rows[prediction.example_id], + temperatures=validated_temperatures, + biases=validated_biases, + answerability_threshold=answerability_threshold, + ) + covered = _is_covered(decision, threshold) + calibrated.append( + replace( + prediction, + choice=decision.choice if covered else None, + probabilities=dict(decision.probabilities), + confidence=decision.confidence, + abstained=not covered, + ) + ) + return calibrated + + def _read_report(path: str | Path) -> tuple[dict[str, Any], list[Prediction]]: payload = json.loads(Path(path).read_text(encoding="utf-8")) if not isinstance(payload, Mapping): @@ -419,7 +843,8 @@ def calibrate_report( test_input: str | Path, test_report: str | Path, output: str | Path, - target_risk: float = 0.05, + target_risk: float | None = None, + target_brier: float | None = None, ) -> Path: """Fit on calibration rows and write a calibrated test report as strict JSON.""" inputs = { @@ -437,40 +862,70 @@ def calibrate_report( test_config, test_predictions = _read_report(test_report) identity = _model_identity(calibration_config, test_config) answerability_threshold = _answerability_threshold(calibration_config, test_config) - - temperature_fit = fit_temperature_details(calibration_examples, calibration_predictions) - threshold_fit = fit_abstention_threshold_details( + if target_risk is not None and target_brier is not None: + raise ValueError("specify target_brier or legacy target_risk, not both") + resolved_target_brier = target_brier if target_brier is not None else target_risk + + vector_fit = fit_vector_scaling_details(calibration_examples, calibration_predictions) + if vector_fit.temperatures: + temperatures = dict(vector_fit.temperatures) + biases = dict(vector_fit.biases) + else: + classes = sorted({option for row in calibration_examples for option in row.options}) + temperatures = {option: 1.0 for option in classes} + biases = {option: 0.0 for option in classes} + threshold_fit = fit_brier_abstention_threshold_details( calibration_examples, calibration_predictions, - target_risk=target_risk, - temperature=temperature_fit.temperature, + temperatures=temperatures, + biases=biases, + target_brier=resolved_target_brier, answerability_threshold=answerability_threshold, ) - calibrated_test = apply_calibration( + calibrated_test = apply_vector_calibration( test_examples, test_predictions, - temperature=temperature_fit.temperature, + temperatures=temperatures, + biases=biases, abstention_threshold=threshold_fit.threshold, answerability_threshold=answerability_threshold, ) usable = _temperature_rows(*validate_predictions(calibration_examples, calibration_predictions)) + identity_temperatures = {option: 1.0 for option in temperatures} + identity_biases = {option: 0.0 for option in temperatures} + geometric_temperature = math.exp( + math.fsum(math.log(value) for value in temperatures.values()) / len(temperatures) + ) fit = CalibrationFit( - temperature=temperature_fit.temperature, + temperature=geometric_temperature, abstention_threshold=threshold_fit.threshold, - target_risk=target_risk, + target_risk=None, rows=len(calibration_examples), - nll_before=_nll_at(usable, 1.0), - nll_after=_nll_at(usable, temperature_fit.temperature), - temperature_fit_rows=temperature_fit.rows, + nll_before=vector_fit.nll_before, + nll_after=vector_fit.nll_after, + temperature_fit_rows=vector_fit.rows, threshold_fit_rows=threshold_fit.rows, threshold_covered_rows=threshold_fit.covered_rows, - threshold_risk=threshold_fit.risk, - temperature_lower_bound=temperature_fit.lower, - temperature_upper_bound=temperature_fit.upper, - temperature_at_lower_bound=temperature_fit.at_lower_bound, - temperature_at_upper_bound=temperature_fit.at_upper_bound, + threshold_risk=None, + temperature_lower_bound=vector_fit.lower, + temperature_upper_bound=vector_fit.upper, + temperature_at_lower_bound=vector_fit.at_lower_bound, + temperature_at_upper_bound=vector_fit.at_upper_bound, abstain_all=threshold_fit.abstain_all, answerability_threshold=answerability_threshold, + temperatures=temperatures, + biases=biases, + log_temperature_l2=vector_fit.log_temperature_l2, + brier_before=( + _mean_vector_brier(usable, identity_temperatures, identity_biases) + if usable + else None + ), + brier_after=( + _mean_vector_brier(usable, temperatures, biases) if usable else None + ), + target_brier=threshold_fit.target_brier, + threshold_brier=threshold_fit.covered_brier, ) payload = json.dumps( { diff --git a/vons/cli.py b/vons/cli.py index 3c4af15a5d7bb2c30b20059a3a77098f0290dd80..674d38b7da02cfbe9d91052710e989fc2d1ae9b7 100644 --- a/vons/cli.py +++ b/vons/cli.py @@ -21,12 +21,13 @@ def _parser() -> argparse.ArgumentParser: command = sub.add_parser("generate-smoke"); command.add_argument("--output", required=True) command = sub.add_parser("generate-synthetic"); command.add_argument("--count", type=int, default=2000); command.add_argument("--seed", type=int, default=7); command.add_argument("--output", required=True) command = sub.add_parser("validate-data"); command.add_argument("--input", required=True); command.add_argument("--manifest") + command = sub.add_parser("split-data"); command.add_argument("--input", required=True); command.add_argument("--split", choices=["train", "development", "calibration", "test", "smoke"], required=True); command.add_argument("--output", required=True) command = sub.add_parser("ollama-check"); command.add_argument("--models", nargs="+", required=True); command.add_argument("--host", default="http://127.0.0.1:11434"); command.add_argument("--output") command = sub.add_parser("ollama-benchmark"); command.add_argument("--model", required=True); command.add_argument("--input", required=True); command.add_argument("--role", default="judge"); command.add_argument("--limit", type=int, default=200); command.add_argument("--seed", type=int, default=7); command.add_argument("--host", default="http://127.0.0.1:11434"); command.add_argument("--output", required=True) command = sub.add_parser("build-research-packet"); command.add_argument("--results", required=True); command.add_argument("--output", required=True) command = sub.add_parser("build-bundle-manifest"); command.add_argument("--onnx", required=True); command.add_argument("--tokenizer", required=True); command.add_argument("--output", required=True); command.add_argument("--checkpoint"); command.add_argument("--model-manifest"); command.add_argument("--calibration", action="append", default=[]); command.add_argument("--runtime-asset", action="append", default=[]); command.add_argument("--license", action="append", default=[]); command.add_argument("--config", action="append", default=[]); command.add_argument("--source-root"); command.add_argument("--source-file", action="append", default=[]) command = sub.add_parser("verify-bundle-manifest"); command.add_argument("--manifest", required=True) - command = sub.add_parser("calibrate"); command.add_argument("--calibration-input", required=True); command.add_argument("--calibration-report", required=True); command.add_argument("--test-input", required=True); command.add_argument("--test-report", required=True); command.add_argument("--output", required=True); command.add_argument("--target-risk", type=float, default=0.05) + command = sub.add_parser("calibrate"); command.add_argument("--calibration-input", required=True); command.add_argument("--calibration-report", required=True); command.add_argument("--test-input", required=True); command.add_argument("--test-report", required=True); command.add_argument("--output", required=True); command.add_argument("--target-brier", type=float); command.add_argument("--target-risk", type=float) for name in ("train", "evaluate", "export", "export-bundle", "export-diffusion-bundle"): command = sub.add_parser(name); command.add_argument("--config"); command.add_argument("--model"); command.add_argument("--input"); command.add_argument("--checkpoint"); command.add_argument("--output") return parser @@ -43,6 +44,12 @@ def main(argv: list[str] | None = None) -> int: if args.manifest: Path(args.manifest).parent.mkdir(parents=True, exist_ok=True); Path(args.manifest).write_text(json.dumps(manifest, indent=2, sort_keys=True), encoding="utf-8") print(json.dumps(manifest, indent=2, sort_keys=True)); return 0 + if args.command == "split-data": + rows = [row for row in read_jsonl(args.input) if row.split == args.split] + if not rows: + raise SystemExit(f"input has no {args.split!r} rows") + write_jsonl(args.output, rows) + print(json.dumps({"output": args.output, "rows": len(rows), "split": args.split}, indent=2)); return 0 if args.command == "ollama-check": client, payload = OllamaClient(args.host), {"host": args.host, "platform": platform.platform(), "models": []} for model in args.models: @@ -85,6 +92,7 @@ def main(argv: list[str] | None = None) -> int: test_report=args.test_report, output=args.output, target_risk=args.target_risk, + target_brier=args.target_brier, ) print(json.dumps({"report": str(output)}, indent=2)); return 0 if args.command == "train": diff --git a/vons/data.py b/vons/data.py index 623d6aac879888de434fffcd39c58683411413ed..eda701f103bf5e8b1dde444972c42a6d59ae554e 100644 --- a/vons/data.py +++ b/vons/data.py @@ -5,6 +5,7 @@ from __future__ import annotations import hashlib import json import random +from collections import Counter from collections.abc import Iterable, Mapping from dataclasses import dataclass from pathlib import Path @@ -108,9 +109,13 @@ def dataset_manifest(path: str | Path, examples: Iterable[Example]) -> dict[str, counts: dict[str, int] = {} for row in rows: counts[row.split] = counts.get(row.split, 0) + 1 + labels = Counter(row.label for row in rows if row.label is not None) return { "path": str(path), "sha256": hashlib.sha256(encoded).hexdigest(), "rows": len(rows), - "splits": counts, "task_groups": sorted({row.task_group for row in rows}), + "splits": counts, + "labels": dict(sorted(labels.items())), + "unanswerable_rows": sum(not row.answerable for row in rows), + "task_groups": sorted({row.task_group for row in rows}), } @@ -130,21 +135,91 @@ def synthetic_examples(count: int, *, seed: int = 7) -> list[Example]: raise ValueError("count must be positive") rng = random.Random(seed) examples: list[Example] = [] - options = ("call_tool", "clarify", "refuse", "respond_directly") + actions = ("call_tool", "clarify", "refuse", "respond_directly") + templates = { + "call_tool": ( + ( + "A registered read-only tool exactly matches the request, every required parameter is " + "present, and policy permits the call." + ), + "exact_safe_tool_match", + "low", + ), + "clarify": ( + ( + "The request has two plausible interpretations and the required target parameter is " + "missing, so choosing a tool or direct answer would guess." + ), + "ambiguous_or_missing_parameter", + "low", + ), + "refuse": ( + ( + "The request asks to expose credentials or bypass authorization, and the explicit safety " + "rule prohibits that action." + ), + "prohibited_or_unauthorized_request", + "high", + ), + "respond_directly": ( + ( + "The verified answer is already present in the supplied state, no external information is " + "needed, and no tool should be called." + ), + "answer_available_without_tool", + "low", + ), + } + label_index = 0 for index in range(count): scenario_id = f"synthetic-{index:06d}" - answerable = index % 11 != 0 + # Preserve an answerability signal without letting missing-label rows + # distort the four-class distribution among answerable examples. + answerable = index % 13 != 0 if answerable: - reason = rng.choice(("the requested data is available", "all required fields are present", "the current state is sufficient")) - state = f"{reason.capitalize()}; the user request is routine." + label = actions[label_index % len(actions)] + label_index += 1 + rule_text, rule, risk = templates[label] + context = rng.choice( + ( + "The host must choose the next action.", + "Only the explicit decision rule may be used.", + "Tool execution remains controlled by the host.", + ) + ) + state = f"Rule: {rule_text} Context: {context}" question = rng.choice(("Which action should the agent take next?", "Choose the best next action.", "What should happen now?")) - label = "call_tool" else: - state = "The state omits a required value and the candidate actions conflict." + state = ( + "The supplied state is internally inconsistent and omits the evidence needed to decide " + "whether any candidate is safe. The correct behavior is to abstain rather than invent a label." + ) question = "What should the agent do next?" label = None + rule = "insufficient_or_conflicting_state" + risk = "unknown" + shuffled_options = list(actions) + rng.shuffle(shuffled_options) split = "train" if index % 10 < 7 else "development" if index % 10 < 8 else "calibration" if index % 10 < 9 else "test" - examples.append(Example(f"{scenario_id}-v0", "next_action", state, question, options, label, answerable, split, {"kind": "synthetic_rule", "generator": "vons.data.synthetic_examples", "seed": seed}, {"scenario_id": scenario_id, "risk": "low"})) + examples.append( + Example( + f"{scenario_id}-v1", + "next_action", + state, + question, + tuple(shuffled_options), + label, + answerable, + split, + { + "kind": "synthetic_rule", + "generator": "vons.data.synthetic_examples", + "generator_version": 1, + "rule": rule, + "seed": seed, + }, + {"scenario_id": scenario_id, "risk": risk}, + ) + ) validate_examples(examples) return examples - diff --git a/vons/inference.py b/vons/inference.py new file mode 100644 index 0000000000000000000000000000000000000000..3b05b38d2422d8e99fff67cf49552caf46216b8d --- /dev/null +++ b/vons/inference.py @@ -0,0 +1,287 @@ +"""Runtime inference helpers for Direct and Diffusion decision backends. + +This module owns the per-request tensor-preparation contract: tokenize each +candidate, measure the longest live tokenized sequence, and pad tensors to +that length (bounded at the manifest budget, usually 512). The exported ONNX +graphs declare dynamic ``options`` and ``sequence_length`` axes so the same +weight file can run with either fixed or variable-length feeds. +""" + +from __future__ import annotations + +import json +from collections.abc import Mapping, Sequence +from dataclasses import dataclass +from typing import Any + +from .contract import Backend, DecisionRequest, Question + +MAX_SEQUENCE_BUDGET = 512 + + +@dataclass(frozen=True) +class TokenizedCandidate: + """Single candidate after tokenization, before padding.""" + + input_ids: tuple[int, ...] + attention_mask: tuple[int, ...] + token_type_ids: tuple[int, ...] + + @property + def token_count(self) -> int: + return len(self.input_ids) + + +@dataclass(frozen=True) +class PaddedCandidates: + """Per-request tensors padded to the longest live candidate length.""" + + input_ids: Any + attention_mask: Any + token_type_ids: Any + option_mask: Any + live_candidates: int + allocated_candidates: int + live_sequence_length: int + max_sequence_budget: int + + +def serialize_state(state: str | Mapping[str, Any]) -> str: + """Return a canonical string form for the request state.""" + if isinstance(state, str): + return state + return json.dumps(state, sort_keys=True, ensure_ascii=False, allow_nan=False, separators=(",", ":")) + + +def candidate_text(state: str | Mapping[str, Any], question: Question, option: str) -> str: + """Render a single candidate using the same template as the web runtime.""" + return f"{serialize_state(state)}\nQuestion: {question.prompt}\nCandidate: {option}" + + +def candidate_list_text(state: str | Mapping[str, Any], question: Question, options: Sequence[str]) -> str: + """Aggregate template used to sanity-check the token budget.""" + joined = "\n".join(str(option) for option in options) + return f"{serialize_state(state)}\nQuestion: {question.prompt}\nCandidates:\n{joined}" + + +def _require_transformers_tokenizer(tokenizer: Any) -> None: + encode = getattr(tokenizer, "encode", None) + if not callable(encode): + raise TypeError("tokenizer must expose encode()") + if not hasattr(tokenizer, "pad_token_id") or not hasattr(tokenizer, "cls_token_id"): + raise TypeError("tokenizer must expose pad_token_id and cls_token_id") + + +def _encode_one(tokenizer: Any, text: str, max_sequence_budget: int) -> tuple[list[int], list[int], list[int]]: + """Encode a single candidate string with the tokenizer's standard output.""" + result = tokenizer.encode( + text, + add_special_tokens=True, + truncation=True, + max_length=max_sequence_budget, + return_attention_mask=True, + return_token_type_ids=True, + ) + if hasattr(result, "ids"): + ids = list(result.ids) + attention_mask = list(result.attention_mask) + token_type_ids = list(result.token_type_ids) + elif isinstance(result, Mapping): + ids = [int(value) for value in result["input_ids"]] + attention_mask = [int(value) for value in result["attention_mask"]] + token_type_ids = [int(value) for value in result.get("token_type_ids", [0] * len(ids))] + else: + ids = [int(value) for value in result] + attention_mask = [1] * len(ids) + token_type_ids = [0] * len(ids) + if len(ids) != len(attention_mask) or len(ids) != len(token_type_ids): + raise ValueError("tokenizer returned inconsistent input/attention/type lengths") + if any(not isinstance(token, int) or token < 0 for token in ids): + raise ValueError("tokenizer returned an invalid token id") + return ids, attention_mask, token_type_ids + + +def tokenize_candidates( + tokenizer: Any, + state: str | Mapping[str, Any], + question: Question, + options: Sequence[str], + *, + max_sequence_budget: int = MAX_SEQUENCE_BUDGET, +) -> list[TokenizedCandidate]: + """Tokenize each candidate independently. + + The individual candidates are each truncated to ``max_sequence_budget`` so + downstream code can treat an over-length request as a validation error + rather than silently dropping tokens from the middle of a prompt. + """ + if not 1 <= max_sequence_budget <= MAX_SEQUENCE_BUDGET: + raise ValueError(f"max_sequence_budget must be in 1..{MAX_SEQUENCE_BUDGET}") + _require_transformers_tokenizer(tokenizer) + aggregate = tokenizer.encode(candidate_list_text(state, question, options), add_special_tokens=True) + aggregate_tokens = len(aggregate.ids) if hasattr(aggregate, "ids") else len(aggregate) + if aggregate_tokens > max_sequence_budget: + raise ValueError( + f"question {question.id!r} exceeds the {max_sequence_budget}-token aggregate input budget" + f" (tokens={aggregate_tokens})" + ) + out: list[TokenizedCandidate] = [] + for option in options: + ids, attention_mask, token_type_ids = _encode_one( + tokenizer, + candidate_text(state, question, option), + max_sequence_budget, + ) + if len(ids) > max_sequence_budget: + raise ValueError( + f"question {question.id!r} candidate has {len(ids)} tokens;" + f" the bundle limit is {max_sequence_budget}" + ) + out.append(TokenizedCandidate(tuple(ids), tuple(attention_mask), tuple(token_type_ids))) + return out + + +def compute_live_sequence_length( + tokenized: Sequence[TokenizedCandidate], + *, + max_sequence_budget: int = MAX_SEQUENCE_BUDGET, +) -> int: + """Return the longest live candidate length, clamped to the budget. + + An empty candidate set is not valid; callers validate option counts + against the contract before reaching this helper. + """ + if not tokenized: + raise ValueError("at least one tokenized candidate is required") + if not 1 <= max_sequence_budget <= MAX_SEQUENCE_BUDGET: + raise ValueError(f"max_sequence_budget must be in 1..{MAX_SEQUENCE_BUDGET}") + longest = max(candidate.token_count for candidate in tokenized) + if longest < 1: + raise ValueError("each candidate must contain at least one token") + return min(longest, max_sequence_budget) + + +def pad_candidates( + tokenized: Sequence[TokenizedCandidate], + *, + slots: int, + live_sequence_length: int, + padding_id: int, +) -> tuple[list[list[int]], list[list[int]], list[list[int]], list[int]]: + """Pad candidates to ``slots`` x ``live_sequence_length`` using ints. + + The caller owns conversion to backend-specific tensors (torch, numpy, + ort, etc.). Option mask slots beyond ``len(tokenized)`` remain zero so + diffusion and direct heads can treat them as masked-out padding. + """ + if not isinstance(slots, int) or slots < len(tokenized) or slots < 1: + raise ValueError("slots must be at least len(tokenized) and positive") + if not isinstance(live_sequence_length, int) or live_sequence_length < 1: + raise ValueError("live_sequence_length must be positive") + if not isinstance(padding_id, int) or padding_id < 0: + raise ValueError("padding_id must be a non-negative integer") + input_ids: list[list[int]] = [[padding_id] * live_sequence_length for _ in range(slots)] + attention_mask: list[list[int]] = [[0] * live_sequence_length for _ in range(slots)] + token_type_ids: list[list[int]] = [[0] * live_sequence_length for _ in range(slots)] + option_mask: list[int] = [0] * slots + for option_index, candidate in enumerate(tokenized): + option_mask[option_index] = 1 + if candidate.token_count > live_sequence_length: + raise ValueError( + f"candidate {option_index} has {candidate.token_count} tokens;" + f" cannot fit in live_sequence_length={live_sequence_length}" + ) + for token_index in range(candidate.token_count): + input_ids[option_index][token_index] = candidate.input_ids[token_index] + attention_mask[option_index][token_index] = candidate.attention_mask[token_index] + token_type_ids[option_index][token_index] = candidate.token_type_ids[token_index] + return input_ids, attention_mask, token_type_ids, option_mask + + +def resolve_allocated_slots( + backend: Backend, + live_candidates: int, + *, + option_count: int, + direct_option_slots: int | None = None, +) -> int: + """Return the number of candidate slots to allocate for one question. + + * ``diffusion`` always uses ``option_count`` (its noise vector and the + exported head are sized to the full slot budget). + * ``direct`` defaults to the live candidate count when no override is + supplied, otherwise the caller's ``direct_option_slots`` experiment + value, clamped to ``[live_candidates, option_count]``. + """ + if not 2 <= option_count <= 32: + raise ValueError("option_count must be in 2..32 (vons manifest bound)") + if not 1 <= live_candidates <= option_count: + raise ValueError("live_candidates must be in 1..option_count") + if backend is Backend.DIFFUSION: + return option_count + if direct_option_slots is None: + return live_candidates + if not isinstance(direct_option_slots, int): + raise TypeError("direct_option_slots must be an integer or None") + if not live_candidates <= direct_option_slots <= option_count: + raise ValueError( + f"direct_option_slots must be in [{live_candidates}, {option_count}]" + ) + return direct_option_slots + + +def prepare_question_tensors( + tokenizer: Any, + request: DecisionRequest, + question: Question, + *, + option_count: int, + max_sequence_budget: int = MAX_SEQUENCE_BUDGET, + direct_option_slots: int | None = None, +) -> tuple[PaddedCandidates, list[TokenizedCandidate]]: + """Tokenize, measure, and pad a single question. + + Returns the padded container plus the raw tokenized candidates for + callers that need per-option token counts (benchmarks, traces). + """ + if max_sequence_budget > MAX_SEQUENCE_BUDGET: + raise ValueError(f"max_sequence_budget may not exceed {MAX_SEQUENCE_BUDGET}") + options = question.options if question.options else ("true", "false") + if len(options) == 0 or len(options) > option_count: + raise ValueError(f"question {question.id!r} has unsupported candidate count") + tokenized = tokenize_candidates( + tokenizer, + request.state, + question, + options, + max_sequence_budget=max_sequence_budget, + ) + live_candidates = len(tokenized) + live_sequence_length = compute_live_sequence_length( + tokenized, + max_sequence_budget=max_sequence_budget, + ) + slots = resolve_allocated_slots( + request.backend, + live_candidates, + option_count=option_count, + direct_option_slots=direct_option_slots, + ) + padding_id = int(getattr(tokenizer, "pad_token_id", 0) or 0) + input_ids, attention_mask, token_type_ids, option_mask = pad_candidates( + tokenized, + slots=slots, + live_sequence_length=live_sequence_length, + padding_id=padding_id, + ) + padded = PaddedCandidates( + input_ids=input_ids, + attention_mask=attention_mask, + token_type_ids=token_type_ids, + option_mask=option_mask, + live_candidates=live_candidates, + allocated_candidates=slots, + live_sequence_length=live_sequence_length, + max_sequence_budget=max_sequence_budget, + ) + return padded, tokenized diff --git a/vons/mind2web_adapter.py b/vons/mind2web_adapter.py new file mode 100644 index 0000000000000000000000000000000000000000..86de8912de0cfe14e17dbef8e17223951fd6f5ea --- /dev/null +++ b/vons/mind2web_adapter.py @@ -0,0 +1,236 @@ +"""Label-free context compression for offline Mind2Web selection. + +The adapter is deliberately independent of the evaluator and gold labels. It +keeps only the last two interaction-history entries, removes presentation-only +DOM attributes, limits each candidate with the exact runtime tokenizer, and +then reduces candidate/state text until the serialized inference prompt is at +most 512 tokens. +""" + +from __future__ import annotations + +import json +import re +from collections.abc import Mapping, Sequence +from dataclasses import dataclass +from typing import Any, Protocol + +CONTEXT_ADAPTER_VERSION = "vons.mind2web-context/v1" +MAX_HISTORY_ACTIONS = 2 +MAX_CANDIDATE_TOKENS = 15 +MAX_PROMPT_TOKENS = 512 + +_SVG_BLOCK = re.compile(r"]*>.*?", re.IGNORECASE | re.DOTALL) +_STYLE_BLOCK = re.compile(r"]*>.*?", re.IGNORECASE | re.DOTALL) +_ATTRIBUTE = re.compile( + r"(? _Encoding: ... + + def decode(self, ids: Sequence[int], skip_special_tokens: bool = True) -> str: ... + + +@dataclass(frozen=True) +class CompressionStats: + version: str + original_prompt_tokens: int + prompt_tokens: int + candidate_token_budget: int + max_candidate_tokens: int + history_actions_before: int + history_actions_after: int + candidates: int + + +def strip_dom_presentation(text: str) -> str: + """Keep visible text, tag names, and the small semantic attribute allowlist.""" + value = _SVG_BLOCK.sub(" ", text) + value = _STYLE_BLOCK.sub(" ", value) + + def replace_attribute(match: re.Match[str]) -> str: + name = match.group(1).lower() + return match.group(0) if name in _KEPT_ATTRIBUTES else "" + + value = _ATTRIBUTE.sub(replace_attribute, value) + return _WHITESPACE.sub(" ", value).strip() + + +def _token_ids(tokenizer: ExactTokenizer, text: str) -> list[int]: + return list(tokenizer.encode(text).ids) + + +def _decode_prefix(tokenizer: ExactTokenizer, ids: Sequence[int], limit: int) -> str: + if limit <= 0 or not ids: + return "" + prefix = list(ids[:limit]) + value = tokenizer.decode(prefix, skip_special_tokens=True).strip() + while value and len(_token_ids(tokenizer, value)) > limit: + prefix.pop() + value = tokenizer.decode(prefix, skip_special_tokens=True).strip() + return value + + +def _state_mapping(value: object) -> dict[str, object]: + if isinstance(value, str): + parsed = json.loads(value) + else: + parsed = value + if not isinstance(parsed, Mapping): + raise TypeError("Mind2Web state must be a JSON object") + goal = parsed.get("goal", "") + history = parsed.get("previous_actions", []) + if not isinstance(goal, str): + raise TypeError("Mind2Web goal must be a string") + if not isinstance(history, list) or any(not isinstance(item, str) for item in history): + raise TypeError("Mind2Web previous_actions must be a string array") + return {"goal": goal, "previous_actions": history[-MAX_HISTORY_ACTIONS:]} + + +def _canonical(value: object) -> str: + return json.dumps( + value, + ensure_ascii=False, + sort_keys=True, + separators=(",", ":"), + allow_nan=False, + ) + + +def _prompt_text(state: Mapping[str, object], question: str, candidates: Sequence[str]) -> str: + prefix = f"{_canonical(state)}\nQuestion: {question}" + return prefix + "\nCandidates:\n" + "\n".join(candidates) + + +def _truncate_goal_to_fit( + tokenizer: ExactTokenizer, + state: dict[str, object], + question: str, + candidates: Sequence[str], + maximum: int, +) -> dict[str, object]: + candidate_state = {"goal": str(state["goal"]), "previous_actions": []} + if len(_token_ids(tokenizer, _prompt_text(candidate_state, question, candidates))) <= maximum: + return candidate_state + goal_ids = _token_ids(tokenizer, str(state["goal"])) + left, right = 0, len(goal_ids) + best = {"goal": "", "previous_actions": []} + while left <= right: + middle = (left + right) // 2 + trial = { + "goal": _decode_prefix(tokenizer, goal_ids, middle), + "previous_actions": [], + } + if len(_token_ids(tokenizer, _prompt_text(trial, question, candidates))) <= maximum: + best = trial + left = middle + 1 + else: + right = middle - 1 + return best + + +def compress_request( + request: Mapping[str, Any], + tokenizer: ExactTokenizer, + *, + max_prompt_tokens: int = MAX_PROMPT_TOKENS, + max_candidate_tokens: int = MAX_CANDIDATE_TOKENS, +) -> tuple[dict[str, object], CompressionStats]: + """Return an inference request that is guaranteed to fit the hard budget.""" + if max_prompt_tokens <= 0 or max_candidate_tokens < 0: + raise ValueError("token budgets must be positive") + question = request.get("question") + candidates = request.get("candidates") + if not isinstance(question, str) or not isinstance(candidates, list): + raise TypeError("Mind2Web request requires question and candidates") + if any( + not isinstance(item, Mapping) + or not isinstance(item.get("id"), str) + or not isinstance(item.get("text"), str) + for item in candidates + ): + raise TypeError("Mind2Web candidates require string id and text") + + raw_state = _state_mapping(request.get("state")) + raw_history = request.get("state") + if isinstance(raw_history, str): + raw_history = json.loads(raw_history) + history_before = ( + len(raw_history.get("previous_actions", [])) + if isinstance(raw_history, Mapping) + and isinstance(raw_history.get("previous_actions", []), list) + else 0 + ) + raw_texts = [str(item["text"]) for item in candidates] + original_prompt_tokens = len( + _token_ids(tokenizer, _prompt_text(raw_state, question, raw_texts)) + ) + cleaned = [strip_dom_presentation(text) for text in raw_texts] + candidate_ids = [_token_ids(tokenizer, text) for text in cleaned] + + def texts_for_budget(budget: int) -> list[str]: + return [_decode_prefix(tokenizer, ids, budget) for ids in candidate_ids] + + left, right = 0, max_candidate_tokens + selected_budget = 0 + selected_texts = texts_for_budget(0) + while left <= right: + middle = (left + right) // 2 + trial_texts = texts_for_budget(middle) + token_count = len( + _token_ids(tokenizer, _prompt_text(raw_state, question, trial_texts)) + ) + if token_count <= max_prompt_tokens: + selected_budget = middle + selected_texts = trial_texts + left = middle + 1 + else: + right = middle - 1 + + state = raw_state + if len(_token_ids(tokenizer, _prompt_text(state, question, selected_texts))) > max_prompt_tokens: + selected_budget = 0 + selected_texts = texts_for_budget(0) + state = _truncate_goal_to_fit( + tokenizer, + raw_state, + question, + selected_texts, + max_prompt_tokens, + ) + + prompt_tokens = len(_token_ids(tokenizer, _prompt_text(state, question, selected_texts))) + if prompt_tokens > max_prompt_tokens: + raise ValueError("fixed Mind2Web prompt scaffolding exceeds the hard token budget") + compressed_candidates = [ + {"id": str(item["id"]), "text": text} + for item, text in zip(candidates, selected_texts, strict=True) + ] + max_observed_candidate_tokens = max( + (len(_token_ids(tokenizer, text)) for text in selected_texts), + default=0, + ) + compressed = { + "state": _canonical(state), + "question": question, + "candidates": compressed_candidates, + } + stats = CompressionStats( + version=CONTEXT_ADAPTER_VERSION, + original_prompt_tokens=original_prompt_tokens, + prompt_tokens=prompt_tokens, + candidate_token_budget=selected_budget, + max_candidate_tokens=max_observed_candidate_tokens, + history_actions_before=history_before, + history_actions_after=len(state["previous_actions"]), + candidates=len(compressed_candidates), + ) + return compressed, stats diff --git a/vons/models.py b/vons/models.py index 5a64b68150359ad7c563652718ff1cd7311b68fb..38b254a57a41946e65b5628fe8e9113e6c3bbe10 100644 --- a/vons/models.py +++ b/vons/models.py @@ -10,9 +10,11 @@ from typing import Any class ModelConfig: hidden_size: int = 256 latent_size: int = 32 - diffusion_steps: int = 32 - inference_steps: int = 4 + diffusion_steps: int = 64 + inference_steps: int = 8 abstain_threshold: float = 0.55 + diffusion_conditioning: str = "token_cross_attention" + attention_heads: int = 4 def require_torch() -> tuple[Any, Any]: @@ -43,7 +45,7 @@ def build_model(backend: str, *, option_count: int, config: ModelConfig | None = logits = logits.masked_fill(~option_mask.bool(), float("-inf")) return {"logits": logits, "answerability": self.answerability(pooled).squeeze(-1)} - class DiffusionDecision(nn.Module): + class PooledDiffusionDecision(nn.Module): def __init__(self) -> None: super().__init__() self.condition = nn.Linear(settings.hidden_size, settings.latent_size) @@ -56,7 +58,91 @@ def build_model(backend: str, *, option_count: int, config: ModelConfig | None = latent = self.input(noisy_scores) + self.condition(pooled) + self.time(timestep) return {"noise": self.denoiser(latent), "answerability": self.answerability(pooled).squeeze(-1)} - return DirectDecision() if backend == "direct" else DiffusionDecision() + class TokenConditionedDiffusionDecision(nn.Module): + """Denoise each option while attending to its complete token sequence.""" + + def __init__(self) -> None: + super().__init__() + if settings.latent_size % settings.attention_heads: + raise ValueError("latent_size must be divisible by attention_heads") + self.score_projection = nn.Linear(1, settings.latent_size) + self.token_projection = nn.Linear(settings.hidden_size, settings.latent_size) + self.time = nn.Embedding(settings.diffusion_steps, settings.latent_size) + self.cross_attention = nn.MultiheadAttention( + settings.latent_size, + settings.attention_heads, + batch_first=True, + ) + self.query_norm = nn.LayerNorm(settings.latent_size) + self.denoiser = nn.Sequential( + nn.Linear(settings.latent_size, settings.hidden_size // 2), + nn.SiLU(), + nn.Linear(settings.hidden_size // 2, 1), + ) + self.answerability = nn.Linear(settings.hidden_size, 1) + + def forward( + self, + noisy_scores: Any, + sequence_hidden: Any, + attention_mask: Any, + timestep: Any, + option_mask: Any | None = None, + ) -> dict[str, Any]: + if sequence_hidden.ndim != 4 or attention_mask.ndim != 3: + raise ValueError( + "token-conditioned diffusion expects [batch, options, sequence, hidden] states" + ) + batch, options, sequence, hidden = sequence_hidden.shape + if hidden != settings.hidden_size: + raise ValueError("sequence hidden size does not match the model configuration") + flat_tokens = self.token_projection( + sequence_hidden.reshape(batch * options, sequence, hidden) + ) + flat_attention = attention_mask.reshape(batch * options, sequence).bool() + time_embedding = self.time(timestep).unsqueeze(1) + queries = self.score_projection(noisy_scores.unsqueeze(-1)) + time_embedding + flat_queries = queries.reshape(batch * options, 1, settings.latent_size) + attended, _weights = self.cross_attention( + flat_queries, + flat_tokens, + flat_tokens, + key_padding_mask=~flat_attention, + need_weights=False, + ) + option_logits = self.denoiser( + self.query_norm(flat_queries + attended).squeeze(1) + ).reshape(batch, options) + if option_mask is not None: + option_logits = option_logits.masked_fill(~option_mask.bool(), float("-inf")) + + token_weights = attention_mask.to(sequence_hidden.dtype).unsqueeze(-1) + candidate_embeddings = (sequence_hidden * token_weights).sum(dim=2) / token_weights.sum( + dim=2 + ).clamp_min(1) + if option_mask is None: + pooled = candidate_embeddings.mean(dim=1) + else: + option_weights = option_mask.to(sequence_hidden.dtype).unsqueeze(-1) + pooled = (candidate_embeddings * option_weights).sum(dim=1) / option_weights.sum( + dim=1 + ).clamp_min(1) + return { + "logits": option_logits, + "answerability": self.answerability(pooled).squeeze(-1), + } + + if backend == "direct": + return DirectDecision() + if backend != "diffusion": + raise ValueError(f"unsupported backend {backend!r}") + if settings.diffusion_conditioning == "pooled": + return PooledDiffusionDecision() + if settings.diffusion_conditioning == "token_cross_attention": + return TokenConditionedDiffusionDecision() + raise ValueError( + f"unsupported diffusion_conditioning {settings.diffusion_conditioning!r}" + ) def linear_beta_schedule(steps: int) -> Any: @@ -66,6 +152,20 @@ def linear_beta_schedule(steps: int) -> Any: return torch.linspace(1e-4, 0.02, steps) +def cosine_beta_schedule(steps: int, *, offset: float = 0.008) -> Any: + """Cosine cumulative-noise schedule from Nichol and Dhariwal.""" + torch, _ = require_torch() + if steps < 2: + raise ValueError("diffusion schedule requires at least two steps") + if not 0.0 < offset < 1.0: + raise ValueError("cosine offset must be between zero and one") + positions = torch.linspace(0, steps, steps + 1, dtype=torch.float64) + alpha_bars = torch.cos(((positions / steps + offset) / (1 + offset)) * torch.pi / 2) ** 2 + alpha_bars = alpha_bars / alpha_bars[0] + betas = 1.0 - alpha_bars[1:] / alpha_bars[:-1] + return betas.clamp(1e-5, 0.999).to(torch.float32) + + def ddim_step(sample: Any, predicted_noise: Any, alpha: Any, alpha_previous: Any) -> Any: """Deterministic DDIM update for a score vector.""" torch, _ = require_torch() @@ -100,3 +200,62 @@ def ddim_sample(model: Any, pooled: Any, *, option_count: int, diffusion_steps: predicted_noise = model(sample, pooled, timestep_batch)["noise"] sample = ddim_step(sample, predicted_noise, current_alpha, previous_alpha) return sample + + +def ddim_sample_token_conditioned( + model: Any, + sequence_hidden: Any, + attention_mask: Any, + option_mask: Any, + *, + diffusion_steps: int = 64, + inference_steps: int = 8, + seed: int | None = None, +) -> Any: + """Sample class logits from the token-conditioned x0 predictor.""" + torch, _ = require_torch() + if not 2 <= inference_steps <= diffusion_steps: + raise ValueError("inference_steps must be between 2 and diffusion_steps") + batch, option_count = option_mask.shape + betas = cosine_beta_schedule(diffusion_steps).to(sequence_hidden.device) + alpha_bars = torch.cumprod(1.0 - betas, dim=0) + generator = None + if seed is not None: + generator = torch.Generator(device=sequence_hidden.device) + generator.manual_seed(seed) + sample = torch.randn( + (batch, option_count), + device=sequence_hidden.device, + generator=generator, + ) + timesteps = torch.linspace( + diffusion_steps - 1, + 0, + inference_steps, + device=sequence_hidden.device, + ).round().long() + final_logits = sample + for index, timestep in enumerate(timesteps): + timestep_batch = torch.full( + (batch,), int(timestep), dtype=torch.long, device=sequence_hidden.device + ) + output = model( + sample, + sequence_hidden, + attention_mask, + timestep_batch, + option_mask, + ) + final_logits = output["logits"] + predicted_x0 = torch.softmax(final_logits, dim=-1) + current_alpha = alpha_bars[timestep] + predicted_noise = ( + sample - torch.sqrt(current_alpha) * predicted_x0 + ) / torch.sqrt(1 - current_alpha).clamp_min(1e-6) + previous_alpha = ( + alpha_bars[timesteps[index + 1]] + if index + 1 < len(timesteps) + else sample.new_tensor(1.0) + ) + sample = ddim_step(sample, predicted_noise, current_alpha, previous_alpha) + return final_logits.masked_fill(~option_mask.bool(), float("-inf")) diff --git a/vons/training.py b/vons/training.py index ad9feb1e4851add567fab1d78538c9476f654d43..3df3a1e0998888575c70cd37c9bbb4fe6c8fc074 100644 --- a/vons/training.py +++ b/vons/training.py @@ -16,7 +16,14 @@ from typing import Any from .data import Example, dataset_manifest, read_jsonl from .evaluation import Prediction, summarize, write_report -from .models import ModelConfig, build_model, ddim_sample, require_torch +from .models import ( + ModelConfig, + build_model, + cosine_beta_schedule, + ddim_sample, + ddim_sample_token_conditioned, + require_torch, +) def _require_transformers() -> tuple[Any, Any]: @@ -44,20 +51,34 @@ def _device(torch: Any, requested: str) -> Any: return torch.device("cpu") -def _encode_examples(tokenizer: Any, encoder: Any, examples: list[Example], device: Any, max_length: int = 512) -> tuple[Any, Any, Any, Any, list[Example]]: +def _encode_examples( + tokenizer: Any, + encoder: Any, + examples: list[Example], + device: Any, + max_length: int = 512, + *, + include_token_states: bool = False, +) -> tuple[Any, Any, Any, Any, list[Example], Any | None, Any | None]: torch, _ = require_torch() option_embeddings: list[Any] = [] pooled_embeddings: list[Any] = [] targets: list[int] = [] kept: list[Example] = [] + token_states: list[Any] = [] + token_masks: list[Any] = [] with torch.no_grad(): for row in examples: texts = [f"{row.state}\nQuestion: {row.question}\nCandidate: {option}" for option in row.options] batch = tokenizer(texts, padding=True, truncation=True, max_length=max_length, return_tensors="pt").to(device) output = encoder(**batch) - hidden = output.last_hidden_state[:, 0, :] + hidden_states = output.last_hidden_state + hidden = hidden_states[:, 0, :] option_embeddings.append(hidden) pooled_embeddings.append(hidden.mean(dim=0)) + if include_token_states: + token_states.append(hidden_states) + token_masks.append(batch["attention_mask"].bool()) targets.append(-1 if row.label is None else row.options.index(row.label)) kept.append(row) max_options = max((len(item.options) for item in kept), default=2) @@ -68,7 +89,29 @@ def _encode_examples(tokenizer: Any, encoder: Any, examples: list[Example], devi for index, values in enumerate(option_embeddings): padded[index, : values.shape[0]] = values mask[index, : values.shape[0]] = True - return padded, pooled, torch.tensor(targets, dtype=torch.long, device=device), mask, kept + padded_token_states = None + padded_token_masks = None + if include_token_states: + max_sequence = max((values.shape[1] for values in token_states), default=1) + padded_token_states = torch.zeros( + (len(kept), max_options, max_sequence, hidden_size), device=device + ) + padded_token_masks = torch.zeros( + (len(kept), max_options, max_sequence), dtype=torch.bool, device=device + ) + for index, (values, values_mask) in enumerate(zip(token_states, token_masks, strict=True)): + options, sequence = values.shape[:2] + padded_token_states[index, :options, :sequence] = values + padded_token_masks[index, :options, :sequence] = values_mask + return ( + padded, + pooled, + torch.tensor(targets, dtype=torch.long, device=device), + mask, + kept, + padded_token_states, + padded_token_masks, + ) def _pad_option_axis(option_embeddings: Any, option_mask: Any, option_count: int) -> tuple[Any, Any]: @@ -83,6 +126,31 @@ def _pad_option_axis(option_embeddings: Any, option_mask: Any, option_count: int return padded_embeddings, padded_mask +def soft_diffusion_targets( + labels: Any, + option_mask: Any, + *, + smoothing: float = 0.1, +) -> Any: + """Create masked continuous class targets for diffusion cross-entropy.""" + torch, _ = require_torch() + if not 0.0 < smoothing < 1.0: + raise ValueError("smoothing must be strictly between zero and one") + if labels.ndim != 1 or option_mask.ndim != 2 or labels.shape[0] != option_mask.shape[0]: + raise ValueError("labels and option_mask batch dimensions must agree") + valid_counts = option_mask.sum(dim=-1) + if bool((valid_counts < 2).any()): + raise ValueError("soft diffusion targets require at least two valid options") + if bool(((labels < 0) | (labels >= option_mask.shape[1])).any()): + raise ValueError("diffusion labels must index the option axis") + if not bool(option_mask.gather(1, labels.unsqueeze(1)).all()): + raise ValueError("diffusion labels must select a valid option") + off_target = smoothing / (valid_counts - 1).to(torch.float32) + targets = off_target.unsqueeze(1) * option_mask.to(torch.float32) + targets.scatter_(1, labels.unsqueeze(1), 1.0 - smoothing) + return targets + + def train(config_path: str | Path) -> Path: config = _load_config(config_path) torch, nn = require_torch() @@ -95,23 +163,55 @@ def train(config_path: str | Path) -> Path: train_rows = [row for row in examples if row.split == "train"] if not train_rows: raise ValueError("training data has no train split") + backend = str(config.get("backend", "direct")) + diffusion_conditioning = str( + config.get("diffusion_conditioning", "token_cross_attention") + ) + if backend == "diffusion": + config["diffusion_conditioning"] = diffusion_conditioning + config.setdefault("diffusion_steps", 64) + config.setdefault("inference_steps", 8) + config.setdefault("noise_schedule", "cosine") + config.setdefault("soft_target_smoothing", 0.1) encoder_config = config["encoder"] tokenizer = AutoTokenizer.from_pretrained(encoder_config["name"], revision=encoder_config.get("revision")) encoder = AutoModel.from_pretrained(encoder_config["name"], revision=encoder_config.get("revision")) device = _device(torch, str(config.get("device", "auto"))) encoder.to(device).eval() - option_embeddings, pooled, targets, option_mask, kept = _encode_examples(tokenizer, encoder, train_rows, device, int(encoder_config.get("max_tokens", 512))) + ( + option_embeddings, + pooled, + targets, + option_mask, + kept, + sequence_hidden, + sequence_attention, + ) = _encode_examples( + tokenizer, + encoder, + train_rows, + device, + int(encoder_config.get("max_tokens", 512)), + include_token_states=( + backend == "diffusion" and diffusion_conditioning == "token_cross_attention" + ), + ) option_count = int(config.get("option_count", option_embeddings.shape[1])) - option_embeddings, option_mask = _pad_option_axis(option_embeddings, option_mask, option_count) - backend = str(config.get("backend", "direct")) + if not (backend == "diffusion" and diffusion_conditioning == "token_cross_attention"): + option_embeddings, option_mask = _pad_option_axis( + option_embeddings, option_mask, option_count + ) model = build_model( backend, - option_count=option_embeddings.shape[1], + option_count=option_count, config=ModelConfig( hidden_size=option_embeddings.shape[-1], - diffusion_steps=int(config.get("diffusion_steps", 32)), - inference_steps=int(config.get("inference_steps", 4)), + latent_size=int(config.get("latent_size", 64 if diffusion_conditioning == "token_cross_attention" else 32)), + diffusion_steps=int(config.get("diffusion_steps", 64)), + inference_steps=int(config.get("inference_steps", 8)), abstain_threshold=float(config.get("abstain_threshold", 0.55)), + diffusion_conditioning=diffusion_conditioning, + attention_heads=int(config.get("attention_heads", 4)), ), ) model.to(device).train() @@ -124,13 +224,18 @@ def train(config_path: str | Path) -> Path: raise ValueError("training data has no answerable examples") schedule = None if backend == "diffusion": - from .models import linear_beta_schedule - diffusion_steps = int(config.get("diffusion_steps", ModelConfig().diffusion_steps)) - betas = linear_beta_schedule(diffusion_steps).to(device) + if diffusion_conditioning == "token_cross_attention": + betas = cosine_beta_schedule(diffusion_steps).to(device) + else: + from .models import linear_beta_schedule + + betas = linear_beta_schedule(diffusion_steps).to(device) schedule = torch.cumprod(1.0 - betas, dim=0) batch_size = max(1, int(config.get("batch_size", 16))) - for _ in range(epochs): + training_history: list[dict[str, float | int]] = [] + for epoch in range(epochs): + epoch_losses: list[float] = [] permutation = torch.randperm(len(kept), device=device) for start in range(0, len(kept), batch_size): indices = permutation[start : start + batch_size] @@ -144,25 +249,63 @@ def train(config_path: str | Path) -> Path: else: decision_loss = output["answerability"].sum() * 0.0 else: - target = torch.nn.functional.one_hot(batch_labels, num_classes=option_embeddings.shape[1]).float() timestep = torch.randint(0, len(schedule), (len(indices),), device=device) + if diffusion_conditioning == "token_cross_attention": + target = soft_diffusion_targets( + batch_labels, + option_mask[indices], + smoothing=float(config.get("soft_target_smoothing", 0.1)), + ).to(device) + else: + target = torch.nn.functional.one_hot( + batch_labels, num_classes=option_embeddings.shape[1] + ).float() noise = torch.randn_like(target) alpha_bar = schedule[timestep].unsqueeze(-1) noisy = alpha_bar.sqrt() * target + (1.0 - alpha_bar).sqrt() * noise - output = model(noisy, pooled[indices], timestep) - if bool(batch_valid.any()): - decision_loss = nn.functional.mse_loss(output["noise"][batch_valid], noise[batch_valid]) + if diffusion_conditioning == "token_cross_attention": + if sequence_hidden is None or sequence_attention is None: + raise RuntimeError("token-conditioned diffusion requires token states") + output = model( + noisy, + sequence_hidden[indices], + sequence_attention[indices], + timestep, + option_mask[indices], + ) + if bool(batch_valid.any()): + finite_logits = output["logits"].masked_fill( + ~option_mask[indices], -1e4 + ) + decision_loss = nn.functional.cross_entropy( + finite_logits[batch_valid], target[batch_valid] + ) + else: + decision_loss = output["answerability"].sum() * 0.0 else: - decision_loss = output["answerability"].sum() * 0.0 + output = model(noisy, pooled[indices], timestep) + if bool(batch_valid.any()): + decision_loss = nn.functional.mse_loss( + output["noise"][batch_valid], noise[batch_valid] + ) + else: + decision_loss = output["answerability"].sum() * 0.0 answerability_loss = nn.functional.binary_cross_entropy_with_logits(output["answerability"], answerable_targets[indices]) loss = decision_loss + 0.1 * answerability_loss loss.backward() optimizer.step() + epoch_losses.append(float(loss.detach().cpu())) + training_history.append( + { + "epoch": epoch + 1, + "mean_loss": sum(epoch_losses) / len(epoch_losses), + } + ) artifact_dir = Path(config.get("artifact_dir", "artifacts/pilot")) artifact_dir.mkdir(parents=True, exist_ok=True) checkpoint = artifact_dir / "model.pt" - torch.save({"state_dict": model.state_dict(), "backend": backend, "option_count": int(option_embeddings.shape[1]), "hidden_size": int(option_embeddings.shape[-1]), "config": config}, checkpoint) - manifest = {"model_id": config.get("model_id", "vons-pilot"), "backend": backend, "encoder": encoder_config, "device": str(device), "platform": platform.platform(), "seed": seed, "rows": len(kept), "data": dataset_manifest(data_path, examples), "checkpoint": str(checkpoint), "created_at": time.time()} + torch.save({"state_dict": model.state_dict(), "backend": backend, "option_count": option_count, "hidden_size": int(option_embeddings.shape[-1]), "config": config, "training_history": training_history}, checkpoint) + manifest = {"model_id": config.get("model_id", "vons-pilot"), "backend": backend, "encoder": encoder_config, "device": str(device), "platform": platform.platform(), "seed": seed, "rows": len(kept), "data": dataset_manifest(data_path, examples), "checkpoint": str(checkpoint), "training_history": training_history, "created_at": time.time()} (artifact_dir / "model-manifest.json").write_text(json.dumps(manifest, indent=2, sort_keys=True), encoding="utf-8") return checkpoint @@ -177,20 +320,45 @@ def evaluate(checkpoint_path: str | Path, input_path: str | Path, output_path: s encoder = AutoModel.from_pretrained(encoder_config["name"], revision=encoder_config.get("revision")) encoder.eval() rows = read_jsonl(input_path) - option_embeddings, pooled, _targets, option_mask, kept = _encode_examples(tokenizer, encoder, rows, torch.device("cpu"), int(encoder_config.get("max_tokens", 512))) + diffusion_conditioning = str(config.get("diffusion_conditioning", "pooled")) + ( + option_embeddings, + pooled, + _targets, + option_mask, + kept, + sequence_hidden, + sequence_attention, + ) = _encode_examples( + tokenizer, + encoder, + rows, + torch.device("cpu"), + int(encoder_config.get("max_tokens", 512)), + include_token_states=( + checkpoint["backend"] == "diffusion" + and diffusion_conditioning == "token_cross_attention" + ), + ) expected_options = int(checkpoint["option_count"]) if option_embeddings.shape[1] > expected_options: raise ValueError(f"evaluation input has {option_embeddings.shape[1]} candidates but checkpoint supports {expected_options}") - if option_embeddings.shape[1] < expected_options: + if ( + option_embeddings.shape[1] < expected_options + and diffusion_conditioning != "token_cross_attention" + ): option_embeddings, option_mask = _pad_option_axis(option_embeddings, option_mask, expected_options) model = build_model( checkpoint["backend"], option_count=checkpoint["option_count"], config=ModelConfig( hidden_size=checkpoint["hidden_size"], + latent_size=int(config.get("latent_size", 32)), diffusion_steps=int(config.get("diffusion_steps", 32)), inference_steps=int(config.get("inference_steps", 4)), abstain_threshold=float(config.get("abstain_threshold", 0.55)), + diffusion_conditioning=diffusion_conditioning, + attention_heads=int(config.get("attention_heads", 4)), ), ) model.load_state_dict(checkpoint["state_dict"]) @@ -207,19 +375,47 @@ def evaluate(checkpoint_path: str | Path, input_path: str | Path, output_path: s logits = output["logits"] answerability = torch.sigmoid(output["answerability"])[0] else: - logits = ddim_sample( - model, - row_pooled, - option_count=expected_options, - diffusion_steps=int(config.get("diffusion_steps", 32)), - inference_steps=int(config.get("inference_steps", 4)), - seed=None if config.get("seed") is None else int(config["seed"]) + index, - ) - answerability = torch.sigmoid(model( - torch.zeros_like(logits), row_pooled, - torch.zeros((1,), dtype=torch.long), - )["answerability"])[0] - logits = logits.masked_fill(~row_mask, float("-inf")) + if diffusion_conditioning == "token_cross_attention": + if sequence_hidden is None or sequence_attention is None: + raise RuntimeError("token-conditioned diffusion requires token states") + row_sequence = sequence_hidden[index : index + 1] + row_attention = sequence_attention[index : index + 1] + logits = ddim_sample_token_conditioned( + model, + row_sequence, + row_attention, + row_mask, + diffusion_steps=int(config.get("diffusion_steps", 64)), + inference_steps=int(config.get("inference_steps", 8)), + seed=( + None + if config.get("seed") is None + else int(config["seed"]) + index + ), + ) + answerability = torch.sigmoid( + model( + torch.zeros_like(logits), + row_sequence, + row_attention, + torch.zeros((1,), dtype=torch.long), + row_mask, + )["answerability"] + )[0] + else: + logits = ddim_sample( + model, + row_pooled, + option_count=expected_options, + diffusion_steps=int(config.get("diffusion_steps", 32)), + inference_steps=int(config.get("inference_steps", 4)), + seed=None if config.get("seed") is None else int(config["seed"]) + index, + ) + answerability = torch.sigmoid(model( + torch.zeros_like(logits), row_pooled, + torch.zeros((1,), dtype=torch.long), + )["answerability"])[0] + logits = logits.masked_fill(~row_mask, float("-inf")) probabilities = torch.softmax(logits, dim=-1) values = probabilities[0, : len(row.options)] choice_index = int(values.argmax()) @@ -237,13 +433,17 @@ def export_head(checkpoint_path: str | Path, output_path: str | Path) -> Path: torch, _ = require_torch() checkpoint = torch.load(checkpoint_path, map_location="cpu") config = checkpoint["config"] + diffusion_conditioning = str(config.get("diffusion_conditioning", "pooled")) model = build_model( checkpoint["backend"], option_count=checkpoint["option_count"], config=ModelConfig( hidden_size=checkpoint["hidden_size"], + latent_size=int(config.get("latent_size", 32)), diffusion_steps=int(config.get("diffusion_steps", 32)), inference_steps=int(config.get("inference_steps", 4)), + diffusion_conditioning=diffusion_conditioning, + attention_heads=int(config.get("attention_heads", 4)), ), ) model.load_state_dict(checkpoint["state_dict"]) @@ -267,6 +467,28 @@ def export_head(checkpoint_path: str | Path, output_path: str | Path) -> Path: result = self.head(noisy_scores, pooled, timestep) return result["noise"], result["answerability"] + class TokenDiffusionExportWrapper(torch.nn.Module): + def __init__(self, head: Any) -> None: + super().__init__() + self.head = head + + def forward( + self, + noisy_scores: Any, + sequence_hidden: Any, + attention_mask: Any, + timestep: Any, + option_mask: Any, + ) -> tuple[Any, Any]: + result = self.head( + noisy_scores, + sequence_hidden, + attention_mask, + timestep, + option_mask, + ) + return result["logits"], result["answerability"] + if checkpoint["backend"] == "direct": wrapper = DirectExportWrapper(model).eval() inputs = ( @@ -281,18 +503,46 @@ def export_head(checkpoint_path: str | Path, output_path: str | Path) -> Path: "logits": {0: "batch"}, "answerability": {0: "batch"}, } elif checkpoint["backend"] == "diffusion": - wrapper = DiffusionExportWrapper(model).eval() - inputs = ( - torch.zeros((1, checkpoint["option_count"])), - torch.zeros((1, checkpoint["hidden_size"])), - torch.zeros((1,), dtype=torch.long), - ) - input_names = ["noisy_scores", "pooled", "timestep"] - output_names = ["noise", "answerability"] - dynamic_axes = { - "noisy_scores": {0: "batch"}, "pooled": {0: "batch"}, "timestep": {0: "batch"}, - "noise": {0: "batch"}, "answerability": {0: "batch"}, - } + if diffusion_conditioning == "token_cross_attention": + example_options = min(4, int(checkpoint["option_count"])) + wrapper = TokenDiffusionExportWrapper(model).eval() + inputs = ( + torch.zeros((1, example_options)), + torch.zeros((1, example_options, 64, checkpoint["hidden_size"])), + torch.ones((1, example_options, 64), dtype=torch.bool), + torch.zeros((1,), dtype=torch.long), + torch.ones((1, example_options), dtype=torch.bool), + ) + input_names = [ + "noisy_scores", + "sequence_hidden", + "attention_mask", + "timestep", + "option_mask", + ] + output_names = ["logits", "answerability"] + dynamic_axes = { + "noisy_scores": {0: "batch", 1: "options"}, + "sequence_hidden": {0: "batch", 1: "options", 2: "sequence_length"}, + "attention_mask": {0: "batch", 1: "options", 2: "sequence_length"}, + "timestep": {0: "batch"}, + "option_mask": {0: "batch", 1: "options"}, + "logits": {0: "batch", 1: "options"}, + "answerability": {0: "batch"}, + } + else: + wrapper = DiffusionExportWrapper(model).eval() + inputs = ( + torch.zeros((1, checkpoint["option_count"])), + torch.zeros((1, checkpoint["hidden_size"])), + torch.zeros((1,), dtype=torch.long), + ) + input_names = ["noisy_scores", "pooled", "timestep"] + output_names = ["noise", "answerability"] + dynamic_axes = { + "noisy_scores": {0: "batch"}, "pooled": {0: "batch"}, "timestep": {0: "batch"}, + "noise": {0: "batch"}, "answerability": {0: "batch"}, + } else: raise ValueError(f"unsupported backend {checkpoint['backend']!r}") output = Path(output_path) @@ -417,8 +667,11 @@ def export_diffusion_bundle(checkpoint_path: str | Path, output_path: str | Path raise ValueError("diffusion bundle export requires a diffusion checkpoint") config = checkpoint["config"] encoder_config = config["encoder"] - encoder = AutoModel.from_pretrained(encoder_config["name"], revision=encoder_config.get("revision")) + encoder = AutoModel.from_pretrained( + encoder_config["name"], revision=encoder_config.get("revision") + ) encoder.eval() + conditioning = str(config.get("diffusion_conditioning", "pooled")) diffusion_steps = int(config.get("diffusion_steps", 32)) inference_steps = int(config.get("inference_steps", 4)) if not 2 <= inference_steps <= diffusion_steps: @@ -428,14 +681,17 @@ def export_diffusion_bundle(checkpoint_path: str | Path, output_path: str | Path option_count=checkpoint["option_count"], config=ModelConfig( hidden_size=checkpoint["hidden_size"], + latent_size=int(config.get("latent_size", 32)), diffusion_steps=diffusion_steps, inference_steps=inference_steps, + diffusion_conditioning=conditioning, + attention_heads=int(config.get("attention_heads", 4)), ), ) model.load_state_dict(checkpoint["state_dict"]) model.eval() - class FullDiffusionExportWrapper(torch.nn.Module): + class FullPooledDiffusionExportWrapper(torch.nn.Module): def __init__(self, encoder_model: Any, head: Any) -> None: super().__init__() self.encoder = encoder_model @@ -452,48 +708,137 @@ def export_diffusion_bundle(checkpoint_path: str | Path, output_path: str | Path initial_noise: Any, ) -> tuple[Any, Any]: batch, options, sequence = input_ids.shape - flat_ids = input_ids.reshape(batch * options, sequence) - flat_attention = attention_mask.reshape(batch * options, sequence) - flat_types = token_type_ids.reshape(batch * options, sequence) encoded = self.encoder( - input_ids=flat_ids, - attention_mask=flat_attention, - token_type_ids=flat_types, + input_ids=input_ids.reshape(batch * options, sequence), + attention_mask=attention_mask.reshape(batch * options, sequence), + token_type_ids=token_type_ids.reshape(batch * options, sequence), ).last_hidden_state[:, 0, :] candidate_embeddings = encoded.reshape(batch, options, -1) weights = option_mask.to(candidate_embeddings.dtype).unsqueeze(-1) - pooled = (candidate_embeddings * weights).sum(dim=1) / weights.sum(dim=1).clamp_min(1) + pooled = (candidate_embeddings * weights).sum(dim=1) / weights.sum( + dim=1 + ).clamp_min(1) sample = initial_noise - timesteps = torch.linspace(diffusion_steps - 1, 0, inference_steps).round().to(torch.long) + timesteps = torch.linspace( + diffusion_steps - 1, 0, inference_steps + ).round().to(torch.long) for index in range(inference_steps): timestep = timesteps[index] - timestep_batch = torch.full((batch,), timestep, dtype=torch.long, device=sample.device) + timestep_batch = torch.full( + (batch,), timestep, dtype=torch.long, device=sample.device + ) predicted_noise = self.head(sample, pooled, timestep_batch)["noise"] alpha = self.alpha_bars[timestep] - previous_timestep = timesteps[index + 1] if index + 1 < inference_steps else torch.tensor(0, device=sample.device) - previous_alpha = self.alpha_bars[previous_timestep] if index + 1 < inference_steps else sample.new_tensor(1.0) - predicted_x0 = (sample - torch.sqrt(1 - alpha) * predicted_noise) / torch.sqrt(alpha) - sample = torch.sqrt(previous_alpha) * predicted_x0 + torch.sqrt(1 - previous_alpha) * predicted_noise + previous_alpha = ( + self.alpha_bars[timesteps[index + 1]] + if index + 1 < inference_steps + else sample.new_tensor(1.0) + ) + predicted_x0 = ( + sample - torch.sqrt(1 - alpha) * predicted_noise + ) / torch.sqrt(alpha) + sample = torch.sqrt(previous_alpha) * predicted_x0 + torch.sqrt( + 1 - previous_alpha + ) * predicted_noise sample = sample.masked_fill(~option_mask.bool(), float("-inf")) - answerability = self.head(initial_noise, pooled, torch.zeros((batch,), dtype=torch.long, device=sample.device))["answerability"] + answerability = self.head( + initial_noise, + pooled, + torch.zeros((batch,), dtype=torch.long, device=sample.device), + )["answerability"] return sample, answerability - wrapper = FullDiffusionExportWrapper(encoder, model).eval() + class FullTokenDiffusionExportWrapper(torch.nn.Module): + def __init__(self, encoder_model: Any, head: Any) -> None: + super().__init__() + self.encoder = encoder_model + self.head = head + self.register_buffer( + "alpha_bars", + torch.cumprod(1.0 - cosine_beta_schedule(diffusion_steps), dim=0), + ) + + def forward( + self, + input_ids: Any, + attention_mask: Any, + token_type_ids: Any, + option_mask: Any, + initial_noise: Any, + ) -> tuple[Any, Any]: + batch, options, sequence = input_ids.shape + encoded = self.encoder( + input_ids=input_ids.reshape(batch * options, sequence), + attention_mask=attention_mask.reshape(batch * options, sequence), + token_type_ids=token_type_ids.reshape(batch * options, sequence), + ).last_hidden_state.reshape(batch, options, sequence, -1) + sample = initial_noise + timesteps = torch.linspace( + diffusion_steps - 1, 0, inference_steps + ).round().to(torch.long) + final_logits = sample + answerability = sample[:, 0] + for index in range(inference_steps): + timestep = timesteps[index] + timestep_batch = torch.full( + (batch,), timestep, dtype=torch.long, device=sample.device + ) + result = self.head( + sample, + encoded, + attention_mask, + timestep_batch, + option_mask, + ) + final_logits = result["logits"] + answerability = result["answerability"] + predicted_x0 = torch.softmax(final_logits, dim=-1) + alpha = self.alpha_bars[timestep] + predicted_noise = ( + sample - torch.sqrt(alpha) * predicted_x0 + ) / torch.sqrt(1 - alpha).clamp_min(1e-6) + previous_alpha = ( + self.alpha_bars[timesteps[index + 1]] + if index + 1 < inference_steps + else sample.new_tensor(1.0) + ) + sample = torch.sqrt(previous_alpha) * predicted_x0 + torch.sqrt( + 1 - previous_alpha + ) * predicted_noise + return final_logits.masked_fill( + ~option_mask.bool(), float("-inf") + ), answerability + sequence = int(encoder_config.get("max_tokens", 512)) option_count = int(checkpoint["option_count"]) + example_options = min(4, option_count) if conditioning == "token_cross_attention" else option_count + wrapper = ( + FullTokenDiffusionExportWrapper(encoder, model).eval() + if conditioning == "token_cross_attention" + else FullPooledDiffusionExportWrapper(encoder, model).eval() + ) inputs = ( - torch.zeros((1, option_count, sequence), dtype=torch.long), - torch.ones((1, option_count, sequence), dtype=torch.long), - torch.zeros((1, option_count, sequence), dtype=torch.long), - torch.ones((1, option_count), dtype=torch.bool), - torch.zeros((1, option_count)), + torch.zeros((1, example_options, sequence), dtype=torch.long), + torch.ones((1, example_options, sequence), dtype=torch.long), + torch.zeros((1, example_options, sequence), dtype=torch.long), + torch.ones((1, example_options), dtype=torch.bool), + torch.zeros((1, example_options)), ) - input_names = ["input_ids", "attention_mask", "token_type_ids", "option_mask", "initial_noise"] + input_names = [ + "input_ids", + "attention_mask", + "token_type_ids", + "option_mask", + "initial_noise", + ] output_names = ["scores", "answerability"] - # Diffusion's first layer is parameterized by the configured candidate - # count, so its option and sequence dimensions are intentionally fixed. - # Batch remains dynamic for serving. dynamic_axes = {name: {0: "batch"} for name in input_names + output_names} + if conditioning == "token_cross_attention": + for name in ("input_ids", "attention_mask", "token_type_ids"): + dynamic_axes[name].update({1: "options", 2: "sequence_length"}) + dynamic_axes["option_mask"][1] = "options" + dynamic_axes["initial_noise"][1] = "options" + dynamic_axes["scores"][1] = "options" output = Path(output_path) output.parent.mkdir(parents=True, exist_ok=True) torch.onnx.export( @@ -505,7 +850,9 @@ def export_diffusion_bundle(checkpoint_path: str | Path, output_path: str | Path dynamic_axes=dynamic_axes, opset_version=18, ) - tokenizer = AutoTokenizer.from_pretrained(encoder_config["name"], revision=encoder_config.get("revision")) + tokenizer = AutoTokenizer.from_pretrained( + encoder_config["name"], revision=encoder_config.get("revision") + ) tokenizer.save_pretrained(output.parent / "tokenizer") manifest = { "format": "onnx", @@ -516,6 +863,10 @@ def export_diffusion_bundle(checkpoint_path: str | Path, output_path: str | Path "tokenizer": str(output.parent / "tokenizer"), "option_count": option_count, "sequence_length": sequence, + "dynamic_options": conditioning == "token_cross_attention", + "dynamic_sequence_length": conditioning == "token_cross_attention", + "diffusion_conditioning": conditioning, + "noise_schedule": str(config.get("noise_schedule", "linear")), "diffusion_steps": diffusion_steps, "inference_steps": inference_steps, "input_names": input_names, @@ -523,5 +874,7 @@ def export_diffusion_bundle(checkpoint_path: str | Path, output_path: str | Path "scope": "end_to_end_encoder_plus_fixed_ddim_decision_head", "seed_contract": "host supplies deterministic initial_noise", } - (output.parent / "bundle-manifest.json").write_text(json.dumps(manifest, indent=2, sort_keys=True), encoding="utf-8") + (output.parent / "bundle-manifest.json").write_text( + json.dumps(manifest, indent=2, sort_keys=True), encoding="utf-8" + ) return output