Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions build_macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
TMP_ROOT=/private/tmp

export BAZELISK_HOME="$TMP_ROOT/tf-bazelisk"
export CCACHE_DIR="$TMP_ROOT/tf-ccache"
export CCACHE_BASEDIR="$ROOT_DIR"
export CCACHE_NOHASHDIR=true
export CCACHE_COMPILERCHECK=content
export TF_PYTHON_VERSION=3.11
export WHEEL_NAME=tensorflow_cpu
export USE_PYWRAP_RULES=1
export DEVELOPER_DIR=/Library/Developer/CommandLineTools

# Pinned toolchain/build assumptions for this macOS build flow.
BAZEL_BIN=/opt/homebrew/bin/bazel
OUTPUT_USER_ROOT="$TMP_ROOT/tf-bazel-root"
MACOS_MINIMUM_OS=12.0
MACOS_SDK_VERSION=26.5
JOBS=12
TARGET=//tensorflow/tools/pip_package:wheel

if command -v ccache >/dev/null 2>&1; then
CCACHE_PREFIX_DIR="$(dirname "$(command -v ccache)")/libexec"
if [ -d "$CCACHE_PREFIX_DIR" ]; then
export PATH="$CCACHE_PREFIX_DIR:$PATH"
fi
fi

if [ ! -x "$BAZEL_BIN" ]; then
echo "bazel not found at $BAZEL_BIN" >&2
exit 1
fi

"$BAZEL_BIN" --output_user_root="$OUTPUT_USER_ROOT" build \
--cpu=darwin_arm64 \
--macos_minimum_os="$MACOS_MINIMUM_OS" \
--macos_sdk_version="$MACOS_SDK_VERSION" \
--copt=-Wno-invalid-specialization \
--host_copt=-Wno-invalid-specialization \
--repo_env=TF_PYTHON_VERSION="$TF_PYTHON_VERSION" \
--repo_env=WHEEL_NAME="$WHEEL_NAME" \
--repo_env=USE_PYWRAP_RULES="$USE_PYWRAP_RULES" \
--action_env=CCACHE_DIR \
--host_action_env=CCACHE_DIR \
--action_env=CCACHE_BASEDIR \
--host_action_env=CCACHE_BASEDIR \
--action_env=CCACHE_NOHASHDIR \
--host_action_env=CCACHE_NOHASHDIR \
--action_env=CCACHE_COMPILERCHECK \
--host_action_env=CCACHE_COMPILERCHECK \
--action_env=DEVELOPER_DIR="$DEVELOPER_DIR" \
--host_action_env=DEVELOPER_DIR="$DEVELOPER_DIR" \
--strategy=CppCompile=local \
--jobs="$JOBS" \
--verbose_failures \
--show_progress_rate_limit=30 \
"$TARGET"
8 changes: 8 additions & 0 deletions tensorflow/compiler/jit/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,14 @@ cc_library(
],
)

# Declares flags.h without linking the flags implementation or exposing its
# transitive op registrations to wrapper generation.
cc_library(
name = "flags_link_free_headers",
hdrs = ["flags.h"],
visibility = ["//tensorflow/compiler/tf2xla/ops:__pkg__"],
)

cc_header_only_library(
name = "flags_headers_only",
features = [
Expand Down
3 changes: 2 additions & 1 deletion tensorflow/compiler/tf2xla/ops/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cc_library(
name = "xla_ops",
srcs = ["xla_ops.cc"],
deps = [
"//tensorflow/compiler/jit:flags",
"//tensorflow/compiler/jit:flags_link_free_headers",
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
Expand Down Expand Up @@ -53,6 +53,7 @@ tf_custom_op_library(
"xla_ops.cc",
],
deps = [
"//tensorflow/compiler/jit:flags_link_free_headers",
"@com_google_absl//absl/algorithm:container",
"@local_xla//xla:shape_util",
"@local_xla//xla:xla_data_proto_cc",
Expand Down
7 changes: 7 additions & 0 deletions tensorflow/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,12 @@ cc_header_only_library(
deps = [
":lib",
":lib_internal",
"//tensorflow/core/framework:common_shape_fns",
"//tensorflow/core/framework:op",
"//tensorflow/core/framework:shape_inference",
"//tensorflow/core/framework:tensor",
"//tensorflow/core/framework:tensor_shape",
"//tensorflow/core/framework:tensor_shape_expr",
"//tensorflow/core/framework:bounds_check",
"//tensorflow/core/platform/default/build_config:platformlib",
],
Expand Down Expand Up @@ -1814,6 +1820,7 @@ tf_cuda_library(
"@com_google_absl//absl/types:optional",
"@com_google_absl//absl/types:span",
"@eigen_archive//:eigen3",
"@local_xla//xla:shape_util",
],
)

Expand Down
4 changes: 2 additions & 2 deletions tensorflow/workspace2.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -767,8 +767,8 @@ def _tf_repositories():
# https://github.com/bazelbuild/apple_support/releases
tf_http_archive(
name = "build_bazel_apple_support",
sha256 = "d71b02d6df0500f43279e22400db6680024c1c439115c57a9a82e9effe199d7b",
urls = tf_mirror_urls("https://github.com/bazelbuild/apple_support/releases/download/1.18.1/apple_support.1.18.1.tar.gz"),
sha256 = "1ae6fcf983cff3edab717636f91ad0efff2e5ba75607fdddddfd6ad0dbdfaf10",
urls = tf_mirror_urls("https://github.com/bazelbuild/apple_support/releases/download/1.24.5/apple_support.1.24.5.tar.gz"),
)

# https://github.com/apple/swift-protobuf/releases
Expand Down
2 changes: 2 additions & 0 deletions third_party/xla/xla/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ cc_library(
tf_proto_library(
name = "shape_util_proto",
srcs = ["shape_util.proto"],
make_default_target_header_only = True,
)

cc_library(
Expand Down Expand Up @@ -549,6 +550,7 @@ xla_cc_test(
srcs = ["shape_util_test.cc"],
deps = [
":shape_util",
":shape_util_proto_cc_impl",
":util",
":xla_data_proto_cc",
"//xla/hlo/testlib:test",
Expand Down
18 changes: 9 additions & 9 deletions third_party/xla/xla/hlo/builder/value_inference_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ TEST_F(DynamismInferenceTest, GetDimensionSize) {
// get_dimension_size(param, 0) is dynamic
// get_dimension_size(param, 1) is static
auto p =
Parameter(&b, 0, ShapeUtil::MakeShape(S32, {2, 3}, {true, false}), "p0");
Parameter(&b, 0, ShapeUtil::MakeShape(S32, {2, 3}, std::vector<bool>{true, false}, {}), "p0");

auto gds0 = GetDimensionSize(p, 0);
auto gds1 = GetDimensionSize(p, 1);
Expand Down Expand Up @@ -559,7 +559,7 @@ class UpperBoundInferenceTest : public ValueInferenceTest {
TEST_F(UpperBoundInferenceTest, GetDimensionSize) {
XlaBuilder b(TestName());
auto p =
Parameter(&b, 0, ShapeUtil::MakeShape(S32, {2, 3}, {true, false}), "p0");
Parameter(&b, 0, ShapeUtil::MakeShape(S32, {2, 3}, std::vector<bool>{true, false}, {}), "p0");

auto gds0 = GetDimensionSize(p, 0);
auto gds1 = GetDimensionSize(p, 1);
Expand All @@ -573,7 +573,7 @@ TEST_F(UpperBoundInferenceTest, GetDimensionSize) {
TEST_F(UpperBoundInferenceTest, GetDimensionSizeSub) {
XlaBuilder b(TestName());
auto p =
Parameter(&b, 0, ShapeUtil::MakeShape(S32, {2, 3}, {true, false}), "p0");
Parameter(&b, 0, ShapeUtil::MakeShape(S32, {2, 3}, std::vector<bool>{true, false}, {}), "p0");

// The range of the first dimension is [0, 2]
auto gds0 = GetDimensionSize(p, 0);
Expand All @@ -587,7 +587,7 @@ TEST_F(UpperBoundInferenceTest, GetDimensionSizeSub) {
TEST_F(UpperBoundInferenceTest, GetDimensionSizeDiv) {
XlaBuilder b(TestName());
auto p =
Parameter(&b, 0, ShapeUtil::MakeShape(S32, {2, 3}, {true, false}), "p0");
Parameter(&b, 0, ShapeUtil::MakeShape(S32, {2, 3}, std::vector<bool>{true, false}, {}), "p0");
// The range of the first dimension is [0, 2]
auto gds0 = GetDimensionSize(p, 0);
// The range of the second dimension is [3, 3]
Expand All @@ -603,7 +603,7 @@ TEST_F(UpperBoundInferenceTest, SumSubtract) {
// upperbound(x + y) should be upperbound(b)
XlaBuilder b(TestName());
auto p =
Parameter(&b, 0, ShapeUtil::MakeShape(S32, {2, 3}, {true, true}), "p0");
Parameter(&b, 0, ShapeUtil::MakeShape(S32, {2, 3}, std::vector<bool>{true, true}, {}), "p0");
// The range of the first dimension is [0, 2]
auto gds0 = GetDimensionSize(p, 0);
// The range of the second dimension is [0, 3]
Expand All @@ -622,7 +622,7 @@ TEST_F(UpperBoundInferenceTest, SumSubtractWithDataShuffling) {
// (broadcast, slice, reshape, identity convert, etc).
XlaBuilder b(TestName());
auto p =
Parameter(&b, 0, ShapeUtil::MakeShape(S32, {2, 3}, {true, true}), "p0");
Parameter(&b, 0, ShapeUtil::MakeShape(S32, {2, 3}, std::vector<bool>{true, true}, {}), "p0");
// The range of the first dimension is [0, 2]
auto gds0 = GetDimensionSize(p, 0);
// The range of the second dimension is [0, 3]
Expand All @@ -644,7 +644,7 @@ TEST_F(UpperBoundInferenceTest, SumSubtractWithDataShuffling) {
TEST_F(UpperBoundInferenceTest, SumSubtractEquivalentGetDimensionSize) {
XlaBuilder b(TestName());
auto p =
Parameter(&b, 0, ShapeUtil::MakeShape(S32, {2, 3}, {true, true}), "p0");
Parameter(&b, 0, ShapeUtil::MakeShape(S32, {2, 3}, std::vector<bool>{true, true}, {}), "p0");
// The range of the first dimension is [0, 2]
auto gds0 = GetDimensionSize(p, 0);
// The range of the second dimension is [0, 3]
Expand All @@ -662,8 +662,8 @@ TEST_F(UpperBoundInferenceTest, ParamCantInferBound) {
// We can infer a parameter's dimension's bound, but not the parameter value's
// bound.
XlaBuilder b(TestName());
auto p0 = Parameter(&b, 0, ShapeUtil::MakeShape(S32, {2}, {true}), "p0");
auto p1 = Parameter(&b, 1, ShapeUtil::MakeShape(S32, {}, {}), "p1");
auto p0 = Parameter(&b, 0, ShapeUtil::MakeShape(S32, {2}, std::vector<bool>{true}, {}), "p0");
auto p1 = Parameter(&b, 1, ShapeUtil::MakeShape(S32, {}), "p1");
auto gds = GetDimensionSize(p0, 0);
auto sub = Div(gds, p1);
EXPECT_FALSE(
Expand Down
Loading