Implementation:Alibaba MNN Protobuf Any PB CC
| Knowledge Sources | |
|---|---|
| Domains | Serialization, Type_System |
| Last Updated | 2026-02-10 12:00 GMT |
Overview
Generated C++ implementation file for the Protocol Buffers Any well-known type, providing type-erased message wrapping.
Description
This file is the auto-generated implementation of google.protobuf.Any, which allows embedding arbitrary protobuf messages inside other messages without compile-time knowledge of their schema. MNN vendors this file as part of the full protobuf runtime to support parsing TensorFlow and Caffe model formats that rely on the Any type for flexible message encapsulation. The implementation includes serialization, deserialization, and type-URL based dispatch logic.
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/any.pb.cc - Lines: 1-352
Signature
namespace google {
namespace protobuf {
class Any final : public ::PROTOBUF_NAMESPACE_ID::Message {
void PackFrom(const ::PROTOBUF_NAMESPACE_ID::Message& message);
bool UnpackTo(::PROTOBUF_NAMESPACE_ID::Message* message) const;
};
} // namespace protobuf
} // namespace google
Import
#include "3rd_party/protobuf/src/google/protobuf/any.pb.h"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| message | google::protobuf::Message |
Yes | Any protobuf message to be packed into the Any wrapper |
Outputs
| Name | Type | Description |
|---|---|---|
| Any | google::protobuf::Any |
Serialized Any message containing type_url and packed value bytes |
Usage Examples
// MNN internal usage
google::protobuf::Any any_msg;
MyModelProto model;
any_msg.PackFrom(model);
// Later: any_msg.UnpackTo(&model);