Implementation:Alibaba MNN FlexBuffers Header
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Serialization, Dynamic_Data |
| Last Updated | 2026-02-10 12:00 GMT |
Overview
Schema-less variant of FlatBuffers that supports self-describing, dynamically-typed binary data.
Description
flexbuffers.h implements the FlexBuffers format, a schema-less companion to FlatBuffers. It provides flexbuffers::Builder for constructing dynamically-typed data and flexbuffers::Reference for reading it back without a schema. This is useful for storing heterogeneous metadata and configuration data within MNN models where a fixed schema is impractical.
Usage
Vendored dependency used internally by MNN for model serialization. Not directly imported by end users.
Code Reference
Source Location
- Repository: Alibaba_MNN
- File:
3rd_party/flatbuffers/include/flatbuffers/flexbuffers.h - Lines: 1-1538
Signature
namespace flexbuffers {
class Builder;
class Reference;
class Map;
class Vector;
Reference GetRoot(const uint8_t *buffer, size_t size);
}
Import
#include "flatbuffers/flexbuffers.h"
I/O Contract
| Input | Output |
|---|---|
| Dynamic key-value data via Builder API | Self-describing binary FlexBuffer |
| Raw FlexBuffer bytes | Typed accessors via Reference, Map, Vector
|
Usage Examples
#include "flatbuffers/flexbuffers.h"
flexbuffers::Builder fbb;
fbb.Map([&]() {
fbb.String("name", "relu");
fbb.Int("version", 3);
});
fbb.Finish();
auto ref = flexbuffers::GetRoot(fbb.GetBuffer());
std::string name = ref.AsMap()["name"].AsString().str();
int version = ref.AsMap()["version"].AsInt32();
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment