| 1329 | } |
| 1330 | |
| 1331 | StatusOr<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) { |
no test coverage detected