tvm_ffi.serialization.to_json_graph_str

tvm_ffi.serialization.to_json_graph_str#

tvm_ffi.serialization.to_json_graph_str(obj, metadata=None)[source]#

Dump an object to a JSON graph string.

The JSON graph is a textual representation of the object graph that preserves shared references. It can be used for debugging or simple persistence.

Parameters:
  • obj (Any) – The object to save.

  • metadata (dict[str, Any] | None, default: None) – Extra metadata to save into the json graph string.

Return type:

str

Returns:

json_str – The JSON graph string.

Examples

import tvm_ffi

a = tvm_ffi.convert([1, 2, 3])
s = tvm_ffi.serialization.to_json_graph_str(a)
b = tvm_ffi.serialization.from_json_graph_str(s)
assert list(b) == [1, 2, 3]