finch-tensor / Finch-mlir

Rewriting Finch in mlir
0 stars 0 forks source link

Typo fix + a question #1

Closed mtsokol closed 3 months ago

mtsokol commented 3 months ago

Hi @nullplay,

Here's a small typo fix. I managed to build it and run tests locally.

I wanted to expand Python test a bit by evaluating MLIR string with a foo called but for that I need two more imports:

from mlir_standalone.ir import *
from mlir_standalone.dialects import builtin as builtin_d, standalone as standalone_d

from mlir_standalone import passmanager
from mlir_standalone import execution_engine

When importing from mlir_standalone import execution_engine I get a:

ImportError: dlopen(/Users/mateusz/CLionProjects/Finch-mlir/build/python_packages/standalone/mlir_standalone/_mlir_libs/_mlirExecutionEngine.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace (_mlirExecutionEngineCreate)

I wonder what I'm missing here. In my local llvm build I can import execution_engine with locally built Python bindings. I built my llvm repo with:

cmake -G Ninja ../llvm \
    -DLLVM_ENABLE_PROJECTS="mlir;llvm;clang;lld" \
    -DLLVM_TARGETS_TO_BUILD="Native" \
    -DCMAKE_BUILD_TYPE=Release \
    -DMLIR_ENABLE_BINDINGS_PYTHON=ON \
    -DPython3_EXECUTABLE="/usr/local/Caskroom/miniconda/base/envs/mlir-python-bindings-dev/bin/python3" \
ninja
nullplay commented 3 months ago

Hi @mtsokol,

Have you tried running smoketest.py inside build directory? I can successfully run smoketest.py without adding new import lines.

/Users/jaeyeonwon/Finch-mlir/build/python_packages/standalone $ cp ../../../test/python/smoketest.py .
/Users/jaeyeonwon/Finch-mlir/build/python_packages/standalone $ python3 smoketest.py
module {
  %c2_i32 = arith.constant 2 : i32
  %0 = standalone.foo %c2_i32 : i32
}

I'm not sure about the the issue happening when you try monolithic build. I'm building this project on llvm built separately on my local machine with following cmake command.

 cmake -G Ninja ../llvm \    
   -DLLVM_ENABLE_PROJECTS=mlir \  
   -DLLVM_BUILD_EXAMPLES=ON \  
   -DLLVM_TARGETS_TO_BUILD="Native;NVPTX;AMDGPU" \
   -DCMAKE_BUILD_TYPE=Release \
   -DLLVM_ENABLE_ASSERTIONS=ON \
  -DMLIR_ENABLE_BINDINGS_PYTHON=ON
mtsokol commented 3 months ago

smoketest works fine for me as it's right now!

I wanted to expand it to experiment a bit but then I need these additional imports, but one od then fails for me. So it's a separate change that i'm trying to run.