diff options
author | Justin Lebar <jlebar@google.com> | 2018-04-22 12:18:05 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-04-22 12:21:03 -0700 |
commit | ea0c8a7ed84eb5cdf8ca6a856f9bd05a95597739 (patch) | |
tree | dbfe401e21e4c0eaae70dc5333f823d02e88b67b /tensorflow/stream_executor/lib | |
parent | d481f07549470b4a03b41f9bb588d7f7ddc85082 (diff) |
[StreamExecutor] [XLA] Delete copy/pasted implementations of MakeUnique.
StreamExecutor and XLA had a copy/pasted implementation of MakeUnique,
in namespaces stream_executor::port and xla.
This change removes those implementations and instead pulls
tensorflow::MakeUnique into namespace stream_executor and namespace xla.
We pull it into stream_executor rather than stream_executor::port for
consistency with TF and XLA, which both pull MakeUnique into their own
namespace.
This change also moves MakeUnique and WrapUnique out of namespace
tensorflow::scam_ops::internal -- scam can simply use
tensorflow::{Make,Wrap}Unique. I suspect the reason it was this way
originally was that TF didn't have Make/WrapUnique.
PiperOrigin-RevId: 193849330
Diffstat (limited to 'tensorflow/stream_executor/lib')
-rw-r--r-- | tensorflow/stream_executor/lib/ptr_util.h | 42 |
1 files changed, 3 insertions, 39 deletions
diff --git a/tensorflow/stream_executor/lib/ptr_util.h b/tensorflow/stream_executor/lib/ptr_util.h index 3f89794688..8f9f420fec 100644 --- a/tensorflow/stream_executor/lib/ptr_util.h +++ b/tensorflow/stream_executor/lib/ptr_util.h @@ -17,47 +17,11 @@ limitations under the License. #define TENSORFLOW_STREAM_EXECUTOR_LIB_PTR_UTIL_H_ #include <memory> +#include "tensorflow/core/util/ptr_util.h" namespace stream_executor { -namespace port { - -// Trait to select overloads and return types for MakeUnique. -template <typename T> -struct MakeUniqueResult { - using scalar = std::unique_ptr<T>; -}; -template <typename T> -struct MakeUniqueResult<T[]> { - using array = std::unique_ptr<T[]>; -}; -template <typename T, size_t N> -struct MakeUniqueResult<T[N]> { - using invalid = void; -}; - -// MakeUnique<T>(...) is an early implementation of C++14 std::make_unique. -// It is designed to be 100% compatible with std::make_unique so that the -// eventual switchover will be a simple renaming operation. -template <typename T, typename... Args> -typename MakeUniqueResult<T>::scalar MakeUnique(Args&&... args) { // NOLINT - return std::unique_ptr<T>( - new T(std::forward<Args>(args)...)); // NOLINT(build/c++11) -} - -// Overload for array of unknown bound. -// The allocation of arrays needs to use the array form of new, -// and cannot take element constructor arguments. -template <typename T> -typename MakeUniqueResult<T>::array MakeUnique(size_t n) { - return std::unique_ptr<T>(new typename std::remove_extent<T>::type[n]()); -} - -// Reject arrays of known bound. -template <typename T, typename... Args> -typename MakeUniqueResult<T>::invalid MakeUnique(Args&&... /* args */) = - delete; // NOLINT - -} // namespace port +using tensorflow::MakeUnique; +using tensorflow::WrapUnique; } // namespace stream_executor namespace perftools { |