pytorch/torch/_library
rzou 27ec3921bc Optimize mutable torch.library.custom_op overhead (#139513)
We don't need to do a loop over all the args, kwargs in the
AdInplaceOrView key; we just need to bump the version on the args,
kwargs that are mutable.

On the benchmark mentioned in
https://github.com/pytorch/pytorch/issues/139494
this made the time go from
```
mutate2 = 61.72943878173828
no_mutate2 = 36.89440155029297
mutate = 236.3092498779297
no_mutate = 59.31964874267578

```
to
```
mutate2 = 47.976478576660156
no_mutate2 = 38.37468719482422
mutate = 71.21315002441406
no_mutate = 59.7432975769043
```

Test Plan:
- existing tests
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139513
Approved by: https://github.com/bdhirsh
ghstack dependencies: #139509
2024-11-05 18:30:53 +00:00
..
__init__.py [BE][Easy][14/19] enforce style for empty lines in import segments in torch/_[a-c]*/ and torch/_[e-h]*/ and torch/_[j-z]*/ (#129765) 2024-07-31 10:42:50 +00:00
autograd.py [BE][Easy][14/19] enforce style for empty lines in import segments in torch/_[a-c]*/ and torch/_[e-h]*/ and torch/_[j-z]*/ (#129765) 2024-07-31 10:42:50 +00:00
custom_ops.py Optimize mutable torch.library.custom_op overhead (#139513) 2024-11-05 18:30:53 +00:00
fake_class_registry.py Propagate real tensor tracing with torchbind + fixing side effects (#138797) 2024-10-28 06:27:36 +00:00
fake_impl.py [real_tensor_prop] Infer Fake kernels during real tensor prop (#139213) 2024-10-30 21:29:33 +00:00
infer_schema.py [BE]: Update mypy to 1.11.2 (#133816) 2024-09-16 19:44:11 +00:00
simple_registry.py [BE][Easy][14/19] enforce style for empty lines in import segments in torch/_[a-c]*/ and torch/_[e-h]*/ and torch/_[j-z]*/ (#129765) 2024-07-31 10:42:50 +00:00
triton.py [triton_op] Skip HOP dispatch when possible (#132822) 2024-08-08 15:56:40 +00:00
utils.py Optimize mutable torch.library.custom_op overhead (#139513) 2024-11-05 18:30:53 +00:00