pytorch/test/custom_operator
rzou 774137d506 Add torch.ops.import_module (#110090)
Generally, to extend PyTorch with custom operators, a user will
create a Python module whose import triggers registration of
the custom operators via a torch.ops.load_library call or a call
to one or more torch.library.* APIs.

It is unexpected for Python modules to have side effects, so some
linters and formatters will complain. Use torch.ops.import_module to
import the module without a linter or formatter complaining.

NB: A more robust API would actually check if a custom op was registered
or modified, but this is technically challenging to do. In the future we
can add a warning if a custom op wasn't registered or modified.

Test Plan:
- existing tests
Pull Request resolved: https://github.com/pytorch/pytorch/pull/110090
Approved by: https://github.com/ezyang
2023-09-27 13:56:47 +00:00
..
CMakeLists.txt Migrate PyTorch to C++17 (#85969) 2022-12-08 02:27:48 +00:00
model.py [BE] Enable ruff's UP rules and autoformat test/ (#105434) 2023-07-19 20:36:06 +00:00
my_custom_ops.py [TORCH_LIBRARY] Add impl_abstract_pystub (#109529) 2023-09-22 04:55:36 +00:00
my_custom_ops2.py [TORCH_LIBRARY] Add impl_abstract_pystub (#109529) 2023-09-22 04:55:36 +00:00
op.cpp [TORCH_LIBRARY] Add impl_abstract_pystub (#109529) 2023-09-22 04:55:36 +00:00
op.h
test_custom_ops.cpp set data permits requires_grad=True on integer tensor 2022-06-01 15:56:32 +00:00
test_custom_ops.py Add torch.ops.import_module (#110090) 2023-09-27 13:56:47 +00:00