o
    ®?eE  ć                   @   sT   d Z ddlmZ ddlmZ ddlmZ edg ddd Zed	g dd
d ZdS )zDLPack modules for Tensorflow.é    )Ś
pywrap_tfe)Ścontext)Ś	tf_exportzexperimental.dlpack.to_dlpack)Śv1c                 C   s
   t  | ”S )a  Returns the dlpack capsule representing the tensor.

  This operation ensures the underlying data memory is ready when returns.

    ```python
    a = tf.tensor([1, 10])
    dlcapsule = tf.experimental.dlpack.to_dlpack(a)
    # dlcapsule represents the dlpack data structure
    ```

  Args:
    tf_tensor: Tensorflow eager tensor, to be converted to dlpack capsule.

  Returns:
    A PyCapsule named as dltensor, which shares the underlying memory to other
     framework. This PyCapsule can be consumed only once.
  )r   ZTFE_ToDlpackCapsule)Z	tf_tensor© r   ś`/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/dlpack/dlpack.pyŚ	to_dlpack   s   
r   zexperimental.dlpack.from_dlpackc                 C   s   t   ”  ”  t | t   ” j”S )aX  Returns the Tensorflow eager tensor.

  The returned tensor uses the memory shared by dlpack capsules from other
  framework.

    ```python
    a = tf.experimental.dlpack.from_dlpack(dlcapsule)
    # `a` uses the memory shared by dlpack
    ```

  Args:
    dlcapsule: A PyCapsule named as dltensor

  Returns:
    A Tensorflow eager tensor
  )r   Zensure_initializedr   ZTFE_FromDlpackCapsuleZ_handle)Z	dlcapsuler   r   r   Śfrom_dlpack,   s   r	   N)	Ś__doc__Ztensorflow.pythonr   Ztensorflow.python.eagerr   Z tensorflow.python.util.tf_exportr   r   r	   r   r   r   r   Ś<module>   s   


