Skip to content

Commit 4a8e0dc

Browse files
authored
Merge pull request #19 from tensorflow/master
downstream merge
2 parents 3bb28df + 8db7e9e commit 4a8e0dc

File tree

1,739 files changed

+70000
-45399
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,739 files changed

+70000
-45399
lines changed

.bazelrc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#
2929
# Other build options:
3030
# short_logs: Only log errors during build, skip warnings.
31+
# verbose_logs: Show all compiler warnings during build.
3132
# monolithic: Build all TF C++ code into a single shared object.
3233
# dynamic_kernels: Try to link all kernels dynamically (experimental).
3334
# libc++: Link against libc++ instead of stdlibc++
@@ -172,6 +173,11 @@ build:using_cuda --define=using_cuda=true
172173
build:using_cuda --action_env TF_NEED_CUDA=1
173174
build:using_cuda --crosstool_top=@local_config_cuda//crosstool:toolchain
174175

176+
# Enable the mlir generated GPU kernels only for cuda builds.
177+
build --define=tensorflow_enable_mlir_generated_gpu_kernels=0
178+
# This is a more specific option, so it takes precedence over the line above for cuda builds.
179+
build:using_cuda --define=tensorflow_enable_mlir_generated_gpu_kernels=1
180+
175181
# This config refers to building CUDA op kernels with nvcc.
176182
build:cuda --config=using_cuda
177183
build:cuda --define=using_cuda_nvcc=true
@@ -331,6 +337,8 @@ build:windows --distinct_host_configuration=false
331337

332338
# Suppress all warning messages.
333339
build:short_logs --output_filter=DONT_MATCH_ANYTHING
340+
build:verbose_logs --output_filter=
341+
build --config=short_logs
334342

335343
# Instruction set optimizations
336344
# TODO(gunan): Create a feature in toolchains for avx/avx2 to
@@ -547,6 +555,7 @@ try-import %workspace%/.bazelrc.user
547555
# Here are bazelrc configs for release builds
548556
build:release_common --config=opt
549557
build:release_common --config=v2
558+
build:release_common --distinct_host_configuration=false
550559
build:release_common --action_env TF_CONFIGURE_IOS="0"
551560

552561
build:release_cpu_linux --config=release_common
@@ -564,9 +573,10 @@ build:release_gpu_common --config=tensorrt
564573
build:release_gpu_common --action_env CUDA_TOOLKIT_PATH="/usr/local/cuda-10.1"
565574
build:release_gpu_common --action_env=TF_CUDA_VERSION="10"
566575
build:release_gpu_common --action_env=TF_CUDNN_VERSION="7"
576+
build:release_gpu_common --action_env=TF_NEED_TENSORRT="1"
567577
build:release_gpu_common --action_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_35,sm_37,sm_52,sm_60,sm_61,compute_70"
568578
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"
579+
build:release_gpu_common --action_env=LD_LIBRARY_PATH="/usr/local/cuda:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64:/usr/local/tensorrt/lib"
570580
build:release_gpu_common --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-5"
571581

572582

RELEASE.md

Lines changed: 329 additions & 45 deletions
Large diffs are not rendered by default.

tensorflow/c/c_api.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ TF_CAPI_EXPORT extern void TF_DeleteBuffer(TF_Buffer*);
125125

126126
TF_CAPI_EXPORT extern TF_Buffer TF_GetBuffer(TF_Buffer* buffer);
127127

128+
// --------------------------------------------------------------------------
129+
// Used to return strings across the C API. The caller does not take ownership
130+
// of the underlying data pointer and is not responsible for freeing it.
131+
typedef struct TF_StringView {
132+
const char* data;
133+
size_t len;
134+
} TF_StringView;
135+
128136
// --------------------------------------------------------------------------
129137
// TF_SessionOptions holds options that can be passed during session creation.
130138
typedef struct TF_SessionOptions TF_SessionOptions;

tensorflow/c/eager/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ cc_library(
262262
],
263263
deps = [
264264
"//tensorflow/core:protos_all_cc",
265+
"//tensorflow/core/platform:refcount",
265266
],
266267
)
267268

@@ -549,6 +550,7 @@ tf_cuda_cc_test(
549550
args = ["--heap_check=local"],
550551
extra_copts = tfe_xla_copts(),
551552
tags = [
553+
"no_oss", # b/162361408
552554
"no_windows",
553555
"noasan", # leaks gRPC server instances
554556
],

tensorflow/c/eager/abstract_tensor_handle.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ limitations under the License.
1818
#include <memory>
1919

2020
#include "tensorflow/core/framework/types.pb.h"
21+
#include "tensorflow/core/platform/refcount.h"
2122
namespace tensorflow {
2223

2324
// Abstract interface to a Tensor handle in either tracing or immediate
2425
// execution mode.
25-
class AbstractTensorHandle {
26+
class AbstractTensorHandle : public core::RefCounted {
2627
protected:
2728
enum AbstractTensorHandleKind { kGraph, kMlir, kEager, kTfrt };
2829
explicit AbstractTensorHandle(AbstractTensorHandleKind kind) : kind_(kind) {}
@@ -34,14 +35,6 @@ class AbstractTensorHandle {
3435

3536
AbstractTensorHandleKind getKind() const { return kind_; }
3637

37-
// Release any underlying resources, including the interface object.
38-
//
39-
// WARNING: The destructor of this class is marked as protected to disallow
40-
// clients from directly destroying this object since it may manage it's own
41-
// lifetime through ref counting. Thus this must be allocated on the heap and
42-
// clients MUST call Release() in order to destroy an instance of this class.
43-
virtual void Release() = 0;
44-
4538
private:
4639
const AbstractTensorHandleKind kind_;
4740
};
@@ -50,7 +43,7 @@ namespace internal {
5043
struct AbstractTensorHandleDeleter {
5144
void operator()(AbstractTensorHandle* p) const {
5245
if (p != nullptr) {
53-
p->Release();
46+
p->Unref();
5447
}
5548
}
5649
};

tensorflow/c/eager/c_api.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,11 +1072,13 @@ TFE_TensorHandle* TFE_NewTensorHandleFromDeviceMemory(
10721072
status->status = context->FindDeviceFromName(device_name, &device);
10731073
tensorflow::CustomDevice* custom_device = nullptr;
10741074
if (!status->status.ok()) {
1075-
status->status =
1076-
context->FindCustomDeviceFromName(device_name, &custom_device);
1077-
if (!status->status.ok()) {
1075+
if (!context->FindCustomDeviceFromName(device_name, &custom_device)) {
10781076
deallocator(data, len, deallocator_arg);
1077+
status->status =
1078+
tensorflow::errors::InvalidArgument(device_name, " unknown device.");
10791079
return nullptr;
1080+
} else {
1081+
status->status = tensorflow::Status::OK();
10801082
}
10811083
}
10821084
std::vector<tensorflow::int64> dimvec(num_dims);

tensorflow/c/eager/c_api_debug.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ limitations under the License.
2626
#include "tensorflow/compiler/jit/xla_device.h"
2727
#endif // TENSORFLOW_EAGER_USE_XLA
2828

29-
using tensorflow::int64;
3029
using tensorflow::string;
3130

3231
namespace {
3332

34-
std::vector<int64> TensorShapeAsVector(const tensorflow::TensorHandle& handle,
35-
tensorflow::Status* status) {
36-
std::vector<int64> shape;
33+
std::vector<tensorflow::int64> TensorShapeAsVector(
34+
const tensorflow::TensorHandle& handle, tensorflow::Status* status) {
35+
std::vector<tensorflow::int64> shape;
3736
int rank = -1;
3837
*status = handle.NumDims(&rank);
3938
if (!status->ok()) {
@@ -79,7 +78,7 @@ TF_CAPI_EXPORT extern TFE_TensorDebugInfo* TFE_TensorHandleTensorDebugInfo(
7978
return nullptr;
8079
}
8180
if (VLOG_IS_ON(3)) {
82-
std::vector<int64> shape_to_log =
81+
std::vector<tensorflow::int64> shape_to_log =
8382
TensorShapeAsVector(*handle, &status->status);
8483
if (!status->status.ok()) {
8584
// Ignore the status here as we are simply logging.
@@ -128,14 +127,14 @@ TF_CAPI_EXPORT extern TFE_TensorDebugInfo* TFE_TensorHandleTensorDebugInfo(
128127
}
129128

130129
int rank = padded_shape.dimensions_size();
131-
std::vector<int64> dev_dims;
130+
std::vector<tensorflow::int64> dev_dims;
132131
dev_dims.reserve(rank);
133132
if (rank == 1) {
134133
// Rank 1 tensors might not have padded_shape.layout.minor_to_major set,
135134
dev_dims.push_back(padded_shape.dimensions(0));
136135
} else {
137136
for (int i = rank - 1; i >= 0; --i) {
138-
int64 dim_index = padded_shape.layout().minor_to_major(i);
137+
tensorflow::int64 dim_index = padded_shape.layout().minor_to_major(i);
139138
dev_dims.push_back(padded_shape.dimensions(dim_index));
140139
}
141140
}
@@ -146,7 +145,8 @@ TF_CAPI_EXPORT extern TFE_TensorDebugInfo* TFE_TensorHandleTensorDebugInfo(
146145

147146
// If the tensor is not an XLA tensor, the device shape is
148147
// the same as regular tensor shape.
149-
std::vector<int64> dev_dims = TensorShapeAsVector(*handle, &status->status);
148+
std::vector<tensorflow::int64> dev_dims =
149+
TensorShapeAsVector(*handle, &status->status);
150150
if (!status->status.ok()) {
151151
return nullptr;
152152
}

tensorflow/c/eager/c_api_unified_experimental.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ TF_AbstractOp* TF_NewAbstractOp(TF_ExecutionContext* c) {
147147

148148
void TF_DeleteAbstractOp(TF_AbstractOp* op) { unwrap(op)->Release(); }
149149

150-
void TF_DeleteAbstractTensor(TF_AbstractTensor* t) { unwrap(t)->Release(); }
150+
void TF_DeleteAbstractTensor(TF_AbstractTensor* t) { unwrap(t)->Unref(); }
151151

152152
TF_OutputList* TF_NewOutputList() { return wrap(new OutputList); }
153153
void TF_DeleteOutputList(TF_OutputList* o) { delete unwrap(o); }

tensorflow/c/eager/c_api_unified_experimental_graph.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class GraphTensor : public TracingTensorHandle {
4949
public:
5050
explicit GraphTensor(TF_Output output)
5151
: TracingTensorHandle(kGraph), output_(output) {}
52-
void Release() override { delete this; }
5352

5453
tensorflow::DataType DataType() const override {
5554
return static_cast<tensorflow::DataType>(TF_OperationOutputType(output_));

tensorflow/c/eager/gradients.cc

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,14 @@ int64 ToId(AbstractTensorHandle* t) {
5151

5252
TapeTensor::TapeTensor(AbstractTensorHandle* handle, AbstractContext* ctx)
5353
: handle_(handle), ctx_(ctx) {
54-
// TODO(b/160888114): Make AbstractTensorHandle RefCounted. Right now we rely
55-
// on the client to keep this tensor live for the duration of the gradient
56-
// computation.
57-
// handle_->Ref();
54+
handle_->Ref();
5855
}
5956
TapeTensor::TapeTensor(const TapeTensor& other) {
6057
handle_ = other.handle_;
61-
// TODO(b/160888114): Make AbstractTensorHandle RefCounted. Right now we rely
62-
// on the client to keep this tensor live for the duration of the gradient
63-
// computation.
64-
// handle_->Ref();
58+
handle_->Ref();
6559
ctx_ = other.ctx_;
6660
}
67-
TapeTensor::~TapeTensor() {
68-
// TODO(b/160888114): Make AbstractTensorHandle RefCounted. Right now we rely
69-
// on the client to keep this tensor live for the duration of the gradient
70-
// computation.
71-
// handle_->Unref();
72-
}
61+
TapeTensor::~TapeTensor() { handle_->Unref(); }
7362

7463
tensorflow::int64 TapeTensor::GetID() const { return ToId(handle_); }
7564

@@ -192,7 +181,7 @@ TapeTensor TapeVSpace::TapeTensorFromGradient(AbstractTensorHandle* g) const {
192181
void TapeVSpace::MarkAsResult(AbstractTensorHandle* gradient) const {}
193182

194183
void TapeVSpace::DeleteGradient(AbstractTensorHandle* gradient) const {
195-
gradient->Release();
184+
gradient->Unref();
196185
}
197186

198187
// Helper functions which delegate to `AbstractOperation`, update

0 commit comments

Comments
 (0)