
    BVhE                     l    d Z ddlmZ ddlmZ ddlmZ  edg       d        Z edg       d	        Zy
)zDLPack modules for Tensorflow.    )
pywrap_tfe)context)	tf_exportzexperimental.dlpack.to_dlpack)v1c                 ,    t        j                  |       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)	tf_tensors    O/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/dlpack/dlpack.py	to_dlpackr      s    & 
	'	'		22    zexperimental.dlpack.from_dlpackc                     t        j                          j                          t        j                  | t        j                          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)	dlcapsules    r
   from_dlpackr   ,   s7    $ 
//&&(		)	))W__5F5N5N	OOr   N)	__doc__tensorflow.pythonr   tensorflow.python.eagerr    tensorflow.python.util.tf_exportr   r   r    r   r
   <module>r      sM    % ( + 6 *r23 33* ,4P 5Pr   