Skip to content

Commit

Permalink
Expose dtypes and remove dead code.
Browse files Browse the repository at this point in the history
  • Loading branch information
hameerabbasi committed Oct 23, 2024
1 parent 94b737e commit 6a14471
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 32 deletions.
40 changes: 38 additions & 2 deletions sparse/mlir_backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,43 @@

from . import levels
from ._conversions import asarray, from_constituent_arrays, to_numpy, to_scipy
from ._dtypes import asdtype
from ._dtypes import (
asdtype,
complex64,
complex128,
float16,
float32,
float64,
int8,
int16,
int32,
int64,
uint8,
uint16,
uint32,
uint64,
)
from ._ops import add

__all__ = ["add", "asarray", "asdtype", "to_numpy", "to_scipy", "levels", "from_constituent_arrays"]
__all__ = [
"add",
"asarray",
"asdtype",
"to_numpy",
"to_scipy",
"levels",
"from_constituent_arrays",
"int8",
"int16",
"int32",
"int64",
"uint8",
"uint16",
"uint32",
"uint64",
"float16",
"float32",
"float64",
"complex64",
"complex128",
]
30 changes: 0 additions & 30 deletions sparse/mlir_backend/_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import dataclasses
import math
import sys
import typing

import mlir.runtime as rt
from mlir import ir
Expand All @@ -22,35 +21,6 @@ def _get_pointer_width() -> int:
_PTR_WIDTH = _get_pointer_width()


def _make_int_classes(namespace: dict[str, object], bit_widths: typing.Iterable[int]) -> None:
for bw in bit_widths:

class SignedBW(SignedIntegerDType):
np_dtype = getattr(np, f"int{bw}")
bit_width = bw

@classmethod
def _get_mlir_type(cls):
return ir.IntegerType.get_signless(cls.bit_width)

SignedBW.__name__ = f"Int{bw}"
SignedBW.__module__ = __name__

class UnsignedBW(UnsignedIntegerDType):
np_dtype = getattr(np, f"uint{bw}")
bit_width = bw

@classmethod
def _get_mlir_type(cls):
return ir.IntegerType.get_signless(cls.bit_width)

UnsignedBW.__name__ = f"UInt{bw}"
UnsignedBW.__module__ = __name__

namespace[SignedBW.__name__] = SignedBW
namespace[UnsignedBW.__name__] = UnsignedBW


@dataclasses.dataclass(eq=True, frozen=True, kw_only=True)
class DType(MlirType):
bit_width: int
Expand Down

0 comments on commit 6a14471

Please sign in to comment.