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

Function ParseInt64Feature

tensorflow/core/util/example_proto_fast_parsing.cc:1731–1777  ·  view source on GitHub ↗

Return the number of int64 elements parsed, or -1 on error. If out is null, this method simply counts the number of elements without any copying.

Source from the content-addressed store, hash-verified

1729// Return the number of int64 elements parsed, or -1 on error. If out is null,
1730// this method simply counts the number of elements without any copying.
1731inline int ParseInt64Feature(protobuf::io::CodedInputStream* stream,
1732 int64* out) {
1733 int num_elements = 0;
1734 uint32 length;
1735 if (!stream->ExpectTag(kDelimitedTag(3)) || !stream->ReadVarint32(&length)) {
1736 return -1;
1737 }
1738 if (length > 0) {
1739 auto limit = stream->PushLimit(length);
1740 uint8 peek_tag = PeekTag(stream);
1741 if (peek_tag == kDelimitedTag(1)) { // packed
1742 uint32 packed_length;
1743 if (!stream->ExpectTag(kDelimitedTag(1)) ||
1744 !stream->ReadVarint32(&packed_length)) {
1745 return -1;
1746 }
1747 auto packed_limit = stream->PushLimit(packed_length);
1748 while (!stream->ExpectAtEnd()) {
1749 protobuf_uint64 n; // There is no API for int64
1750 if (!stream->ReadVarint64(&n)) {
1751 return -1;
1752 }
1753 if (out != nullptr) {
1754 *out++ = n;
1755 }
1756 num_elements++;
1757 }
1758 stream->PopLimit(packed_limit);
1759 } else if (peek_tag == kVarintTag(1)) {
1760 while (!stream->ExpectAtEnd()) {
1761 protobuf_uint64 n; // There is no API for int64
1762 if (!stream->ExpectTag(kVarintTag(1)) || !stream->ReadVarint64(&n)) {
1763 return -1;
1764 }
1765 if (out != nullptr) {
1766 *out++ = n;
1767 }
1768 num_elements++;
1769 }
1770 } else {
1771 // Unknown tag.
1772 return -1;
1773 }
1774 stream->PopLimit(limit);
1775 }
1776 return num_elements;
1777}
1778
1779inline DataType ParseDataType(protobuf::io::CodedInputStream* stream) {
1780 uint8 peek_tag = PeekTag(stream);

Callers 1

FastParseSequenceExampleFunction · 0.85

Calls 5

kDelimitedTagFunction · 0.85
PeekTagFunction · 0.85
kVarintTagFunction · 0.85
ReadVarint32Method · 0.80
ReadVarint64Method · 0.80

Tested by

no test coverage detected