| 1314 | } |
| 1315 | |
| 1316 | StatusOr<Literal> LiteralBase::BitcastConvert( |
| 1317 | PrimitiveType primitive_dest_type) const { |
| 1318 | if (primitive_util::BitWidth(shape().element_type()) != |
| 1319 | primitive_util::BitWidth(primitive_dest_type)) { |
| 1320 | return InvalidArgument( |
| 1321 | "Cannot bitcast convert from %s to %s, bit widths are different: %d != " |
| 1322 | "%d", |
| 1323 | PrimitiveType_Name(shape().element_type()), |
| 1324 | PrimitiveType_Name(primitive_dest_type), |
| 1325 | primitive_util::BitWidth(shape().element_type()), |
| 1326 | primitive_util::BitWidth(primitive_dest_type)); |
| 1327 | } |
| 1328 | return ConvertSwitch(*this, primitive_dest_type, /*bitcast=*/true); |
| 1329 | } |
| 1330 | |
| 1331 | StatusOr<Literal> LiteralBase::ConvertToShape(const Shape& dest_shape) const { |
| 1332 | if (!dest_shape.IsTuple()) { |