Skip to content

Commit 8e6b0c7

Browse files
blaine-risterpytorchmergebot
authored andcommitted
[Inductor] Remove no_type_check annotation on properties (pytorch#163570)
Some properties with `cache_on_self` were prevously annotated with `no_type_check`, to get around mypy limitations. This PR replaces both annotations with `cache_property_on_self`, to enable type checking. Pull Request resolved: pytorch#163570 Approved by: https://github.com/mlazos, https://github.com/PaulZhang12, https://github.com/Skylion007
1 parent 0696a4b commit 8e6b0c7

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

torch/_inductor/codegen/simd.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import operator
1212
import textwrap
1313
from collections import Counter
14-
from typing import Any, Callable, Generic, no_type_check, Optional, TYPE_CHECKING, Union
14+
from typing import Any, Callable, Generic, Optional, TYPE_CHECKING, Union
1515
from typing_extensions import TypeVar
1616

1717
import sympy
@@ -46,7 +46,7 @@
4646
from ..runtime.runtime_utils import green_text, yellow_text
4747
from ..scheduler import BaseSchedulerNode, BaseScheduling, WhyNoFuse
4848
from ..utils import (
49-
cache_on_self,
49+
cache_property_on_self,
5050
expr_fits_within_32bit,
5151
get_dtype_size,
5252
IndentedBuffer,
@@ -133,17 +133,15 @@ def __init__(
133133
self.root = root
134134

135135
@property
136-
@cache_on_self
137-
@no_type_check # https://github.com/python/mypy/issues/17184
136+
@cache_property_on_self
138137
def is_reduction(self) -> bool:
139138
return prefix_is_reduction(self.prefix)
140139

141140
def symbol(self) -> sympy.Symbol:
142141
return sympy_index_symbol(self.name)
143142

144143
@property
145-
@cache_on_self
146-
@no_type_check
144+
@cache_property_on_self
147145
def symt(self) -> SymT:
148146
prefix_to_symt = {prefix: symt for symt, prefix in prefix_str.items()}
149147
return prefix_to_symt[self.prefix]
@@ -430,8 +428,7 @@ def simplify_indexing(index: sympy.Expr):
430428
self.initialize_range_tree(pid_cache)
431429

432430
@property
433-
@cache_on_self
434-
@no_type_check # https://github.com/python/mypy/issues/17184
431+
@cache_property_on_self
435432
def num_reduction_dims(self) -> int:
436433
return sum(prefix_is_reduction(prefix) for prefix in self.numels)
437434

0 commit comments

Comments
 (0)