Python Binding's ExecutionEngine memrefCopy

Hi,
I am trying to compile and run a simple piece of MLIR using MLIR’s Python bindings. Whatever I do, it quits with JIT session error: Symbols not found: [ memrefCopy ].

In C++ I can provide ExecutionEngineOptions, but these don’t seem to avalailable from Python. So I have no idea how I can tell it to use libmlir_c_runner_utils.so.

All my attempts to use execution_engine.register_runtime(...) were not successful.

I’d appreciate any hint on how to JIT&execute MLIR from Python when the compilation generates a dependency to memrefCopy.

execution_engine = ExecutionEngine(self.module)
argA = ctypes.pointer(ctypes.pointer(get_ranked_memref_descriptor(self.A)))
argB = ctypes.pointer(ctypes.pointer(get_ranked_memref_descriptor(self.B)))
argC = ctypes.pointer(ctypes.pointer(get_ranked_memref_descriptor(self.C)))
execution_engine.invoke("run", argA, argB, argC)

Hi Frank :slight_smile:

How about:

shared_libs = [
  "../../../../lib/libmlir_runner_utils.so",
  "../../../../lib/libmlir_c_runner_utils.so",
]
execution_engine = ExecutionEngine(
  lowerToLLVM(module), opt_level=3, shared_libs=shared_libs
)

as per llvm-project/mlir/test/python/execution_engine.py at main · llvm/llvm-project · GitHub ?

2 Likes

Oh my, …starring at it without seeing the forest for the trees :face_with_spiral_eyes:

Thanks @nicolasvasilache , this of course works fine.