From db81a3f31c52dc7731d63b5b2bf0414a67224e3f Mon Sep 17 00:00:00 2001 From: cyy Date: Thu, 12 Dec 2024 00:15:44 +0000 Subject: [PATCH] [TorchGen] remove remove_non_owning_ref_types from valuetype_type (#142449) It is not used Pull Request resolved: https://github.com/pytorch/pytorch/pull/142449 Approved by: https://github.com/ezyang --- torchgen/api/cpp.py | 9 +-------- torchgen/executorch/api/et_cpp.py | 7 ------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/torchgen/api/cpp.py b/torchgen/api/cpp.py index c46f265b515..7695367a030 100644 --- a/torchgen/api/cpp.py +++ b/torchgen/api/cpp.py @@ -99,22 +99,16 @@ def valuetype_type( *, binds: ArgName, mutable: bool = True, - remove_non_owning_ref_types: bool = False, symint: bool = False, ) -> NamedCType | None: if isinstance(t, BaseType): - if t.name == BaseTy.Tensor or t.name == BaseTy.Scalar: + if t.name in (BaseTy.Tensor, BaseTy.Scalar): return None elif str(t) == "SymInt": if symint: return NamedCType(binds, BaseCType(SymIntT)) else: return NamedCType(binds, BaseCType(longT)) - if remove_non_owning_ref_types: - if t.name == BaseTy.str: - raise AssertionError( - "string ref->value conversion: not implemented yet" - ) # All other BaseType currently map directly to BaseCppTypes. return NamedCType(binds, BaseCType(BaseTypeToCppMapping[t.name])) elif isinstance(t, OptionalType): @@ -150,7 +144,6 @@ def argumenttype_type( binds=binds, mutable=mutable, symint=symint, - remove_non_owning_ref_types=remove_non_owning_ref_types, ) if r is not None: return r diff --git a/torchgen/executorch/api/et_cpp.py b/torchgen/executorch/api/et_cpp.py index 554a63864e0..d09f0079197 100644 --- a/torchgen/executorch/api/et_cpp.py +++ b/torchgen/executorch/api/et_cpp.py @@ -67,7 +67,6 @@ def valuetype_type( t: Type, *, binds: ArgName, - remove_non_owning_ref_types: bool = False, ) -> NamedCType | None: if isinstance(t, BaseType): if t.name == BaseTy.Tensor or t.name == BaseTy.Scalar: @@ -75,11 +74,6 @@ def valuetype_type( # For SymInt we simply treat it as int. elif str(t) == "SymInt": return NamedCType(binds, BaseCType(BaseTypeToCppMapping[BaseTy.int])) - if remove_non_owning_ref_types: - if t.name == BaseTy.str: - raise AssertionError( - "string ref->value conversion: not implemented yet" - ) # All other BaseType currently map directly to BaseCppTypes. return NamedCType(binds, BaseCType(BaseTypeToCppMapping[t.name])) elif isinstance(t, OptionalType): @@ -114,7 +108,6 @@ def argumenttype_type( r = valuetype_type( t, binds=binds, - remove_non_owning_ref_types=remove_non_owning_ref_types, ) if r is not None: return r