message: [XLA] CHECK that sparse indices are in range in MutableLiteralBase::AppendSparseElement.
  Previously there was no range-checking on sparse elements' indices.
diff: @@ -958,12 +958,15 @@ template <typename NativeT>
  void MutableLiteralBase::AppendSparseElement(
  absl::Span<const int64> multi_index, NativeT value,
  const ShapeIndex& shape_index) {
  - // TODO(jlebar): CHECK that multi_index is in range?
  Piece& p = piece(shape_index);
  const Shape& subshape = p.subshape();
  CHECK(LayoutUtil::IsSparseArray(subshape));
  int64 rank = subshape.rank();
  CHECK_EQ(multi_index.size(), rank);
  + for (int64 i = 0; i < rank; ++i) {
  + CHECK_GE(multi_index[i], 0);
  + CHECK_LT(multi_index[i], subshape.dimensions(i));
  + }
  int64 last_element = p.sparse_indices()->index_count();
  CHECK_LT(last_element, LayoutUtil::MaxSparseElements(subshape.layout()));
  p.sparse_indices()->Append(multi_index);
  