diff options
author | 2018-04-10 22:44:36 -0700 | |
---|---|---|
committer | 2018-04-10 22:47:29 -0700 | |
commit | 231146433a45ca8135e132ee0b48469798ca0b1f (patch) | |
tree | 88a095664397cf1ebe092580cad2c76a508b70a5 /tensorflow/compiler/xla/literal_util.h | |
parent | 785c484288913ed7989881483aefa3bee0cec015 (diff) |
[XLA] Fix the size of data buffer for sparse literals.
PiperOrigin-RevId: 192404543
Diffstat (limited to 'tensorflow/compiler/xla/literal_util.h')
-rw-r--r-- | tensorflow/compiler/xla/literal_util.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tensorflow/compiler/xla/literal_util.h b/tensorflow/compiler/xla/literal_util.h index a6a3dffeb7..8aa19222dc 100644 --- a/tensorflow/compiler/xla/literal_util.h +++ b/tensorflow/compiler/xla/literal_util.h @@ -1287,12 +1287,13 @@ void Literal::PopulateSparse(SparseIndexArray indices, CHECK_LE(num_elements, max_elements); CHECK_EQ(num_elements, indices.index_count()); auto root_data = root_piece().data<NativeT>(); - root_data.remove_suffix(max_elements - values.size()); + // Piece::data() returns an ArraySlice of size equal to the number of indices + // in the SparseIndexArray. So there is no need to adjust the size of the data + // here. It is enough to just copy the incoming values into the data buffer. std::copy(values.begin(), values.end(), root_data.begin()); *this->root_piece().sparse_indices() = std::move(indices); if (sort) { auto root_data = this->root_piece().data<NativeT>(); - root_data.remove_suffix(root_data.size() - num_elements); this->root_piece().sparse_indices()->SortWithValues(root_data); } DCHECK(this->root_piece().sparse_indices()->Validate(shape())); |