a
    yn„f&	  ã                   @  sl   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 dZ
e	 ¡ Zeƒ dddd	œd
d„ƒZdd„ ZdS )é    )Úannotations)Úregularize_backend)Úhigh_level_function)ÚHighLevelContext)ÚNumpyMetadata)Ú
to_backendTN)Ú	highlevelÚbehaviorÚattrsc                c  s   | fV  t | ||||ƒS )az  
    Args:
        array: Array-like data (anything #ak.to_layout recognizes).
        backend (`"cpu"`, `"cuda"`, or `"jax"`): If `"cpu"`, the array structure is
            recursively copied (if need be) to main memory for use with
            the default Numpy backend; if `"cuda"`, the structure is copied
            to the GPU(s) for use with CuPy. If `"jax"`, the structure is
            copied to the CPU for use with JAX.
        highlevel (bool): If True, return an #ak.Array; otherwise, return
            a low-level #ak.contents.Content subclass.
        behavior (None or dict): Custom #ak.behavior for the output array, if
            high-level.
        attrs (None or dict): Custom attributes for the output array, if
            high-level.

    Converts an array from `"cpu"`, `"cuda"`, `"jax"` kernels to `"cpu"`,
    `"cuda"`, `"jax"`, or `"typetracer"` .

    Any components that are already in the desired backend are viewed,
    rather than copied, so this operation can be an inexpensive way to ensure
    that an array is ready for a particular library.

    To use `"cuda"`, the `cupy` package must be installed, either with

        pip install cupy

    or

        conda install -c conda-forge cupy

    To use `"jax"`, the `jax` package must be installed, either with

        pip install jax

    or

        conda install -c conda-forge jax

    See #ak.kernels.
    )Ú_impl)ÚarrayÚbackendr   r	   r
   © r   úc/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/operations/ak_to_backend.pyr      s    +r   c                 C  sX   t ||d�� }|j| ddd�}W d   ƒ n1 s20    Y  | t|ƒ¡}|j||d�S )N)r	   r
   TF)Zallow_recordZallow_unknown)r   )r   Úunwrapr   r   Úwrap)r   r   r   r	   r
   ÚctxZlayoutZbackend_layoutr   r   r   r   @   s    .r   )Ú
__future__r   Zawkward._backends.dispatchr   Zawkward._dispatchr   Zawkward._layoutr   Zawkward._nplikes.numpy_liker   Ú__all__ÚinstanceÚnpr   r   r   r   r   r   Ú<module>   s   0