mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Add new_empty (with dtype argument only) to torch::stable (#159508)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/159508 Approved by: https://github.com/janeyx99 ghstack dependencies: #160557
This commit is contained in:
committed by
PyTorch MergeBot
parent
543896fcf3
commit
78a8e6a671
@ -186,4 +186,5 @@ aten_shimified_ops: dict[str, dict[str, list[str]]] = {
|
||||
"aten.pad.default": {},
|
||||
"aten.narrow.default": {},
|
||||
"aten.amax.default": {},
|
||||
"aten.new_empty.default": {},
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ from torchgen.model import (
|
||||
OperatorName,
|
||||
OptionalType,
|
||||
Type,
|
||||
Variant,
|
||||
)
|
||||
from torchgen.utils import FileManager, mapMaybe
|
||||
|
||||
@ -396,7 +397,22 @@ def gen_static_dispatch_backend_call(
|
||||
) -> str:
|
||||
sig = DispatcherSignature.from_schema(f.func)
|
||||
cpp_sig = gen_static_dispatch_backend_call_signature(sig, f)
|
||||
|
||||
if backend_index is None:
|
||||
# Check if this is a symint function and if the function only has method variants
|
||||
if sig.symint and f.func.has_symint():
|
||||
has_function_variant = Variant.function in f.variants
|
||||
|
||||
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>"
|
||||
|
||||
return f"at::{cpp_sig.name()}"
|
||||
else:
|
||||
return f"at::{backend_index.dispatch_key.lower()}::{cpp_sig.name()}"
|
||||
|
Reference in New Issue
Block a user