a
    .SicE                     @   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   TFE_ToDlpackCapsule)Z	tf_tensor r   [/var/www/html/django/DPS/env/lib/python3.9/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   ensure_initializedr   TFE_FromDlpackCapsule_handle)Z	dlcapsuler   r   r   from_dlpack,   s    r   N)	__doc__tensorflow.pythonr   tensorflow.python.eagerr    tensorflow.python.util.tf_exportr   r	   r   r   r   r   r   <module>   s   


