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

Method WriteToProto

tensorflow/compiler/xla/literal.cc:1755–1836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1753} // namespace
1754
1755void LiteralBase::Piece::WriteToProto(LiteralProto* proto) const {
1756 *proto->mutable_shape() = subshape().ToProto();
1757 switch (subshape().element_type()) {
1758 case PRED:
1759 CopyToRepeatedField(proto->mutable_preds(), data<bool>());
1760 break;
1761 case S8:
1762 proto->set_s8s(static_cast<const signed char*>(data<int8>().data()),
1763 element_count());
1764 break;
1765 case U8:
1766 proto->set_u8s(static_cast<const unsigned char*>(data<uint8>().data()),
1767 element_count());
1768 break;
1769 case U32:
1770 CopyToRepeatedField(proto->mutable_u32s(), data<uint32>());
1771 break;
1772 case U64:
1773 CopyToRepeatedField(proto->mutable_u64s(), data<uint64>());
1774 break;
1775 case S32:
1776 CopyToRepeatedField(proto->mutable_s32s(), data<int32>());
1777 break;
1778 case S64:
1779 CopyToRepeatedField(proto->mutable_s64s(), data<int64>());
1780 break;
1781 case U16:
1782 *proto->mutable_u16s() = string(
1783 reinterpret_cast<const char*>(data<uint16_t>().data()), size_bytes());
1784 if (!kLittleEndian) {
1785 ConvertEndianShort(proto->mutable_u16s());
1786 }
1787 break;
1788 case S16:
1789 *proto->mutable_s16s() = string(
1790 reinterpret_cast<const char*>(data<int16_t>().data()), size_bytes());
1791 if (!kLittleEndian) {
1792 ConvertEndianShort(proto->mutable_s16s());
1793 }
1794 break;
1795 case F16:
1796 *proto->mutable_f16s() = string(
1797 reinterpret_cast<const char*>(data<half>().data()), size_bytes());
1798 if (!kLittleEndian) {
1799 ConvertEndianShort(proto->mutable_f16s());
1800 }
1801 break;
1802 case BF16:
1803 *proto->mutable_bf16s() = string(
1804 reinterpret_cast<const char*>(data<bfloat16>().data()), size_bytes());
1805 if (!kLittleEndian) {
1806 ConvertEndianShort(proto->mutable_bf16s());
1807 }
1808 break;
1809 case F32:
1810 CopyToRepeatedField(proto->mutable_f32s(), data<float>());
1811 break;
1812 case F64:

Callers 1

ToProtoMethod · 0.80

Calls 6

CopyToRepeatedFieldFunction · 0.85
ConvertEndianShortFunction · 0.85
mutable_shapeMethod · 0.45
ToProtoMethod · 0.45
element_typeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected