Skip to content

[Builder] [Bugfix]: guard NB stream-op index extraction for scalar streams - #14

Open
choonsik1 wants to merge 1 commit into
sunwookim028:mainfrom
choonsik1:fix/nb-stream-scalar
Open

[Builder] [Bugfix]: guard NB stream-op index extraction for scalar streams#14
choonsik1 wants to merge 1 commit into
sunwookim028:mainfrom
choonsik1:fix/nb-stream-scalar

Conversation

@choonsik1

@choonsik1 choonsik1 commented Jul 22, 2026

Copy link
Copy Markdown

Description

The four non-blocking stream-op branches (try_put/try_get/empty/full) in build_Call read node.func.value.slice unconditionally to extract array indices. That attribute only exists for a subscripted stream (S[0].empty(), an ast.Subscript); a scalar stream call (fifo.empty(), an ast.Name) raised "'Name' object has no attribute 'slice'". Only the indexed path was covered by tests, so the scalar path was never exercised.

Proposed Solutions

Fix: guard the index extraction with isinstance(node.func.value, ast.Subscript) and pass indices=[] for scalar streams (an empty index list is valid downstream -- the emitter prints no subscript, the simulator reads head/tail from the stream struct regardless). This mirrors the guard the infer.py branch already has.

Examples

Add tests/dataflow/test_stream_nb_scalar.py: empty/full/try_get/try_put on scalar streams (sim + HLS codegen). Fails on pre-fix code. Indexed-path tests (test_stream_nb_simple, test_stream_ops_*) still pass -- no regression.

Checklist

Please make sure to review and check all of these items:

  • PR's title starts with a category (e.g. [Bugfix], [IR], [Builder], etc)
  • All changes have test coverage (It would be good to provide ~2 different test cases to test the robustness of your code)
  • Pass the formatting check locally
  • Code is well-documented

The four non-blocking stream-op branches (try_put/try_get/empty/full) in
build_Call read node.func.value.slice unconditionally to extract array
indices. That attribute only exists for a subscripted stream (S[0].empty(),
an ast.Subscript); a scalar stream call (fifo.empty(), an ast.Name) raised
"'Name' object has no attribute 'slice'". Only the indexed path was covered
by tests, so the scalar path was never exercised.

Fix: guard the index extraction with isinstance(node.func.value,
ast.Subscript) and pass indices=[] for scalar streams (an empty index list
is valid downstream -- the emitter prints no subscript, the simulator reads
head/tail from the stream struct regardless). This mirrors the guard the
infer.py branch already has.

Add tests/dataflow/test_stream_nb_scalar.py: empty/full/try_get/try_put on
scalar streams (sim + HLS codegen). Fails on pre-fix code. Indexed-path
tests (test_stream_nb_simple, test_stream_ops_*) still pass -- no regression.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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