Skip to content

Commit

Permalink
Use wheel from GitHub release
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsokol committed Oct 22, 2024
1 parent 32abcf0 commit b15dd11
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 28 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest']
python: ['3.10', '3.11', '3.12']
python: ['3.10'] # , '3.11', '3.12'
pip_opts: ['']
numba_boundscheck: [0]
include:
- os: macos-latest
python: '3.10'
- os: windows-latest
python: '3.10'
- os: ubuntu-latest
python: '3.10'
numba_boundscheck: 1
- os: ubuntu-latest
python: '3.10'
pip_opts: 'numpy<2'
# include:
# - os: macos-latest
# python: '3.10'
# - os: windows-latest
# python: '3.10'
# - os: ubuntu-latest
# python: '3.10'
# numba_boundscheck: 1
# - os: ubuntu-latest
# python: '3.10'
# pip_opts: 'numpy<2'
fail-fast: false
runs-on: ${{ matrix.os }}
env:
Expand Down
2 changes: 1 addition & 1 deletion ci/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- pytest
- pytest-cov
- pytest-xdist
- mlir-python-bindings==19.*
- pip:
- finch-tensor >=0.1.31
- pytest-codspeed
- https://github.com/nullplay/Finch-mlir/releases/download/latest/mlir_finch-0.0.1-cp310-cp310-linux_x86_64.whl
2 changes: 1 addition & 1 deletion sparse/mlir_backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
try:
import mlir # noqa: F401
import mlir_finch # noqa: F401
except ModuleNotFoundError as e:
raise ImportError(
"MLIR Python bindings not installed. Run "
Expand Down
2 changes: 1 addition & 1 deletion sparse/mlir_backend/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import weakref
from dataclasses import dataclass

from mlir import ir
from mlir_finch import ir


class MlirType(abc.ABC):
Expand Down
6 changes: 3 additions & 3 deletions sparse/mlir_backend/_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from collections.abc import Iterable
from typing import Any

import mlir.runtime as rt
from mlir import ir
from mlir.dialects import sparse_tensor
import mlir_finch.runtime as rt
from mlir_finch import ir
from mlir_finch.dialects import sparse_tensor

import numpy as np
import scipy.sparse as sps
Expand Down
14 changes: 12 additions & 2 deletions sparse/mlir_backend/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@
import ctypes.util
import os
import pathlib
import sys

from mlir.ir import Context
from mlir.passmanager import PassManager
from mlir_finch.ir import Context
from mlir_finch.passmanager import PassManager

DEBUG = bool(int(os.environ.get("DEBUG", "0")))
CWD = pathlib.Path(".")

LD_ENV_PATH = f"{sys.prefix}/lib/python3.10/site-packages/lib"

if "LD_LIBRARY_PATH" in os.environ:
os.environ["LD_LIBRARY_PATH"] = f"{LD_ENV_PATH}:{os.environ['LD_LIBRARY_PATH']}"
else:
os.environ["LD_LIBRARY_PATH"] = LD_ENV_PATH

MLIR_C_RUNNER_UTILS = ctypes.util.find_library("mlir_c_runner_utils")
if os.name == "posix":
MLIR_C_RUNNER_UTILS = f"{LD_ENV_PATH}/{MLIR_C_RUNNER_UTILS}"
libc = ctypes.CDLL(ctypes.util.find_library("c")) if os.name != "nt" else ctypes.cdll.msvcrt
libc.free.argtypes = [ctypes.c_void_p]
libc.free.restype = None
Expand Down
2 changes: 1 addition & 1 deletion sparse/mlir_backend/_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
import typing

from mlir import ir
from mlir_finch import ir

import numpy as np

Expand Down
14 changes: 7 additions & 7 deletions sparse/mlir_backend/_ops.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ctypes

import mlir.execution_engine
import mlir.passmanager
from mlir import ir
from mlir.dialects import arith, func, linalg, sparse_tensor, tensor
import mlir_finch.execution_engine
import mlir_finch.passmanager
from mlir_finch import ir
from mlir_finch.dialects import arith, func, linalg, sparse_tensor, tensor

import numpy as np

Expand Down Expand Up @@ -67,7 +67,7 @@ def add(a, b):
if DEBUG:
(CWD / "add_module_opt.mlir").write_text(str(module))

return mlir.execution_engine.ExecutionEngine(module, opt_level=2, shared_libs=[MLIR_C_RUNNER_UTILS])
return mlir_finch.execution_engine.ExecutionEngine(module, opt_level=2, shared_libs=[MLIR_C_RUNNER_UTILS])


@fn_cache
Expand All @@ -92,7 +92,7 @@ def reshape(a, shape):
if DEBUG:
(CWD / "reshape_module_opt.mlir").write_text(str(module))

return mlir.execution_engine.ExecutionEngine(module, opt_level=2, shared_libs=[MLIR_C_RUNNER_UTILS])
return mlir_finch.execution_engine.ExecutionEngine(module, opt_level=2, shared_libs=[MLIR_C_RUNNER_UTILS])


@fn_cache
Expand Down Expand Up @@ -120,7 +120,7 @@ def broadcast_to(in_tensor):
if DEBUG:
(CWD / "broadcast_to_module_opt.mlir").write_text(str(module))

return mlir.execution_engine.ExecutionEngine(module, opt_level=2, shared_libs=[MLIR_C_RUNNER_UTILS])
return mlir_finch.execution_engine.ExecutionEngine(module, opt_level=2, shared_libs=[MLIR_C_RUNNER_UTILS])


def add(x1: Tensor, x2: Tensor) -> Tensor:
Expand Down

0 comments on commit b15dd11

Please sign in to comment.