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

Method ConvertToShape

tensorflow/compiler/xla/literal.cc:1331–1344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1329}
1330
1331StatusOr<Literal> LiteralBase::ConvertToShape(const Shape& dest_shape) const {
1332 if (!dest_shape.IsTuple()) {
1333 return Convert(dest_shape.element_type());
1334 }
1335 std::vector<Literal> elements;
1336 for (int i = 0; i < ShapeUtil::TupleElementCount(shape()); ++i) {
1337 auto element = LiteralSlice(*this, {i});
1338 TF_ASSIGN_OR_RETURN(
1339 auto new_element,
1340 element.ConvertToShape(ShapeUtil::GetSubshape(dest_shape, {i})));
1341 elements.push_back(std::move(new_element));
1342 }
1343 return MutableLiteralBase::MoveIntoTuple(absl::MakeSpan(elements));
1344}
1345
1346/* static */ Literal MutableLiteralBase::MoveIntoTuple(
1347 absl::Span<Literal> elements) {

Callers 2

HandleReduceWindowMethod · 0.80
HandleReduceMethod · 0.80

Calls 6

LiteralSliceClass · 0.85
ConvertFunction · 0.50
shapeFunction · 0.50
IsTupleMethod · 0.45
element_typeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected