Skip to content

Commit

Permalink
Merge branch 'master' into tflite
Browse files Browse the repository at this point in the history
  • Loading branch information
sby authored Nov 6, 2018
2 parents 1dd6c36 + e436475 commit 31c345a
Show file tree
Hide file tree
Showing 1,995 changed files with 25,638 additions and 14,023 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ Pods
Podfile.lock
*.pbxproj
*.xcworkspacedata
/tensorflow/contrib/lite/tools/make/downloads/**
/tensorflow/contrib/lite/gen/**
/tensorflow/contrib/lite/examples/ios/simple/data/*.txt
/tensorflow/contrib/lite/examples/ios/simple/data/*.tflite
/tensorflow/lite/tools/make/downloads/**
/tensorflow/lite/gen/**
/tensorflow/lite/examples/ios/simple/data/*.txt
/tensorflow/lite/examples/ios/simple/data/*.tflite
xcuserdata/**
/api_init_files_list.txt
/estimator_api_init_files_list.txt
Expand Down
2 changes: 2 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ exports_files(
[
"LICENSE",
"ACKNOWLEDGEMENTS",
"configure",
"configure.py",
],
)
8 changes: 4 additions & 4 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ Ag Ramesh, Alex Wiltschko, Alexander Pantyukhin, Amogh Mannekote, An Jiaoyang, A
* Update `tf.keras` to the Keras 2.1.6 API.
* Added [`tf.keras.layers.CuDNNGRU`](https://www.tensorflow.org/versions/r1.9/api_docs/python/tf/keras/layers/CuDNNGRU) and [`tf.keras.layers.CuDNNLSTM`](https://www.tensorflow.org/versions/r1.9/api_docs/python/tf/keras/layers/CuDNNLSTM) layers. [Try it](https://colab.sandbox.google.com/github/tensorflow/tensorflow/blob/master/tensorflow/contrib/eager/python/examples/nmt_with_attention/nmt_with_attention.ipynb?linkId=53292082).
* Adding support of core [feature columns](https://www.tensorflow.org/get_started/feature_columns) and [losses](https://www.tensorflow.org/api_docs/python/tf/losses) to [gradient boosted trees estimators](https://github.com/tensorflow/models/tree/master/official/boosted_trees).
* The [python interface](https://www.tensorflow.org/versions/r1.9/api_docs/python/tf/contrib/lite)
for the [TFLite Optimizing Converter](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/toco/README.md)
* The [python interface](https://www.tensorflow.org/versions/r1.9/api_docs/python/tf/lite)
for the [TFLite Optimizing Converter](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/toco/README.md)
has been expanded, and the command line interface (AKA: `toco`, `tflite_convert`) is once again
included in the standard `pip` installation.
* Improved data-loading and text processing with:
Expand Down Expand Up @@ -562,7 +562,7 @@ Yoni Tsafir, yordun, Yuan (Terry) Tang, Yuxin Wu, zhengdi, Zhengsheng Wei, 田
## Major Features And Improvements
* [Eager execution](https://github.com/tensorflow/tensorflow/tree/r1.5/tensorflow/contrib/eager)
preview version is now available.
* [TensorFlow Lite](https://github.com/tensorflow/tensorflow/tree/r1.5/tensorflow/contrib/lite)
* [TensorFlow Lite](https://github.com/tensorflow/tensorflow/tree/r1.5/tensorflow/lite)
dev preview is now available.
* CUDA 9.0 and cuDNN 7 support.
* Accelerated Linear Algebra (XLA):
Expand Down Expand Up @@ -909,7 +909,7 @@ See also [TensorBoard 0.1.4](https://github.com/tensorflow/tensorboard/releases/
* Adds tf.contrib.nn.rank_sampled_softmax_loss, a sampled-softmax variant that can improve rank loss.
* `tf.contrib.metrics`.{streaming_covariance,streaming_pearson_correlation} modified to return nan when they have seen less or equal to 1 unit of weight.
* Adds time series models to contrib. See contrib/timeseries/README.md for details.
* Adds FULLY_CONNECTED Op to tensorflow/contrib/lite/schema.fbs
* Adds FULLY_CONNECTED Op to tensorflow/lite/schema.fbs

## Known Issues
* Tensorflow_gpu compilation fails with Bazel 0.5.3.
Expand Down
25 changes: 19 additions & 6 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1418,11 +1418,16 @@ def set_mpi_home(environ_cp):
def valid_mpi_path(mpi_home):
exists = (
os.path.exists(os.path.join(mpi_home, 'include')) and
os.path.exists(os.path.join(mpi_home, 'lib')))
(os.path.exists(os.path.join(mpi_home, 'lib')) or
os.path.exists(os.path.join(mpi_home, 'lib64')) or
os.path.exists(os.path.join(mpi_home, 'lib32'))))
if not exists:
print('Invalid path to the MPI Toolkit. %s or %s cannot be found' %
(os.path.join(mpi_home, 'include'),
os.path.exists(os.path.join(mpi_home, 'lib'))))
print(
'Invalid path to the MPI Toolkit. %s or %s or %s or %s cannot be found'
% (os.path.join(mpi_home, 'include'),
os.path.exists(os.path.join(mpi_home, 'lib')),
os.path.exists(os.path.join(mpi_home, 'lib64')),
os.path.exists(os.path.join(mpi_home, 'lib32'))))
return exists

_ = prompt_loop_or_load_from_env(
Expand Down Expand Up @@ -1463,8 +1468,17 @@ def set_other_mpi_vars(environ_cp):
if os.path.exists(os.path.join(mpi_home, 'lib/libmpi.so')):
symlink_force(
os.path.join(mpi_home, 'lib/libmpi.so'), 'third_party/mpi/libmpi.so')
elif os.path.exists(os.path.join(mpi_home, 'lib64/libmpi.so')):
symlink_force(
os.path.join(mpi_home, 'lib64/libmpi.so'), 'third_party/mpi/libmpi.so')
elif os.path.exists(os.path.join(mpi_home, 'lib32/libmpi.so')):
symlink_force(
os.path.join(mpi_home, 'lib32/libmpi.so'), 'third_party/mpi/libmpi.so')

else:
raise ValueError('Cannot find the MPI library file in %s/lib' % mpi_home)
raise ValueError(
'Cannot find the MPI library file in %s/lib or %s/lib64 or %s/lib32' %
mpi_home, mpi_home, mpi_home)


def set_system_libs_flag(environ_cp):
Expand Down Expand Up @@ -1681,4 +1695,3 @@ def main():

if __name__ == '__main__':
main()

6 changes: 6 additions & 0 deletions tensorflow/api_template.__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@
# does not have 'python', 'core' directories. Then, it will be copied
# to tensorflow/ which does have these two directories.
pass
# Similarly for compiler. Do it separately to make sure we do this even if the
# others don't exist.
try:
del compiler
except NameError:
pass
# pylint: enable=undefined-variable
6 changes: 6 additions & 0 deletions tensorflow/api_template_v1.__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,10 @@
# does not have 'python', 'core' directories. Then, it will be copied
# to tensorflow/ which does have these two directories.
pass
# Similarly for compiler. Do it separately to make sure we do this even if the
# others don't exist.
try:
del compiler
except NameError:
pass
# pylint: enable=undefined-variable
5 changes: 3 additions & 2 deletions tensorflow/c/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ tf_cuda_cc_test(
size = "small",
srcs = ["c_api_test.cc"],
data = [
":test_op1.so",
"//tensorflow/cc/saved_model:saved_model_half_plus_two",
],
kernels = [":test_op_kernel"],
Expand Down Expand Up @@ -283,8 +284,8 @@ tf_cc_test(
)

tf_custom_op_library(
name = "test_op.so",
srcs = ["test_op.cc"],
name = "test_op1.so",
srcs = ["test_op1.cc"],
)

tf_kernel_library(
Expand Down
25 changes: 25 additions & 0 deletions tensorflow/c/c_api_experimental.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8775,3 +8775,28 @@ void TF_AttrBuilderCheckCanRunOnDevice(TF_AttrBuilder* builder,
tensorflow::DeviceType(device_type), builder->BuildNodeDef(),
/* def = */ nullptr, /* kernel_class_name = */ nullptr);
}

const char* TF_GetNumberAttrForOpListInput(const char* op_name, int input_index,
TF_Status* status) {
const tensorflow::OpDef* op_def = nullptr;
status->status =
tensorflow::OpRegistry::Global()->LookUpOpDef(op_name, &op_def);
if (!status->status.ok()) return nullptr;

if (input_index >= op_def->input_arg_size() || input_index < 0) {
status->status = tensorflow::errors::InvalidArgument(
input_index, " out of range for ", op_name);
return nullptr;
}

const tensorflow::OpDef_ArgDef& input_arg = op_def->input_arg()[input_index];

if (input_arg.number_attr().empty()) {
status->status = tensorflow::errors::NotFound(
op_name, " does not have number_attr() defined.");
return nullptr;
}

// The returned string is owned by OpRegistry, so liveness is not a concern.
return input_arg.number_attr().c_str();
}
7 changes: 7 additions & 0 deletions tensorflow/c/c_api_experimental.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ TF_CAPI_EXPORT extern void TF_AttrBuilderSetTypeList(TF_AttrBuilder* builder,
TF_CAPI_EXPORT extern void TF_AttrBuilderCheckCanRunOnDevice(
TF_AttrBuilder* builder, const char* device_type, TF_Status* status);

// For argument number input_index, fetch the corresponding number_attr that
// needs to be updated with the argument length of the input list.
// Returns nullptr if there is any problem like op_name is not found, or the
// argument does not support this attribute type.
TF_CAPI_EXPORT extern const char* TF_GetNumberAttrForOpListInput(
const char* op_name, int input_index, TF_Status* status);

#ifdef __cplusplus
} /* end extern "C" */
#endif
Expand Down
58 changes: 21 additions & 37 deletions tensorflow/c/c_api_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,26 @@ TEST(CAPI, LibraryLoadFunctions) {
// tf_cuda_cc_test() bazel rule and remove the next line.
if (!GPUDeviceName().empty()) return;

// Load the library.
TF_Status* status = TF_NewStatus();
TF_Library* lib =
TF_LoadLibrary("tensorflow/c/test_op.so", status);
TF_Code code = TF_GetCode(status);
string status_msg(TF_Message(status));
TF_DeleteStatus(status);
ASSERT_EQ(TF_OK, code) << status_msg;
#if !defined(TENSORFLOW_NO_SHARED_OBJECTS)
{
// Load the library.
TF_Status* status = TF_NewStatus();
TF_Library* lib =
TF_LoadLibrary("tensorflow/c/test_op1.so", status);
TF_Code code = TF_GetCode(status);
string status_msg(TF_Message(status));
TF_DeleteStatus(status);
ASSERT_EQ(TF_OK, code) << status_msg;

// Test op list.
TF_Buffer op_list_buf = TF_GetOpList(lib);
tensorflow::OpList op_list;
EXPECT_TRUE(op_list.ParseFromArray(op_list_buf.data, op_list_buf.length));
ASSERT_EQ(op_list.op_size(), 1);
EXPECT_EQ("TestCApi1", op_list.op(0).name());
TF_DeleteLibraryHandle(lib);
}
#endif // !defined(TENSORFLOW_NO_SHARED_OBJECTS)
{
TF_Buffer* op_list_buffer = TF_GetAllOpList();
tensorflow::OpList op_list;
Expand All @@ -210,19 +221,6 @@ TEST(CAPI, LibraryLoadFunctions) {
EXPECT_TRUE(found);
TF_DeleteBuffer(op_list_buffer);
}

#if !defined(TENSORFLOW_NO_SHARED_OBJECTS)
{
// Test op list.
TF_Buffer op_list_buf = TF_GetOpList(lib);
tensorflow::OpList op_list;
EXPECT_TRUE(op_list.ParseFromArray(op_list_buf.data, op_list_buf.length));
ASSERT_EQ(op_list.op_size(), 1);
EXPECT_EQ("TestCApi", op_list.op(0).name());
}
#endif // !defined(TENSORFLOW_NO_SHARED_OBJECTS)

TF_DeleteLibraryHandle(lib);
}

void TestEncodeDecode(int line, const std::vector<string>& data) {
Expand Down Expand Up @@ -2349,14 +2347,8 @@ TEST(TestApiDef, TestCreateApiDef) {
// tf_cuda_cc_test() bazel rule and remove the next line.
if (!GPUDeviceName().empty()) return;

TF_Status* status = TF_NewStatus();
TF_Library* lib =
TF_LoadLibrary("tensorflow/c/test_op.so", status);
EXPECT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status);
TF_DeleteStatus(status);

TF_Buffer* op_list_buf = TF_GetAllOpList();
status = TF_NewStatus();
TF_Status* status = TF_NewStatus();
auto* api_def_map = TF_NewApiDefMap(op_list_buf, status);
EXPECT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status);
TF_DeleteStatus(status);
Expand All @@ -2376,22 +2368,15 @@ TEST(TestApiDef, TestCreateApiDef) {
TF_DeleteBuffer(api_def_buf);
TF_DeleteApiDefMap(api_def_map);
TF_DeleteBuffer(op_list_buf);
TF_DeleteLibraryHandle(lib);
}

TEST(TestApiDef, TestCreateApiDefWithOverwrites) {
// TODO(b/73318067): Fix linking for the GPU test generated by the
// tf_cuda_cc_test() bazel rule and remove the next line.
if (!GPUDeviceName().empty()) return;

TF_Status* status = TF_NewStatus();
TF_Library* lib =
TF_LoadLibrary("tensorflow/c/test_op.so", status);
EXPECT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status);
TF_DeleteStatus(status);

TF_Buffer* op_list_buf = TF_GetAllOpList();
status = TF_NewStatus();
TF_Status* status = TF_NewStatus();
auto* api_def_map = TF_NewApiDefMap(op_list_buf, status);
EXPECT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status);
TF_DeleteStatus(status);
Expand Down Expand Up @@ -2422,7 +2407,6 @@ TEST(TestApiDef, TestCreateApiDefWithOverwrites) {
TF_DeleteBuffer(api_def_buf);
TF_DeleteApiDefMap(api_def_map);
TF_DeleteBuffer(op_list_buf);
TF_DeleteLibraryHandle(lib);
}

class DummyKernel : public tensorflow::OpKernel {
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/c/eager/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ tf_cuda_library(
name = "c_api_internal",
hdrs = ["c_api_internal.h"],
visibility = [
"//learning/deepmind/courier:__pkg__",
"//learning/deepmind/courier:__subpackages__",
"//tensorflow:internal",
],
deps = [
Expand Down
4 changes: 0 additions & 4 deletions tensorflow/c/eager/c_api_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ struct TFE_TensorHandle {
tensorflow::Device* op_device)
: handle(new tensorflow::TensorHandle(t, d, op_device, nullptr)) {}

TFE_TensorHandle(tensorflow::uint64 node_id, tensorflow::DataType dtype,
tensorflow::EagerContext* ctx)
: handle(new tensorflow::TensorHandle(node_id, dtype, ctx)) {}

TFE_TensorHandle(tensorflow::TensorHandle* handle) : handle(handle) {}

tensorflow::TensorHandle* handle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -13,17 +13,11 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#ifndef TENSORFLOW_STREAM_EXECUTOR_LIB_STRINGPIECE_H_
#define TENSORFLOW_STREAM_EXECUTOR_LIB_STRINGPIECE_H_
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/op_kernel.h"

#include "absl/strings/string_view.h"
namespace tensorflow {

namespace stream_executor {
namespace port {
REGISTER_OP("TestCApi1").Doc(R"doc(Used to test C API)doc");

using StringPiece = absl::string_view;

} // namespace port
} // namespace stream_executor

#endif // TENSORFLOW_STREAM_EXECUTOR_LIB_STRINGPIECE_H_
} // namespace tensorflow
3 changes: 3 additions & 0 deletions tensorflow/cc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ cc_library_with_android_deps(
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
"@com_google_absl//absl/strings",
],
)

Expand Down Expand Up @@ -516,6 +517,8 @@ tf_gen_op_wrappers_cc(
":array_ops",
":const_op",
":math_ops",
"//tensorflow/cc:ops",
"//tensorflow/cc:scope",
],
)

Expand Down
4 changes: 4 additions & 0 deletions tensorflow/compiler/jit/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,13 @@ cc_library(
"//tensorflow/core/kernels:resource_variable_ops",
"//tensorflow/core/kernels:sendrecv_ops",
"//tensorflow/core/kernels:shape_ops",
"//tensorflow/core/kernels:stack",
"//tensorflow/core/kernels:variable_ops",
"//tensorflow/core/kernels/data:generator_dataset_op",
"//tensorflow/core/kernels/data:iterator_ops",
"//tensorflow/core/kernels/data:prefetch_dataset_op",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/synchronization",
],
)

Expand Down Expand Up @@ -240,6 +242,7 @@ cc_library(
"//tensorflow/core:protos_all_cc",
"//tensorflow/core/kernels:variable_ops",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/memory",
],
)
Expand Down Expand Up @@ -499,6 +502,7 @@ cc_library(
"@com_google_absl//absl/container:inlined_vector",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
],
)

Expand Down
3 changes: 2 additions & 1 deletion tensorflow/compiler/jit/build_xla_ops_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ Status NodeRequiresCompilation(Node* n, bool* result) {
return errors::Internal("Could not find compilation device ",
device_type.type());
}
*result = registration->requires_compilation;
*result = registration->autoclustering_policy ==
XlaOpRegistry::AutoclusteringPolicy::kAlways;
return Status::OK();
}

Expand Down
1 change: 0 additions & 1 deletion tensorflow/compiler/jit/deadness_analysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ Predicate* PredicateFactory::MakeAndOrImpl(
op->GetOperands().begin(),
op->GetOperands().end());
} else {
std::vector<Predicate*> sub_ops_intersection;
common_inner_operands.clear();
absl::c_copy_if(op->GetOperands(),
std::back_inserter(common_inner_operands),
Expand Down
Loading

0 comments on commit 31c345a

Please sign in to comment.