[Mlir-commits] [mlir] [MLIR] Tweak standalone example `smoketest.py` (PR #112448)

Mateusz Sokół llvmlistbot at llvm.org
Tue Oct 15 15:35:44 PDT 2024


https://github.com/mtsokol created https://github.com/llvm/llvm-project/pull/112448

Hi!
While working with MLIR standalone example it took me some time to figure out how to access dialects and execution engine from MLIR Python package.

I think it might be useful to include them in the standalone build already. WDYT?


>From 657b00d80808e0fe99b07435c8b40821c013cc58 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mateusz=20Sok=C3=B3=C5=82?= <mat646 at gmail.com>
Date: Tue, 15 Oct 2024 22:31:26 +0000
Subject: [PATCH] Tweak standalone example `smoketest.py`

---
 mlir/examples/standalone/python/CMakeLists.txt    | 2 ++
 mlir/examples/standalone/test/python/smoketest.py | 8 +++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/mlir/examples/standalone/python/CMakeLists.txt b/mlir/examples/standalone/python/CMakeLists.txt
index a8c43827a5a375..b948f4d524e0b5 100644
--- a/mlir/examples/standalone/python/CMakeLists.txt
+++ b/mlir/examples/standalone/python/CMakeLists.txt
@@ -43,7 +43,9 @@ add_mlir_python_common_capi_library(StandalonePythonCAPI
     # TODO: Remove this in favor of showing fine grained registration once
     # available.
     MLIRPythonExtension.RegisterEverything
+    MLIRPythonExtension.ExecutionEngine
     MLIRPythonSources.Core
+    MLIRPythonSources.Dialects
 )
 
 ################################################################################
diff --git a/mlir/examples/standalone/test/python/smoketest.py b/mlir/examples/standalone/test/python/smoketest.py
index 08e08cbd2fe24c..3ea4283f8f41c2 100644
--- a/mlir/examples/standalone/test/python/smoketest.py
+++ b/mlir/examples/standalone/test/python/smoketest.py
@@ -1,7 +1,13 @@
 # RUN: %python %s | FileCheck %s
 
 from mlir_standalone.ir import *
-from mlir_standalone.dialects import builtin as builtin_d, standalone as standalone_d
+from mlir_standalone import execution_engine, passmanager
+from mlir_standalone.dialects import (
+    builtin as builtin_d,
+    linalg as linalg_d,
+    sparse_tensor as sparse_tensor_d,
+    standalone as standalone_d,
+)
 
 with Context():
     standalone_d.register_dialect()



More information about the Mlir-commits mailing list