Tighten torch.library.infer_schema input types (#130705)

Made the following changes:
- mutates_args is now keyword-only and mandatory. This is to align with
  torch.library.custom_op (which makes it mandatory because it's easy to
  miss)
- op_name is now keyword-only. This helps the readability of the API
- updated all usages of infer_schema

This change is not BC-breaking because we introduced
torch.library.infer_schema a couple of days ago.

Test Plan:
- tests
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130705
Approved by: https://github.com/yushangdi
ghstack dependencies: #131777
This commit is contained in:
rzou
2024-07-26 13:54:19 -07:00
committed by PyTorch MergeBot
parent 957a89f56c
commit e393c7fa05
6 changed files with 59 additions and 50 deletions

View File

@ -104,7 +104,7 @@ def custom_op(qualname, func_or_schema=None):
f"is passed to `custom_op`"
)
schema = infer_schema(func)
schema = infer_schema(func, mutates_args=())
_custom_op_with_schema(qualname, schema)
return func