Skip to content

Add new_empty (with dtype argument only) to torch::stable #159508

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

Open
wants to merge 4 commits into
base: gh/mikaylagawarecki/331/base
Choose a base branch
from

Conversation

mikaylagawarecki
Copy link
Contributor

@mikaylagawarecki mikaylagawarecki commented Jul 30, 2025

…(pending header-onlyness)

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Jul 30, 2025

🔗 Helpful Links

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

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

❌ 4 New Failures

As of commit ae40182 with merge base 556e2a7 (image):

NEW FAILURES - The following jobs have failed:

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

mikaylagawarecki added a commit that referenced this pull request Jul 30, 2025
…(pending header-onlyness)

ghstack-source-id: 6cde171
Pull Request resolved: #159508
Copy link
Contributor

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

…le::Tensor (pending header-onlyness)"

needs ScalarType.h, which needs to be header-only




[ghstack-poisoned]
mikaylagawarecki added a commit that referenced this pull request Aug 4, 2025
…(pending header-onlyness)

ghstack-source-id: b06a267
Pull Request resolved: #159508
…le::Tensor (pending header-onlyness)"

needs ScalarType.h, which needs to be header-only




[ghstack-poisoned]
mikaylagawarecki added a commit that referenced this pull request Aug 11, 2025
ghstack-source-id: 4c53a24
Pull Request resolved: #159508
Comment on lines +407 to +416
if not has_function_variant:
# Functions with both function and method variants can use the at::{*}_symint version
# (e.g., narrow -> at::narrow_symint), BUT
# Method-only functions with symint parameters should use at::symint:: namespace
# Remove the _symint suffix since at::symint:: namespace uses the base name
# (e.g., new_empty -> at::symint::new_empty<c10::SymInt>)
base_name = cpp_sig.name()
base_name = base_name.removesuffix("_symint") # Remove "_symint" suffix
return f"at::symint::{base_name}<c10::SymInt>"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the relevant part here

pytorch/torchgen/gen.py

Lines 717 to 739 in 6d91d6d

if Variant.function in f.variants:
result += f"""
// aten::{f.func}
inline {sig.decl()} {{
return at::_ops::{f.func.name.unambiguous_name()}::call({exprs_str});
}}"""
# The template function can be used from template situations
# where you want to switch between the symint or not version
# depending on a template argument
#
# NB: we ALWAYS generate this even for methods. But we put it in
# this header so it can take advantage of per-op headers
if has_symint:
result += f"""
namespace symint {{
template <typename T, typename = std::enable_if_t<std::is_same_v<T, {intlike_t}>>>
{sig.decl(suppress_symint_suffix=True)} {{
return at::_ops::{f.func.name.unambiguous_name()}::call({exprs_str});
}}
}}
"""
return result

@mikaylagawarecki mikaylagawarecki changed the title Add new_empty to torch::stable + dtype/scalar_type to stable::Tensor (pending header-onlyness) Add new_empty (with dtype argument only) to torch::stable Aug 11, 2025
needs ScalarType.h, which needs to be header-only




[ghstack-poisoned]
mikaylagawarecki added a commit that referenced this pull request Aug 11, 2025
ghstack-source-id: ac037b9
Pull Request resolved: #159508
@mikaylagawarecki mikaylagawarecki marked this pull request as ready for review August 11, 2025 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant