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

Function Convert

tensorflow/core/lib/strings/base64.cc:48–59  ·  view source on GitHub ↗

Converts a char (8 bits) into a 6-bit value for decoding. If the input char is invalid for base64 encoding, the return value has at least its upper 25 bits set.

Source from the content-addressed store, hash-verified

46// is invalid for base64 encoding, the return value has at least its upper 25
47// bits set.
48inline uint32 Convert(char x) {
49 // If x < 128, then we look up x in the table. If x is valid, then the table
50 // will have a value <= 0x3F, otherwise the table will have -1. If x >= 128,
51 // we still do some table lookup, but the value is ignored since we explicitly
52 // set the high bit of y to 1. Either way, y is negative (high bit set) in
53 // case of error.
54 const int8 y = kBase64Bytes[x & 0x7F] | (x & 0x80);
55 // Casting from int8 to int32 preserves sign by sign extension. If y was
56 // negative, at least its 25 high bits of the return value are set.
57 const int32 z = static_cast<int32>(y);
58 return static_cast<uint32>(z);
59}
60
61Status DecodeThreeChars(const char* codes, char* result) {
62 const uint32 packed = (Convert(codes[0]) << 18) | (Convert(codes[1]) << 12) |

Callers 15

DecodeThreeCharsFunction · 0.70
ConvertMethod · 0.50
ConvertMlirToGraphFunction · 0.50
ConvertGraphToMlirFunction · 0.50
ConvertSavedModelToMlirFunction · 0.50
ImportInstructionMethod · 0.50
ConvertToShapeMethod · 0.50

Calls

no outgoing calls

Tested by 9

TEST_FFunction · 0.40
TEST_FFunction · 0.40
TEST_FFunction · 0.40
TEST_FFunction · 0.40
TEST_FFunction · 0.40
TEST_FFunction · 0.40
TEST_FFunction · 0.40
ExpectErrorMethod · 0.40
ExpectOKMethod · 0.40