Repository navigation
fix(ttnn): import torch inside _create_golden_function_topk (fixes #55212) - #55213
Merged
bbradelTT merged 2 commits intoSep 4, 2026
Merged
Conversation
…re sweep test (fixes tenstorrent#55212)
Contributor
Author
|
Synced branch with latest Verification summary:
|
bbradelTT
approved these changes
Sep 4, 2026
vmelnykovTT
pushed a commit
that referenced
this pull request
Sep 17, 2026
…5212) (#55213) ### Problem & Summary - Fixes #55212: `ttnn.get_golden_function(ttnn.topk)` raised `NameError: name 'torch' is not defined` because `_create_golden_function_topk()` in `ttnn/ttnn/operations/reduction.py` omitted the `import torch` statement inside the closure. - This caused `tests/sweep_framework/sweeps/reduction/topk/topk.py` to comment out `ttnn.get_golden_function(ttnn.topk)` with a workaround comment `"topk golden function is not working, missing import torch"`. ### Changes Made 1. **`ttnn/ttnn/operations/reduction.py`**: Added `import torch` inside `_create_golden_function_topk()`, matching the convention used by `_create_golden_function()`. 2. **`tests/sweep_framework/sweeps/reduction/topk/topk.py`**: Restored the call to `ttnn.get_golden_function(ttnn.topk)` now that the golden function resolves cleanly. ### Verification - Static analysis with `pyflakes ttnn/ttnn/operations/reduction.py` passes with zero undefined names.
morhimanshu
pushed a commit
to morhimanshu/tt-metal
that referenced
this pull request
Oct 1, 2026
…nstorrent#55212) (tenstorrent#55213) ### Problem & Summary - Fixes tenstorrent#55212: `ttnn.get_golden_function(ttnn.topk)` raised `NameError: name 'torch' is not defined` because `_create_golden_function_topk()` in `ttnn/ttnn/operations/reduction.py` omitted the `import torch` statement inside the closure. - This caused `tests/sweep_framework/sweeps/reduction/topk/topk.py` to comment out `ttnn.get_golden_function(ttnn.topk)` with a workaround comment `"topk golden function is not working, missing import torch"`. ### Changes Made 1. **`ttnn/ttnn/operations/reduction.py`**: Added `import torch` inside `_create_golden_function_topk()`, matching the convention used by `_create_golden_function()`. 2. **`tests/sweep_framework/sweeps/reduction/topk/topk.py`**: Restored the call to `ttnn.get_golden_function(ttnn.topk)` now that the golden function resolves cleanly. ### Verification - Static analysis with `pyflakes ttnn/ttnn/operations/reduction.py` passes with zero undefined names.
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.
Problem & Summary
ttnn.get_golden_function(ttnn.topk)raisedNameError: name 'torch' is not definedbecause_create_golden_function_topk()inttnn/ttnn/operations/reduction.pyomitted theimport torchstatement inside the closure.tests/sweep_framework/sweeps/reduction/topk/topk.pyto comment outttnn.get_golden_function(ttnn.topk)with a workaround comment"topk golden function is not working, missing import torch".Changes Made
ttnn/ttnn/operations/reduction.py: Addedimport torchinside_create_golden_function_topk(), matching the convention used by_create_golden_function().tests/sweep_framework/sweeps/reduction/topk/topk.py: Restored the call tottnn.get_golden_function(ttnn.topk)now that the golden function resolves cleanly.Verification
pyflakes ttnn/ttnn/operations/reduction.pypasses with zero undefined names.