mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
Add tests for torch.ops.load_library (#158838)
According to this [comment](https://github.com/pytorch/pytorch/pull/157524#issuecomment-3097899129), adding a related test to keep BC. Pull Request resolved: https://github.com/pytorch/pytorch/pull/158838 Approved by: https://github.com/zou3519
This commit is contained in:
@ -2333,6 +2333,14 @@ TORCH_LIBRARY(test_autograd_function_backed_op, m) {
|
||||
loss.backward()
|
||||
self.assertEqual(x.grad, temp)
|
||||
|
||||
# Using a non-existent DSO is a quick way to trigger an OSError,
|
||||
# which can be used to not break BC.
|
||||
def test_load_library(self):
|
||||
with self.assertRaisesRegex(
|
||||
OSError, "Could not load this library: .*libnoexist.so"
|
||||
):
|
||||
torch.ops.load_library("libnoexist.so")
|
||||
|
||||
|
||||
def op_with_incorrect_schema(testcase, name):
|
||||
lib = testcase.lib()
|
||||
|
Reference in New Issue
Block a user