Per-tensor ASYM -> SYM_INT32 staging declares qBits+1, wasting one bit in downstream declared widths

Open
#522 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
40/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c
Domain
embedded-iot

Research direction

Read the per-tensor ASYM to SYM_INT32 staging route in src/tensor/TensorConversion.c around lines 761–764, then trace symInt32QConfig_t, the guard site, and symAccumResultBits. Compare the staged range with the grouped-weight design referenced in #520. Done means the int12 × ASYM-8, N = 8 case declares 23 bits, with a regression test pinning that result.

Written by the indexing model from the issue text.

Description

Summary

The per-tensor ASYM -> SYM_INT32 staging route (src/tensor/TensorConversion.c ~:761-764) declares the staged mantissas (code - zp) with qMaxBits = qBits + 1. The SYM kernels read a width w as the two's-complement range [-2^(w-1), 2^(w-1)-1], i.e. [-2^q, 2^q-1]. The true range of code - zp is ±(2^q - 1). The declared output width of a downstream SYM kernel therefore carries one wasted bit. Example: int12 x ASYM-8, N = 8, declares 24 bits where 23 is exact.

This violates the "no wasted bit in declared widths" rule (the memory planner sizes wires from declared widths).

Context

The grouped-weight path gets the exact range through a kernel-owned code-domain tag (symGroupedWeight_t, follow-up to #520). The per-tensor path has no such channel: the information would have to travel on the SYM_INT32 scratch config (symInt32QConfig_t), the most widely used wire struct.

Suggested fix

A code-domain tag (two's complement vs ASYM image) on the staged SYM_INT32 operand, read by the guard site and the result-width helper (symAccumResultBits), mirroring the grouped design. Pin it with: int12 x ASYM-8, N = 8 -> declared 23.

Found during the #520 follow-ups (Fable review).

Dominant language
C
Stars
2
Forks
3
Avg merge
13h 6m
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from es-ude/OnDeviceTraining

All issues in es-ude/OnDeviceTraining

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.