| # Copyright 2024 The ChromiumOS Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| workspace(name = "cros_tflite") |
| |
| load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
| load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") |
| |
| # Update `bazel_external_uris` in ebuild as well when upgrading TensorFlow, and |
| # all the required dependencies need to be upload to our mirror first. |
| TENSORFLOW_VERSION = "2.18.0" |
| |
| # Use the provided tensorflow repo if it exists. Currently the ebuild will |
| # download and unpack tensorflow for us. |
| # TODO: b/314854484 - Move the tensorflow building logic and patch management |
| # from ebuild to here. |
| maybe( |
| http_archive, |
| name = "org_tensorflow", |
| patch_args = ["-p1"], |
| patch_tool = "patch", |
| patches = [ |
| "//patch:0001-bazel-toolchains.patch", |
| "//patch:0002-ashmem-create.patch", |
| "//patch:0003-gpu-delegate.patch", |
| "//patch:0004-Convolution2DTransposeBias.patch", |
| "//patch:0005-ruy-amd-cpu.patch", |
| "//patch:0006-memory-usage-monitor.patch", |
| "//patch:0007-absl-log.patch", |
| "//patch:0008-absl-base-prefetch.patch", |
| "//patch:0009-Add-cros-mtk-pre-compile-custom-op.patch", |
| "//patch:0010-stop-dts-validation-early.patch", |
| "//patch:0011-dts-powopmodel-broadcastfloattest.patch", |
| "//patch:0012-dts-rsqrtint16.patch", |
| "//patch:0013-dts-stridedsliceoptests.patch", |
| "//patch:0014-dts-rsqrt-nan.patch", |
| "//patch:0015-mtk-preemption.patch", |
| "//patch:0016-accel-config-optimization.patch", |
| "//patch:0017-Add-missing-absl-strings-string_view-target.patch", |
| ], |
| sha256 = "d7876f4bb0235cac60eb6316392a7c48676729860da1ab659fb440379ad5186d", |
| strip_prefix = "tensorflow-{}".format(TENSORFLOW_VERSION), |
| url = "https://github.com/tensorflow/tensorflow/archive/v{}.tar.gz".format(TENSORFLOW_VERSION), |
| ) |
| |
| # Ensure that we have farmhash available under the name @farmhash_archive. |
| load("@org_tensorflow//third_party/farmhash:workspace.bzl", farmhash = "repo") |
| |
| farmhash() |
| |
| # Python is required before initializing TensorFlow. |
| http_archive( |
| name = "rules_python", |
| sha256 = "9d04041ac92a0985e344235f5d946f71ac543f1b1565f2cdbc9a2aaee8adf55b", |
| strip_prefix = "rules_python-0.26.0", |
| url = "https://github.com/bazelbuild/rules_python/releases/download/0.26.0/rules_python-0.26.0.tar.gz", |
| ) |
| |
| load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains") |
| |
| py_repositories() |
| |
| load( |
| "@org_tensorflow//tensorflow/tools/toolchains/python:python_repo.bzl", |
| "python_repository", |
| ) |
| |
| python_repository(name = "python_version_repo") |
| |
| load("@python_version_repo//:py_version.bzl", "HERMETIC_PYTHON_VERSION") |
| |
| python_register_toolchains( |
| name = "python", |
| ignore_root_user_error = True, |
| python_version = HERMETIC_PYTHON_VERSION, |
| ) |
| |
| # Initialize TensorFlow and its external dependencies. |
| load("@org_tensorflow//tensorflow:workspace3.bzl", "tf_workspace3") |
| |
| tf_workspace3() |
| |
| load("@org_tensorflow//tensorflow:workspace2.bzl", "tf_workspace2") |
| |
| tf_workspace2() |
| |
| load("@org_tensorflow//tensorflow:workspace1.bzl", "tf_workspace1") |
| |
| tf_workspace1() |
| |
| load("@org_tensorflow//tensorflow:workspace0.bzl", "tf_workspace0") |
| |
| tf_workspace0() |
| |
| # Introduce hermetic CUDA in Google ML projects. |
| load( |
| "@local_tsl//third_party/gpus/cuda/hermetic:cuda_configure.bzl", |
| "cuda_configure", |
| ) |
| |
| cuda_configure(name = "local_config_cuda") |
| |
| # Intel OpenVINO Delegate dependencies |
| load("@cros_tflite//delegate/intel_openvino:openvino.bzl", "openvino_repository") |
| |
| openvino_repository(name = "intel_openvino") |