|
Mila 0.13.48
Deep Neural Network Library
|
Type-safe metadata container for component serialization. More...
Public Member Functions | |
| SerializationMetadata ()=default | |
| bool | empty () const noexcept |
| Check if metadata is empty. | |
| bool | getBool (const std::string &key) const |
| Get boolean value. | |
| double | getDouble (const std::string &key) const |
| Get double value. | |
| std::vector< double > | getDoubleVector (const std::string &key) const |
| Get double vector value. | |
| int64_t | getInt (const std::string &key) const |
| Get integer value. | |
| std::vector< int64_t > | getIntVector (const std::string &key) const |
| Get integer vector value. | |
| shape_t | getShape (const std::string &key) const |
| Get shape value. | |
| std::string | getString (const std::string &key) const |
| Get string value. | |
| std::vector< std::string > | getStringVector (const std::string &key) const |
| Get string vector value. | |
| bool | has (const std::string &key) const |
| Check if key exists in metadata. | |
| std::vector< std::string > | keys () const |
| Get all keys in metadata. | |
| SerializationMetadata & | set (const std::string &key, bool value) |
| Set boolean value. | |
| SerializationMetadata & | set (const std::string &key, const char *value) |
| Set string value from C-string literal. | |
| SerializationMetadata & | set (const std::string &key, const shape_t &value) |
| Set shape value. | |
| SerializationMetadata & | set (const std::string &key, const std::string &value) |
| Set string value. | |
| SerializationMetadata & | set (const std::string &key, const std::vector< double > &value) |
| Set double vector value. | |
| SerializationMetadata & | set (const std::string &key, const std::vector< std::string > &value) |
| Set string vector value. | |
| SerializationMetadata & | set (const std::string &key, double value) |
| Set floating-point value (double). | |
| SerializationMetadata & | set (const std::string &key, float value) |
| Set floating-point value (float). | |
| SerializationMetadata & | set (const std::string &key, int64_t value) |
| Set integer value. | |
| SerializationMetadata & | set (const std::string &key, MetadataValue value) |
| Set metadata value with automatic type deduction. | |
| size_t | size () const noexcept |
| Get number of metadata entries. | |
| json | toJson () const |
| Convert to JSON representation (internal use only). | |
| std::optional< bool > | tryGetBool (const std::string &key) const noexcept |
| Get optional boolean value. | |
| std::optional< double > | tryGetDouble (const std::string &key) const noexcept |
| Get optional double value. | |
| std::optional< float > | tryGetFloat (const std::string &key) const noexcept |
| Get optional float value. | |
| std::optional< int64_t > | tryGetInt (const std::string &key) const noexcept |
| Get optional integer value. | |
| std::optional< shape_t > | tryGetShape (const std::string &key) const noexcept |
| Get optional shape value. | |
| std::optional< std::string > | tryGetString (const std::string &key) const noexcept |
| Get optional string value. | |
Static Public Member Functions | |
| static SerializationMetadata | fromJson (const json &j) |
| Construct from JSON representation (internal use only). | |
Private Member Functions | |
| const MetadataValue & | getValue (const std::string &key) const |
Private Attributes | |
| std::map< std::string, MetadataValue > | data_ |
Type-safe metadata container for component serialization.
Provides fluent API for building and reading component metadata without exposing JSON implementation details. Internally uses JSON for serialization but can be swapped with other formats without breaking user code.
|
inlinenoexcept |
Check if metadata is empty.
|
inlinestatic |
Construct from JSON representation (internal use only).
Used by ModelArchive to deserialize metadata. Not intended for direct user consumption.
| j | JSON object |

|
inline |
Get boolean value.
| key | Metadata key |
| std::runtime_error | if key not found or type mismatch |
|
inline |
Get double value.
| key | Metadata key |
| std::runtime_error | if key not found or type mismatch |
|
inline |
Get double vector value.
| key | Metadata key |
| std::runtime_error | if key not found or type mismatch |
|
inline |
Get integer value.
| key | Metadata key |
| std::runtime_error | if key not found or type mismatch |
|
inline |
Get integer vector value.
| key | Metadata key |
| std::runtime_error | if key not found or type mismatch |
|
inline |
Get shape value.
Constructs a TensorShape from the stored wire-format integer vector.
| key | Metadata key |
| std::runtime_error | if key not found or type mismatch |
|
inline |
Get string value.
| key | Metadata key |
| std::runtime_error | if key not found or type mismatch |
|
inline |
Get string vector value.
| key | Metadata key |
| std::runtime_error | if key not found or type mismatch |
|
inlineprivate |
|
inline |
Check if key exists in metadata.
| key | Metadata key |
|
inline |
Get all keys in metadata.
|
inline |
Set boolean value.
| key | Metadata key |
| value | Boolean value |
|
inline |
Set string value from C-string literal.
| key | Metadata key |
| value | C-string value |
|
inline |
Set shape value.
Converts TensorShape to the wire format (std::vector<int64_t>) for JSON serialization. getShape() performs the inverse conversion on load.
| key | Metadata key |
| value | Shape value |
|
inline |
Set string value.
| key | Metadata key |
| value | String value |
|
inline |
Set double vector value.
| key | Metadata key |
| value | Double vector |
|
inline |
Set string vector value.
| key | Metadata key |
| value | String vector |
|
inline |
Set floating-point value (double).
| key | Metadata key |
| value | Double value |
|
inline |
Set floating-point value (float).
Stores the float as double in the internal representation for consistent handling by the metadata container.
| key | Metadata key |
| value | Float value |
|
inline |
Set integer value.
| key | Metadata key |
| value | Integer value |
|
inline |
Set metadata value with automatic type deduction.
| key | Metadata key |
| value | Metadata value (string, int64_t, double, bool, vector, shape_t) |
|
inlinenoexcept |
Get number of metadata entries.
|
inline |
Convert to JSON representation (internal use only).
Used by ModelArchive to serialize metadata. Not intended for direct user consumption.
|
inlinenoexcept |
Get optional boolean value.
| key | Metadata key |
|
inlinenoexcept |
Get optional double value.
| key | Metadata key |
|
inlinenoexcept |
Get optional float value.
Converts stored integer or double metadata to float when possible.
| key | Metadata key |
|
inlinenoexcept |
Get optional integer value.
| key | Metadata key |
|
inlinenoexcept |
Get optional shape value.
Constructs a TensorShape from the stored wire-format integer vector.
| key | Metadata key |
|
inlinenoexcept |
Get optional string value.
| key | Metadata key |
|
private |