Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Alibaba MNN Protobuf Generated Table Driven Lite H

From Leeroopedia


Knowledge Sources
Domains Serialization, Parsing
Last Updated 2026-02-10 12:00 GMT

Overview

Lite version of the table-driven parsing header, providing the core parsing logic without full protobuf runtime dependencies.

Description

This header contains the actual implementation of table-driven parsing routines in the protobuf-lite variant, which avoids dependencies on reflection, descriptors, and other heavyweight features. It includes template specializations for parsing each wire type (varint, fixed32, fixed64, length-delimited, groups) and dispatching to the correct field handler based on the parse table metadata. MNN vendors this file because it provides the performance-critical fast path for deserializing TensorFlow and Caffe model protobuf data, enabling efficient parsing of large model files with minimal overhead.

Usage

Vendored dependency used internally by MNN for parsing protobuf-based model formats (TensorFlow, Caffe). Not directly imported by end users.

Code Reference

Source Location

  • Repository: Alibaba_MNN
  • File: 3rd_party/protobuf/src/google/protobuf/generated_message_table_driven_lite.h
  • Lines: 1-874

Signature

namespace google {
namespace protobuf {
namespace internal {
template <typename Entry> bool ParseField(io::CodedInputStream* input, const ParseTable& table, MessageLite* msg);
bool MergePartialFromCodedStreamLite(MessageLite* msg, const ParseTable& table, io::CodedInputStream* input);
template <> bool HandleString<false>(io::CodedInputStream* input, MessageLite* msg, Arena* arena, uint32 offset);
}  // namespace internal
}  // namespace protobuf
}  // namespace google

Import

#include "3rd_party/protobuf/src/google/protobuf/generated_message_table_driven_lite.h"

I/O Contract

Inputs

Name Type Required Description
input io::CodedInputStream* Yes Coded input stream wrapping serialized protobuf bytes
table const ParseTable& Yes Compiled parse table with field metadata for table-driven dispatch
msg MessageLite* Yes Target message object to populate with parsed data

Outputs

Name Type Description
success bool Whether parsing completed without errors
msg MessageLite* Message with fields populated from the wire-format input

Usage Examples

// MNN internal usage (generated lite message parsing)
io::CodedInputStream input(raw_data, size);
static const internal::ParseTable kTable = { ... };
bool ok = internal::MergePartialFromCodedStreamLite(
    this, kTable, &input);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment