Skip to content

Fix word alignment of generated testbench weights - #41

Closed
BerkmKuzu1 wants to merge 1 commit into
pulp-platform:mainfrom
BerkmKuzu1:fix/16-weight-alignment
Closed

BerkmKuzu1 wants to merge 1 commit into
pulp-platform:mainfrom
BerkmKuzu1:fix/16-weight-alignment

Conversation

@BerkmKuzu1

Copy link
Copy Markdown

Generated weights use PI_L1, but the standalone testbench's pmsis.h only assigns a section and does not guarantee word alignment. Add aligned(4) to PI_L1 so the generated weights satisfy the aligned-access requirement in #16.

The generated C already uses PI_L1; its alignment is defined by this local stub, so the fix can stay within NEureka without modifying the generator submodule. This also gives the other generated L1 vectors a minimum four-byte alignment, including in 1x1 mode. Tensor contents, layout and the pinned pulp-nnx revision are unchanged; PI_L2 is unchanged.

Add a small regression using the actual HeaderWriter: an odd-sized weight vector following a one-byte object must have a declared alignment of at least four bytes and a word-aligned address when compiled and run.

Validation:

  • git submodule update --init
  • python -B -m unittest discover -s model -p test_weight_alignment.py -v: both tests fail before the fix and pass afterward with native GCC 6.3. The tests need a native compiler selected by CC or gcc on PATH, and skip if none is found.
  • Independently generated real stimuli for 1x1, 3x3 and depthwise 3x3, each with 2-bit and 8-bit weights. For all six generated weight.c files, the minimum-alignment assertion fails with the original stub and passes with this change; native address checks also pass.

RISC-V software linking and RTL simulation were not run. The existing GitLab-backed simulation workflow skips fork PRs, so a green GitHub workflow alone would not establish simulation coverage.

Closes #16.

Guarantee at least four-byte alignment for PI_L1 vectors in the standalone testbench stub. Add declaration and runtime address regression checks using the pinned HeaderWriter.

Closes pulp-platform#16
@FrancescoConti

Copy link
Copy Markdown
Member

I do not see any need for this change or for new tests on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

modify the SW to always generate weights aligned

2 participants