Fix AttributeError in TensorTensor.execute from undefined tile-count method#6
Open
RuifengHua wants to merge 2 commits into
Open
Fix AttributeError in TensorTensor.execute from undefined tile-count method#6RuifengHua wants to merge 2 commits into
RuifengHua wants to merge 2 commits into
Conversation
Commit c38d790 ("NKI Lib 2026-04-13") added TensorTensor.execute() with a loop over self._dst.get_num_tiles_without_virtual_batches(), a method not defined on TileStream or any other class. This resulted in every call to the primitive raising AttributeError, making TensorTensor unusable. The sibling primitives (TensorScalar, Reciprocal) all iterate with self._dst.get_num_tiles(), the method actually defined on TileStream, which returns the product of the tile grid. Fix by calling get_num_tiles(). Add integration tests covering all five ops (multiply/add/subtract/maximum/minimum) across single-tile and multi-tile (partial-tile) shapes, verified in simulation.
|
Thanks for your contribution! I've reached out to our team to review your commit and we will get back to you shortly with any follow-up. |
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.
Summary
TensorTensor.execute()loops overself._dst.get_num_tiles_without_virtual_batches(), but that method is not defined onTileStream(or any other class in the library). Any call to the primitive therefore raisesAttributeError, makingTensorTensorunusable:The sibling elementwise primitives (
TensorScalar,Reciprocal) all iterate their tile loop withself._dst.get_num_tiles()— the method actually defined onTileStream, which returns the product of the tile grid.TensorTensoris the only one referencing the undefined name.This PR fixes the call to
get_num_tiles()and adds an integration test suite for the primitive (which previously had no direct test coverage).Repro (before fix)
Test plan
Added
test/integration/nkilib/experimental/primitives/blas/test_tensor_tensor.py, verified in simulation mode (--test-mode simulation):multiply,add,subtract,maximum,minimum), single-tile and multi-tile shapesP(incl.P > 128with a partial last tile) × free dimF× dtype (float32,bfloat16)AttributeError) and passes after the fixNote: validated in simulation only (no perf claim — this is a correctness fix). Tolerances:
1e-4(fp32) /1e-2(bf16).By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.