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

Method DecomposeTuple

tensorflow/compiler/xla/literal.cc:337–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

335}
336
337std::vector<Literal> Literal::DecomposeTuple() {
338 CHECK(shape().IsTuple());
339 std::vector<Literal> elements;
340 for (int i = 0; i < ShapeUtil::TupleElementCount(shape()); ++i) {
341 elements.push_back(Literal(ShapeUtil::GetSubshape(shape(), {i}),
342 /*allocate_arrays=*/false));
343 Literal& element = elements.back();
344 element.root_piece_->ForEachMutableSubpiece(
345 [&](const ShapeIndex& index, Piece* dest_piece) {
346 ShapeIndex src_index = {i};
347 for (int64 j : index) {
348 src_index.push_back(j);
349 }
350 Piece& src_piece = piece(src_index);
351
352 // Move the respective buffer over to the element Literal.
353 dest_piece->set_buffer(src_piece.buffer());
354 src_piece.set_buffer(nullptr);
355 });
356 }
357 // Set this literal to be nil-shaped.
358 *this = Literal();
359 return elements;
360}
361
362namespace {
363

Callers 7

TESTFunction · 0.80
TEST_FFunction · 0.80
LiteralToPythonFunction · 0.80
PerformReductionStepFunction · 0.80
TEST_FFunction · 0.80
XLA_TEST_FFunction · 0.80
XLA_TEST_FFunction · 0.80

Calls 8

LiteralClass · 0.70
shapeFunction · 0.50
IsTupleMethod · 0.45
push_backMethod · 0.45
backMethod · 0.45
set_bufferMethod · 0.45
bufferMethod · 0.45

Tested by 5

TESTFunction · 0.64
TEST_FFunction · 0.64
TEST_FFunction · 0.64
XLA_TEST_FFunction · 0.64
XLA_TEST_FFunction · 0.64