Beispiel #1
0
    def compiler():
        with ir.Context(), ir.Location.unknown():
            kernel_func = get_kernel_func_from_module(module)
            timer_func = emit_timer_func()
            wrapped_func = emit_benchmark_wrapped_main_func(
                kernel_func, timer_func)
            main_module_with_benchmark = ir.Module.parse(
                str(timer_func) + str(wrapped_func) + str(kernel_func))
            setup_passes(main_module_with_benchmark)
            c_runner_utils = os.getenv("MLIR_C_RUNNER_UTILS", "")
            assert os.path.exists(c_runner_utils),\
                f"{c_runner_utils} does not exist." \
                f" Please pass a valid value for" \
                f" MLIR_C_RUNNER_UTILS environment variable."
            runner_utils = os.getenv("MLIR_RUNNER_UTILS", "")
            assert os.path.exists(runner_utils),\
                f"{runner_utils} does not exist." \
                f" Please pass a valid value for MLIR_RUNNER_UTILS" \
                f" environment variable."

            engine = ExecutionEngine(
                main_module_with_benchmark,
                3,
                shared_libs=[c_runner_utils, runner_utils])
            return engine.invoke
Beispiel #2
0
 def compile(self, compiler, support_lib: str):
   """Compile the ir.Module."""
   assert self._module is not None, \
       'StressTest: must call build() before compile()'
   assert self._engine is None, \
       'StressTest: must not call compile() repeatedly'
   compiler(self._module)
   self._engine = ExecutionEngine(
       self._module, opt_level=0, shared_libs=[support_lib])
   return self
 def __call__(self, module: ir.Module) -> ExecutionEngine:
     self._passmanager.run(module)
     return ExecutionEngine(module,
                            opt_level=0,
                            shared_libs=[self._support_lib])