Skip to content

Make at::vec::Vectorized ops work with scalars #150380

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
wants to merge 6 commits into from

Conversation

swolchok
Copy link
Contributor

@swolchok swolchok commented Apr 1, 2025

Stack from ghstack (oldest at bottom):

I noticed that I couldn't use vec::Vectorized operations with scalars, even though there is an implicit conversion from T to vec::Vectorized<T>, so I made it work.

Test Plan: Added tests. Reverted vec_base.h, left the new tests in place, and confirmed that new tests don't compile in that state.

cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Apr 1, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/150380

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit ed186e4 with merge base caf8d9b (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added the module: cpu CPU specific problem (e.g., perf, algorithm) label Apr 1, 2025
swolchok added a commit that referenced this pull request Apr 1, 2025
I noticed that I couldn't use `vec::Vectorized` operations with scalars, even though there is an implicit conversion from `T` to `vec::Vectorized<T>`, so I made it work.

Test Plan: Added tests. Reverted vec_base.h, left the new tests in place, and confirmed that new tests don't compile in that state.

ghstack-source-id: 6fce62e30b7ba4a6ad6f786c0412dcc046b0f4d8
Pull Request resolved: #150380
@@ -668,6 +680,8 @@ template <class T> Vectorized<T> inline operator+(const Vectorized<T> &a, const
return c;
}

VECTORIZED_SUPPORT_SCALARS_FOR_BINARY_OP(+)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's with the indentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's what my editor wanted to do. this file isn't formatted by lintrunner :\

Copy link
Contributor Author

@swolchok swolchok Apr 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sent PR to autoformat top-level vec headers

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Apr 1, 2025
I noticed that I couldn't use `vec::Vectorized` operations with scalars, even though there is an implicit conversion from `T` to `vec::Vectorized<T>`, so I made it work.

Test Plan: Added tests. Reverted vec_base.h, left the new tests in place, and confirmed that new tests don't compile in that state.

ghstack-source-id: 1c229f424c6ccc72eb9d10a6c8e2293c7890dcc7
Pull Request resolved: #150380
@swolchok swolchok added the release notes: cpp release notes category label Apr 1, 2025
@swolchok swolchok requested a review from Skylion007 April 1, 2025 17:06
[ghstack-poisoned]
swolchok added a commit that referenced this pull request Apr 2, 2025
I noticed that I couldn't use `vec::Vectorized` operations with scalars, even though there is an implicit conversion from `T` to `vec::Vectorized<T>`, so I made it work.

Test Plan: Added tests. Reverted vec_base.h, left the new tests in place, and confirmed that new tests don't compile in that state.

ghstack-source-id: b000faca381a09cae767a2751bce90cf8e11bc08
Pull Request resolved: #150380
[ghstack-poisoned]
[ghstack-poisoned]
@swolchok
Copy link
Contributor Author

swolchok commented Apr 3, 2025

ping

pytorchmergebot pushed a commit that referenced this pull request Apr 4, 2025
I got a complaint about indentation on #150380. Make the machines fix it for us.

Pull Request resolved: #150426
Approved by: https://github.com/aditew01, https://github.com/cyyever, https://github.com/frost-intel, https://github.com/Skylion007
@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #150568

1 similar comment
@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #150568

@swolchok
Copy link
Contributor Author

swolchok commented Apr 4, 2025

@Skylion007 can you please take another look?

@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #150568

1 similar comment
@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #150568

[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Rebased gh/swolchok/730/orig onto refs/remotes/origin/viable/strict because #150568 was rebased, please pull locally before adding more changes (for example, via ghstack checkout https://github.com/pytorch/pytorch/pull/150380)

@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #150568

pytorchmergebot pushed a commit that referenced this pull request Apr 6, 2025
Makes Vectorized look even more like a scalar type, getting me closer to being able to use the same generic code with scalars and Vectorized (e.g., for sigmoid, which needs `exp(-x)`).

Pull Request resolved: #150568
Approved by: https://github.com/Skylion007
ghstack dependencies: #150380
timocafe pushed a commit to timocafe/pytorch that referenced this pull request Apr 16, 2025
timocafe pushed a commit to timocafe/pytorch that referenced this pull request Apr 16, 2025
I noticed that I couldn't use `vec::Vectorized` operations with scalars, even though there is an implicit conversion from `T` to `vec::Vectorized<T>`, so I made it work.

Test Plan: Added tests. Reverted vec_base.h, left the new tests in place, and confirmed that new tests don't compile in that state.

Pull Request resolved: pytorch#150380
Approved by: https://github.com/Skylion007
timocafe pushed a commit to timocafe/pytorch that referenced this pull request Apr 16, 2025
…ch#150568)

Makes Vectorized look even more like a scalar type, getting me closer to being able to use the same generic code with scalars and Vectorized (e.g., for sigmoid, which needs `exp(-x)`).

Pull Request resolved: pytorch#150568
Approved by: https://github.com/Skylion007
ghstack dependencies: pytorch#150380
amathewc pushed a commit to amathewc/pytorch that referenced this pull request Apr 17, 2025
amathewc pushed a commit to amathewc/pytorch that referenced this pull request Apr 17, 2025
I noticed that I couldn't use `vec::Vectorized` operations with scalars, even though there is an implicit conversion from `T` to `vec::Vectorized<T>`, so I made it work.

Test Plan: Added tests. Reverted vec_base.h, left the new tests in place, and confirmed that new tests don't compile in that state.

Pull Request resolved: pytorch#150380
Approved by: https://github.com/Skylion007
amathewc pushed a commit to amathewc/pytorch that referenced this pull request Apr 17, 2025
…ch#150568)

Makes Vectorized look even more like a scalar type, getting me closer to being able to use the same generic code with scalars and Vectorized (e.g., for sigmoid, which needs `exp(-x)`).

Pull Request resolved: pytorch#150568
Approved by: https://github.com/Skylion007
ghstack dependencies: pytorch#150380
Divigroup-RAP pushed a commit to Divigroup-RAP/PYTORCH that referenced this pull request Apr 22, 2025
I noticed that I couldn't use `vec::Vectorized` operations with scalars, even though there is an implicit conversion from `T` to `vec::Vectorized<T>`, so I made it work.

Test Plan: Added tests. Reverted vec_base.h, left the new tests in place, and confirmed that new tests don't compile in that state.

ghstack-source-id: 8ae256b5f0a68bb8067116e7879fe47f3a00107a
Pull Request resolved: pytorch/pytorch#150380
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merged module: cpu CPU specific problem (e.g., perf, algorithm) release notes: cpp release notes category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants