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

Method CopyPieceSubtree

tensorflow/compiler/xla/literal.cc:2001–2027  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1999}
2000
2001void MutableBorrowingLiteral::CopyPieceSubtree(const Shape& shape,
2002 Piece* src_piece,
2003 Piece* dest_piece) {
2004 DCHECK(ShapeUtil::Equal(src_piece->subshape(), dest_piece->subshape()))
2005 << "src_piece has shape: "
2006 << ShapeUtil::HumanString(src_piece->subshape())
2007 << "dest_piece has shape: "
2008 << ShapeUtil::HumanString(dest_piece->subshape());
2009 if (shape.IsTuple()) {
2010 for (int i = 0; i < ShapeUtil::TupleElementCount(shape); ++i) {
2011 const Shape& subshape = shape.tuple_shapes(i);
2012
2013 auto child_piece = Piece();
2014 child_piece.set_subshape(&subshape);
2015
2016 CopyPieceSubtree(subshape, &src_piece->child(i), &child_piece);
2017
2018 dest_piece->emplace_back(std::move(child_piece));
2019 }
2020 } else if (shape.IsArray()) {
2021 dest_piece->set_buffer(src_piece->buffer());
2022 } else {
2023 // If the shape is neither an array nor tuple, then it must be
2024 // zero-sized. Otherwise, some memory needs to be allocated for it.
2025 CHECK_EQ(dest_piece->size_bytes(), 0);
2026 }
2027}
2028
2029MutableLiteralBase::~MutableLiteralBase() {}
2030

Callers

nothing calls this directly

Calls 11

set_subshapeMethod · 0.80
EqualClass · 0.70
PieceClass · 0.70
IsTupleMethod · 0.45
tuple_shapesMethod · 0.45
childMethod · 0.45
emplace_backMethod · 0.45
IsArrayMethod · 0.45
set_bufferMethod · 0.45
bufferMethod · 0.45
size_bytesMethod · 0.45

Tested by

no test coverage detected