Skip to content

Commit

Permalink
ability to test 3p deps checked out as local repos
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
sjain-stanford committed Oct 19, 2023
1 parent d837214 commit 7a20a4b
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 33 deletions.
6 changes: 6 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Also available under a BSD-style license. See LICENSE.

third_party/
14 changes: 10 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/bazel-bin
/bazel-out
/bazel-mlir-tcp
/bazel-testlogs
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Also available under a BSD-style license. See LICENSE.

bazel-bin
bazel-out
bazel-mlir-tcp
bazel-testlogs
third_party/
92 changes: 63 additions & 29 deletions deps.bzl
Original file line number Diff line number Diff line change
@@ -1,37 +1,71 @@
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Also available under a BSD-style license. See LICENSE.

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load(
":local_repos.bzl",
"local_llvm_repo_path",
"local_stablehlo_repo_path",
"local_torch_mlir_repo_path",
"use_local_llvm_repo",
"use_local_stablehlo_repo",
"use_local_torch_mlir_repo",
)

def third_party_deps():
LLVM_COMMIT = "28b27c1b10ae8d1f5b4fb9df691e8cf0da9be3f6"
LLVM_SHA256 = "1f7a7ca5983801d671901644659c32d028e5e7316418fabcb6159454249aefa3"
http_archive(
name = "llvm-raw",
build_file_content = "# empty",
sha256 = LLVM_SHA256,
strip_prefix = "llvm-project-" + LLVM_COMMIT,
urls = ["https://github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT)],
)
if use_local_llvm_repo():
native.new_local_repository(
name = "llvm-raw",
build_file_content = "# empty",
path = local_llvm_repo_path(),
)
else:
LLVM_COMMIT = "28b27c1b10ae8d1f5b4fb9df691e8cf0da9be3f6"
LLVM_SHA256 = "1f7a7ca5983801d671901644659c32d028e5e7316418fabcb6159454249aefa3"
http_archive(
name = "llvm-raw",
build_file_content = "# empty",
sha256 = LLVM_SHA256,
strip_prefix = "llvm-project-" + LLVM_COMMIT,
urls = ["https://github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT)],
)

TORCH_MLIR_COMMIT = "52abae1526e51ae8c415ca98ce4a56b00782b68b"
TORCH_MLIR_SHA256 = "f9973f3519b4ba98475917eb700f447b65fee88e9dd60c61f174ce38335ccb3b"
http_archive(
name = "torch-mlir-raw",
sha256 = TORCH_MLIR_SHA256,
build_file_content = "# empty",
strip_prefix = "torch-mlir-" + TORCH_MLIR_COMMIT,
urls = ["https://github.com/llvm/torch-mlir/archive/{commit}.tar.gz".format(commit = TORCH_MLIR_COMMIT)],
)
if use_local_torch_mlir_repo():
native.new_local_repository(
name = "torch-mlir-raw",
build_file_content = "# empty",
path = local_torch_mlir_repo_path(),
)
else:
TORCH_MLIR_COMMIT = "52abae1526e51ae8c415ca98ce4a56b00782b68b"
TORCH_MLIR_SHA256 = "f9973f3519b4ba98475917eb700f447b65fee88e9dd60c61f174ce38335ccb3b"
http_archive(
name = "torch-mlir-raw",
sha256 = TORCH_MLIR_SHA256,
build_file_content = "# empty",
strip_prefix = "torch-mlir-" + TORCH_MLIR_COMMIT,
urls = ["https://github.com/llvm/torch-mlir/archive/{commit}.tar.gz".format(commit = TORCH_MLIR_COMMIT)],
)

STABLEHLO_COMMIT = "5a8bb985f50a679721292b14f97f270344ac64a3"
STABLEHLO_SHA256 = "abda3e8e029c1409b53b1eea080e5cfb4c4ef6705064d7cd954d8272d059567a"
http_archive(
name = "stablehlo",
sha256 = STABLEHLO_SHA256,
strip_prefix = "stablehlo-" + STABLEHLO_COMMIT,
urls = ["https://github.com/openxla/stablehlo/archive/{commit}.tar.gz".format(commit = STABLEHLO_COMMIT)],
# This patch allows testing stablehlo from mlir-tcp
patches = ["@//:stablehlo.patch"],
patch_args = ["-p1"],
)
if use_local_stablehlo_repo():
native.local_repository(
name = "stablehlo",
path = local_stablehlo_repo_path(),
)
else:
STABLEHLO_COMMIT = "5a8bb985f50a679721292b14f97f270344ac64a3"
STABLEHLO_SHA256 = "abda3e8e029c1409b53b1eea080e5cfb4c4ef6705064d7cd954d8272d059567a"
http_archive(
name = "stablehlo",
sha256 = STABLEHLO_SHA256,
strip_prefix = "stablehlo-" + STABLEHLO_COMMIT,
urls = ["https://github.com/openxla/stablehlo/archive/{commit}.tar.gz".format(commit = STABLEHLO_COMMIT)],
# This patch allows testing stablehlo from mlir-tcp
patches = ["@//:stablehlo.patch"],
patch_args = ["-p1"],
)

SKYLIB_VERSION = "1.3.0"

Expand Down
36 changes: 36 additions & 0 deletions local_repos.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Also available under a BSD-style license. See LICENSE.

# Modify this file to get bazel to use a local source checkout for the 3p deps
# (e.g. to quickly test out local changes).
#
# To avoid accidentally checking in modifications to this file, you can ask git
# to ignore changes to this file by running the following:
#
# $ git update-index --assume-unchanged local_repos.bzl

def use_local_llvm_repo():
# Change this to return True to have mlir-tcp use the source tree at
# `local_llvm_repo_path()`
return False

def use_local_torch_mlir_repo():
# Change this to return True to have mlir-tcp use the source tree at
# `local_torch_mlir_repo_path()`
return False

def use_local_stablehlo_repo():
# Change this to return True to have mlir-tcp use the source tree at
# `local_stablehlo_repo_path()`
return False

def local_llvm_repo_path():
return "./third_party/llvm-project"

def local_torch_mlir_repo_path():
return "./third_party/torch-mlir"

def local_stablehlo_repo_path():
return "./third_party/stablehlo"

0 comments on commit 7a20a4b

Please sign in to comment.