o
    i	                     @  sJ   d Z ddlmZ ddlmZ ddlmZ ddddZdddZddgZ	dS )a  Utilities for serializing and deserializing FFI object graphs.

These helpers produce a stable JSON graph representation that preserves
object identity and references. It is useful for debugging and for
lightweight persistence when pickling is not available.
    )annotations)Any   )_ffi_apiNobjr   metadatadict[str, Any] | Nonereturnstrc                 C  s   t | |S )a  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
        The object to save.

    metadata
        Extra metadata to save into the json graph string.

    Returns
    -------
    json_str
        The JSON graph string.

    Examples
    --------
    .. code-block:: python

        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]

    )r   ToJSONGraphString)r   r    r   R/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/tvm_ffi/serialization.pyto_json_graph_str   s    r   json_strc                 C  s
   t | S )aM  Load an object from a JSON graph string.

    The JSON graph string is produced by :py:func:`to_json_graph_str` and
    can be converted back into the corresponding FFI-backed objects.

    Parameters
    ----------
    json_str
        The JSON graph string to load.

    Returns
    -------
    obj
        The loaded object.

    )r   FromJSONGraphString)r   r   r   r   from_json_graph_strB   s   
r   )N)r   r   r   r   r	   r
   )r   r
   r	   r   )
__doc__
__future__r   typingr    r   r   r   __all__r   r   r   r   <module>   s   
#