Add support to Bazel

Is there any plan to add support to use Bazel to build TVM?

We are open to this idea, but do not have a specific plan yet. Would be nice if you are interested and I’m happy to help

Yes, we are building projects with Bazel, and it would be nice to integrate tvm natively with Bazel. I will be interested to see if I can draft a bunch of bazel rules for tvm.

I’m opposed to this. I think we should have one official way to build TVM. Otherwise we’d need to test it in CI, plus it would add burden to developers who’d need to make sure their changes to CMake files are also reflected in Bazel.

Agree with @kparzysz. We should consider the duplication issue for both the CI system and contributors.

However, PyTorch supports both cmake and bazel. Not sure how they solve those problems. I’m open to supporting it if we have the answer to the above questions :slight_smile:

I think it would be ok to checkin a bazel genrule that knows how to shell to the existing tvm build system (cmake) so that you can just add the TVM repository and start depending on the end build artifacts. I agree with @kparzysz that duplicating the build system is something we should not do.

Yeah I think @kparzysz’s points are definitely valid. Build systems can be complicated and sometimes mutually contradictory, so maintaining only one official system makes sense as maintainers. I believe this ask is primarily about unofficial community support of Bazel, and as it helps with tvm adoption, I dont think this is something I would disagree with

Thanks for the discussion! I agree with @kparzysz that duplicates build system is somehow a big burden to developers especially who is not familiar with the other one. As for @areusch 's advice, there’s an official bazel rule foreign_cc to handle cmake script in bazel system, so it will be smooth and easy to just integrate tvm in an external bazel project.

The reason I raised this topic is that I think Bazel can offer better deps control and increase compiling speed, which is from the experience of tensorflow v1.x (who also has both cmake and bazel build system).

@LoSealL I agree bazel would probably more tightly describe the deps. For build speed, have you tried using ninja? cmake -GNinja .. && ninja is pretty fast, assuming you don’t need to fetch anything.