[custom op] Use canonical API to constrain unbacked values (#108372)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/108372
Approved by: https://github.com/angelayi, https://github.com/ezyang
This commit is contained in:
Tugsbayasgalan Manlaibaatar 2023-10-09 12:07:27 -07:00 committed by PyTorch MergeBot
parent 33403336fa
commit 35e48e262c
2 changed files with 4 additions and 5 deletions

View file

@ -782,7 +782,6 @@ def validate_function_matches_schema(
compare(kwargonly, schema.arguments.flat_kwarg_only)
def infer_schema(prototype_function: typing.Callable) -> str:
sig = inspect.signature(prototype_function)

View file

@ -137,9 +137,7 @@ class AbstractImplCtx:
that depends on the data of the input Tensors.
Args:
min (int): A statically known inclusive lower bound for this symint.
min must be at least 2 due to implementation details of
torch.compile. Default: 2.
min (int): A statically known inclusive lower bound for this symint. Default: 0
max (Optional[int]): A statically known inclusive upper bound for this
symint. Default: None
@ -202,5 +200,7 @@ class AbstractImplCtx:
)
result = self._shape_env.create_unbacked_symint()
torch.fx.experimental.symbolic_shapes.constrain_range(result, min=0, max=max)
torch.fx.experimental.symbolic_shapes._constrain_range_for_size(
result, min=min, max=max
)
return result