Function tvm::ffi::ToJSONGraph#
Defined in File serialization.h
Function Documentation#
-
json::Value tvm::ffi::ToJSONGraph(const Any &value, const Any &metadata = Any(nullptr))#
Serialize ffi::Any to a JSON that stores the object graph.
The JSON graph structure is stored as follows:
{ "root_index": <int>, // Index of root node in nodes array "nodes": [<node>, ...], // Array of serialized nodes "metadata": <object> // Optional metadata }
Each node has the format:
{"type": "<type_key>", "data": <type_data>}
For object types and strings, the data may contain indices to other nodes. For object fields whose static type is known as a primitive type, it is stored directly, otherwise, it is stored as a reference to the nodes array by an index.This function preserves the type and multiple references to the same object, which is useful for debugging and serialization.
- Parameters:
value – The ffi::Any value to serialize.
metadata – Extra metadata attached to “metadata” field of the JSON object.
- Returns:
The serialized JSON value.