Skip to content

0D/1D support for generic reduce #16623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bbradelTT opened this issue Jan 10, 2025 · 1 comment · Fixed by #19517
Closed

0D/1D support for generic reduce #16623

bbradelTT opened this issue Jan 10, 2025 · 1 comment · Fixed by #19517
Assignees

Comments

@bbradelTT
Copy link
Contributor

bbradelTT commented Jan 10, 2025

From @ayerofieiev-tt

There is probably also a bug for 1D tensors in ops like Sum
If user specifies a dimension over which to make a reduction and an input tensor is 1D...
0 dim will actually mean 1 dim

Will need to look into this once 0D/1D tiled tensor support is fully in.

Would also be good to look at 0 volume tensors (one dimension has size 0). E.g. for 2D and 4D.

@bbradelTT
Copy link
Contributor Author

Directory: ttnn/cpp/ttnn/operations/reduction

@bbradelTT bbradelTT assigned nsorabaTT and unassigned bbradelTT Mar 19, 2025
@nsorabaTT nsorabaTT linked a pull request Mar 22, 2025 that will close this issue
7 tasks
@bbradelTT bbradelTT changed the title 0D/1D support for reduce 0D/1D support for generic reduce Mar 24, 2025
github-merge-queue bot pushed a commit that referenced this issue Mar 25, 2025
### Ticket
[Link to Github
Issue](#16623)

### Problem description
Currently, generic reduction operations only support non-zero volume
tensors and tensors with rank >=2.

[This](#19480) and
[this](#19478) impact 1D
std/var and min/max as well. To be taken up separately.

### What's changed
This PR adds the following:

1. Support 0D and 1D tensors for all generic ops
2. Support zero volume tensors of any rank (0-4)
4. Add a sweep to test all generic reduction ops across all zero and non
zero volume tensors for ranks 0-4.
5. Add unit tests for handpicked cases from above
6. Allow "scalar" to propagate to all generic reduce ops.

| Reduce Op | All ranks supported | Zero volume supported? | Matches
Torch? |

|-----------|----------------------|------------------------|-----------------|
| `sum` | Y | Y | Y |
| `mean` | Y | Y | Y |
| `max` | Y | Y | Y |
| `min` | Y | Y | Y |
| `std` | Y | Y | N |
| `var` | Y | Y | N |


#### Review hint:
`f3f2be19bb8349a530d6263aa7d44a012e907ad4` cleans up existing sweeps.
Rest adds new features.

### Checklist
- [x] [All post
commit](https://github.com/tenstorrent/tt-metal/actions/workflows/all-post-commit-workflows.yaml)
[CI 28265 passing
](https://github.com/tenstorrent/tt-metal/actions/runs/14041777945)
- [ ] [Blackhole Post
commit](https://github.com/tenstorrent/tt-metal/actions/workflows/blackhole-post-commit.yaml)
CI passes (if applicable)
- [ ] [Model
regression](https://github.com/tenstorrent/tt-metal/actions/workflows/perf-models.yaml)
CI passes (if applicable)
- [ ] [Device performance
regression](https://github.com/tenstorrent/tt-metal/actions/workflows/perf-device-models.yaml)
CI passes (if applicable)
- [ ] **(For models and ops writers)** Full [new models
tests](https://github.com/tenstorrent/tt-metal/actions/workflows/full-new-models-suite.yaml)
CI passes (if applicable)
- [x] New/Existing tests provide coverage for changes
- [x] [ttnn - Run sweeps
#2457](https://github.com/tenstorrent/tt-metal/actions/runs/14041766008)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants