[Builder] [Bugfix]: guard NB stream-op index extraction for scalar streams - #14
Open
choonsik1 wants to merge 1 commit into
Open
[Builder] [Bugfix]: guard NB stream-op index extraction for scalar streams#14choonsik1 wants to merge 1 commit into
choonsik1 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: