llvm / llvm/torch-mlir

Bazel configuration missing for Python bindings?

Open
#3,787 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
1.9k
Forks
736
Avg merge
5d 22h
Merged PRs (30d)
15

Description

I'm interested in using the torch-mlir python bindings in a project that uses Bazel as its build system. Based on the [developer docs](https://github.com/llvm/torch-mlir/blob/main/docs/development.md#bazel-build), it seems like the Bazel configs for torch-mlir are mostly focused on supporting `torch-mlir-opt`, and indeed I don't see any CAPI or Python binding rules in the main [Bazel build file](https://github.com/llvm/torch-mlir/blob/main/utils/bazel/torch-mlir-overlay/BUILD.bazel).

I think what's needed to do this is:
* The CAPI library (from `torch-mlir-c/Dialects.h`). This can be built with `mlir_c_api_cc_library` from `@llvm-project//mlir:build_defs.bzl`.
* The pybind11 extension library (from `python/TorchMLIRModule.cpp`).
* A tablegen rule to generate the Python wrapper code for ops (`_torch_ops_gen.py`).
* (Maybe) A convenience `py_library` that bundles the above and any MLIR Python dependencies.

There are examples of these in the MLIR project's [Bazel file](https://github.com/llvm/llvm-project/blob/main/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel).

Is there interest in this from the maintainers? I'd be willing to contribute these changes if so.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with docs/development.md#bazel-build and utils/bazel/torch-mlir-overlay/BUILD.bazel to understand the existing Bazel setup. Compare the requested CAPI, pybind11, and TableGen rules with the examples in the MLIR project's BUILD.bazel. Done means the torch-mlir Python bindings and their dependencies can be built through Bazel.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python, pytorch
Domain
api, build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.