Ignore reductions of zero-dim tensors per PyTorch conventions#1771
Merged
Ignore reductions of zero-dim tensors per PyTorch conventions#1771
Conversation
52e8806 to
6cffe01
Compare
jjsjann123
reviewed
Jun 24, 2022
|
|
||
| // PyTorch allows reduction of 0-dim tensors | ||
| if (tv->domain()->noReductions().size() == 0) { | ||
| return reductionOpZeroDimTensor(tv); |
Collaborator
There was a problem hiding this comment.
nitpick, do we need to explicitly construct out here? Wondering if this gives us anything other than a simple return set(inp);
jjsjann123
approved these changes
Jun 24, 2022
Collaborator
jjsjann123
left a comment
There was a problem hiding this comment.
LGTM, minor comment/question.
shmsong
pushed a commit
to shmsong/pytorch
that referenced
this pull request
Jul 24, 2022
Syncing nvfuser devel branch to upstream master. https://github.com/csarofeen/pytorch/ Code changes includes: - TransformPropagator refactor: switched to Dijkstra instead of exhaustive enumeration on all possible paths to reduce compilation time on transform propagation; - Indexing refactor: remove reference tensor creation in all tensor indexing logic (csarofeen#1690) - (more) generic grouped grid reduction kernel; - Minor parser/fuser patches: 1. zero-dim tensor reduction support 3. no-op binary removal within fused graph 4. expand supported in fusion Squashed commits to WAR github API Commits that's actually in this PR from the devel branch: ``` a054b3e Refactor TransormPropagator to allow specifying a position and propagating to part of the DAG (csarofeen#1775) d67e1cd Indexing refactor stage 1: remove reference tensor creation in all tensor indexing logic (csarofeen#1690) 1b65299 Issue 1770 (csarofeen#1774) 35b0427 Avoid compilation errors like below: (csarofeen#1773) 452c773 Ignore reductions of zero-dim tensors per PyTorch conventions (csarofeen#1771) 31d6c56 TransformPropagator refactor (csarofeen#1769) 570c5a8 Merge pull request csarofeen#1767 from csarofeen/upstream_merge_0621 9d6c3d8 merging upstream 61305cd 0ed815f New TransformPropagator algorithm (csarofeen#1763) 6c19520 no-op binary removal (csarofeen#1764) ec7fa41 Proper propagation of IterType (csarofeen#1762) b263562 Fix dimensionality check (csarofeen#1759) 2d6343f More generic grouped grid reduction kernel (csarofeen#1740) 64e2b56 [nvfuser] prevent spamming warning message (pytorch#77777) (csarofeen#1758) 0c43162 [nvFuser] Improving bitwise ops support (pytorch#77158) (csarofeen#1757) b93a147 Parser expand (csarofeen#1754) ``` RUN_TORCHBENCH: nvfuser Pull Request resolved: pytorch#80355 Approved by: https://github.com/davidberard98
jjsjann123
added a commit
to NVIDIA/Fuser
that referenced
this pull request
Jul 25, 2025
Reducing 0-dimensional inputs is allowed since csarofeen/pytorch#1771. In this PR I added a fallback path for the `var_mean` op, so that it doesn't hit this check https://github.com/NVIDIA/Fuser/blob/4483f51a396a8c594caae8078e3cb82c7d3caa44/csrc/ops/arith.cpp#L1724 The change in the `numFeatures` function is required to avoid segfaults. --------- Co-authored-by: Christian Sarofeen <csarofeen@nvidia.com> Co-authored-by: jjsjann123 <jiej@nvidia.com>
nsarka
pushed a commit
to nsarka/Fuser
that referenced
this pull request
Jul 28, 2025
Reducing 0-dimensional inputs is allowed since csarofeen/pytorch#1771. In this PR I added a fallback path for the `var_mean` op, so that it doesn't hit this check https://github.com/NVIDIA/Fuser/blob/4483f51a396a8c594caae8078e3cb82c7d3caa44/csrc/ops/arith.cpp#L1724 The change in the `numFeatures` function is required to avoid segfaults. --------- Co-authored-by: Christian Sarofeen <csarofeen@nvidia.com> Co-authored-by: jjsjann123 <jiej@nvidia.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.
Fixes #1768
We should also add a python test, but I'm having a build problem right now.