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 Any PB H

From Leeroopedia


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

Overview

Generated C++ header file declaring the Protocol Buffers Any well-known type for type-erased message wrapping.

Description

This header declares the google::protobuf::Any class, which provides a mechanism to embed arbitrary protobuf messages without requiring their type at compile time. The Any type stores a serialized message alongside a type URL that identifies the schema. MNN vendors this header to support TensorFlow and Caffe model formats that use Any for flexible message composition within their serialized graph definitions.

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.h
  • Lines: 1-391

Signature

namespace google {
namespace protobuf {
class Any final : public ::PROTOBUF_NAMESPACE_ID::Message {
  const std::string& type_url() const;
  const std::string& value() const;
  bool Is() const;
};
}  // namespace protobuf
}  // namespace google

Import

#include "3rd_party/protobuf/src/google/protobuf/any.pb.h"

I/O Contract

Inputs

Name Type Required Description
N/A N/A N/A Header-only declarations; no direct runtime inputs

Outputs

Name Type Description
Any class google::protobuf::Any Type-erased protobuf message container with type_url and value accessors

Usage Examples

// MNN internal usage
#include "google/protobuf/any.pb.h"
google::protobuf::Any any;
if (any.Is<tensorflow::TensorProto>()) {
  tensorflow::TensorProto tensor;
  any.UnpackTo(&tensor);
}

Related Pages

Page Connections

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