#ifndef TENSORFLOW_LIB_CORE_RAW_CODING_H_ #define TENSORFLOW_LIB_CORE_RAW_CODING_H_ #include #include "tensorflow/core/platform/port.h" namespace tensorflow { namespace core { // Lower-level versions of Get... that read directly from a character buffer // without any bounds checking. inline uint32 DecodeFixed32(const char* ptr) { if (port::kLittleEndian) { // Load the raw bytes uint32 result; memcpy(&result, ptr, sizeof(result)); // gcc optimizes this to a plain load return result; } else { return ((static_cast(static_cast(ptr[0]))) | (static_cast(static_cast(ptr[1])) << 8) | (static_cast(static_cast(ptr[2])) << 16) | (static_cast(static_cast(ptr[3])) << 24)); } } inline uint64 DecodeFixed64(const char* ptr) { if (port::kLittleEndian) { // Load the raw bytes uint64 result; memcpy(&result, ptr, sizeof(result)); // gcc optimizes this to a plain load return result; } else { uint64 lo = DecodeFixed32(ptr); uint64 hi = DecodeFixed32(ptr + 4); return (hi << 32) | lo; } } } // namespace core } // namespace tensorflow #endif // TENSORFLOW_LIB_CORE_RAW_CODING_H_