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 Descriptor Database CC

From Leeroopedia


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

Overview

Implementation of the Protocol Buffers DescriptorDatabase classes for managing collections of file descriptors used in dynamic message creation.

Description

This file implements several descriptor database variants: SimpleDescriptorDatabase for in-memory storage, EncodedDescriptorDatabase for lazy parsing of serialized descriptors, and MergedDescriptorDatabase for combining multiple databases. These databases serve as backing stores for DescriptorPool, enabling on-demand loading and resolution of proto schemas. MNN vendors this file because the TensorFlow model converter uses descriptor databases to manage the collection of proto schemas needed to parse complex model graph definitions that span multiple proto files.

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/descriptor_database.cc
  • Lines: 1-1031

Signature

namespace google {
namespace protobuf {
bool SimpleDescriptorDatabase::Add(const FileDescriptorProto& file);
bool SimpleDescriptorDatabase::FindFileByName(const std::string& filename, FileDescriptorProto* output);
bool EncodedDescriptorDatabase::Add(const void* encoded, int size);
bool MergedDescriptorDatabase::FindFileByName(const std::string& filename, FileDescriptorProto* output);
}  // namespace protobuf
}  // namespace google

Import

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

I/O Contract

Inputs

Name Type Required Description
file FileDescriptorProto Yes Proto file descriptor to add to the database
filename const std::string& Yes Name of the proto file to look up in the database

Outputs

Name Type Description
success bool Whether the add or find operation succeeded
output FileDescriptorProto* Populated file descriptor proto on successful lookup

Usage Examples

// MNN internal usage
google::protobuf::SimpleDescriptorDatabase db;
db.Add(file_proto);
google::protobuf::FileDescriptorProto result;
db.FindFileByName("tensorflow/core/framework/graph.proto", &result);

Related Pages

Page Connections

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