diff --git a/.github/workflows/sdist.yml b/.github/workflows/sdist.yml deleted file mode 100644 index 0357cf1..0000000 --- a/.github/workflows/sdist.yml +++ /dev/null @@ -1,98 +0,0 @@ -name: sdist - -on: - workflow_dispatch: - release: - types: - - published - -jobs: - build_sdist: - runs-on: ubuntu-20.04 - outputs: - VERSION: ${{ steps.build_sdist.outputs.version }} - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - - name: Build sdist - id: build_sdist - run: | - VERSION="$(python setup.py --version)" - python setup.py sdist --formats=zip - zip -d dist/mlir-python-utils-$VERSION.zip "/mlir-python-utils-$VERSION/PKG-INFO" - zip -d dist/mlir-python-utils-$VERSION.zip "/mlir-python-utils-$VERSION/mlir_python_utils.egg-info/*" - echo "version=${VERSION}" | tee -a $GITHUB_OUTPUT - - - name: Upload sdist - uses: actions/upload-artifact@v3 - with: - path: dist/mlir-python-utils-*.zip - name: build_artifact - - upload_sdist: - - name: Upload sdist - - needs: [build_sdist] - - runs-on: ubuntu-latest - permissions: write-all - steps: - - uses: actions/download-artifact@v3 - with: - # unpacks default artifact into dist/ - # if `name: artifact` is omitted, the action will create extra parent dir - name: build_artifact - path: dist - - - name: Set up a release page - id: setup_release - run: | - VERSION=${{ needs.build_sdist.outputs.version }} - echo "`mlir-python-utils` $VERSION distribution created at $(date)" > body.md - echo "tag_name=${VERSION}" | tee -a $GITHUB_OUTPUT - echo "release_title=mlir-python-utils-${VERSION}" | tee -a $GITHUB_OUTPUT - - - name: Release current commit - uses: ncipollo/release-action@v1.12.0 - with: - artifacts: "dist/*.zip" - bodyFile: body.md - token: "${{ secrets.GITHUB_TOKEN }}" - tag: "${{ steps.setup_release.outputs.tag_name }}" - name: "${{ steps.setup_release.outputs.release_title }}" - removeArtifacts: false - allowUpdates: true - replacesArtifacts: true - makeLatest: true - - - name: Release current commit - uses: ncipollo/release-action@v1.12.0 - with: - artifacts: "dist/*.zip" - bodyFile: body.md - token: "${{ secrets.GITHUB_TOKEN }}" - tag: "latest" - name: "latest" - removeArtifacts: false - allowUpdates: true - replacesArtifacts: true - makeLatest: true - - - name: Release current commit - uses: ncipollo/release-action@v1.12.0 - with: - owner: makslevental - repo: wheels - artifacts: "dist/*.zip" - token: "${{ secrets.WHEELS_REPO }}" - tag: "i" - name: "i" - removeArtifacts: false - allowUpdates: true - replacesArtifacts: true - makeLatest: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 282697f..3d7c8e7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -116,7 +116,7 @@ jobs: pip install jupyter sed -i.bak 's/OUTPUT_TIMEOUT = 10/OUTPUT_TIMEOUT = 100/g' \ $(python -c 'import site; print(site.getsitepackages()[0])')/jupyter_client/runapp.py - BRANCH=${{ github.ref_name }} jupyter run examples/mlir_python_utils.ipynb + BRANCH=${{ github.ref_name }} jupyter run examples/mlir_python_extras.ipynb mlir-bindings-aarch64: diff --git a/.github/workflows/test_pypi.yml b/.github/workflows/test_pypi.yml index d8ffc8c..dbe5a3b 100644 --- a/.github/workflows/test_pypi.yml +++ b/.github/workflows/test_pypi.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/upload-artifact@v3 with: - path: ./wheelhouse/mlir_python_utils*.whl + path: ./wheelhouse/mlir_python_extras*.whl build_sdist: name: Build source distribution diff --git a/README.md b/README.md index a51b976..e72bd4f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# mlir-python-utils +# mlir-python-extras The missing pieces (as far as boilerplate reduction goes) of the MLIR python bindings. @@ -77,7 +77,7 @@ The few main features/affordances: 1. `region_op`s (like `@func` above) \   - 1. These are decorators around ops (bindings for MLIR operations) that have regions (e.g., [in_parallel](https://github.com/makslevental/mlir-python-utils/blob/a9885db18096a610d29a26293396d860d40ad213/mlir_utils/dialects/ext/scf.py#L185)). + 1. These are decorators around ops (bindings for MLIR operations) that have regions (e.g., [in_parallel](https://github.com/makslevental/mlir-python-extras/blob/a9885db18096a610d29a26293396d860d40ad213/mlir_extras/dialects/ext/scf.py#L185)). They turn decorated functions, by executing them "eagerly", into an instance of such an op, e.g., ```python @func @@ -87,7 +87,7 @@ The few main features/affordances: becomes `func.func @foo(%arg0: i32) { }`; if the region carrying op produces a result, the identifier for the python function (`foo`) becomes the corresponding `ir.Value` of the result (if the op doesn't produce a result then the identifier becomes the corresponding `ir.OpView`). \ \ - See [mlir_utils.util.op_region_builder](https://github.com/makslevental/mlir-python-utils/blob/a9885db18096a610d29a26293396d860d40ad213/mlir_utils/util.py#L123) for details. + See [mlir_extras.util.op_region_builder](https://github.com/makslevental/mlir-python-extras/blob/a9885db18096a610d29a26293396d860d40ad213/mlir_extras/util.py#L123) for details. \   2. `@canonicalize` (like `@canonicalize(using=scf)` above) @@ -96,16 +96,16 @@ The few main features/affordances: 1. These are decorators that **rewrite the python AST**. They transform a select few forms (basically only `if`s) into a more "canonical" form, in order to more easily map to MLIR. If that scares you, fear not; they are not essential and all target MLIR can still be mapped to without using them (by using the slightly more verbose `region_op`). \ \ - See [mlir_utils.ast.canonicalize](https://github.com/makslevental/mlir-python-utils/blob/a9885db18096a610d29a26293396d860d40ad213/mlir_utils/ast/canonicalize.py) for details. + See [mlir_extras.ast.canonicalize](https://github.com/makslevental/mlir-python-extras/blob/a9885db18096a610d29a26293396d860d40ad213/mlir_extras/ast/canonicalize.py) for details. \   -3. `mlir_utils.types` (like `T.memref(K, K, T.i64)` above) +3. `mlir_extras.types` (like `T.memref(K, K, T.i64)` above) \   - 1. These are just convenient wrappers around upstream type constructors. Note, because MLIR types are uniqued to a `ir.Context`, these are all actually functions that return the type (yes, even `T.i64`, which uses [`__getattr__` on the module](https://github.com/makslevental/mlir-python-utils/blob/2ca62e9c1540b1624c302bc9efb4666ff5d1c133/mlir_utils/types.py#L98)). + 1. These are just convenient wrappers around upstream type constructors. Note, because MLIR types are uniqued to a `ir.Context`, these are all actually functions that return the type (yes, even `T.i64`, which uses [`__getattr__` on the module](https://github.com/makslevental/mlir-python-extras/blob/2ca62e9c1540b1624c302bc9efb4666ff5d1c133/mlir_extras/types.py#L98)). \ \ - See [mlir_utils.types](https://github.com/makslevental/mlir-python-utils/blob/a9885db18096a610d29a26293396d860d40ad213/mlir_utils/types.py) for details. + See [mlir_extras.types](https://github.com/makslevental/mlir-python-extras/blob/a9885db18096a610d29a26293396d860d40ad213/mlir_extras/types.py) for details. \   4. `Pipeline()` @@ -114,8 +114,8 @@ The few main features/affordances: 1. This is just a (generated) wrapper around available **upstream** passes; it can be used to build pass pipelines (by `str(Pipeline())`). It is mainly convenient with IDEs/editors that will tab-complete the available methods on the `Pipeline` class (which correspond to passes), Note, if your host bindings don't register some upstream passes, then this will generate "illegal" pass pipelines. \ \ - See [mlir_utils._configuration.generate_pass_pipeline.py](https://github.com/makslevental/mlir-python-utils/blob/a9885db18096a610d29a26293396d860d40ad213/mlir_utils/_configuration/generate_pass_pipeline.py) for details on generation - [mlir_utils.runtime.passes.py](https://github.com/makslevental/mlir-python-utils/blob/a9885db18096a610d29a26293396d860d40ad213/mlir_utils/runtime/passes.py#L80) for the passes themselves. + See [mlir_extras._configuration.generate_pass_pipeline.py](https://github.com/makslevental/mlir-python-extras/blob/a9885db18096a610d29a26293396d860d40ad213/mlir_extras/_configuration/generate_pass_pipeline.py) for details on generation + [mlir_extras.runtime.passes.py](https://github.com/makslevental/mlir-python-extras/blob/a9885db18096a610d29a26293396d860d40ad213/mlir_extras/runtime/passes.py#L80) for the passes themselves. \   @@ -133,7 +133,7 @@ Practically speaking that means you need to have *some* package installed that i So ```shell -$ YOUR_HOST_MLIR_PYTHON_PACKAGE_PREFIX= pip install git+https://github.com/makslevental/mlir-python-utils +$ YOUR_HOST_MLIR_PYTHON_PACKAGE_PREFIX= pip install git+https://github.com/makslevental/mlir-python-extras ``` where `YOUR_HOST_MLIR_PYTHON_PACKAGE_PREFIX` is (as it says) the package prefix for your chosen host bindings. @@ -148,7 +148,7 @@ $ pip install mlir-python-bindings -f https://makslevental.github.io/wheels/ and then ```shell -$ pip install git+https://github.com/makslevental/mlir-python-utils +$ pip install git+https://github.com/makslevental/mlir-python-extras ``` ## Examples/Demo diff --git a/examples/mlir_python_utils.ipynb b/examples/mlir_python_extras.ipynb similarity index 96% rename from examples/mlir_python_utils.ipynb rename to examples/mlir_python_extras.ipynb index 1e1c434..166d39a 100644 --- a/examples/mlir_python_utils.ipynb +++ b/examples/mlir_python_extras.ipynb @@ -6,9 +6,9 @@ "id": "MVpw-wdNOFv0" }, "source": [ - "# Welcome to `mlir-python-utils` enjoy your stay!\n", + "# Welcome to `mlir-python-extras` enjoy your stay!\n", "\n", - "more at https://github.com/makslevental/mlir-python-utils" + "more at https://github.com/makslevental/mlir-python-extras" ] }, { @@ -19,7 +19,7 @@ }, "outputs": [], "source": [ - "!pip install mlir-python-utils[mlir] -f https://github.com/makslevental/mlir-python-utils.git@$BRANCH &> /dev/null" + "!pip install mlir-python-extras[mlir] -f https://github.com/makslevental/mlir-python-extras.git@$BRANCH &> /dev/null" ] }, { @@ -30,7 +30,7 @@ }, "outputs": [], "source": [ - "!mlir-python-utils-generate-all-upstream-trampolines &> /dev/null" + "!mlir-python-extras-generate-all-upstream-trampolines &> /dev/null" ] }, { @@ -52,19 +52,19 @@ "source": [ "import numpy as np\n", "\n", - "import mlir.utils.types as T\n", - "from mlir.utils.ast.canonicalize import canonicalize\n", - "from mlir.utils.context import MLIRContext, mlir_mod_ctx\n", - "from mlir.utils.dialects.ext.arith import constant\n", - "from mlir.utils.dialects.ext.memref import load, store, S\n", - "from mlir.utils.dialects.ext.func import func\n", - "from mlir.utils.dialects.ext.scf import canonicalizer as scf, range_ as range\n", - "from mlir.utils.runtime.passes import Pipeline, run_pipeline\n", - "from mlir.utils.runtime.refbackend import LLVMJITBackend\n", + "import mlir.extras.types as T\n", + "from mlir.extras.ast.canonicalize import canonicalize\n", + "from mlir.extras.context import MLIRContext, mlir_mod_ctx\n", + "from mlir.extras.dialects.ext.arith import constant\n", + "from mlir.extras.dialects.ext.memref import load, store, S\n", + "from mlir.extras.dialects.ext.func import func\n", + "from mlir.extras.dialects.ext.scf import canonicalizer as scf, range_ as range\n", + "from mlir.extras.runtime.passes import Pipeline, run_pipeline\n", + "from mlir.extras.runtime.refbackend import LLVMJITBackend\n", "\n", "# you need this to register the memref value caster\n", "# noinspection PyUnresolvedReferences\n", - "import mlir.utils.dialects.ext.memref\n", + "import mlir.extras.dialects.ext.memref\n", "\n", "ctx_man = mlir_mod_ctx()\n", "ctx = ctx_man.__enter__()\n", @@ -663,7 +663,7 @@ "ranked_memref_kxk_f32 = T.memref(K, K, T.f32)\n", "ranked_memref_dxd_f32 = T.memref(D, D, T.f32, layout=((K, 1), S))\n", "\n", - "from mlir.utils.dialects import linalg\n", + "from mlir.extras.dialects import linalg\n", "\n", "@func\n", "@canonicalize(using=scf)\n", diff --git a/examples/mwe.py b/examples/mwe.py index f632052..b0b2dbe 100644 --- a/examples/mwe.py +++ b/examples/mwe.py @@ -2,15 +2,15 @@ # you need this to register the memref value caster # noinspection PyUnresolvedReferences -import mlir.utils.dialects.ext.memref -import mlir.utils.types as T -from mlir.utils.ast.canonicalize import canonicalize -from mlir.utils.context import MLIRContext, mlir_mod_ctx -from mlir.utils.dialects.ext.arith import constant -from mlir.utils.dialects.ext.func import func -from mlir.utils.dialects.ext.scf import canonicalizer as scf, range_ as range -from mlir.utils.runtime.passes import Pipeline -from mlir.utils.runtime.refbackend import LLVMJITBackend +import mlir.extras.dialects.ext.memref +import mlir.extras.types as T +from mlir.extras.ast.canonicalize import canonicalize +from mlir.extras.context import MLIRContext, mlir_mod_ctx +from mlir.extras.dialects.ext.arith import constant +from mlir.extras.dialects.ext.func import func +from mlir.extras.dialects.ext.scf import canonicalizer as scf, range_ as range +from mlir.extras.runtime.passes import Pipeline +from mlir.extras.runtime.refbackend import LLVMJITBackend def setting_memref(ctx: MLIRContext, backend: LLVMJITBackend): diff --git a/mlir/utils/_configuration/__init__.py b/mlir/extras/_configuration/__init__.py similarity index 100% rename from mlir/utils/_configuration/__init__.py rename to mlir/extras/_configuration/__init__.py diff --git a/mlir/utils/_configuration/generate_pass_pipeline.py b/mlir/extras/_configuration/generate_pass_pipeline.py similarity index 100% rename from mlir/utils/_configuration/generate_pass_pipeline.py rename to mlir/extras/_configuration/generate_pass_pipeline.py diff --git a/mlir/utils/_configuration/generate_trampolines.py b/mlir/extras/_configuration/generate_trampolines.py similarity index 97% rename from mlir/utils/_configuration/generate_trampolines.py rename to mlir/extras/_configuration/generate_trampolines.py index cb37452..11d30dd 100644 --- a/mlir/utils/_configuration/generate_trampolines.py +++ b/mlir/extras/_configuration/generate_trampolines.py @@ -349,20 +349,20 @@ def generate_all_upstream_trampolines(): generate_linalg(f"{mlir_dialects.__name__}.linalg") elif mod.name == "transform": transform_module_path = Path(mlir_dialects.__path__[0]) / mod.name - transform_module_path_mlir_utils = mlir_mod_path / mod.name - if not transform_module_path_mlir_utils.exists(): - os.makedirs(transform_module_path_mlir_utils) + transform_module_path_mlir_extras = mlir_mod_path / mod.name + if not transform_module_path_mlir_extras.exists(): + os.makedirs(transform_module_path_mlir_extras) generate_trampolines( f"{mlir_dialects.__name__}.{mod.name}", - transform_module_path_mlir_utils, + transform_module_path_mlir_extras, "__init__", skips={"1kOp"}, ) for mod in pkgutil.iter_modules([str(transform_module_path)]): generate_trampolines( f"{mlir_dialects.__name__}.transform.{mod.name}", - transform_module_path_mlir_utils, + transform_module_path_mlir_extras, mod.name, skips={"1kOp"}, ) diff --git a/mlir/utils/_configuration/util.py b/mlir/extras/_configuration/util.py similarity index 100% rename from mlir/utils/_configuration/util.py rename to mlir/extras/_configuration/util.py diff --git a/mlir/utils/ast/__init__.py b/mlir/extras/ast/__init__.py similarity index 100% rename from mlir/utils/ast/__init__.py rename to mlir/extras/ast/__init__.py diff --git a/mlir/utils/ast/canonicalize.py b/mlir/extras/ast/canonicalize.py similarity index 100% rename from mlir/utils/ast/canonicalize.py rename to mlir/extras/ast/canonicalize.py diff --git a/mlir/utils/ast/util.py b/mlir/extras/ast/util.py similarity index 100% rename from mlir/utils/ast/util.py rename to mlir/extras/ast/util.py diff --git a/mlir/utils/context.py b/mlir/extras/context.py similarity index 100% rename from mlir/utils/context.py rename to mlir/extras/context.py diff --git a/mlir/utils/dialects/.gitignore b/mlir/extras/dialects/.gitignore similarity index 100% rename from mlir/utils/dialects/.gitignore rename to mlir/extras/dialects/.gitignore diff --git a/mlir/utils/dialects/__init__.py b/mlir/extras/dialects/ext/__init__.py similarity index 100% rename from mlir/utils/dialects/__init__.py rename to mlir/extras/dialects/ext/__init__.py diff --git a/mlir/utils/dialects/ext/arith.py b/mlir/extras/dialects/ext/arith.py similarity index 100% rename from mlir/utils/dialects/ext/arith.py rename to mlir/extras/dialects/ext/arith.py diff --git a/mlir/utils/dialects/ext/cf.py b/mlir/extras/dialects/ext/cf.py similarity index 100% rename from mlir/utils/dialects/ext/cf.py rename to mlir/extras/dialects/ext/cf.py diff --git a/mlir/utils/dialects/ext/func.py b/mlir/extras/dialects/ext/func.py similarity index 100% rename from mlir/utils/dialects/ext/func.py rename to mlir/extras/dialects/ext/func.py diff --git a/mlir/utils/dialects/ext/gpu.py b/mlir/extras/dialects/ext/gpu.py similarity index 100% rename from mlir/utils/dialects/ext/gpu.py rename to mlir/extras/dialects/ext/gpu.py diff --git a/mlir/utils/dialects/ext/linalg.py b/mlir/extras/dialects/ext/linalg.py similarity index 100% rename from mlir/utils/dialects/ext/linalg.py rename to mlir/extras/dialects/ext/linalg.py diff --git a/mlir/utils/dialects/ext/memref.py b/mlir/extras/dialects/ext/memref.py similarity index 100% rename from mlir/utils/dialects/ext/memref.py rename to mlir/extras/dialects/ext/memref.py diff --git a/mlir/utils/dialects/ext/nvgpu.py b/mlir/extras/dialects/ext/nvgpu.py similarity index 100% rename from mlir/utils/dialects/ext/nvgpu.py rename to mlir/extras/dialects/ext/nvgpu.py diff --git a/mlir/utils/dialects/ext/scf.py b/mlir/extras/dialects/ext/scf.py similarity index 100% rename from mlir/utils/dialects/ext/scf.py rename to mlir/extras/dialects/ext/scf.py diff --git a/mlir/utils/dialects/ext/tensor.py b/mlir/extras/dialects/ext/tensor.py similarity index 100% rename from mlir/utils/dialects/ext/tensor.py rename to mlir/extras/dialects/ext/tensor.py diff --git a/mlir/utils/dialects/ext/transform.py b/mlir/extras/dialects/ext/transform.py similarity index 100% rename from mlir/utils/dialects/ext/transform.py rename to mlir/extras/dialects/ext/transform.py diff --git a/mlir/utils/meta.py b/mlir/extras/meta.py similarity index 100% rename from mlir/utils/meta.py rename to mlir/extras/meta.py diff --git a/mlir/utils/dialects/ext/__init__.py b/mlir/extras/runtime/__init__.py similarity index 100% rename from mlir/utils/dialects/ext/__init__.py rename to mlir/extras/runtime/__init__.py diff --git a/mlir/utils/runtime/passes.py b/mlir/extras/runtime/passes.py similarity index 100% rename from mlir/utils/runtime/passes.py rename to mlir/extras/runtime/passes.py diff --git a/mlir/utils/runtime/refbackend.py b/mlir/extras/runtime/refbackend.py similarity index 100% rename from mlir/utils/runtime/refbackend.py rename to mlir/extras/runtime/refbackend.py diff --git a/mlir/utils/testing/__init__.py b/mlir/extras/testing/__init__.py similarity index 100% rename from mlir/utils/testing/__init__.py rename to mlir/extras/testing/__init__.py diff --git a/mlir/utils/testing/generate_test_checks.py b/mlir/extras/testing/generate_test_checks.py similarity index 100% rename from mlir/utils/testing/generate_test_checks.py rename to mlir/extras/testing/generate_test_checks.py diff --git a/mlir/utils/testing/testing.py b/mlir/extras/testing/testing.py similarity index 100% rename from mlir/utils/testing/testing.py rename to mlir/extras/testing/testing.py diff --git a/mlir/utils/types.py b/mlir/extras/types.py similarity index 100% rename from mlir/utils/types.py rename to mlir/extras/types.py diff --git a/mlir/utils/util.py b/mlir/extras/util.py similarity index 96% rename from mlir/utils/util.py rename to mlir/extras/util.py index fbb9f26..cb55d3c 100644 --- a/mlir/utils/util.py +++ b/mlir/extras/util.py @@ -30,19 +30,19 @@ def get_user_code_loc(user_base: Optional[Path] = None): - from .. import utils + from .. import extras if Context.current is None: return - mlir_utils_root_path = Path(utils.__path__[0]) + mlir_extras_root_path = Path(extras.__path__[0]) prev_frame = inspect.currentframe().f_back if user_base is None: user_base = Path(prev_frame.f_code.co_filename) while prev_frame.f_back and ( - Path(prev_frame.f_code.co_filename).is_relative_to(mlir_utils_root_path) + Path(prev_frame.f_code.co_filename).is_relative_to(mlir_extras_root_path) or Path(prev_frame.f_code.co_filename).is_relative_to(sys.prefix) or Path(prev_frame.f_code.co_filename).is_relative_to(user_base) ): diff --git a/mlir/utils/runtime/__init__.py b/mlir/utils/runtime/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/setup.py b/setup.py index 5a2d17b..042e68c 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ HOST_MLIR_PYTHON_PACKAGE_PREFIX = os.environ.get( "HOST_MLIR_PYTHON_PACKAGE_PREFIX", "mlir" ) -PACKAGE_NAME = f"{HOST_MLIR_PYTHON_PACKAGE_PREFIX.replace('.', '-').replace('_', '-')}-python-utils" +PACKAGE_NAME = f"{HOST_MLIR_PYTHON_PACKAGE_PREFIX.replace('.', '-').replace('_', '-')}-python-extras" def load_requirements(fname): @@ -30,6 +30,6 @@ def load_requirements(fname): python_requires=">=3.10", # lhs is package namespace, rhs is path (relative to this setup.py) package_dir={ - f"{HOST_MLIR_PYTHON_PACKAGE_PREFIX}.utils": "mlir/utils", + f"{HOST_MLIR_PYTHON_PACKAGE_PREFIX}.extras": "mlir/extras", }, ) diff --git a/tests/test_async.py b/tests/test_async.py index 442cf35..5df600d 100644 --- a/tests/test_async.py +++ b/tests/test_async.py @@ -6,11 +6,11 @@ import pytest -from mlir.utils.runtime.passes import Pipeline -from mlir.utils.runtime.refbackend import LLVMJITBackend +from mlir.extras.runtime.passes import Pipeline +from mlir.extras.runtime.refbackend import LLVMJITBackend # noinspection PyUnresolvedReferences -from mlir.utils.testing import mlir_ctx as ctx, filecheck, MLIRContext, backend +from mlir.extras.testing import mlir_ctx as ctx, filecheck, MLIRContext, backend # needed since the fix isn't defined here nor conftest.py pytest.mark.usefixtures("ctx") @@ -21,7 +21,7 @@ platform.machine() == "aarch64", reason="https://github.com/numba/numba/issues/9109" ) @pytest.mark.skipif( - platform.system() == "Windows", reason="windows can't load runner utils" + platform.system() == "Windows", reason="windows can't load runner extras" ) def test_simple_parfor(ctx: MLIRContext, backend: LLVMJITBackend): module = ctx.module.parse( diff --git a/tests/test_func.py b/tests/test_func.py index 785e793..5620b3e 100644 --- a/tests/test_func.py +++ b/tests/test_func.py @@ -4,13 +4,13 @@ import pytest -import mlir.utils.types as T -from mlir.utils.context import mlir_mod_ctx -from mlir.utils.dialects.ext.arith import constant -from mlir.utils.dialects.ext.func import func +import mlir.extras.types as T +from mlir.extras.context import mlir_mod_ctx +from mlir.extras.dialects.ext.arith import constant +from mlir.extras.dialects.ext.func import func # noinspection PyUnresolvedReferences -from mlir.utils.testing import mlir_ctx as ctx, filecheck, MLIRContext +from mlir.extras.testing import mlir_ctx as ctx, filecheck, MLIRContext # needed since the fix isn't defined here nor conftest.py pytest.mark.usefixtures("ctx") diff --git a/tests/test_gpu.py b/tests/test_gpu.py index 846ef19..96c6994 100644 --- a/tests/test_gpu.py +++ b/tests/test_gpu.py @@ -3,11 +3,11 @@ import pytest from mlir.dialects._gpu_enum_gen import AllReduceOperation -import mlir.utils.types as T -from mlir.utils.ast.canonicalize import canonicalize -from mlir.utils.dialects.ext.arith import constant -from mlir.utils.dialects.ext.func import func -from mlir.utils.dialects.ext.gpu import ( +import mlir.extras.types as T +from mlir.extras.ast.canonicalize import canonicalize +from mlir.extras.dialects.ext.arith import constant +from mlir.extras.dialects.ext.func import func +from mlir.extras.dialects.ext.gpu import ( thread_attr as thread, block_id_x, block_id_y, @@ -17,19 +17,19 @@ launch, all_reduce_, ) -from mlir.utils.dialects.ext.memref import alloc -from mlir.utils.dialects.ext.memref import load, store -from mlir.utils.dialects.ext.scf import canonicalizer -from mlir.utils.dialects.ext.scf import forall, in_parallel_ +from mlir.extras.dialects.ext.memref import alloc +from mlir.extras.dialects.ext.memref import load, store +from mlir.extras.dialects.ext.scf import canonicalizer +from mlir.extras.dialects.ext.scf import forall, in_parallel_ from mlir.dialects.gpu import host_register -from mlir.utils.dialects.ext.gpu import all_reduce, wait +from mlir.extras.dialects.ext.gpu import all_reduce, wait from mlir.dialects.llvm import mlir_zero from mlir.dialects.math import fma from mlir.dialects.memref import cast -from mlir.utils.runtime.passes import run_pipeline, Pipeline +from mlir.extras.runtime.passes import run_pipeline, Pipeline # noinspection PyUnresolvedReferences -from mlir.utils.testing import mlir_ctx as ctx, filecheck, MLIRContext +from mlir.extras.testing import mlir_ctx as ctx, filecheck, MLIRContext # needed since the fix isn't defined here nor conftest.py pytest.mark.usefixtures("ctx") diff --git a/tests/test_memref.py b/tests/test_memref.py index 9d70068..b69e2cb 100644 --- a/tests/test_memref.py +++ b/tests/test_memref.py @@ -4,11 +4,11 @@ import pytest from mlir.ir import MLIRError, Type -import mlir.utils.types as T -from mlir.utils.ast.canonicalize import canonicalize -from mlir.utils.dialects.ext.arith import Scalar, constant -from mlir.utils.dialects.ext.memref import alloc, S -from mlir.utils.dialects.ext.scf import ( +import mlir.extras.types as T +from mlir.extras.ast.canonicalize import canonicalize +from mlir.extras.dialects.ext.arith import Scalar, constant +from mlir.extras.dialects.ext.memref import alloc, S +from mlir.extras.dialects.ext.scf import ( range_, yield_, canonicalizer, @@ -16,7 +16,7 @@ from mlir.dialects.memref import subview # noinspection PyUnresolvedReferences -from mlir.utils.testing import mlir_ctx as ctx, filecheck, MLIRContext +from mlir.extras.testing import mlir_ctx as ctx, filecheck, MLIRContext # needed since the fix isn't defined here nor conftest.py pytest.mark.usefixtures("ctx") diff --git a/tests/test_nvgpu_nvvm.py b/tests/test_nvgpu_nvvm.py index 080ce60..9b9fd51 100644 --- a/tests/test_nvgpu_nvvm.py +++ b/tests/test_nvgpu_nvvm.py @@ -2,15 +2,15 @@ import pytest -import mlir.utils.types as T -from mlir.utils.dialects.ext.arith import constant -from mlir.utils.dialects.ext.func import func -from mlir.utils.dialects.ext.nvgpu import tensormap_descriptor +import mlir.extras.types as T +from mlir.extras.dialects.ext.arith import constant +from mlir.extras.dialects.ext.func import func +from mlir.extras.dialects.ext.nvgpu import tensormap_descriptor from mlir.dialects.memref import cast from mlir.dialects.nvgpu import tma_create_descriptor # noinspection PyUnresolvedReferences -from mlir.utils.testing import mlir_ctx as ctx, filecheck, MLIRContext +from mlir.extras.testing import mlir_ctx as ctx, filecheck, MLIRContext # needed since the fix isn't defined here nor conftest.py pytest.mark.usefixtures("ctx") diff --git a/tests/test_operator_overloading.py b/tests/test_operator_overloading.py index 211b648..9820e3d 100644 --- a/tests/test_operator_overloading.py +++ b/tests/test_operator_overloading.py @@ -2,12 +2,12 @@ import pytest -import mlir.utils.types as T -from mlir.utils.dialects.ext.arith import constant, Scalar -from mlir.utils.dialects.ext.tensor import Tensor, empty +import mlir.extras.types as T +from mlir.extras.dialects.ext.arith import constant, Scalar +from mlir.extras.dialects.ext.tensor import Tensor, empty # noinspection PyUnresolvedReferences -from mlir.utils.testing import mlir_ctx as ctx, filecheck, MLIRContext +from mlir.extras.testing import mlir_ctx as ctx, filecheck, MLIRContext # needed since the fix isn't defined here nor conftest.py pytest.mark.usefixtures("ctx") diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index 68d6b57..1c3be2e 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -1,4 +1,4 @@ -from mlir.utils.runtime.passes import cse, lower_affine, convert_arith_to_llvm +from mlir.extras.runtime.passes import cse, lower_affine, convert_arith_to_llvm def test_basic(): diff --git a/tests/test_regions.py b/tests/test_regions.py index d5f6e88..bfa6cd8 100644 --- a/tests/test_regions.py +++ b/tests/test_regions.py @@ -2,26 +2,26 @@ import pytest -import mlir.utils.types as T -from mlir.utils.dialects.ext import linalg -from mlir.utils.dialects.ext import memref -from mlir.utils.dialects.ext.arith import constant -from mlir.utils.dialects.ext.cf import br, cond_br -from mlir.utils.dialects.ext.func import func -from mlir.utils.dialects.ext.tensor import S +import mlir.extras.types as T +from mlir.extras.dialects.ext import linalg +from mlir.extras.dialects.ext import memref +from mlir.extras.dialects.ext.arith import constant +from mlir.extras.dialects.ext.cf import br, cond_br +from mlir.extras.dialects.ext.func import func +from mlir.extras.dialects.ext.tensor import S from mlir.dialects.func import return_ from mlir.dialects.memref import alloca_scope, alloca_scope_return -from mlir.utils.dialects.ext.memref import alloca_scope +from mlir.extras.dialects.ext.memref import alloca_scope from mlir.dialects.scf import yield_ as scf_yield -from mlir.utils.dialects.ext.scf import execute_region +from mlir.extras.dialects.ext.scf import execute_region from mlir.dialects.tensor import yield_ as tensor_yield -from mlir.utils.dialects.ext.tensor import generate +from mlir.extras.dialects.ext.tensor import generate from mlir.dialects.tensor import rank -from mlir.utils.meta import bb +from mlir.extras.meta import bb # noinspection PyUnresolvedReferences -from mlir.utils.testing import mlir_ctx as ctx, filecheck, MLIRContext -from mlir.utils.types import tensor +from mlir.extras.testing import mlir_ctx as ctx, filecheck, MLIRContext +from mlir.extras.types import tensor # needed since the fix isn't defined here nor conftest.py pytest.mark.usefixtures("ctx") diff --git a/tests/test_runtime.py b/tests/test_runtime.py index 8edb284..26d4ab6 100644 --- a/tests/test_runtime.py +++ b/tests/test_runtime.py @@ -8,27 +8,27 @@ from mlir.ir import UnitAttr, Module from mlir.runtime import get_unranked_memref_descriptor, get_ranked_memref_descriptor -import mlir.utils.types as T -from mlir.utils.ast.canonicalize import canonicalize -from mlir.utils.dialects.ext import linalg +import mlir.extras.types as T +from mlir.extras.ast.canonicalize import canonicalize +from mlir.extras.dialects.ext import linalg from mlir.dialects.arith import sitofp, index_cast -from mlir.utils.dialects.ext.arith import constant -from mlir.utils.dialects.ext.func import func -from mlir.utils.dialects.ext.memref import load, store, S -from mlir.utils.dialects.ext.scf import ( +from mlir.extras.dialects.ext.arith import constant +from mlir.extras.dialects.ext.func import func +from mlir.extras.dialects.ext.memref import load, store, S +from mlir.extras.dialects.ext.scf import ( canonicalizer, range_, ) from mlir.dialects.memref import cast -from mlir.utils.runtime.passes import Pipeline, run_pipeline -from mlir.utils.runtime.refbackend import ( +from mlir.extras.runtime.passes import Pipeline, run_pipeline +from mlir.extras.runtime.refbackend import ( LLVMJITBackend, convert_returns_from_ctype, refback_cb_attr, ) # noinspection PyUnresolvedReferences -from mlir.utils.testing import mlir_ctx as ctx, filecheck, MLIRContext, backend +from mlir.extras.testing import mlir_ctx as ctx, filecheck, MLIRContext, backend # needed since the fix isn't defined here nor conftest.py pytest.mark.usefixtures("ctx") @@ -36,7 +36,7 @@ @pytest.mark.skipif( - platform.system() == "Windows", reason="windows can't load runner utils" + platform.system() == "Windows", reason="windows can't load runner extras" ) def test_smoke(ctx: MLIRContext, backend: LLVMJITBackend, capfd): # TODO(max): ValueError: foo requires closure of length 0, not 1 @@ -443,7 +443,7 @@ def foo(x: ranked_memref_4x4_f32): @pytest.mark.skipif( - platform.system() == "Windows", reason="windows can't load runner utils" + platform.system() == "Windows", reason="windows can't load runner extras" ) def test_munge_calling_conventions_setup_auto_cb_auto_wrapper_run_cast_np_array( ctx: MLIRContext, backend: LLVMJITBackend, capfd diff --git a/tests/test_scf.py b/tests/test_scf.py index 44e599a..ff3660a 100644 --- a/tests/test_scf.py +++ b/tests/test_scf.py @@ -2,12 +2,12 @@ import pytest -import mlir.utils.types as T -from mlir.utils.ast.canonicalize import canonicalize -from mlir.utils.dialects.ext import scf -from mlir.utils.dialects.ext import tensor -from mlir.utils.dialects.ext.arith import constant, Scalar -from mlir.utils.dialects.ext.scf import ( +import mlir.extras.types as T +from mlir.extras.ast.canonicalize import canonicalize +from mlir.extras.dialects.ext import scf +from mlir.extras.dialects.ext import tensor +from mlir.extras.dialects.ext.arith import constant, Scalar +from mlir.extras.dialects.ext.scf import ( for_, range_, yield_, @@ -24,12 +24,12 @@ while__, while___, ) -from mlir.utils.dialects.ext.tensor import empty, Tensor +from mlir.extras.dialects.ext.tensor import empty, Tensor from mlir.dialects.memref import alloca_scope_return -from mlir.utils.dialects.ext.memref import alloca_scope +from mlir.extras.dialects.ext.memref import alloca_scope # noinspection PyUnresolvedReferences -from mlir.utils.testing import mlir_ctx as ctx, filecheck, MLIRContext +from mlir.extras.testing import mlir_ctx as ctx, filecheck, MLIRContext # needed since the fix isn't defined here nor conftest.py pytest.mark.usefixtures("ctx") diff --git a/tests/test_tensor.py b/tests/test_tensor.py index dae99d0..998ce7b 100644 --- a/tests/test_tensor.py +++ b/tests/test_tensor.py @@ -3,18 +3,18 @@ import numpy as np import pytest -from mlir.utils.ast.canonicalize import canonicalize -from mlir.utils.dialects.ext.arith import Scalar, constant -from mlir.utils.dialects.ext.scf import ( +from mlir.extras.ast.canonicalize import canonicalize +from mlir.extras.dialects.ext.arith import Scalar, constant +from mlir.extras.dialects.ext.scf import ( range_, yield_, canonicalizer, ) -from mlir.utils.dialects.ext.tensor import Tensor, empty +from mlir.extras.dialects.ext.tensor import Tensor, empty # noinspection PyUnresolvedReferences -from mlir.utils.testing import mlir_ctx as ctx, filecheck, MLIRContext -import mlir.utils.types as T +from mlir.extras.testing import mlir_ctx as ctx, filecheck, MLIRContext +import mlir.extras.types as T # needed since the fix isn't defined here nor conftest.py pytest.mark.usefixtures("ctx") diff --git a/tests/test_transform.py b/tests/test_transform.py index f76c2b2..bb092a1 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -3,18 +3,18 @@ import pytest from mlir.dialects.gpu import MappingId -from mlir.utils import types as T -from mlir.utils.ast.canonicalize import canonicalize +from mlir.extras import types as T +from mlir.extras.ast.canonicalize import canonicalize from mlir.dialects import linalg, arith -from mlir.utils.dialects.ext import linalg -from mlir.utils.dialects.ext.func import func -from mlir.utils.dialects.ext.gpu import block_attr, thread_attr -from mlir.utils.dialects.ext.scf import ( +from mlir.extras.dialects.ext import linalg +from mlir.extras.dialects.ext.func import func +from mlir.extras.dialects.ext.gpu import block_attr, thread_attr +from mlir.extras.dialects.ext.scf import ( range_, canonicalizer, ) -from mlir.utils.dialects.ext.tensor import pad -from mlir.utils.dialects.ext.transform import ( +from mlir.extras.dialects.ext.tensor import pad +from mlir.extras.dialects.ext.transform import ( sequence, unroll, get_parent, @@ -24,10 +24,10 @@ apply_patterns, ) from mlir.dialects.transform import apply_patterns_canonicalization, apply_cse -from mlir.utils.runtime.passes import run_pipeline, Pipeline +from mlir.extras.runtime.passes import run_pipeline, Pipeline # noinspection PyUnresolvedReferences -from mlir.utils.testing import mlir_ctx as ctx, filecheck, MLIRContext +from mlir.extras.testing import mlir_ctx as ctx, filecheck, MLIRContext # needed since the fix isn't defined here nor conftest.py pytest.mark.usefixtures("ctx") diff --git a/tests/test_transformers.py b/tests/test_transformers.py index abd9818..80ed8b5 100644 --- a/tests/test_transformers.py +++ b/tests/test_transformers.py @@ -5,9 +5,9 @@ import astpretty import pytest -from mlir.utils.ast.canonicalize import transform_func -from mlir.utils.dialects.ext.arith import constant -from mlir.utils.dialects.ext.scf import ( +from mlir.extras.ast.canonicalize import transform_func +from mlir.extras.dialects.ext.arith import constant +from mlir.extras.dialects.ext.scf import ( CanonicalizeElIfs, ReplaceIfWithWith, ReplaceYieldWithSCFYield, @@ -16,7 +16,7 @@ ) # noinspection PyUnresolvedReferences -from mlir.utils.testing import mlir_ctx as ctx, filecheck, MLIRContext +from mlir.extras.testing import mlir_ctx as ctx, filecheck, MLIRContext # needed since the fix isn't defined here nor conftest.py pytest.mark.usefixtures("ctx") diff --git a/tests/test_types.py b/tests/test_types.py index 7ed8d42..76ba8d4 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -1,11 +1,11 @@ import pytest -import mlir.utils.types as T -from mlir.utils.dialects.ext.tensor import S +import mlir.extras.types as T +from mlir.extras.dialects.ext.tensor import S # noinspection PyUnresolvedReferences -from mlir.utils.testing import mlir_ctx as ctx, filecheck, MLIRContext -from mlir.utils.types import tensor, memref, vector +from mlir.extras.testing import mlir_ctx as ctx, filecheck, MLIRContext +from mlir.extras.types import tensor, memref, vector # needed since the fix isn't defined here nor conftest.py pytest.mark.usefixtures("ctx") diff --git a/tests/util.py b/tests/util.py index d64694b..e676e4d 100644 --- a/tests/util.py +++ b/tests/util.py @@ -12,7 +12,7 @@ def jax_not_installed(): def mlir_bindings_not_installed(): try: - import mlir.utils + import mlir.extras # don't skip return False