Ggml(ggml-org/ggml)

ggml 是一个用于机器学习的 C++ 张量库,专门为需要在没有沉重运行时的情况下运行模型的开发者打造。

15.9k · C++

要开始编译验证,可以直接执行 git clone https://github.com/ggml-org/ggml 获取源码。最应该把 [examples/simple] 这个矩阵乘法的简短示例直接搬进你自己的代码库,因为它去掉了复杂的模型加载逻辑,是用 C++ 理解底层张量运算最直接的切入点。

README 摘录

# ggml <div align="center"> <img src="https://raw.githubusercontent.com/ggml-org/media/refs/heads/master/logo/ggml-logo.jpg" width="256" height="256" alt="ggml logo" /> <b>Tensor library for machine learning</b> [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Release](https://img.shields.io/github/v/release/ggml-org/ggml?filter=v*)](https://github.com/ggml-org/ggml/releases) [![CI](https://github.com/ggml-org/ggml/actions/workflows/build-cpu.yml/badge.svg)](https://github.com/ggml-org/ggml/actions/workflows/build-cpu.yml) </div> ## Quick start Build from source: ```bash git clone https://github.com/ggml-org/ggml cd ggml mkdir build && cd build cmake .. cmake --build . --config Release -j 8 ``` For a minimal, fully commented example (matrix multiplication), see [examples/simple](examples/simple). ## Description The main goal of `ggml` is to be a simple, portable, and efficient tensor library for machine learning with minimal setup. - Plain C/C++ implementation without any dependencies - Cross-platform - x86, ARM, RISC-V, LoongArch, PowerPC, s390x, and WebAssembly - SIMD-optimized kernels for x86, ARM, and RISC-V - Broad backend support - CPU, GPU, NPU, and browser - 2- to 8-bit integer quantization, plus MXFP4 and NVFP4 microscaling formats - Zero memory allocations during runtime ## Documentation - [The GGUF file format](docs/gguf.md) - [Introduction to ggml](https://huggingface.co/blog/introduction-to-ggml) - [GGML

GitHub