Format:NCNN model
| Developer | Tencent |
|---|---|
| Magic | 7767517 (text first line, or int32 in .param.bin) |
| Extensions | .param, .bin, .param.bin |
| Endianness | little |
| License | BSD-3-Clause |
| On this wiki | Facts · Code · Notes · Topics |
Tencent ncnn's model pair: a text .param graph (first line 7767517, then layer and blob counts and one line per layer) plus a .bin weight blob, or the binary .param.bin made by ncnn2mem.
Files
An ncnn network is two files: net.param (the graph) and net.bin (weights), or net.param.bin (binary graph from the ncnn2mem tool) plus net.bin (docs/developer-guide/param-and-model-file-structure.md, ncnn 0ca5a4b).
net.param (text)
Line 1 is the magic number 7767517. Line 2 is two integers: layer count and blob count. Then exactly one physical line per layer: type name input_count output_count input_blobs... output_blobs... key=value.... Layer types are names such as Input, Convolution, InnerProduct, Softmax; layer names must be unique; blob names are the edges of the graph. Parameters are index=value pairs: scalar keys are 0 to 31; array keys are -23300 minus the index, with the value count,v1,v2,... (for example -23303=2,2.0,3.0 is array 3); modern files may also write arrays as 3=2.0,3.0 and strings as 4=hello (up to 255 characters). The meaning of each key per layer type is in the operation-param-weight-table document of the same directory. Float values should have a decimal point or exponent, because ncnn2mem writes integer spellings as integer bit patterns.
Example from the doc: Input input 0 1 data 0=4 1=4 2=1 then InnerProduct ip 1 1 data fc 0=10 1=1 2=80 then Softmax softmax 1 1 fc prob 0=0.
net.bin
The concatenation of every layer's weight buffers in layer order, each aligned to 32 bits. A weight buffer is an optional flag (unsigned 32-bit little-endian), the raw data, optional padding. The flag selects the storage: 0 = float32, 0x01306B47 = float16, 0x01348B83 = bfloat16, any other value = quantized int8 (a quantization table plus indexes follow); the flag may be omitted when the layer forces its storage type. Because the .bin has no tensor names or shapes, shapes must be derived from the layer parameters in the .param file.
Loading code
src/net.cpp checks the magic in both loaders: Net::load_param (text, around line 1546) and Net::load_param_bin (binary, around line 1958) reject any other value with the message "param is too old, please regenerate". So that string in a binary identifies ncnn's loader. Unverified: shipped apps often rename the extension or XOR/encrypt the .param (the sources read here define no encryption), so search for the 4-byte value 7767517 (hex 0x007685DD in little-endian: DD 85 76 00) in the binary or assets.
See Technique:Identifying machine-learning models in applications.
Code & repositories
- https://github.com/Tencent/ncnn @
0ca5a4b6d59bbeb94dd85d94a9390f96684b2a8e· license: BSD-3-Clause (declared by the contributor; GitHub's detector did not recognize LICENSE.txt)
ncnn inference framework; docs/developer-guide/param-and-model-file-structure.md and src/net.cpp define the model files
Tested on: source read, not run · checked 2026-10-19; last activity 2026-10-19; Note: the latest release ships binaries; the wiki links only the source, never the binaries