--- test/test_fx.py.orig 2026-04-18 17:21:07 UTC +++ test/test_fx.py @@ -248,9 +248,12 @@ class TestFX(JitTestCase): ) torch.fx.proxy.TracerBase.check_mutable_operations = True + self._torchbind_test_loaded = False if not (IS_FBCODE or IS_WINDOWS or IS_MACOS): lib_file_path = find_library_location("libtorchbind_test.so") - torch.ops.load_library(str(lib_file_path)) + if lib_file_path.exists(): + torch.ops.load_library(str(lib_file_path)) + self._torchbind_test_loaded = True def tearDown(self): super().tearDown() @@ -869,7 +872,7 @@ class TestFX(JitTestCase): self.checkGraphModule(m, (a, b)) def test_native_callable(self): - if IS_FBCODE or IS_WINDOWS or IS_MACOS: + if IS_FBCODE or IS_WINDOWS or IS_MACOS or not self._torchbind_test_loaded: raise unittest.SkipTest("non-portable load_library call used in test") # This test exercises the case where we use FX to translate from Python # code to some native callable object @@ -3062,7 +3065,7 @@ class TestFX(JitTestCase): node.__update_args_kwargs((), {}) def test_torchbind_class_attribute_in_fx(self): - if IS_FBCODE or IS_WINDOWS or IS_MACOS: + if IS_FBCODE or IS_WINDOWS or IS_MACOS or not self._torchbind_test_loaded: self.skipTest( "torch.classes._TorchScriptTesting._StackString is registered, skipping" ) @@ -3079,7 +3082,7 @@ class TestFX(JitTestCase): self.checkGraphModule(m, ()) def test_torchbind_class_attribute_in_fx_tensor_arg(self): - if IS_FBCODE or IS_WINDOWS or IS_MACOS: + if IS_FBCODE or IS_WINDOWS or IS_MACOS or not self._torchbind_test_loaded: self.skipTest( "torch.classes._TorchScriptTesting._ReLUClass is registered, skipping" )