mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
[dynamo] Use sentinel value for guard filter. (#151131)
Summary: `None` can collide with the real values in the scope, so we should use a separate value. Also added "has_value" to the struct so that it's more clear whether the value is absent or not. Test Plan: CI Differential Revision: D72881300 Pull Request resolved: https://github.com/pytorch/pytorch/pull/151131 Approved by: https://github.com/jansel, https://github.com/anijain2305
This commit is contained in:
parent
5b16a0704e
commit
be24e7b4b4
|
|
@ -2485,10 +2485,13 @@ class CheckFunctionManager:
|
|||
if guard_filter_fn:
|
||||
|
||||
def make_guard_filter_entry(guard):
|
||||
MISSING = object()
|
||||
name = strip_local_scope(guard.name)
|
||||
if name == "":
|
||||
value = None
|
||||
has_value = False
|
||||
value = MISSING
|
||||
else:
|
||||
has_value = True
|
||||
value = builder.get(guard.name)
|
||||
is_global = is_from_global_source(guard.originating_source)
|
||||
guard_fn = guard.create_fn
|
||||
|
|
@ -2496,6 +2499,7 @@ class CheckFunctionManager:
|
|||
guard_fn = guard.create_fn.func
|
||||
return GuardFilterEntry(
|
||||
name=name,
|
||||
has_value=has_value,
|
||||
value=value,
|
||||
guard_type=guard_fn.__name__,
|
||||
derived_guard_types=tuple(guard.guard_types)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ class GuardFail(NamedTuple):
|
|||
@dataclasses.dataclass(frozen=True)
|
||||
class GuardFilterEntry:
|
||||
name: str
|
||||
has_value: bool
|
||||
value: object
|
||||
guard_type: str
|
||||
derived_guard_types: tuple[str, ...]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user