Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 0 additions & 152 deletions .basedpyright/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -21195,14 +21195,6 @@
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 16,
"endColumn": 31,
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
Expand Down Expand Up @@ -21243,14 +21235,6 @@
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 16,
"endColumn": 31,
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
Expand Down Expand Up @@ -21491,14 +21475,6 @@
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 57,
"endColumn": 72,
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
Expand Down Expand Up @@ -21555,14 +21531,6 @@
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 16,
"endColumn": 31,
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
Expand Down Expand Up @@ -38643,94 +38611,6 @@
"lineCount": 1
}
},
{
"code": "reportUnknownParameterType",
"range": {
"startColumn": 8,
"endColumn": 23,
"lineCount": 1
}
},
{
"code": "reportUnknownParameterType",
"range": {
"startColumn": 30,
"endColumn": 45,
"lineCount": 1
}
},
{
"code": "reportMissingParameterType",
"range": {
"startColumn": 30,
"endColumn": 45,
"lineCount": 1
}
},
{
"code": "reportUnknownParameterType",
"range": {
"startColumn": 47,
"endColumn": 62,
"lineCount": 1
}
},
{
"code": "reportMissingParameterType",
"range": {
"startColumn": 47,
"endColumn": 62,
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 29,
"endColumn": 50,
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 41,
"endColumn": 51,
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 36,
"endColumn": 31,
"lineCount": 3
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 20,
"endColumn": 37,
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 55,
"endColumn": 76,
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 49,
"endColumn": 67,
"lineCount": 1
}
},
{
"code": "reportUnannotatedClassAttribute",
"range": {
Expand Down Expand Up @@ -57867,14 +57747,6 @@
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
"startColumn": 66,
"endColumn": 70,
"lineCount": 1
}
},
{
"code": "reportPrivateLocalImportUsage",
"range": {
Expand Down Expand Up @@ -59541,14 +59413,6 @@
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
"startColumn": 32,
"endColumn": 36,
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
Expand Down Expand Up @@ -72725,22 +72589,6 @@
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 16,
"endColumn": 46,
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 11,
"endColumn": 24,
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
Expand Down
6 changes: 4 additions & 2 deletions loopy/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ class ExpansionState:
"""

kernel: LoopKernel
instruction: InstructionBase
instruction: InstructionBase | None
stack: tuple[ConcreteMatchable, ...]
"""A tuple representing the current expansion stack, as a tuple of
``(name, tag)`` pairs.
Expand All @@ -1238,6 +1238,7 @@ def __hash__(self) -> int:

@property
def insn_id(self) -> str:
assert self.instruction is not None
return self.instruction.id

def apply_arg_context(self, expr: Expression) -> Expression:
Expand Down Expand Up @@ -1530,7 +1531,7 @@ def map_subst_rule(
def __call__(self, # pyright: ignore[reportIncompatibleMethodOverride]
expr: Expression,
kernel: LoopKernel,
insn: InstructionBase,
insn: InstructionBase | None,
*args: P.args, **kwargs: P.kwargs) -> Expression:
"""
:arg insn: A :class:`~loopy.kernel.InstructionBase` of which *expr* is
Expand Down Expand Up @@ -1691,6 +1692,7 @@ def map_subst_rule(
from loopy.match import ConcreteMatchable
new_stack = (*expn_state.stack, ConcreteMatchable(name, tags))

assert expn_state.instruction is not None
if self.within(expn_state.kernel, expn_state.instruction, new_stack):
# expand
rule = self.rules[name]
Expand Down
17 changes: 11 additions & 6 deletions loopy/transform/iname.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def map_reduction(self, expr: Reduction, /,
expn_state: ExpansionState) -> Expression:
if (self.iname_to_split in expr.inames
and self.iname_to_split not in expn_state.arg_context
and expn_state.instruction is not None
and self.within(
expn_state.kernel,
expn_state.instruction)):
Expand All @@ -217,6 +218,7 @@ def map_variable(self, expr: prim.Variable, /,
expn_state: ExpansionState) -> Expression:
if (expr.name == self.iname_to_split
and self.iname_to_split not in expn_state.arg_context
and expn_state.instruction is not None
and self.within(
expn_state.kernel,
expn_state.instruction)):
Expand Down Expand Up @@ -875,6 +877,7 @@ def __init__(self,
def map_reduction(self, expr: Reduction, /,
expn_state: ExpansionState) -> Expression:
if (set(expr.inames) & self.old_inames_set
and expn_state.instruction is not None
and self.within(
expn_state.kernel,
expn_state.instruction,
Expand All @@ -896,15 +899,16 @@ def map_variable(self, expr: prim.Variable, /,
expn_state: ExpansionState) -> Expression:
new_name = self.old_to_new.get(expr.name)

if (new_name is None
or expr.name in expn_state.arg_context
or not self.within(
if (new_name is not None
and expr.name not in expn_state.arg_context
and expn_state.instruction is not None
and self.within(
expn_state.kernel,
expn_state.instruction,
expn_state.stack)):
return super().map_variable(expr, expn_state)
else:
return prim.Variable(new_name)
else:
return super().map_variable(expr, expn_state)

@override
def map_instruction(self,
Expand Down Expand Up @@ -1346,6 +1350,7 @@ def map_reduction(self, expr: Reduction, /,
raise NotImplementedError()

if (self.inames <= set(expr.inames)
and expn_state.instruction is not None
and self.within(
expn_state.kernel,
expn_state.instruction,
Expand Down Expand Up @@ -1544,7 +1549,7 @@ def get_cache_key(self, expr: Expression, expn_state: ExpansionState) -> Hashabl
@override
def map_reduction(self, expr: Reduction, /,
expn_state: ExpansionState) -> Expression:
within = self.within(
within = expn_state.instruction is not None and self.within(
expn_state.kernel,
expn_state.instruction,
expn_state.stack)
Expand Down
1 change: 1 addition & 0 deletions loopy/transform/loop_fusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ def map_reduction(self,
outer_redn_inames: frozenset[InameStr] = _EMPTY_INAME_SET
):
redn_inames = frozenset(expr.inames)
assert expn_state.instruction is not None
iname_chain = (
expn_state.instruction.within_inames | outer_redn_inames | redn_inames
)
Expand Down
1 change: 1 addition & 0 deletions loopy/transform/precompute.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ def map_subst_rule(self,
expn_state: ExpansionState):
if not (
name == self.subst_name
and expn_state.instruction is not None
and self.within(
expn_state.kernel,
expn_state.instruction,
Expand Down
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,19 @@ filterwarnings = [
'ignore:.*:loopy.diagnostic.DirectCallUncachedWarning',
]

[tool.ty]
baseline = ".ty-baseline.json"

[tool.ty.analysis]
return-type-inference = "always"

# https://docs.astral.sh/ty/coming-from-mypy-or-pyright/#recommended-configuration
[tool.ty.rules]
dynamic-function-decorator-return = "error"
missing-type-argument = "error"
possibly-unresolved-reference = "warn"
unsound-return-statement = "error"

[tool.basedpyright]
reportImplicitStringConcatenation = "none"
reportUnnecessaryIsInstance = "none"
Expand Down
Loading