Test export_library method.
()
| 100 | |
| 101 | |
| 102 | def test_executable_export_library(): |
| 103 | """Test export_library method.""" |
| 104 | lib = tvm.tirx.build(MyModule, target="llvm") |
| 105 | executable = Executable(lib) |
| 106 | |
| 107 | # Create a temporary directory for the library |
| 108 | temp_dir = tempfile.mkdtemp() |
| 109 | try: |
| 110 | lib_path = os.path.join(temp_dir, "test_lib.so") |
| 111 | executable.export_library(lib_path) |
| 112 | |
| 113 | # Verify the library was created |
| 114 | assert os.path.exists(lib_path) |
| 115 | |
| 116 | # Load the library back |
| 117 | loaded_mod = tvm.runtime.load_module(lib_path) |
| 118 | assert loaded_mod is not None |
| 119 | |
| 120 | # Test the loaded module |
| 121 | a = tvm.runtime.tensor(np.array([1.0] * 10, dtype="float32")) |
| 122 | b = tvm.runtime.tensor(np.array([2.0] * 10, dtype="float32")) |
| 123 | c = tvm.runtime.tensor(np.array([0.0] * 10, dtype="float32")) |
| 124 | |
| 125 | loaded_mod["add"](a, b, c) |
| 126 | |
| 127 | # Check results |
| 128 | tvm.testing.assert_allclose(c.numpy(), np.array([3.0] * 10, dtype="float32")) |
| 129 | finally: |
| 130 | # Clean up |
| 131 | if os.path.exists(temp_dir): |
| 132 | import shutil |
| 133 | |
| 134 | shutil.rmtree(temp_dir) |
| 135 | |
| 136 | |
| 137 | def test_executable_export_library_with_workspace(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…