mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
[TorchGen] Remove unused variables and function imports (#164538)
This PR removes unused code in torchgen. Pull Request resolved: https://github.com/pytorch/pytorch/pull/164538 Approved by: https://github.com/Skylion007, https://github.com/albanD
This commit is contained in:
committed by
PyTorch MergeBot
parent
da49a57d34
commit
1f8ee5da11
@ -654,28 +654,6 @@ def emit_inplace_functionalization_body(
|
||||
for e in translate(unwrapped_args_ctx, functional_sig.arguments(), method=False)
|
||||
]
|
||||
|
||||
if f.func.is_out_fn():
|
||||
mutable_input_post_processing = "\n".join(
|
||||
[
|
||||
f"""
|
||||
at::functionalization::impl::replace_(
|
||||
{a.name}, {"std::get<" + str(i) + ">(tmp_output)" if len(f.func.returns) > 1 else "tmp_output"});
|
||||
at::functionalization::impl::commit_update({a.name});"""
|
||||
for (i, a) in enumerate(f.func.arguments.out)
|
||||
if a.annotation and a.annotation.is_write and a.type.is_tensor_like()
|
||||
]
|
||||
)
|
||||
else:
|
||||
mutable_input_post_processing = "\n".join( # noqa: F841
|
||||
[
|
||||
f"""
|
||||
at::functionalization::impl::replace_({a.name}, tmp_output);
|
||||
at::functionalization::impl::commit_update({a.name});"""
|
||||
for a in f.func.arguments.flat_all
|
||||
if a.annotation and a.annotation.is_write and a.type.is_tensor_like()
|
||||
]
|
||||
)
|
||||
|
||||
meta_conversion_str, meta_call_ctx = convert_to_meta_tensors(dispatcher_sig)
|
||||
# We don't want to run the inplace meta func for ops like .set_(), because:
|
||||
# (1) they're unnecessary: inplace meta checks are only useful for ops like add_(),
|
||||
|
@ -11,8 +11,8 @@ from dataclasses import is_dataclass
|
||||
from enum import auto, Enum
|
||||
from pathlib import Path
|
||||
from pprint import pformat
|
||||
from typing import Any, Generic, NoReturn, TYPE_CHECKING, TypeVar
|
||||
from typing_extensions import assert_never, deprecated, Self
|
||||
from typing import Any, Generic, TYPE_CHECKING, TypeVar
|
||||
from typing_extensions import assert_never, Self
|
||||
|
||||
from torchgen.code_template import CodeTemplate
|
||||
|
||||
@ -98,15 +98,6 @@ def context(msg_fn: Callable[[], str]) -> Iterator[None]:
|
||||
raise
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# A little trick from https://github.com/python/mypy/issues/6366
|
||||
# for getting mypy to do exhaustiveness checking
|
||||
# TODO: put this somewhere else, maybe
|
||||
@deprecated("Use typing_extensions.assert_never instead")
|
||||
def assert_never(x: NoReturn) -> NoReturn: # type: ignore[misc] # noqa: F811
|
||||
raise AssertionError(f"Unhandled type: {type(x).__name__}")
|
||||
|
||||
|
||||
@functools.cache
|
||||
def _read_template(template_fn: str) -> CodeTemplate:
|
||||
return CodeTemplate.from_file(template_fn)
|
||||
|
Reference in New Issue
Block a user