MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / UpdateSlice

Method UpdateSlice

tensorflow/compiler/xla/array.h:471–488  ·  view source on GitHub ↗

Performs the equivalent of a DynamicUpdateSlice in-place on this array.

Source from the content-addressed store, hash-verified

469
470 // Performs the equivalent of a DynamicUpdateSlice in-place on this array.
471 void UpdateSlice(const Array<T>& from,
472 absl::Span<const int64> start_indices) {
473 CHECK_EQ(from.num_dimensions(), num_dimensions());
474 std::vector<int64> limit_indices;
475 std::transform(start_indices.begin(), start_indices.end(),
476 from.dimensions().begin(), std::back_inserter(limit_indices),
477 std::plus<int64>{});
478 std::vector<int64> index(sizes_.size());
479 int64 from_i = 0;
480 for (int64 i = 0; i < num_elements(); ++i, next_index(&index)) {
481 if (array_impl::all_inside_range(index, start_indices, limit_indices)) {
482 // Even though the bounds of from are different to our bounds, we're
483 // iterating in the same order. So we can simply write successive linear
484 // indices instead of recalculating a multi-dimensional index.
485 values_[i] = from.values_[from_i++];
486 }
487 }
488 }
489
490 // Performs an in-place reshape, modifying the dimensions but not the
491 // underlying data.

Callers 1

TESTFunction · 0.80

Calls 7

all_inside_rangeFunction · 0.85
num_dimensionsMethod · 0.80
transformFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
dimensionsMethod · 0.45
sizeMethod · 0.45

Tested by 1

TESTFunction · 0.64