diff options
author | 2018-08-20 20:20:14 -0700 | |
---|---|---|
committer | 2018-08-20 20:23:24 -0700 | |
commit | e924d67bff8c4fb58c8316d00b662f8d1e80eb95 (patch) | |
tree | bf1b0f5b9d0c699150295f98187b19d6a10710a6 /tensorflow/compiler/xla/literal_util.h | |
parent | 49115abfd39d30506679d9fdc572ccd2f7c22dbe (diff) |
[XLA] Use absl::make_unique instead of xla::MakeUnique.
Same for WrapUnique.
PiperOrigin-RevId: 209531124
Diffstat (limited to 'tensorflow/compiler/xla/literal_util.h')
-rw-r--r-- | tensorflow/compiler/xla/literal_util.h | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/tensorflow/compiler/xla/literal_util.h b/tensorflow/compiler/xla/literal_util.h index e3737a9d00..1109021ea8 100644 --- a/tensorflow/compiler/xla/literal_util.h +++ b/tensorflow/compiler/xla/literal_util.h @@ -27,6 +27,7 @@ limitations under the License. #include <type_traits> #include <vector> +#include "absl/memory/memory.h" #include "tensorflow/compiler/xla/array2d.h" #include "tensorflow/compiler/xla/array3d.h" #include "tensorflow/compiler/xla/array4d.h" @@ -34,7 +35,6 @@ limitations under the License. #include "tensorflow/compiler/xla/layout_util.h" #include "tensorflow/compiler/xla/literal.h" #include "tensorflow/compiler/xla/primitive_util.h" -#include "tensorflow/compiler/xla/ptr_util.h" #include "tensorflow/compiler/xla/shape_util.h" #include "tensorflow/compiler/xla/sparse_index_array.h" #include "tensorflow/compiler/xla/status_macros.h" @@ -327,7 +327,7 @@ std::ostream& operator<<(std::ostream& out, const Literal& literal); template <typename NativeT> /* static */ std::unique_ptr<Literal> LiteralUtil::CreateR0(NativeT value) { - auto literal = MakeUnique<Literal>(ShapeUtil::MakeShape( + auto literal = absl::make_unique<Literal>(ShapeUtil::MakeShape( primitive_util::NativeToPrimitiveType<NativeT>(), {})); literal->Set({}, value); return literal; @@ -336,7 +336,7 @@ template <typename NativeT> template <typename NativeT> /* static */ std::unique_ptr<Literal> LiteralUtil::CreateR1( tensorflow::gtl::ArraySlice<NativeT> values) { - auto literal = MakeUnique<Literal>( + auto literal = absl::make_unique<Literal>( ShapeUtil::MakeShape(primitive_util::NativeToPrimitiveType<NativeT>(), {static_cast<int64>(values.size())})); literal->PopulateR1(values); @@ -347,7 +347,7 @@ template <typename NativeT> /* static */ std::unique_ptr<Literal> LiteralUtil::CreateR2WithLayout( std::initializer_list<std::initializer_list<NativeT>> values, const Layout& layout) { - auto literal = MakeUnique<Literal>(ShapeUtil::MakeShapeWithLayout( + auto literal = absl::make_unique<Literal>(ShapeUtil::MakeShapeWithLayout( primitive_util::NativeToPrimitiveType<NativeT>(), {static_cast<int64>(values.size()), static_cast<int64>(values.begin()->size())}, @@ -433,9 +433,10 @@ template <typename NativeT> int64 rank = dimensions.size(); CHECK_EQ(num_elements, indices.index_count()); CHECK_EQ(rank, indices.rank()); - auto literal = MakeUnique<Literal>(ShapeUtil::MakeShapeWithSparseLayout( - primitive_util::NativeToPrimitiveType<NativeT>(), dimensions, - indices.max_indices())); + auto literal = + absl::make_unique<Literal>(ShapeUtil::MakeShapeWithSparseLayout( + primitive_util::NativeToPrimitiveType<NativeT>(), dimensions, + indices.max_indices())); literal->PopulateSparse(indices, values, sort); return literal; } @@ -451,7 +452,7 @@ template <typename NativeT> template <typename NativeT> /* static */ std::unique_ptr<Literal> LiteralUtil::CreateFromArrayWithLayout( const Array<NativeT>& values, const Layout& layout) { - auto literal = MakeUnique<Literal>(ShapeUtil::MakeShapeWithLayout( + auto literal = absl::make_unique<Literal>(ShapeUtil::MakeShapeWithLayout( primitive_util::NativeToPrimitiveType<NativeT>(), values.dimensions(), AsInt64Slice(layout.minor_to_major()))); literal->PopulateFromArray(values); @@ -571,8 +572,9 @@ template <typename NativeT> /* static */ std::unique_ptr<Literal> LiteralUtil::CreateFullWithDescendingLayout( tensorflow::gtl::ArraySlice<int64> dimensions, NativeT value) { - auto literal = MakeUnique<Literal>(ShapeUtil::MakeShapeWithDescendingLayout( - primitive_util::NativeToPrimitiveType<NativeT>(), dimensions)); + auto literal = + absl::make_unique<Literal>(ShapeUtil::MakeShapeWithDescendingLayout( + primitive_util::NativeToPrimitiveType<NativeT>(), dimensions)); literal->PopulateWithValue(value); return literal; } @@ -584,7 +586,7 @@ LiteralUtil::CreateRandomLiteral( const std::function<T(tensorflow::gtl::ArraySlice<int64>)>& generator) { using NativeT = typename primitive_util::PrimitiveTypeToNative<type>::type; TF_RET_CHECK(shape.element_type() == type); - auto literal = MakeUnique<Literal>(shape); + auto literal = absl::make_unique<Literal>(shape); TF_RETURN_IF_ERROR(literal.get()->Populate<NativeT>( [&](tensorflow::gtl::ArraySlice<int64> indexes) { return generator(indexes); |