Skip to content

0.3.0

Choose a tag to compare

@github-actions github-actions released this 11 Nov 03:46
· 37 commits to main since this release

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 return independent storage pay a page fault for every output
    page, because glibc maps an output-sized buffer per request and returns it to the kernel on free.
    The troubleshooting entry names the mapping thresholds that keep those pages.
  • The conformance suite resolves its Vulkan device once per test binary instead of once per worker
    thread, so a GPU run touches one native device path whatever the test thread count. The
    troubleshooting page records the Windows abort that no wrapper call can report, with the memory and
    concurrency measurements that ruled out the wrapper as its cause.
  • The evidence history records the standalone C++ reproduction of the light-mode defect that
    Extractor::input_borrowed rejects, on Windows and Linux, together with the upstream issue and the
    proposed fix.
  • Extractor::input and Extractor::input_borrowed restart the native handle once a request
    extracted, so one extractor answers a second request instead of returning the blobs the first one
    cached. The restart recreates the handle, because ncnn's Extractor::clear empties the blob table
    and leaves the handle unable to accept input, and it re-applies the per-extractor settings.
    Extractor::continue_session opts the next input out of that restart, which keeps a key/value
    cache across inputs.
  • Extractor::set_light_mode documents the graphs light mode cannot run: ncnn releases a bottom blob
    after its first consumer, so a blob that feeds several layers (a residual connection, or an input
    consumed twice) needs light mode off.