Skip to content

Releases

0.4.0

Choose a tag to compare

@github-actions github-actions released this 18 Nov 02:07

Added

  • Extractor::extract_mat returns an output as an independently owned Mat without copying it:
    the native extractor already detaches the tensor from its own blob pool, and this form takes that
    buffer instead of duplicating it. OutputGuard::into_mat is the same form through a scoped guard,
    and extract_mat with TensorWidth::Stored uses it for stored storage.
  • api_benchmark gained the owned-mat, guard-into, native-buffer and native-owned modes.
  • A raw feature exposes the generated bindings as ncnn_rust::sys. The default build no longer
    publishes them, so the crate's default surface carries no generated C ABI.
  • Prebuilt SDK archives on the sdk-20261020 release: one shared-library
    ncnn-rust-sdk-20261020-<platform>.tar.gz each for linux-x64-cpu, linux-x64-vulkan,
    windows-x64-cpu and macos-arm64-cpu, next to a SHA256SUMS file. tools/install-sdk.py
    installs one and checks it against that digest and against the release stamped in
    include/ncnn/platform.h, so a machine needs neither CMake, glslang nor a C++ build of ncnn, and
    --list prints the platform names.

Changed

  • extract_mat with either width and OutputGuard::into_mat copy only when the storage cannot be owned: a
    network built with NetBuilder::reuse_blob_memory returns tensors inside its pools, and an
    extractor that submitted a borrowed input returns caller storage.
  • The native request reference in api_benchmark now runs the options each wrapper row uses
    (native-request borrows its input and keeps light mode off, the owned variants enable it) and
    releases its input handle before the request. The request-path figures in the performance page were
    measured again: the wrapper matches the C API on every form that borrows or reuses its output, and
    the forms that return copied storage cost one or two 256 KB buffers per request.
  • The request forms collapse onto one storage decision per side. extract and extract_mat take a
    TensorWidth, so FP32 and stored width no longer need separate methods, and extract_into appends
    rather than replaces, so the separate append form is gone. On Net, infer, infer_stored and
    infer_into take an Input, which folds the owned, borrowed-slice and sub-view forms into them.
    The extractor request surface drops from eight methods to four and the network from six to three,
    and no capability is lost.
  • Extractor::extract_owned is now the sugar form of extract_into: it allocates the vector and
    delegates, so the FP32 conversion has one implementation instead of two.
  • The loading methods take a source instead of a parameter shape. load_param accepts
    ParamSource::{Text, Binary, File, Reader}, load_model accepts
    WeightSource::{Bytes, File, Reader} plus WeightSource::EMPTY, and Net::load runs both stages
    in one call. From conversions keep load_param("…") and load_model(&bytes) unchanged.

Removed

  • Extractor::extract_stored, Extractor::extract_stored_owned, Extractor::extract_append,
    Net::infer_borrowed, Net::infer_borrowed_into and Net::infer_view_into, replaced by the
    TensorWidth and Input arguments that docs/migration.md maps from the old names.
  • Extractor::inputs and Extractor::outputs_with, which only looped over input and extract;
    the caller writes that loop and keeps the error policy visible.
  • OutputGuard::detach, the copying twin of into_mat: into_mat already copies when it cannot
    own the storage, so the guard keeps one ownership path.
  • Net::load_param_file, Net::load_param_binary, Net::load_param_reader, Net::load_model_file
    and Net::load_model_reader. Their capability moves into ParamSource and WeightSource, which
    also removes the four near-identical parameter loaders and the three weight loaders.
    Net::load_model_file_native stays separate because mapped loading changes the lifetime contract.
  • Mat::append_f32_to, whose behaviour Mat::to_f32_into now has: it appends, leaves the vector
    untouched on failure, and keeps the capacity, so the replace form was the special case a caller
    writes with clear().
  • Mat::read_f32_unchecked, which ran the same validation and the same native copy as Mat::to_f32:
    an unsafe marker promised nothing the safe form does not already do, so to_f32 is the only
    FP32 copy.
  • PoolAllocator, which is now alloc::Pool: the crate carried two types called Allocator (the
    CPU pool and gpu::Allocator), and the per-extractor and option setters read ambiguously.

ncnn 20261020 SDK

Choose a tag to compare

@github-actions github-actions released this 17 Nov 10:20

Prebuilt ncnn 20261020 SDKs: the shared library, the feature set ncnn-rust requires and the project patches. Install with 'python3 tools/install-sdk.py --platform --dest

'; --list prints the names. SHA256SUMS detects a corrupted transfer, not a substituted release.

0.3.0

Choose a tag to compare

@github-actions github-actions released this 11 Nov 03:46

Added

  • Net::layers and Net::blobs describe the loaded graph: layer names, registered types, type
    indices, blob counts and the support flags ncnn declares per layer type, plus the wiring and
    recorded shape of every blob.
  • LayerInfo also carries the shape each layer recorded for its inputs and outputs, and
    layer_type_index resolves a type name to the index the registry uses.
  • ParamDict::kind reports how an entry is stored through ParamKind, which is what a custom layer
    needs before it picks a getter, and version_number returns the pinned release date as the integer
    ncnn encodes.
  • Zero-copy input: Mat::from_external borrows caller storage, Extractor::input_borrowed submits it
    without a copy and Net::infer_borrowed bounds the borrow to one request.
    Net::infer_borrowed_into fuses that with the reusable output buffer, which is the request form
    that allocates no data buffers.
  • Consuming tensor helpers that keep the storage a tensor already owns: Mat::into_reshape rewrites
    the header instead of duplicating aliased storage, and Mat::into_normalized normalizes in place
    instead of copying first.
  • Batched tensors: Mat::from_f32_batch builds storage with a batch count above one, TensorInfo::n
    reports it and Mat::to_f32 reads the batches back.
  • Layout helpers Mat::flatten and Mat::with_packing, and the four-axis border helpers
    Mat::copy_make_border_3d and Mat::copy_cut_border_3d with the Borders argument.
  • DataReader::from_file streams a file through the native stdio reader, and the file loaders
    Net::load_param_file and Net::load_model_file now read natively instead of copying the file
    into a Rust buffer first.
  • Device::pipeline_cache and Device::set_pipeline_cache move the serialized Vulkan pipeline cache
    through memory, next to the existing path helpers.
  • image::affine_transform, image::invert_affine, image::warp_affine and image::WarpBorder
    cover the affine preprocessing path.
  • Options::set_blob_allocator, Options::set_workspace_allocator and
    Options::set_kvcache_allocator attach caller-owned pools to a network.
  • crates/ncnn/examples/fast_allocator.rs measures the request path with a drop-in allocator, and the
    performance page records what it changes: on Windows the owned-output form is dominated by the
    process heap, while the forms that reuse a buffer do not move.
  • heap::retain_pages keeps the pages of a freed output buffer mapped on glibc Linux, which removes
    the per-request page faults of the forms that return independent storage.
    heap::set_mapping_limit, heap::disable_trimming and heap::retain_pages_up_to set the two
    thresholds individually, and every function reports whether the heap accepted them, so portable
    code calls the preset and ignores a false on other targets. The crate applies the settings
    itself because a service cannot always set the environment of its own process. The Windows heap
    needs no threshold and exposes none, so the call reports false there, and the heap test asserts
    both hosts: the faults and their removal on glibc, the absent faults and the false result on
    Windows.
  • crates/ncnn/examples/heap_retention.rs prints the owned-output and reused-buffer figures before
    and after that call plus the raw two-buffer cost of the host, and CI runs it next to the allocator
    example.
  • NetBuilder::reuse_blob_memory gives a network one pool allocator for intermediate blobs and one
    for layer workspace, and the network keeps both alive, so every extractor takes its scratch memory
    from the pools instead of allocating it per request. Net::reuses_blob_memory reports whether a
    network was built that way. The api_benchmark pooled-request mode times the four request forms on
    a pooled network next to a default one, and the owned form drops by about ten times on glibc and by
    two to three times on the Windows host that the performance page records.
  • Net::option reads the option value a loaded network actually uses.
  • Tensor helpers that run on the native kernels: Mat::fill, Mat::normalize_in_place,
    Mat::to_pixels, Mat::to_pixels_resize, Mat::copy_make_border, Mat::copy_cut_border and the
    BorderMode argument.
  • Net::load_param_reader and Net::load_model_reader load from a DataReader, and
    register_custom_layer_by_typeindex registers a factory for a type index.
  • Extractor::clear restarts a handle so the next request starts from an empty cache,
    Extractor::continue_session keeps the cached state for the next input, which is what
    token-by-token decoding needs, and
    Extractor::{set_light_mode, set_blob_allocator, set_workspace_allocator, set_kvcache_allocator, set_kvcache_max_seqlen_hint} override the network options for one request path. A restart
    re-applies them, so a reused handle keeps the settings it was given.
  • Mat::{channel, channel_range, depth, depth_range, column_range, row_range, batch, batch_range}
    return a MatView, a read-only alias of part of the tensor that copies only when it goes back in
    as an input. Mat::is_empty reports a tensor without storage, and TensorInfo::total and
    TensorInfo::shape report the native storage slots and the extent of each axis.
  • Net::layer_handle returns a GraphLayer, the layer the loaded graph holds at an index, for the
    native layer calls the raw module exposes, next to the Net::layers description of the same layer.
    The guard owns the C handle and releases it on drop, while the layer stays with the network.
  • Net::shared_blobs lists the blobs more than one layer reads. Extractor::set_light_mode and
    Net::extractor return Error::Invalid while that list is not empty, because light mode releases
    a bottom blob after its first consumer and the graph would otherwise return the values of that
    consumer; an explicit Split layer keeps a graph compatible.
  • MatView::as_mat exposes the tensor a view aliases, and Net::infer_view_into runs one request
    over sub views and appends the outputs to a caller buffer. It is the zero-copy form for a model
    that takes a crop, a channel or one batch item, and it replaces the copy that
    Extractor::input performs on a view.
  • crates/ncnn/examples/threads.rs runs one network per worker thread and reports the aggregate
    throughput next to a single network that uses every core.
  • The nightly fuzz workflow also fuzzes the pixel view and the typed tensor paths, so the buffer
    checks, region arithmetic, element decoding and reshape validation are covered next to the model
    loaders.
  • CI compares the public API with the published release, resolves every documentation link and
    anchor offline, and a v* tag publishes both packages in dependency order before creating the
    GitHub release from the changelog section.

Changed

  • Mat::normalize_in_place applies the same per-channel view as Mat::normalized, so both forms
    agree on tensors below three dimensions, which the native call otherwise treats as per-row
    coefficients.
  • Normalization writes one pass over the destination instead of copying and then running a native
    Scale layer, so Mat::normalized costs about as much as a bare clone. The scale and bias match
    the native layer; the last bit can differ when the compiler contracts the multiply and the add.
  • Mat::flatten returns unpacked storage, so its result reads through Mat::to_f32 without a typed
    conversion.
  • DataReader::from_bytes builds a bounded memory reader: a read is clamped to the bytes that
    remain instead of failing, and the same handle scans parameter text, which the reader-based
    loaders rely on.
  • A borrowed input now returns Error::Invalid when the network runs with light mode. The native
    forward path reads the storage refcount before an in-place layer may write, and an external tensor
    has none, so the previous combination reached a native null read; owned input is unaffected.
  • The fuzz target also feeds the binary parameter loader and the reader loaders.
  • The coverage job writes an lcov with per-line records, prints the summary, fails below 85 percent
    line coverage, and rejects a report without DA records.
  • The nightly fuzz workflow runs its target on the nightly toolchain, which rust-toolchain.toml
    otherwise shadows, and the version matrix resolves tags with GITHUB_TOKEN, imports the shared SDK
    into the loader path, and reports the declaration gap for tags that cannot link the adapter. A
    passing matrix run comments on the open tracking issue and closes it.
  • Both CPU examples and both device examples run in CI, and rustdoc builds with -D warnings on
    every push instead of only during the documentation deploy.
  • The README drops its validation section and gains single-layer and preprocessing tables next to
    the trained-model table; the CI description stays in docs/support-matrix.md.
  • The Net, NetBuilder, Extractor, OutputGuard, Mat view, gpu and CpuOption items state
    their preconditions, error cases and layout requirements instead of one summary line.
  • A probe test prints the finiteness of three attention configurations. The ubuntu-24.04-arm
    runner matches x86-64 for the two-dimensional operand, while a three-dimensional operand with one
    channel returns NaN for one sequence row there, so the layer case uses the two-dimensional form
    and every case asserts finite output on every target again.
  • Allocator::upload, imports and command recording name the failing operation
    (Error::NativeAt), so a refused allocation reads as Vulkan upload instead of a bare status.
  • docs/contracts.md, docs/troubleshooting.md and docs/evidence-history.md record the measured
    device-memory exhaustion behaviour, and Mat::to_i8 states that it reads signed storage.
  • The performance page records a Linux run of the request-path modes: the modes that reuse storage
    match the C API, and the forms that ret...
Read more

0.2.0

Choose a tag to compare

@Edwardssss Edwardssss released this 09 Nov 16:53

Added

  • ElementKind, Mat::to_f32_typed, Mat::to_i8, Mat::from_typed and Mat::from_i8 read and
    build packed, 16-bit and quantized storage.
  • Extractor::extract_stored, Extractor::extract_stored_owned and Net::infer_stored keep the
    element width a layer wrote, including on Vulkan networks, whose extraction detaches its download
    copy from the pool allocator.
  • examples/typed_tensors.rs and examples/vulkan_resident.rs.
  • Runnable documentation examples for Mat::from_f32, Net::infer and Extractor::extract_stored.
  • CHANGELOG.md, SECURITY.md, docs/troubleshooting.md, docs/migration.md,
    docs/native-abi.md and docs/layer-coverage.md.
  • Every push compares the generated INT8 and operator fixtures against a native C++ reference, a
    coverage job reports line coverage of the wrapper, and a nightly workflow fuzzes the text
    parameter loader and the bounded weight reader.

Changed

  • Every conformance layer case runs one inference; the parameter-only tier is gone.
  • NCNN_TEST_DEVICE=vulkan repeats the operator families, graph pairs and layer cases on the
    default device.
  • Layer cases cover the key/value cache, channels inside depth copies, negative slice starts and
    requantizing convolutions.
  • Error::Invalid carries formatted detail, so shape, name and width mismatches name the values.
  • Mat::to_f32 validates the storage it reads, and the copy-count messages name
    Extractor::extract_stored as the path that avoids a conversion.
  • Public enums are #[non_exhaustive], and the guard requirements are stated as remedies.
  • Thread-affinity requirements are stated on Net, Mat and Device.

Fixed

  • The layer suite selected its child test by a bare name that matched no test, so no case ran.
  • LSTM fixtures supplied half of the recurrent weight block.
  • InverseSpectrogram fixtures supplied one channel where the transform reads one channel per
    frequency bin.
  • ROIAlign fixtures placed the region in a channel-padded tensor that the layer reads flat.

ncnn-rust 0.1.1

Choose a tag to compare

@Edwardssss Edwardssss released this 09 Nov 07:45

Patch release that fixes the Windows link-kind detection and widens the test surface.

Install

cargo add ncnn-rust@0.1.1

Fixes

  • Link kind detection. MSVC names a static library and a DLL import library ncnn.lib, so the
    static default silently linked ncnn.dll and a consumer build failed at launch with
    STATUS_DLL_NOT_FOUND. The build script now derives the kind from the SDK layout, rejects an
    explicit contradiction with the expected setting, and names the directory that holds the DLL.
    The READMEs describe the Windows bin layout.

Tests

  • Vulkan contracts. One test covers device selection, allocator accounting, resident
    inference, guard descriptors, external buffer import, persistent pipeline caches and
    cross-device rejection. It runs on a physical RTX 3060 and on the CI lavapipe device.
  • Every layer type. The conformance suite now has a case for each of the 108 layer types the
    SDK ships; 40 of them reach a forward pass and the rest assert that the type registers and its
    parameters parse.
  • Public API paths. File loading, custom readers, parameter dictionaries, unchecked reads,
    reshape views, the three endpoint forms and concatenated output ranges.
  • Packaged crate build. A job now builds and runs a separate crate that depends on the two
    published archives, which is the only check that sees the published manifest and file list.

Documentation

  • README_zh.md mirrors the English README, and both files link to each other.
  • The version matrix runs monthly; topics are rust and ncnn.

Verification

The v0.1.1 tag passed all eight CI jobs: ubuntu-latest, ubuntu-24.04-arm, windows-latest,
macos-15, macos-15-intel, the 1.85.1 MSRV job, the Vulkan lavapipe job and the packaged crate
build. API reference: https://edwardssss.github.io/ncnn.rust/ncnn_rust/.

ncnn-rust 0.1.0

Choose a tag to compare

@Edwardssss Edwardssss released this 09 Nov 02:35

First release of the safe ncnn-rust API and the ncnn-rust-sys bindings.

Install

cargo add ncnn-rust

ncnn-rust supplies the safe API and ncnn-rust-sys supplies the bindings. Both crates ship Rust
code only; building them compiles the C++ adapters against an ncnn 20261020 SDK that the build
environment supplies through NCNN_INSTALL_DIR. The README covers the SDK feature set, the Vulkan
feature and the runtime loader path.

Contents

  • Owned-input inference with final-vector or reusable-buffer output, and scoped read-only CPU
    output guards that reserve the network without copying.
  • Tensors, image preprocessing, custom layers, readers, allocators and explicit native option
    mapping.
  • Optional Vulkan backend: device selection, resident tensors, allocator, recording commands,
    completed guards, buffer import and persistent pipeline caches.
  • An in-repo conformance suite that covers shapes, elementwise semantics and a zero-allocation
    steady-state gate without external model files.

Documentation

The API reference is published at https://edwardssss.github.io/ncnn.rust/ncnn_rust/. docs.rs
cannot build these crates because its sandbox has no ncnn SDK.

Verification

The v0.1.0 tag passed the CI matrix before publication: ubuntu-latest, ubuntu-24.04-arm,
windows-latest, macos-15, macos-15-intel, the 1.85.1 MSRV job and a Vulkan job on Mesa
lavapipe.