Start llvm-bazel integration

This commit is contained in:
Mihai Maruseac 2021-02-09 10:00:38 -08:00
parent e4f72eb72f
commit fb3d8d64d8
5 changed files with 61 additions and 54 deletions

View File

@ -6,6 +6,7 @@ workspace(name = "org_tensorflow")
# restriction that load() statements need to be at the top of .bzl files.
# E.g. we can not retrieve a new repository with http_archive and then load()
# a macro from that repository in the same file.
# TODO(mihaimaruseac): Rename `tf_workspace*` to signal what they contain
load("@//tensorflow:workspace3.bzl", "tf_workspace3")
tf_workspace3()
@ -14,6 +15,10 @@ load("@//tensorflow:workspace2.bzl", "tf_workspace2")
tf_workspace2()
load("@//tensorflow:setup_llvm.bzl", "setup_llvm")
setup_llvm()
load("@//tensorflow:workspace1.bzl", "tf_workspace1")
tf_workspace1()

View File

@ -51,11 +51,6 @@ class SubstrOp : public OpKernel {
const Tensor& len_tensor = context->input(2);
const TensorShape& input_shape = input_tensor.shape();
const TensorShape& pos_shape = pos_tensor.shape();
const TensorShape& len_shape = len_tensor.shape();
OP_REQUIRES(context, (pos_shape == len_shape),
errors::InvalidArgument(
"pos and len should have the same shape, got: ",
pos_shape.DebugString(), " vs. ", len_shape.DebugString()));
bool is_scalar = TensorShapeUtils::IsScalar(pos_shape);

View File

@ -222,19 +222,6 @@ test_suite(
name = "all_tests",
)
tflite_micro_cc_test(
name = "cast_test",
srcs = ["cast_test.cc"],
deps = [
":kernel_runner",
"//tensorflow/lite/c:common",
"//tensorflow/lite/micro:debug_log",
"//tensorflow/lite/micro:op_resolvers",
"//tensorflow/lite/micro:test_helpers",
"//tensorflow/lite/micro/testing:micro_test",
],
)
tflite_micro_cc_test(
name = "elementwise_test",
srcs = ["elementwise_test.cc"],
@ -261,19 +248,6 @@ tflite_micro_cc_test(
],
)
tflite_micro_cc_test(
name = "zeros_like_test",
srcs = ["zeros_like_test.cc"],
deps = [
":kernel_runner",
"//tensorflow/lite/c:common",
"//tensorflow/lite/micro:debug_log",
"//tensorflow/lite/micro:op_resolvers",
"//tensorflow/lite/micro:test_helpers",
"//tensorflow/lite/micro/testing:micro_test",
],
)
tflite_micro_cc_test(
name = "pooling_test",
srcs = [

View File

@ -492,16 +492,6 @@ class SubstrOpTest(test.TestCase, parameterized.TestCase):
with self.assertRaises(ValueError):
string_ops.substr(b"test", 3, 1, unit="UTF8")
def testInvalidPos(self):
# Test case for GitHub issue 46900.
with self.assertRaises((ValueError, errors_impl.InvalidArgumentError)):
x = string_ops.substr(b"abc", len=1, pos=[1, -1])
self.evaluate(x)
with self.assertRaises((ValueError, errors_impl.InvalidArgumentError)):
x = string_ops.substr(b"abc", len=1, pos=[1, 2])
self.evaluate(x)
if __name__ == "__main__":
test.main()

View File

@ -684,25 +684,68 @@ def tf_repositories(path_prefix = "", tf_repo_name = ""):
],
)
# Check out LLVM and MLIR from llvm-project.
LLVM_COMMIT = "a5222aa0858a42660629c410a5b669dee16a4359"
LLVM_SHA256 = "69637e9b10bbe8672a5ab1d329578d4bac18e2c311f00bbcc6e6f8c855578931"
LLVM_URLS = [
# Check out LLVM code as needed for MLIR and other components.
# Since LLVM updates frequently and there is no stable interface to it, we
# can get into situation where an LLVM update breaks TF because BUILD files
# are not also updated in sync. To fix this, we always sync two different
# repositories:
#
# * `llvm-bazel` for the Bazel BUILD files
# * `llvm-project-raw` for the actual code
#
# Once both are downloaded and unpacked, we configure `llvm-project` to mix
# the BUILD files and the code.
#
# For all this to work, we need to set up the following variables upon
# exporting code to open source and on every integration.
LLVM_COMMIT = "2fa4186d4e1c0c5ce05efb4275f94bb7c2538dda"
LLVM_BAZEL_TAG = "llvm-project-{commit}".format(commit = LLVM_COMMIT)
LLVM_BAZEL_SHA256 = "dd70781c16b4df03fed658b1d2ec8b884219c6fe20c262a9f8a98978b4e786e7"
LLVM_PROJECT_SHA256 = "44d53acbed53c73cffd41281e053f86850ad7032ccf3ea68f238a010767b7260"
LLVM_BAZEL_URLS = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/google/llvm-bazel/archive/{tag}.tar.gz".format(tag = LLVM_BAZEL_TAG),
"https://github.com/google/llvm-bazel/archive/{tag}.tar.gz".format(tag = LLVM_BAZEL_TAG),
]
LLVM_PROJECT_URLS = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT),
"https://github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT),
]
tf_http_archive(
name = "llvm-project",
sha256 = LLVM_SHA256,
strip_prefix = "llvm-project-" + LLVM_COMMIT,
urls = LLVM_URLS,
additional_build_files = {
clean_dep("//third_party/llvm:llvm.autogenerated.BUILD"): "llvm/BUILD",
"//third_party/mlir:BUILD": "mlir/BUILD",
"//third_party/mlir:test.BUILD": "mlir/test/BUILD",
},
name = "llvm-bazel",
# TODO(mihaimaruseac): Wait until https://github.com/google/llvm-bazel/pull/130 or until Bazel 4.0 before removing the patch
patch_file = clean_dep("//third_party:llvm-bazel.patch"),
sha256 = LLVM_BAZEL_SHA256,
strip_prefix = "llvm-bazel-{tag}/llvm-bazel".format(tag = LLVM_BAZEL_TAG),
urls = LLVM_BAZEL_URLS,
)
tf_http_archive(
name = "llvm-project-raw",
build_file = clean_dep("//third_party/llvm-project:BUILD.bazel"),
sha256 = LLVM_PROJECT_SHA256,
strip_prefix = "llvm-project-" + LLVM_COMMIT,
urls = LLVM_PROJECT_URLS,
)
# TODO(mihaimaruseac): We no longer need these, but Copybara processes still need them before this CL lands (?)
LLVM_SHA256 = "44d53acbed53c73cffd41281e053f86850ad7032ccf3ea68f238a010767b7260"
LLVM_URLS = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT),
"https://github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT),
]
# tf_http_archive(
# name = "llvm-project",
# sha256 = LLVM_SHA256,
# strip_prefix = "llvm-project-" + LLVM_COMMIT,
# urls = LLVM_URLS,
# additional_build_files = {
# clean_dep("//third_party/llvm:llvm.autogenerated.BUILD"): "llvm/BUILD",
# "//third_party/mlir:BUILD": "mlir/BUILD",
# "//third_party/mlir:test.BUILD": "mlir/test/BUILD",
# },
# )
# Intel openMP that is part of LLVM sources.
tf_http_archive(
name = "llvm_openmp",