Skip to content

feat(tensor): bit-granular read cursor for byteConversionAppend + pub…#390

Merged
LeoBuron merged 1 commit into
mainfrom
feat/bit-granular-read-cursor
Jul 21, 2026
Merged

feat(tensor): bit-granular read cursor for byteConversionAppend + pub…#390
LeoBuron merged 1 commit into
mainfrom
feat/bit-granular-read-cursor

Conversation

@LeoBuron

Copy link
Copy Markdown
Member

…lic unpackSignExtend

The append loop could start WRITING at any bit position (dstStartBit) but always started READING at bit 0 of the source byte pointer — decoding a packed mixed-width stream (DeltaSym: segments rarely start byte-aligned) was impossible.

  • byteConversionAppend gains a trailing srcStartBit: the input cursor is seeded the same way as the output cursor (index srcStartBit/8, phase srcStartBit%8). Reads exactly numValues*dataInBits bits, so segments may also END mid-byte. byteConversion delegates with (0, 0).
  • unpackSignExtend is now public (TensorConversion.h) with a srcStartBit parameter, so DeltaSym-style decoders can sign-extend a segment that starts mid-byte; internally switched from byteConversion to byteConversionAppend (clear-then-set defines all widened bits, no memset).

…lic unpackSignExtend

The append loop could start WRITING at any bit position (dstStartBit) but
always started READING at bit 0 of the source byte pointer — decoding a
packed mixed-width stream (DeltaSym: segments rarely start byte-aligned)
was impossible.

- byteConversionAppend gains a trailing srcStartBit: the input cursor is
  seeded the same way as the output cursor (index srcStartBit/8, phase
  srcStartBit%8). Reads exactly numValues*dataInBits bits, so segments may
  also END mid-byte. byteConversion delegates with (0, 0).
- unpackSignExtend is now public (TensorConversion.h) with a srcStartBit
  parameter, so DeltaSym-style decoders can sign-extend a segment that
  starts mid-byte; internally switched from byteConversion to
  byteConversionAppend (clear-then-set defines all widened bits, no memset).

Co-Authored-By: Claude Fable 5 <[email protected]>
@LeoBuron
LeoBuron requested a review from PandiasChild July 21, 2026 11:33
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d7820690-45c4-48bf-a9a9-bf5b04d42b67

📥 Commits

Reviewing files that changed from the base of the PR and between 9de065f and 927db2b.

📒 Files selected for processing (7)
  • docs/conventions/tensor.md
  • src/tensor/Tensor.c
  • src/tensor/TensorConversion.c
  • src/tensor/include/Tensor.h
  • src/tensor/include/TensorConversion.h
  • test/unit/tensor/UnitTestTensor.c
  • test/unit/tensor/UnitTestTensorConversion.c

📝 Walkthrough

Walkthrough

The tensor conversion bridge now accepts independent source and destination bit offsets. Signed unpacking exposes srcStartBit, uses append-based widening, and has expanded unit coverage and documentation.

Changes

Bit-Offset Conversion

Layer / File(s) Summary
Conversion contracts
src/tensor/include/Tensor.h, src/tensor/include/TensorConversion.h, docs/conventions/tensor.md
byteConversionAppend documents and accepts srcStartBit; unpackSignExtend is declared with mid-byte decoding semantics and documented sign-extension behavior.
Conversion implementation
src/tensor/Tensor.c, src/tensor/TensorConversion.c
Packing and unpacking derive source and destination bit positions, while tensor conversion callers pass the updated arguments.
Offset conversion validation
test/unit/tensor/UnitTestTensor.c, test/unit/tensor/UnitTestTensorConversion.c
Tests cover offset reads, offset transcoding, narrowing, mixed-width round trips, and signed decoding at nonzero offsets.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TensorConversion
  participant unpackSignExtend
  participant byteConversionAppend
  TensorConversion->>unpackSignExtend: decode packed signed values
  unpackSignExtend->>byteConversionAppend: read from srcStartBit
  byteConversionAppend-->>unpackSignExtend: widened values
  unpackSignExtend-->>TensorConversion: sign-extended int32 outputs
Loading

Poem

I’m a rabbit with bits in a row,
Hopping where source and destinations go.
Mid-byte I munch, then widen with care,
Signed little values bloom in the air.
Tests thump their paws: the offsets align!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 76.47% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly points to the main changes: bit-granular reads for byteConversionAppend and making unpackSignExtend public.
Description check ✅ Passed The description is directly related to the PR and accurately summarizes the byteConversionAppend and unpackSignExtend changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/bit-granular-read-cursor

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@LeoBuron
LeoBuron merged commit 927db2b into main Jul 21, 2026
34 checks passed
@LeoBuron
LeoBuron deleted the feat/bit-granular-read-cursor branch July 21, 2026 12:00
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.

1 participant