xref: /aosp_15_r20/external/tensorflow/tensorflow/workspace0.bzl (revision b6fb3261f9314811a0f4371741dbb8839866f948)
1"""TensorFlow workspace initialization. Consult the WORKSPACE on how to use it."""
2
3load("//third_party/googleapis:repository_rules.bzl", "config_googleapis")
4load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
5load("@bazel_toolchains//repositories:repositories.bzl", bazel_toolchains_repositories = "repositories")
6load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies")
7load("@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies")
8load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies")
9load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
10load("@local_config_android//:android.bzl", "android_workspace")
11load("@rules_cc//cc:repositories.bzl", "rules_cc_toolchains")
12
13def _tf_bind():
14    """Bind targets for some external repositories"""
15    ##############################################################################
16    # BIND DEFINITIONS
17    #
18    # Please do not add bind() definitions unless we have no other choice.
19    # If that ends up being the case, please leave a comment explaining
20    # why we can't depend on the canonical build target.
21
22    # Needed by Protobuf
23    native.bind(
24        name = "grpc_cpp_plugin",
25        actual = "@com_github_grpc_grpc//src/compiler:grpc_cpp_plugin",
26    )
27    native.bind(
28        name = "grpc_python_plugin",
29        actual = "@com_github_grpc_grpc//src/compiler:grpc_python_plugin",
30    )
31
32    native.bind(
33        name = "grpc_lib",
34        actual = "@com_github_grpc_grpc//:grpc++",
35    )
36
37    native.bind(
38        name = "grpc_lib_unsecure",
39        actual = "@com_github_grpc_grpc//:grpc++_unsecure",
40    )
41
42    # Needed by Protobuf
43    native.bind(
44        name = "python_headers",
45        actual = str(Label("//third_party/python_runtime:headers")),
46    )
47
48    # Needed by Protobuf
49    native.bind(
50        name = "six",
51        actual = "@six_archive//:six",
52    )
53
54def _tf_bind():
55    """Bind targets for some external repositories"""
56    ##############################################################################
57    # BIND DEFINITIONS
58    #
59    # Please do not add bind() definitions unless we have no other choice.
60    # If that ends up being the case, please leave a comment explaining
61    # why we can't depend on the canonical build target.
62
63    # Needed by Protobuf
64    native.bind(
65        name = "grpc_cpp_plugin",
66        actual = "@com_github_grpc_grpc//src/compiler:grpc_cpp_plugin",
67    )
68    native.bind(
69        name = "grpc_python_plugin",
70        actual = "@com_github_grpc_grpc//src/compiler:grpc_python_plugin",
71    )
72
73    native.bind(
74        name = "grpc_lib",
75        actual = "@com_github_grpc_grpc//:grpc++",
76    )
77
78    native.bind(
79        name = "grpc_lib_unsecure",
80        actual = "@com_github_grpc_grpc//:grpc++_unsecure",
81    )
82
83    # Needed by Protobuf
84    native.bind(
85        name = "python_headers",
86        actual = str(Label("//third_party/python_runtime:headers")),
87    )
88
89    # Needed by Protobuf
90    native.bind(
91        name = "six",
92        actual = "@six_archive//:six",
93    )
94
95def workspace():
96    http_archive(
97        name = "inception_v1",
98        build_file = "//:models.BUILD",
99        sha256 = "7efe12a8363f09bc24d7b7a450304a15655a57a7751929b2c1593a71183bb105",
100        urls = [
101            "https://storage.googleapis.com/download.tensorflow.org/models/inception_v1.zip",
102        ],
103    )
104
105    http_archive(
106        name = "mobile_ssd",
107        build_file = "//:models.BUILD",
108        sha256 = "bddd81ea5c80a97adfac1c9f770e6f55cbafd7cce4d3bbe15fbeb041e6b8f3e8",
109        urls = [
110            "https://storage.googleapis.com/download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_android_export.zip",
111        ],
112    )
113
114    http_archive(
115        name = "mobile_multibox",
116        build_file = "//:models.BUILD",
117        sha256 = "859edcddf84dddb974c36c36cfc1f74555148e9c9213dedacf1d6b613ad52b96",
118        urls = [
119            "https://storage.googleapis.com/download.tensorflow.org/models/mobile_multibox_v1a.zip",
120        ],
121    )
122
123    http_archive(
124        name = "stylize",
125        build_file = "//:models.BUILD",
126        sha256 = "3d374a730aef330424a356a8d4f04d8a54277c425e274ecb7d9c83aa912c6bfa",
127        urls = [
128            "https://storage.googleapis.com/download.tensorflow.org/models/stylize_v1.zip",
129        ],
130    )
131
132    http_archive(
133        name = "speech_commands",
134        build_file = "//:models.BUILD",
135        sha256 = "c3ec4fea3158eb111f1d932336351edfe8bd515bb6e87aad4f25dbad0a600d0c",
136        urls = [
137            "https://storage.googleapis.com/download.tensorflow.org/models/speech_commands_v0.01.zip",
138        ],
139    )
140
141    http_archive(
142        name = "person_detect_data",
143        sha256 = "170542270da256994ce24d1e357f6e84a54fdaf7d28ff2b74725a40b70b082cf",
144        urls = [
145            "https://storage.googleapis.com/download.tensorflow.org/data/tf_lite_micro_person_data_grayscale_2020_05_24.zip",
146        ],
147    )
148
149    rules_cc_toolchains()
150
151    bazel_toolchains_repositories()
152
153    # Apple rules for Bazel. https://github.com/bazelbuild/rules_apple.
154    # Note: We add this to fix Kokoro builds.
155    # The rules below call into `rules_proto` but the hash has changed and
156    # Bazel refuses to continue. So, we add our own mirror.
157    http_archive(
158        name = "rules_proto",
159        sha256 = "20b240eba17a36be4b0b22635aca63053913d5c1ee36e16be36499d167a2f533",
160        strip_prefix = "rules_proto-11bf7c25e666dd7ddacbcd4d4c4a9de7a25175f8",
161        urls = [
162            "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_proto/archive/11bf7c25e666dd7ddacbcd4d4c4a9de7a25175f8.tar.gz",
163            "https://github.com/bazelbuild/rules_proto/archive/11bf7c25e666dd7ddacbcd4d4c4a9de7a25175f8.tar.gz",
164        ],
165    )
166
167    # Now, finally use the rules
168    apple_rules_dependencies()
169    swift_rules_dependencies()
170    apple_support_dependencies()
171
172    android_workspace()
173
174    # If a target is bound twice, the later one wins, so we have to do tf bindings
175    # at the end of the WORKSPACE file.
176    _tf_bind()
177
178    grpc_extra_deps()
179    config_googleapis()
180
181# Alias so it can be loaded without assigning to a different symbol to prevent
182# shadowing previous loads and trigger a buildifier warning.
183tf_workspace0 = workspace
184