diff options
author | Christopher Olston <olston@google.com> | 2017-03-10 07:21:40 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-03-10 07:50:12 -0800 |
commit | 3af39a00d151bd55b69c8b045a6e67284c22c9f5 (patch) | |
tree | 806ae99e8c1bf84996f79d1f21522f48308eae65 | |
parent | 411f26595861ca28809e3178f79fadcf378cabd6 (diff) |
Rename the new TryConcat()/TrySplit() to Concat()/Split() and mark the existing Concat()/Split() as deprecated.
This is the first change in a sequence that will remove the crashy Concat()/Split().
Change: 149755537
-rw-r--r-- | tensorflow/core/framework/tensor_util.cc | 10 | ||||
-rw-r--r-- | tensorflow/core/framework/tensor_util.h | 20 | ||||
-rw-r--r-- | tensorflow/core/framework/tensor_util_test.cc | 4 |
3 files changed, 17 insertions, 17 deletions
diff --git a/tensorflow/core/framework/tensor_util.cc b/tensorflow/core/framework/tensor_util.cc index 9628d002dd..96886853c1 100644 --- a/tensorflow/core/framework/tensor_util.cc +++ b/tensorflow/core/framework/tensor_util.cc @@ -44,11 +44,11 @@ Tensor DeepCopy(const Tensor& other) { Tensor Concat(const gtl::ArraySlice<Tensor>& tensors) { Tensor result; - TF_CHECK_OK(TryConcat(tensors, &result)); + TF_CHECK_OK(Concat(tensors, &result)); return result; } -Status TryConcat(const gtl::ArraySlice<Tensor>& tensors, Tensor* result) { +Status Concat(const gtl::ArraySlice<Tensor>& tensors, Tensor* result) { if (tensors.empty()) { return errors::InvalidArgument("Cannot concatenate zero tensors"); } @@ -112,12 +112,12 @@ Status TryConcat(const gtl::ArraySlice<Tensor>& tensors, Tensor* result) { std::vector<Tensor> Split(const Tensor& tensor, const gtl::ArraySlice<int64>& sizes) { std::vector<Tensor> result; - TF_CHECK_OK(TrySplit(tensor, sizes, &result)); + TF_CHECK_OK(Split(tensor, sizes, &result)); return result; } -Status TrySplit(const Tensor& tensor, const gtl::ArraySlice<int64>& sizes, - std::vector<Tensor>* result) { +Status Split(const Tensor& tensor, const gtl::ArraySlice<int64>& sizes, + std::vector<Tensor>* result) { if (tensor.dims() == 0) { return errors::InvalidArgument("Cannot split a zero-dimensional tensor"); } diff --git a/tensorflow/core/framework/tensor_util.h b/tensorflow/core/framework/tensor_util.h index 5a7dbb4719..d05fcf538e 100644 --- a/tensorflow/core/framework/tensor_util.h +++ b/tensorflow/core/framework/tensor_util.h @@ -38,12 +38,12 @@ Tensor DeepCopy(const Tensor& other); // REQUIRES: Each member of 'tensors' must point to data stored in CPU memory. // REQUIRES: Each member of 'tensors' must be a Tensor of a copy-able type if it // is not appropriately memory-aligned. -Tensor Concat(const gtl::ArraySlice<Tensor>& tensors); +Status Concat(const gtl::ArraySlice<Tensor>& tensors, + Tensor* result) TF_MUST_USE_RESULT; -// Version of Concat() that returns an error Status instead of crashing, upon -// encountering an error. -Status TryConcat(const gtl::ArraySlice<Tensor>& tensors, - Tensor* result) TF_MUST_USE_RESULT; +// Version of Concat() that crashes upon hitting an error. +// DEPRECATED. DO NOT USE. +Tensor Concat(const gtl::ArraySlice<Tensor>& tensors); // Splits 'tensor' into 'sizes.size()' individual tensors, along the 0th // dimension. The ith output tensor has 0th-dimension size 'sizes[i]'. @@ -55,14 +55,14 @@ Status TryConcat(const gtl::ArraySlice<Tensor>& tensors, // appropriately memory-aligned. // // Split() and Concat() are inverse operations. +Status Split(const Tensor& tensor, const gtl::ArraySlice<int64>& sizes, + std::vector<Tensor>* result) TF_MUST_USE_RESULT; + +// Version of Split() that crashes upon hitting an error. +// DEPRECATED. DO NOT USE. std::vector<Tensor> Split(const Tensor& tensor, const gtl::ArraySlice<int64>& sizes); -// Version of Split() that returns an error Status instead of crashing, upon -// encountering an error. -Status TrySplit(const Tensor& tensor, const gtl::ArraySlice<int64>& sizes, - std::vector<Tensor>* result) TF_MUST_USE_RESULT; - } // namespace tensor } // namespace tensorflow diff --git a/tensorflow/core/framework/tensor_util_test.cc b/tensorflow/core/framework/tensor_util_test.cc index 51b4c64eda..ca16c03bff 100644 --- a/tensorflow/core/framework/tensor_util_test.cc +++ b/tensorflow/core/framework/tensor_util_test.cc @@ -164,7 +164,7 @@ TEST(TensorUtil, Concat) { } Tensor concated; - TF_ASSERT_OK(tensor::TryConcat(to_concat, &concated)); + TF_ASSERT_OK(tensor::Concat(to_concat, &concated)); ASSERT_EQ(TensorShape({total_size, 2}), concated.shape()); for (int i = 0; i < total_size; ++i) { for (int j = 0; j < 2; ++j) { @@ -183,7 +183,7 @@ TEST(TensorUtil, Split) { std::vector<int64> sizes = {1, 4, 5}; std::vector<Tensor> splits; - TF_ASSERT_OK(tensor::TrySplit(to_split, sizes, &splits)); + TF_ASSERT_OK(tensor::Split(to_split, sizes, &splits)); ASSERT_EQ(sizes.size(), splits.size()); int offset = 0; |