* pnnx: store bool MemoryData attributes as raw int8
Keep bool constants as one byte per element and select MemoryData
load_type=3. Implement the reserved raw int8 ModelBin loading mode and
pad exported bool data to four bytes so subsequent weights stay aligned.
This preserves the byte representation used by the proposed logical ops.
Add regression coverage for scalar and padded bool exports in both fp16
modes, multidimensional MemoryData, raw int8 loading through reference
and copy readers, trailing fp32 weights, and missing padding. Document
the format.
Based on the bool attribute serialization fixes proposed in:
https://github.com/Tencent/ncnn/pull/6956https://github.com/Tencent/ncnn/pull/6866Fixes#6855
* tools: preserve byte MemoryData when optimizing models
Save MemoryData load_type so raw int8 constants retain their byte
representation after ModelWriter saves the model. Skip fusion paths that
interpret MemoryData as float32 when its elements are not four bytes.
This change does not add bool arithmetic support or automatic type
promotion. Byte bool storage is intended for future logical, comparison
and selection operators.
Validated ncnnoptimize save and reload for scalar and one-to-five-element
bool constants in fp32 and fp16 storage modes, preserving byte values
and element size in all 12 cases.
---------
Co-authored-by: ktz03 <2484593937@qq.com>
Co-authored-by: Giulio Corradi <53930027+giuliocorradi@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
* Harden Net graph loading and metadata validation
Apply count and blob index validation from Tencent/ncnn PRs #6902,
#6916, #6922 and #6949 to both text and binary graph loading. Bound
header counts to 1,000,000 while preserving repeated blob references
and zero-output layers.
Validate text integer tokens and name lengths, shape hint types,
record lengths and extent arithmetic, feature masks, layer type tags,
and one-blob layer connection counts. Guard missing producers during
extraction and handle null custom layer creators.
Own partially loaded layers before reading their connections, honor
registered destroyers on all failure and CPU replacement paths, and
clear stale graph metadata when reloading or rejecting a model.
Add in-memory Net regressions for malformed and truncated inputs, valid
shape layouts, reload isolation, custom layer lifetime and external
inputs, without requiring filesystem access.
Validated with native tests, SqueezeNet inference, ASan/UBSan and
32-bit big-endian PowerPC tests; compile checked Vulkan and reduced
C++03 configurations.
Sources:
https://github.com/Tencent/ncnn/pull/6902https://github.com/Tencent/ncnn/pull/6916https://github.com/Tencent/ncnn/pull/6922https://github.com/Tencent/ncnn/pull/6949
Co-authored-by: kaltsit-10 <kaltsit-10@users.noreply.github.com>
Co-authored-by: beilzx <2069360659@qq.com>
Co-authored-by: ktz03 <2484593937@qq.com>
* docs: add guide for AHB zero-copy input on Android
Address #5531 - the AHB import API (VkAndroidHardwareBufferImageAllocator,
ImportAndroidHardwareBufferPipeline) has no user-facing docs today and
existing users hit linker errors against the official prebuilt because
build-android.cmd targets -DANDROID_PLATFORM=android-21 which strips the
AHB symbols.
The new page covers build prerequisites (__ANDROID_API__ >= 26),
AImageReader_newWithUsage setup, the per-frame call sequence, per-AHB-
pointer pipeline caching (~5000x setup-cost reduction), and trouble-
shooting for #5531 / #5190.
* docs(ahb): add ex.input(VkMat) format-matching caveat + soften cache bound
Two findings from a follow-up spike on Adreno 830:
- ex.input(VkMat) does NOT auto-convert format. The previous draft's hint
"// ex.input(\"data\", dst, cmd);" actually crashes if the network was
loaded with use_fp16_storage / use_fp16_packed (common on Vulkan path) -
NetPrivate::forward_layer recurses on itself looking for an implicit
converter that doesn't exist, observed as a ~180-frame stack overflow at
net.cpp:251. Add a dedicated caveat explaining the failure mode and the
vkdev->convert_packing workaround, and weaken the snippet hint accordingly.
- AImageReader's AHB pool isn't strictly bounded by maxImages. Under steady
state it stays at maxImages (3 -> 3 cache_n in 36 consecutive cycles), but
surface/focus events can transiently push it higher (observed cache_n=7
with maxImages=3 in one run). Soften the "<= maxImages entries" claim.
* docs(ahb): note cross-vendor validation (Adreno + Mali)
Same import path verified end-to-end on:
- Adreno 830, Vulkan 1.3.284 (Galaxy S25 Ultra)
- Mali-G925 Immortalis MC12, Vulkan 1.3.278 (Galaxy Tab S11)
Both report VK_ANDROID_external_memory_android_hardware_buffer spec
version 5 and surface AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420 AHBs from the
camera HAL. Only auxiliary usage bits differ between vendors and are
not consumed by this path (Adreno: 0x20103, Mali: 0x20133).
* Refactor BF16 conversion to use float32_to_bfloat16
* Fix image URL and update build instructions in README
* Remove NCNN_SIMPLEOMP option from workflow
* Update build instructions in how-to-build.md
Add single-file Vulkan pipeline cache save/load support with strict device, driver, shader, and payload validation. Cache compiled SPIR-V per shader hash alongside the driver pipeline cache blob, add focused cache tests, and document the current Vulkan pipeline cache architecture and usage.
Limit Vulkan layer test cache growth with a shared test-only pipeline cache window so repeated test_layer() calls can still exercise cache reuse.
Co-authored-by: futz12 <56149058+futz12@users.noreply.github.com>
Co-authored-by: CLV-Iclucia <89170890+CLV-Iclucia@users.noreply.github.com>
- synchronize the latest English content to the Chinese documentation
- correct spelling errors in the English version of glsl-extention
- Fix spelling 'enable_validation_layer' in src/gpu.cpp