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

Method MoveFrom

tensorflow/compiler/xla/literal.cc:464–496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

462}
463
464Status Literal::MoveFrom(Literal&& src_literal,
465 const ShapeIndex& dest_shape_index) {
466 const Shape& dest_subshape =
467 ShapeUtil::GetSubshape(shape(), dest_shape_index);
468 if (!ShapeUtil::Equal(dest_subshape, src_literal.shape())) {
469 return InvalidArgument(
470 "Destination subshape not equal to source shape: %s vs %s",
471 ShapeUtil::HumanString(dest_subshape),
472 ShapeUtil::HumanString(src_literal.shape()));
473 }
474
475 src_literal.root_piece_->ForEachSubpiece(
476 [&](const ShapeIndex& src_index, const Piece& src_piece) {
477 if (!src_piece.subshape().IsArray()) {
478 return;
479 }
480
481 ShapeIndex dest_index = dest_shape_index;
482 for (int64 i : src_index) {
483 dest_index.push_back(i);
484 }
485 Piece& dest_piece = piece(dest_index);
486 tensorflow::port::AlignedFree(dest_piece.buffer());
487 dest_piece.set_buffer(src_piece.buffer());
488 });
489
490 src_literal.shape_ = absl::make_unique<Shape>(ShapeUtil::MakeNil());
491 delete src_literal.root_piece_;
492 src_literal.root_piece_ = new LiteralBase::Piece();
493 src_literal.root_piece_->set_subshape(src_literal.shape_.get());
494
495 return Status::OK();
496}
497
498Status MutableLiteralBase::CopySliceFrom(const LiteralSlice& src_literal,
499 absl::Span<const int64> src_base,

Callers 3

MakeTupleOwnedMethod · 0.45
MoveIntoTupleMethod · 0.45
HandleReduceMethod · 0.45

Calls 12

InvalidArgumentFunction · 0.85
ForEachSubpieceMethod · 0.80
set_subshapeMethod · 0.80
EqualClass · 0.70
shapeFunction · 0.50
AlignedFreeFunction · 0.50
shapeMethod · 0.45
IsArrayMethod · 0.45
push_backMethod · 0.45
bufferMethod · 0.45
set_bufferMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected