[TorchGen] Simplify argument_type_str (#142491)

Fixes #ISSUE_NUMBER

Pull Request resolved: https://github.com/pytorch/pytorch/pull/142491
Approved by: https://github.com/ezyang
This commit is contained in:
cyy
2024-12-11 19:01:16 +00:00
committed by PyTorch MergeBot
parent 42d4eec5f3
commit e228381846

View File

@ -656,15 +656,14 @@ def argument_type_str(
t: Type, *, simple_type: bool = False, symint: bool = True
) -> str:
if isinstance(t, BaseType):
if t.name == BaseTy.Tensor:
return "Tensor"
elif t.name == BaseTy.int:
if t.name == BaseTy.int:
return "int64_t"
elif t.name == BaseTy.float:
return "double"
elif t.name == BaseTy.str:
return "c10::string_view"
elif t.name in [
BaseTy.Tensor,
BaseTy.bool,
BaseTy.QScheme,
BaseTy.Scalar,
@ -683,9 +682,6 @@ def argument_type_str(
return t.name.name
elif isinstance(t, OptionalType):
if str(t.elem) == "Tensor":
# Is it desired to keep '?' for simple_type with new style dispatcher?
return "Tensor?"
elem = argument_type_str(t.elem, simple_type=simple_type, symint=symint)
return f"{elem}?"
elif isinstance(t, ListType):