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

Function ConvertEndianShort

tensorflow/compiler/xla/literal.cc:54–59  ·  view source on GitHub ↗

Converts between little and big endian. Precondition: size % 2 == 0 (elements in the array are 16 bits long)

Source from the content-addressed store, hash-verified

52//
53// Precondition: size % 2 == 0 (elements in the array are 16 bits long)
54void ConvertEndianShort(string* bytes) {
55 CHECK_EQ(bytes->size() / 2, 0);
56 for (int64 i = 0; i < bytes->size(); i += 2) {
57 std::swap((*bytes)[i], (*bytes)[i + 1]);
58 }
59}
60
61void ConvertEndianShort(char* bytes, int64 size) {
62 CHECK_EQ(size / 2, 0);

Callers 2

WriteToProtoMethod · 0.85
CopyFromProtoMethod · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected