[torch.library] Add ability to create library fragments (#98439)

In C++ we have TORCH_LIBRARY_FRAGMENT. This PR adds the same
functionality to the Python torch.library API.

The motivation for this is: for the simple custom op API, we don't want
users to need to deal with Library objects. One way to hide this from
users is to create library fragments.

Test Plan:
- tests that you can create multiple fragments and def+impl operators on each.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/98439
Approved by: https://github.com/ezyang, https://github.com/bdhirsh
This commit is contained in:
Richard Zou
2023-04-07 11:26:35 -07:00
committed by PyTorch MergeBot
parent 618ea6fac3
commit d5120ff18a
3 changed files with 56 additions and 5 deletions

View File

@ -268,6 +268,7 @@ CI_SERIAL_LIST = [
"test_tensor_creation_ops",
"test_sparse_csr",
"test_dispatch",
"test_python_dispatch", # torch.library creation and deletion must be serialized
"test_spectral_ops", # Cause CUDA illegal memory access https://github.com/pytorch/pytorch/issues/88916
"nn/test_pooling",
"nn/test_convolution", # Doesn't respect set_per_process_memory_fraction, results in OOM for other tests in slow gradcheck