Skip to content

fix(pnnx): widen bool MemoryData attributes to fp32 in .bin (#6855) - #6956

Open
ktz03 wants to merge 1 commit into
Tencent:masterfrom
ktz03:fix-pnnx-bool-memorydata-6855
Open

fix(pnnx): widen bool MemoryData attributes to fp32 in .bin (#6855)#6956
ktz03 wants to merge 1 commit into
Tencent:masterfrom
ktz03:fix-pnnx-bool-memorydata-6855

Conversation

@ktz03

@ktz03 ktz03 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • pnnx wrote bool constants as 1 byte/element in model.ncnn.bin.
  • MemoryData::load_model() always reads float32, so the bin cursor drifts and every later weight loads shifted data.
  • Widen bool attributes to 0.f / 1.f on write, mirroring the existing int64→int32 path in save_ncnn.cpp.

Test plan

  • Re-run the reporter's minimal repro (Conv2d + register_buffer(..., dtype=torch.bool))
  • Confirm load_param/load_model succeed and output matches torch reference
  • Spot-check a real model that folds bool masks (e.g. YOLOE seg path from the issue)

Fixes #6855

…6855)

pnnx wrote bool constants as 1 byte/element while MemoryData::load_model reads float32, desynchronising every subsequent weight. Mirror the int64->int32 widening path by emitting 0.f/1.f per bool element.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pnnx: bool attributes desynchronise the ncnn .bin — MemoryData declares element count but only 1 byte/element is written

1 participant