Skip to content

Commit 3bb28df

Browse files
authored
Merge pull request #17 from tensorflow/master
downstream merge
2 parents 9e475fe + bf3b14f commit 3bb28df

File tree

1,812 files changed

+62470
-25964
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,812 files changed

+62470
-25964
lines changed

.bazelrc

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,16 @@
7878
# elinux: General Embedded Linux options shared by all flavors.
7979
# elinux_aarch64: Embedded Linux options for aarch64 (ARM64) CPU support.
8080
# elinux_armhf: Embedded Linux options for armhf (ARMv7) CPU support.
81-
81+
#
82+
# Release build options (for all operating systems)
83+
# release_common: Common options for all builds on all operating systems.
84+
# release_windows_common: Common options for all builds on Windows.
85+
# release_gpu_common: Common options for GPU builds on Linux and Windows.
86+
# release_cpu_linux: Toolchain and CUDA options for Linux CPU builds.
87+
# release_cpu_macos: Toolchain and CUDA options for MacOS CPU builds.
88+
# release_gpu_linux: Toolchain and CUDA options for Linux GPU builds.
89+
# release_cpu_windows: Toolchain and CUDA options for Windows CPU builds.
90+
# release_gpu_windows: Toolchain and CUDA options for Windows GPU builds.
8291

8392
# Allow builds using libc++ as a linker library
8493
# This is mostly for OSSFuzz, so we also pass in the flags from environment to clean build file
@@ -534,3 +543,41 @@ try-import %workspace%/.tf_configure.bazelrc
534543

535544
# Put user-specific options in .bazelrc.user
536545
try-import %workspace%/.bazelrc.user
546+
547+
# Here are bazelrc configs for release builds
548+
build:release_common --config=opt
549+
build:release_common --config=v2
550+
build:release_common --action_env TF_CONFIGURE_IOS="0"
551+
552+
build:release_cpu_linux --config=release_common
553+
build:release_cpu_linux --config=avx_linux
554+
# We use the same toolchain for CPU/GPU packages.
555+
# Did not add this to the defaults in case this changes.
556+
build:release_cpu_linux --crosstool_top=//third_party/toolchains/preconfig/ubuntu16.04/gcc7_manylinux2010-nvcc-cuda10.1:toolchain
557+
558+
build:release_cpu_macos --config=release_common
559+
build:release_cpu_macos --config=avx_linux
560+
561+
build:release_gpu_common --config=release_common
562+
build:release_gpu_common --config=cuda
563+
build:release_gpu_common --config=tensorrt
564+
build:release_gpu_common --action_env CUDA_TOOLKIT_PATH="/usr/local/cuda-10.1"
565+
build:release_gpu_common --action_env=TF_CUDA_VERSION="10"
566+
build:release_gpu_common --action_env=TF_CUDNN_VERSION="7"
567+
build:release_gpu_common --action_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_35,sm_37,sm_52,sm_60,sm_61,compute_70"
568+
build:release_gpu_common --action_env=TENSORRT_INSTALL_PATH="/usr/local/tensorrt"
569+
build:release_gpu_common --action_env=LD_LIBRARY_PATH="/usr/local/tensorrt/lib"
570+
build:release_gpu_common --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-5"
571+
572+
573+
build:release_gpu_linux --config=release_gpu_common
574+
build:release_gpu_linux --config=avx_linux
575+
build:release_gpu_linux --crosstool_top=//third_party/toolchains/preconfig/ubuntu16.04/gcc7_manylinux2010-nvcc-cuda10.1:toolchain
576+
577+
build:release_windows_common --config=release_common
578+
build:release_windows_common --define=no_tensorflow_py_deps=true
579+
build:release_windows_common --announce_rc
580+
581+
build:release_cpu_windows --config=release_windows_common
582+
583+
build:release_gpu_windows --config=release_windows_common

RELEASE.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
* C-API functions `TF_StringDecode`, `TF_StringEncode`, and
1212
`TF_StringEncodedSize` are no longer relevant and have been removed; see
1313
core/platform/ctstring.h for string access/modification in C.
14+
* Removed `tf.distribute.Strategy.experimental_run_v2` method, which was deprecated in TF 2.2.
15+
* `tensorflow.python`, `tensorflow.core` and `tensorflow.compiler` modules are
16+
now hidden. These modules are not part of TensorFlow public API.
1417

1518
## Known Caveats
1619

@@ -20,25 +23,39 @@
2023

2124
* <INSERT MAJOR FEATURE HERE, USING MARKDOWN SYNTAX>
2225
* <IF RELEASE CONTAINS MULTIPLE FEATURES FROM SAME AREA, GROUP THEM TOGETHER>
26+
* A new module named `tf.experimental.numpy` is added, which is a NumPy-compatible API for writing TF programs. This module provides class `ndarray`, which mimics the `ndarray` class in NumPy, and wraps an immutable `tf.Tensor` under the hood. A subset of NumPy functions (e.g. `numpy.add`) are provided. Their inter-operation with TF facilities is seamless in most cases. See tensorflow/python/ops/numpy_ops/README.md for details of what are supported and what are the differences with NumPy.
2327

2428
## Bug Fixes and Other Changes
2529

2630
* <SIMILAR TO ABOVE SECTION, BUT FOR OTHER IMPORTANT CHANGES / BUG FIXES>
2731
* <IF A CHANGE CLOSES A GITHUB ISSUE, IT SHOULD BE DOCUMENTED HERE>
2832
* <NOTES SHOULD BE GROUPED PER AREA>
2933
* TF Core:
30-
* <ADD RELEASE NOTES HERE>
34+
* <ADD RELEASE NOTES HERE>
35+
* `tf.types.experimental.TensorLike` is a new `Union` type that can be used as
36+
type annotation for variables representing a Tensor or a value that can be
37+
converted to Tensor by `tf.convert_to_tensor`.
38+
* Calling ops with a python constants or numpy values is now consistent with
39+
tf.convert_to_tensor behavior. This avoids operations like tf.reshape
40+
truncating inputs such as from int64 to int32.
41+
* Added `tf.sparse.map_values` to apply a function to the `.value`s of `SparseTensror` arguments.
3142
* `tf.data`:
3243
* Added optional `exclude_cols` parameter to CsvDataset. This parameter is
3344
the complement of `select_cols`; at most one of these should be specified.
45+
* We have implemented an optimization which reorders data-discarding
46+
transformations such as `take` and `shard` to happen earlier in the
47+
dataset when it is safe to do so. The optimization can be disabled via
48+
the `experimental_optimization.reorder_data_discarding_ops` dataset
49+
option.
3450
* `tf.distribute`:
3551
* <ADD RELEASE NOTES HERE>
3652
* `tf.keras`:
3753
* <ADD RELEASE NOTES HERE>
3854
* `tf.function`/AutoGraph:
3955
* <ADD RELEASE NOTES HERE>
4056
* `tf.lite`:
41-
* <ADD RELEASE NOTES HERE>
57+
* Better support for ops with high-dimensional broadcasting inputs by adding
58+
`BroadcastTo` ops when necessary.
4259
* `tf.random`:
4360
* <ADD RELEASE NOTES HERE>
4461
* Math and Linear Algebra:
@@ -50,9 +67,9 @@
5067
* Tracing and Debugging:
5168
* <ADD RELEASE NOTES HERE>
5269
* Other:
53-
* We have replaced uses of "whitelist" with "allowlist" where possible.
54-
Please see https://developers.google.com/style/word-list#blacklist for more
55-
context.
70+
* We have replaced uses of "whitelist" and "blacklist" with "allowlist"
71+
and "denylist" where possible. Please see
72+
https://developers.google.com/style/word-list#blacklist for more context.
5673
* <ADD RELEASE NOTES HERE>
5774

5875
## Thanks to our Contributors

tensorflow/BUILD

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,16 +532,14 @@ selects.config_setting_group(
532532
package_group(
533533
name = "internal",
534534
packages = [
535-
# To pass open source testing in the pip Kokoros.
536-
"//bazel_pip/tensorflow/...",
537535
"//learning/brain/swift/x10/...",
538536
"//perftools/accelerators/xprof/api/...",
539-
"//third_party/py/autograph/...",
540-
"//third_party/swift/tensorflow/x10/...",
541-
"//third_party/swift/tensorflow_apis/...",
542537
"//tensorflow/...",
543538
"//tensorflow_estimator/python/estimator/...",
544539
"//tensorflow_models/official/...",
540+
"//third_party/py/autograph/...",
541+
"//third_party/swift/tensorflow/x10/...",
542+
"//third_party/swift/tensorflow_apis/...",
545543
],
546544
)
547545

tensorflow/api_template.__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,23 @@ def _running_from_pip_package():
158158
setattr(_current_module, "initializers", initializers)
159159
# pylint: enable=undefined-variable
160160

161+
# Delete modules that should be hidden from dir().
162+
# Don't fail if these modules are not available.
163+
# For e.g. this file will be originally placed under tensorflow/_api/v1 which
164+
# does not have 'python', 'core' directories. Then, it will be copied
165+
# to tensorflow/ which does have these two directories.
166+
# pylint: disable=undefined-variable
167+
try:
168+
del python
169+
except NameError:
170+
pass
171+
try:
172+
del core
173+
except NameError:
174+
pass
175+
try:
176+
del compiler
177+
except NameError:
178+
pass
179+
161180
# __all__ PLACEHOLDER

tensorflow/api_template_v1.__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,25 @@ def _running_from_pip_package():
156156
if _fi.file_exists(_plugin_dir):
157157
_ll.load_library(_plugin_dir)
158158

159+
# Delete modules that should be hidden from dir().
160+
# Don't fail if these modules are not available.
161+
# For e.g. this file will be originally placed under tensorflow/_api/v1 which
162+
# does not have 'python', 'core' directories. Then, it will be copied
163+
# to tensorflow/ which does have these two directories.
164+
165+
# pylint: disable=undefined-variable
166+
try:
167+
del python
168+
except NameError:
169+
pass
170+
try:
171+
del core
172+
except NameError:
173+
pass
174+
try:
175+
del compiler
176+
except NameError:
177+
pass
178+
179+
159180
# __all__ PLACEHOLDER

tensorflow/c/c_api_experimental.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ limitations under the License.
2929
#include "tensorflow/core/common_runtime/eager/context.h"
3030
#include "tensorflow/core/common_runtime/eager/eager_operation.h"
3131
#include "tensorflow/core/distributed_runtime/rpc/grpc_server_lib.h"
32+
#include "tensorflow/core/framework/collective.h"
3233
#include "tensorflow/core/framework/node_def.pb.h"
3334
#include "tensorflow/core/framework/shape_inference.h"
3435
#include "tensorflow/core/framework/tensor.pb.h"
@@ -525,12 +526,12 @@ tensorflow::Status EnableCollectiveOps(const tensorflow::ServerDef& server_def,
525526

526527
LOG_AND_RETURN_IF_ERROR(context->StoreCollectiveOpsServer(
527528
std::move(new_server), grpc_server->worker_env()->device_mgr,
528-
grpc_server->worker_env()->collective_executor_mgr));
529+
grpc_server->worker_env()->collective_executor_mgr.get()));
529530
} else {
530531
LOG_AND_RETURN_IF_ERROR(grpc_server->UpdateServerDef(server_def));
531532
LOG_AND_RETURN_IF_ERROR(context->StoreCollectiveOpsServer(
532533
/*new_server=*/nullptr, grpc_server->worker_env()->device_mgr,
533-
grpc_server->worker_env()->collective_executor_mgr));
534+
grpc_server->worker_env()->collective_executor_mgr.get()));
534535
}
535536
return tensorflow::Status::OK();
536537
#undef LOG_AND_RETURN_IF_ERROR
@@ -551,6 +552,14 @@ TF_CAPI_EXPORT extern void TFE_EnableCollectiveOps(TFE_Context* ctx,
551552
status->status = EnableCollectiveOps(server_def, ctx);
552553
}
553554

555+
TF_CAPI_EXPORT extern void TFE_AbortCollectiveOps(TFE_Context* ctx,
556+
TF_Status* status) {
557+
tensorflow::EagerContext* context =
558+
tensorflow::ContextFromInterface(tensorflow::unwrap(ctx));
559+
auto collective_executor_handle = context->GetCollectiveExecutorHandle();
560+
collective_executor_handle->get()->StartAbort(status->status);
561+
}
562+
554563
TF_ShapeAndTypeList* TF_NewShapeAndTypeList(int num_items) {
555564
TF_ShapeAndTypeList* result = new TF_ShapeAndTypeList;
556565
result->num_items = num_items;

tensorflow/c/c_api_experimental.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,14 @@ TF_CAPI_EXPORT extern void TFE_EnableCollectiveOps(TFE_Context* ctx,
230230
size_t proto_len,
231231
TF_Status* status);
232232

233+
// Aborts all ongoing collectives with the specified status. After abortion,
234+
// subsequent collectives will error with this status immediately.
235+
//
236+
// This is intended to be used when a peer failure is detected. There's yet no
237+
// way to reset the collectives other than restarting the program.
238+
TF_CAPI_EXPORT extern void TFE_AbortCollectiveOps(TFE_Context* ctx,
239+
TF_Status* status);
240+
233241
// Information about the shape of a Tensor and its type.
234242
struct TF_ShapeAndType {
235243
// Number of dimensions. -1 indicates unknown rank.

tensorflow/c/eager/BUILD

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ tf_cuda_cc_test(
240240
"//tensorflow/c:c_api",
241241
"//tensorflow/c:c_test_util",
242242
"//tensorflow/c:tf_status_helper",
243+
"//tensorflow/c/experimental/gradients:math_grad",
244+
"//tensorflow/c/experimental/ops:array_ops",
243245
"//tensorflow/cc/profiler",
244246
"//tensorflow/compiler/mlir/tensorflow/c:mlir_c_api_registration",
245247
"//tensorflow/core:lib",
@@ -308,6 +310,8 @@ cc_library(
308310
"//tensorflow/core:framework",
309311
"//tensorflow/core:lib",
310312
"//tensorflow/core:protos_all_cc",
313+
"//tensorflow/core/util:abstract_stack_trace",
314+
"@com_google_absl//absl/types:optional",
311315
"@com_google_absl//absl/types:span",
312316
],
313317
)
@@ -514,7 +518,6 @@ tf_cuda_cc_test(
514518
extra_copts = tfe_xla_copts(),
515519
tags = [
516520
"no_windows",
517-
"noasan", # leaks gRPC server instances
518521
],
519522
deps = [
520523
":c_api",
@@ -581,7 +584,6 @@ tf_cuda_cc_test(
581584
extra_copts = tfe_xla_copts(),
582585
tags = [
583586
"no_windows",
584-
"noasan", # leaks gRPC server instances
585587
],
586588
deps = [
587589
":c_api",

tensorflow/c/eager/c_api.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ limitations under the License.
9494
#include "tensorflow/core/profiler/lib/traceme.h"
9595
#include "tensorflow/core/public/version.h"
9696

97-
using tensorflow::int64;
9897
using tensorflow::string;
9998

10099
namespace {
@@ -968,7 +967,7 @@ int64_t TFE_TensorHandleNumElements(TFE_TensorHandle* h, TF_Status* status) {
968967
return -1;
969968
}
970969

971-
int64 num_elements = -1;
970+
tensorflow::int64 num_elements = -1;
972971
status->status = tensorflow::unwrap(h)->NumElements(&num_elements);
973972
return num_elements;
974973
}
@@ -980,7 +979,7 @@ int64_t TFE_TensorHandleDim(TFE_TensorHandle* h, int dim_index,
980979
return -1;
981980
}
982981

983-
int64 dim = -1;
982+
tensorflow::int64 dim = -1;
984983
status->status = tensorflow::unwrap(h)->Dim(dim_index, &dim);
985984
return dim;
986985
}

tensorflow/c/eager/c_api_distributed_test.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ void TestFunctionWithPackedInput(const bool remote) {
174174
const char task2_name[] = "/job:localhost/replica:0/task:2/device:CPU:0";
175175

176176
// Create one variable per task.
177-
TFE_TensorHandle* h0 = TestVariable(ctx, 1.0, task0_name);
178-
TFE_TensorHandle* h1 = TestVariable(ctx, 2.0, task1_name);
179-
TFE_TensorHandle* h2 = TestVariable(ctx, 3.0, task2_name);
177+
TFE_TensorHandle* h0 = TestVariable(ctx, 1.0, task1_name);
178+
TFE_TensorHandle* h1 = TestVariable(ctx, 2.0, task2_name);
179+
TFE_TensorHandle* h2 = TestVariable(ctx, 3.0, task0_name);
180180

181181
// Add a sync point in order to make sure that variables have been initialized
182182
// before the function execution starts.
@@ -185,6 +185,9 @@ void TestFunctionWithPackedInput(const bool remote) {
185185
VarIsInitialized(ctx, h2);
186186

187187
// Pack 3 variable handles into one TFE_TensorHandle.
188+
// When remote is false, function device is placed on task0. Handle types are
189+
// REMOTE, REMOTE, LOCAL on task0. When remote is true, function device is
190+
// placed on task1, Handle types are LOCAL, REMOTE, LOCAL on task1.
188191
int num_replicas = 3;
189192
std::vector<TFE_TensorHandle*> handles = {h0, h1, h2};
190193
TFE_TensorHandle* packed_handle =

tensorflow/c/eager/c_api_test_util.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ TFE_TensorHandle* TestMatrixTensorHandle(TFE_Context* ctx) {
8888
return th;
8989
}
9090

91+
TFE_TensorHandle* TestMatrixTensorHandleWithInput(TFE_Context* ctx,
92+
float data[], int64_t dims[],
93+
int num_dims) {
94+
TF_Status* status = TF_NewStatus();
95+
TF_Tensor* t =
96+
TFE_AllocateHostTensor(ctx, TF_FLOAT, &dims[0], num_dims, status);
97+
memcpy(TF_TensorData(t), &data[0], TF_TensorByteSize(t));
98+
TFE_TensorHandle* th = TFE_NewTensorHandleFromTensor(ctx, t, status);
99+
CHECK_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status);
100+
TF_DeleteTensor(t);
101+
TF_DeleteStatus(status);
102+
return th;
103+
}
104+
91105
TFE_TensorHandle* TestMatrixTensorHandle100x100(TFE_Context* ctx) {
92106
constexpr int64_t dims[] = {100, 100};
93107
constexpr int num_elements = dims[0] * dims[1];

tensorflow/c/eager/c_api_test_util.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ TFE_TensorHandle* DoubleTestMatrixTensorHandle(TFE_Context* ctx);
3434
// Return a tensor handle containing a 2x2 matrix of floats
3535
TFE_TensorHandle* TestMatrixTensorHandle(TFE_Context* ctx);
3636

37+
// Return a tensor handle containing 2D matrix containing given data and
38+
// dimensions
39+
TFE_TensorHandle* TestMatrixTensorHandleWithInput(TFE_Context* ctx,
40+
float data[], int64_t dims[],
41+
int num_dims);
42+
3743
// Return a tensor handle containing a 100x100 matrix of floats
3844
TFE_TensorHandle* TestMatrixTensorHandle100x100(TFE_Context* ctx);
3945

0 commit comments

Comments
 (0)