Commit Graph

40 Commits (94f7593c9b6f4cee06abb7296129cee029ac380a)

Author SHA1 Message Date
Yuanqiang Liu 238c0501da
fix cmake torch-mlir-capi linking and bazel build (#2336) 2023-07-24 12:38:56 +08:00
Sambhav Jain facce24ae3
[Bazel] Fix broken Bazel build (#2252)
Bazel GHA run: https://github.com/sjain-stanford/torch-mlir/actions/runs/5408580473
2023-06-29 08:45:35 -07:00
Sambhav Jain a3a62a9951
[Bazel] Add `@llvm_zstd` to WORKSPACE (#2049)
This un-breaks Bazel CI since b31c5fa1fb.

Manually triggered GHA: 
- https://github.com/sjain-stanford/torch-mlir/actions/runs/4764744603 (failed)
- https://github.com/sjain-stanford/torch-mlir/actions/runs/4769130681 (with buildifier fix)
2023-04-24 10:02:33 -07:00
Sambhav Jain 91e0f38b57
[Bazel] Add StableHLO registration dependency (#1937)
Fixes a broken bazel build from https://github.com/llvm/torch-mlir/pull/1887 causing the following build error:

```
ERROR: /root/.cache/bazel/_bazel_root/b89349c08f7224396763d14fe35cba11/external/torch-mlir/BUILD.bazel:819:10: Compiling tools/torch-mlir-opt/torch-mlir-opt.cpp failed: (Exit 1): clang failed: error executing command /usr/lib/llvm-16/bin/clang -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer ... (remaining 366 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/torch-mlir/tools/torch-mlir-opt/torch-mlir-opt.cpp:16:10: fatal error: 'stablehlo/dialect/Register.h' file not found
#include "stablehlo/dialect/Register.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Target @torch-mlir//:torch-mlir-opt failed to build
```

GHA workflow with the fix:
https://github.com/sjain-stanford/torch-mlir/actions/runs/4421486154
2023-03-14 20:04:09 -07:00
Ahmed S. Taei 3bed35c0ee
[Bazel] Fix clang version, missing mhlo deps and add reqs files (#1898)
* Fix clang version, missing mhlo deps and add reqs files
2023-02-24 15:07:34 -08:00
Ashay Rane 711646d095
mhlo: migrate conversion to stablehlo (#1840)
This patch replaces all MHLO operations with their StableHLO
counterparts and adds a validation pass to ensure that no MHLO operations
remain before translating all Stablehlo operations to the MHLO dialect
for further lowering to the Linalg dialect.

This patch also updates all lit tests so that they refer to the
`convert-torch-to-stablehlo` pass and so that they check for StableHLO
operations.
2023-02-02 07:29:47 -06:00
Ahmed S. Taei 6b76e2e927
Use global for MLIRTorchOpsIncGenTdFiles (#1784) 2023-01-11 14:18:35 -08:00
Ashay Rane a897c49803
CI: miscellaneous fixes for Release builds (#1781)
- Use v3 of actions/checkout, since the version we use (v2) uses
   Node.js 12, which is deprecated by GitHub.

 - Source the PowerShell venv sctipt (instead of the bash sript) since
   the calling script is a PowerShell script.  Without this, the build
   doesn't use venv at all.

 - Make the build dependencies in whl-requirements.txt (used by
   setup.py) match those in requirements.txt.  To that end, this patch
   creates a build-requirements.txt that is referenced by
   requirements.txt and whl-requirements.txt.
2023-01-06 20:41:43 -06:00
Vivek Khandelwal ddbcf569e0 [Bazel] Fix Bazel build
Signed-Off By: Vivek Khandelwal<vivek@nod-labs.com>
2022-12-22 12:22:33 +05:30
Sambhav Jain 109c91ae9b
[CI] Verify bazel buildifier is run and changes committed (#1700)
Ensures the buildifier (linter for bazel build files) is run and changes are pushed.
2022-12-08 15:56:57 -08:00
Sambhav Jain f8a2592905
[Bazel] Resolve circular dependency and add targets for conversion to MLProgram dialect (#1694)
A circular dependency was introduced in e7edcc62fd. 

Specifically, the `makeShapeLLVMCompatible` and `makeShapeTorchCompatible` utilities were being called from `lib/Dialect/Torch/IR/TorchTypes.cpp` and `lib/Dialect/Torch/IR/TorchOps.cpp` defined under the `:TorchMLIRTorchDialect` bazel target, leading it to take a dependency on `:TorchMLIRConversionUtils` which already depends on `:TorchMLIRTorchDialect`, hence creating a circular dependency.

This commit resolves the same by moving said utilities from `lib/Conversion/Utils/Utils.cpp` to `lib/Dialect/Torch/Utils/Utils.cpp`. Please LMK if there's a better way to fix this and I will update the code.

This commit also adds the required targets to support building the new conversions from Torch to ML Program dialect that was introduced in f416953600.

Bazel build GHA triggered manually to verify: https://github.com/sjain-stanford/torch-mlir/actions/runs/3645944517
2022-12-08 09:49:54 -08:00
Sambhav Jain fc4c8d4ed9
Enable torch-mlir LIT tests in Bazel (#1585)
Adds support to run `.mlir` LIT tests in bazel. 

```
bazel test @torch-mlir//test/...
```

Follow-on PR will contain these updates:
- Add tests to GHA CI workflow
- Add `.py` LIT tests to bazel
2022-11-15 14:02:19 -08:00
Sambhav Jain 4032eeca64
Add Bazel buildifier to torch-mlir (#1586)
Formats bazel BUILD and .bzl files with a standard convention. 

Invoke using
```
bazel run @torch-mlir//:buildifier
```
2022-11-15 12:34:27 -08:00
Sambhav Jain b320f7fb77
Simplify Bazel build workflow (#1587)
Remove `run_bazel_build.sh`, simplify docker's entrypoint to start container at `utils/bazel` directory, update docs.
2022-11-15 08:34:43 -08:00
Sambhav Jain dcff5a7150
[Bazel] Update to Ubuntu-22.04 and clang-16 for Bazel build docker (#1523)
* Update Ubuntu and clang in the docker container
* Specifically build just `@torch-mlir//:torch-mlir-opt`


Triggered GHA run:
https://github.com/sjain-stanford/torch-mlir/actions/runs/3317006870/jobs/5479411204
2022-11-10 13:11:06 -08:00
Ahmed S. Taei 8da8d971c8
[Bazel] Use gloab instead of explicit files (#1529) 2022-10-26 13:28:00 -07:00
Ahmed S. Taei d865c1de7a
[Bazel] Use glob instead of explicit files (#1520) 2022-10-25 12:23:24 -07:00
Ahmed S. Taei 844d58279d
[Bazel] Update bazel_skylib version (#1498)
This should fix current bazel build
2022-10-17 09:05:54 -07:00
Vivek Khandelwal d4e1867e90 [MLIR] Fix bazel build
Signed-Off By: Vivek Khandelwal<vivek@nod-labs.com>
2022-10-06 23:16:51 +05:30
Sambhav Jain 0765449684
[Bazel] Make pytorch-requirements.txt available within the docker container (#1439)
Updates the bazel Dockerfile to match changes from https://github.com/llvm/torch-mlir/pull/1419. This should get the bazel build back to green.

Also triggered bazel build on GHA here: https://github.com/sjain-stanford/torch-mlir/actions/runs/3154741943. Let's wait for it to complete before landing this.
2022-09-29 16:30:31 -07:00
Sambhav Jain 068eec41cb
[Bazel] Remove MHLO enable flag (#1350)
The `-DTORCH_MLIR_ENABLE_MHLO` flag was recently introduced for `TorchMLIRTorchConversionPassesIncGen` [here](https://sourcegraph.com/github.com/llvm/torch-mlir@99093d0623c3d3e6fb961ad0c8fda5ee9fc264fe/-/blob/utils/bazel/torch-mlir-overlay/BUILD.bazel?L319) in [this recent PR](https://github.com/llvm/torch-mlir/pull/1321) (was already present for `TorchMLIRConversionPassesIncGen` [here](https://sourcegraph.com/github.com/llvm/torch-mlir@99093d0623c3d3e6fb961ad0c8fda5ee9fc264fe/-/blob/utils/bazel/torch-mlir-overlay/BUILD.bazel?L288)). Before this PR, the MHLO sources in TorchConversion were not being built. This indicates a build issue that pre-existed but didn’t trigger until this path was enabled recently. Disabling to get the build green for now, until we can diagnose and fix the build for MHLO sources in TorchConversion.
2022-09-07 13:11:19 -07:00
Tanyo Kwok 57d8ec151f
[MHLO] add VerifyMhloBackendContract (#1321)
* [MHLO] add VerifyMhloBackendContract

* guard with macro
2022-09-01 17:08:17 +08:00
Sean Silva 0e3ddbac91 Remove VerifyInvariantsBeforeBackendLowering
LowerToBackendContract now checks all this consistently.
2022-08-26 10:24:43 -07:00
Sambhav Jain 1e1759c2eb
[Bazel] Run buildifier (#1250)
Lint all Bazel files (BUILD, WORKSPACE, .bzl, or .sky).

Steps followed:
```shell
./utils/bazel/run_docker.sh

# run within container
git clone https://github.com/bazelbuild/buildtools.git
cd buildtools
bazel build //buildifier
# buildifier formatter
./bazel-bin/buildifier/buildifier_/buildifier -r ../utils/bazel/
# buildifier linter
./bazel-bin/buildifier/buildifier_/buildifier --lint=fix -r ../utils/bazel/
```
2022-08-18 22:42:58 -07:00
Sambhav Jain 7d4a0d0e2b
[Bazel] Add LowerToBackendContract.cpp to TorchMLIRTorchPasses bazel target (#1243)
Pass is introduced in [this commit](57681f7947). Including it to the bazel targets to get a green build.
2022-08-17 18:15:23 -07:00
Sean Silva 57681f7947 Iteratively run the main simplification pipeline.
This introduces a new pass LowerToBackendContract (better name very
welcome) which performs the bulk of the simplifications that we do,
such as
- shape refinement
- dtype refinement
- maximizing value semantics
- inlining global slots
- decomposing complex ops

The key difference from before is that it iterates the set of
transformations, which can help to break a number of "catch-22" issues
where one simplification depends on another, the latest example being
here:
https://github.com/llvm/torch-mlir/issues/1131

This also exposed that RefineTypes was sometimes crashing/asserting for
certain inputs. This commit hardens it a bit.
2022-08-17 14:54:33 -07:00
Sambhav Jain 9c8b962720
Dockerize and Cache Bazel {Local, CI} Builds (#1240)
This PR adds:

- A minimal docker wrapper to the bazel GHA workflow to make it reproducible locally
- Bazel cache to speed up GHA workflows (down to ~5 minutes from ~40+minutes)

This is a no-op for non-bazel workflows and an incremental improvement.
2022-08-17 12:46:17 -07:00
Ramana Radhakrishnan b8d51a74d9
Update TorchToStd to TorchtoArith in bazel files too. (#1210)
The CI didn't catch the missing rename of TorchToArith until the
merge had happened. This is following up from #1163
2022-08-10 14:51:13 -07:00
Sambhav Jain 072c2b5aaf
[Bazel] Add EraseModuleInitializer to TorchMLIRTorchPasses library (#1202)
The torch-mlir bazel build is [failing](https://github.com/llvm/torch-mlir/runs/7737425906?check_suite_focus=true) since [this commit](504de5e701) due to a linker failure (undefined symbol: `mlir::torch::Torch::createEraseModuleInitializerPass()`).

```
ERROR: /home/runner/.cache/bazel/_bazel_runner/db599744cd37f8c161e5034d9b9cd520/external/torch-mlir/BUILD.bazel:845:10: Linking external/torch-mlir/torch-mlir-opt failed: (Exit 1): clang failed: error executing command /usr/lib/llvm-11/bin/clang @bazel-out/k8-fastbuild/bin/external/torch-mlir/torch-mlir-opt-2.params

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
ld.lld: error: undefined symbol: mlir::torch::Torch::createEraseModuleInitializerPass()
>>> referenced by Passes.cpp
>>>               bazel-out/k8-fastbuild/bin/external/torch-mlir/_objs/TorchMLIRTorchPasses/Passes.pic.o:(mlir::torch::Torch::createTorchFunctionToTorchBackendPipeline(mlir::OpPassManager&, mlir::torch::Torch::TorchLoweringPipelineOptions const&))
>>> referenced by Passes.cpp
>>>               bazel-out/k8-fastbuild/bin/external/torch-mlir/_objs/TorchMLIRTorchPasses/Passes.pic.o:((anonymous namespace)::registerEraseModuleInitializerPass()::'lambda'()::operator()() const)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

This PR adds `lib/Dialect/Torch/Transforms/EraseModuleInitializer.cpp` to `TorchMLIRTorchPasses` library.
2022-08-09 13:34:59 -07:00
Jacques Pienaar e75c7c5292
Flip to C++17 (#1198)
LLVM now uses C++17.
2022-08-09 08:38:30 -07:00
武家伟 d030591df9
[MHLO] Init MHLO pooling-like op conversion (#1141)
* [MHLO] Init MHLO pooling-like op conversion and remove 'op' suffix in filenames

Co-authored-by: Bairen Yi <yibairen.byron@bytedance.com>
Co-authored-by: Jiawei Wu <xremold@gmail.com>
Co-authored-by: Tianyou Guo tianyou.gty@alibaba-inc.com
Co-authored-by: Xu Yan <yancey.yx@alibaba-inc.com>
Co-authored-by: Ziheng Jiang <ziheng.jiang@bytedance.com>

See RFC #999
2022-08-04 12:34:22 +08:00
Tanyo Kwok f0a24f59f6
[MHLO] Init MHLO linear op patterns (#1132)
See RFC https://github.com/llvm/torch-mlir/issues/999

Co-authored-by: Bairen Yi yibairen.byron@bytedance.com
Co-authored-by: Jiawei Wu xremold@gmail.com
Co-authored-by: Tianyou Guo tianyou.gty@alibaba-inc.com
Co-authored-by: Xu Yan yancey.yx@alibaba-inc.com
Co-authored-by: Ziheng Jiang ziheng.jiang@bytedance.com
2022-08-03 19:10:54 -07:00
Ahmed S. Taei 48ec300586
[Fix bazel] Add recently added torch->mhlo conversion pass to bazel (#1148) 2022-08-03 14:12:07 -07:00
Ahmed S. Taei 82af44da2f
Fix mhlo bazel rule name (#1136) 2022-08-02 12:28:53 -07:00
Ahmed S. Taei b389053653
Add mhlo to bazel build (#1120) 2022-07-28 23:24:42 -07:00
Ashay Rane 89e0288fdc
build: fix bazel build after adding VerifyConversionToValueSemantics.cpp (#1055)
A previous patch added a new file
("VerifyConversionToValueSemantics.cpp") to the build, but it did not
add it to the list files known to bazel.  This patch fixes the problem.
2022-07-14 10:26:51 -07:00
Maksim Levental e143a34948
Bump LLVM (#966) 2022-06-22 22:50:39 -05:00
Ahmed S. Taei 57a28dfadc
[Bazel][Fix] Add missing dependency (#806) 2022-04-27 23:22:27 -07:00
Ahmed S. Taei 7f2577a848
Fix bazel build post llvm-project bump (#803) 2022-04-26 19:21:52 -07:00
Ahmed S. Taei eaf34fa02b
Add bazel build support (1/N) (#706)
This PR adds rules for building the compiler part with bazel, a followup PRs will build the python bindings.
2022-04-06 11:20:39 -07:00