|
1 | 1 | # RUN: env MLIR_RUNNER_UTILS=%mlir_runner_utils MLIR_C_RUNNER_UTILS=%mlir_c_runner_utils %PYTHON %s 2>&1 | FileCheck %s |
2 | 2 | # REQUIRES: host-supports-jit |
3 | 3 | import gc, sys, os, tempfile |
| 4 | +from textwrap import dedent |
4 | 5 | from mlir.ir import * |
5 | 6 | from mlir.passmanager import * |
6 | 7 | from mlir.execution_engine import * |
|
21 | 22 | "MLIR_C_RUNNER_UTILS", "../../../../lib/libmlir_c_runner_utils.so" |
22 | 23 | ) |
23 | 24 |
|
| 25 | + |
24 | 26 | # Log everything to stderr and flush so that we have a unified stream to match |
25 | 27 | # errors/info emitted by MLIR to stderr. |
26 | 28 | def log(*args): |
@@ -337,6 +339,7 @@ def callback(a): |
337 | 339 | ctypes.pointer(ctypes.pointer(get_ranked_memref_descriptor(inp_arr))), |
338 | 340 | ) |
339 | 341 |
|
| 342 | + |
340 | 343 | run(testUnrankedMemRefWithOffsetCallback) |
341 | 344 |
|
342 | 345 |
|
@@ -785,15 +788,25 @@ def testDumpToObjectFile(): |
785 | 788 | try: |
786 | 789 | with Context(): |
787 | 790 | module = Module.parse( |
788 | | - """ |
789 | | - module { |
790 | | - func.func @main() attributes { llvm.emit_c_interface } { |
791 | | - return |
792 | | - } |
793 | | - }""" |
| 791 | + dedent( |
| 792 | + """ |
| 793 | + func.func private @printF32(f32) |
| 794 | + func.func @main(%arg0: f32) attributes { llvm.emit_c_interface } { |
| 795 | + call @printF32(%arg0) : (f32) -> () |
| 796 | + return |
| 797 | + } |
| 798 | + """ |
| 799 | + ) |
794 | 800 | ) |
795 | 801 |
|
796 | | - execution_engine = ExecutionEngine(lowerToLLVM(module), opt_level=3) |
| 802 | + execution_engine = ExecutionEngine( |
| 803 | + lowerToLLVM(module), |
| 804 | + opt_level=3, |
| 805 | + # Loading MLIR_C_RUNNER_UTILS is necessary even though we don't actually run the code (i.e., call printF32) |
| 806 | + # because RTDyldObjectLinkingLayer::emit will try to resolve symbols before dumping |
| 807 | + # (see the jitLinkForORC call at the bottom there). |
| 808 | + shared_libs=[MLIR_C_RUNNER_UTILS], |
| 809 | + ) |
797 | 810 |
|
798 | 811 | # CHECK: Object file exists: True |
799 | 812 | print(f"Object file exists: {os.path.exists(object_path)}") |
|
0 commit comments