| 1076 | } |
| 1077 | |
| 1078 | XlaOp XlaBuilder::Tuple(absl::Span<const XlaOp> elements) { |
| 1079 | return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { |
| 1080 | HloInstructionProto instr; |
| 1081 | std::vector<const Shape*> operand_shape_ptrs; |
| 1082 | TF_ASSIGN_OR_RETURN(const auto& operand_shapes, GetOperandShapes(elements)); |
| 1083 | absl::c_transform(operand_shapes, std::back_inserter(operand_shape_ptrs), |
| 1084 | [](const Shape& shape) { return &shape; }); |
| 1085 | TF_ASSIGN_OR_RETURN(const Shape shape, |
| 1086 | ShapeInference::InferVariadicOpShape( |
| 1087 | HloOpcode::kTuple, operand_shape_ptrs)); |
| 1088 | *instr.mutable_shape() = shape.ToProto(); |
| 1089 | return AddInstruction(std::move(instr), HloOpcode::kTuple, elements); |
| 1090 | }); |
| 1091 | } |
| 1092 | |
| 1093 | XlaOp XlaBuilder::GetTupleElement(XlaOp tuple_data, int64 index) { |
| 1094 | return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { |
no test coverage detected