o
    ih
                     @   s   d dl Zd dlZd dlZedejjedejjedejj	edejj	edejj
edejjedejjed	ejjiZeejj
eejjeejj	iZd
edejfddZdddZdd Zdd Zdd ZdS )    Nint32int16int8boolint64float32float64float16dtypereturnc                 C   sP   | dkrt jjS | dkrt jjS ztt j| W S  ty'   td|  dd w )NFP32FP16zUnknown data type string '')trtDataTypeFLOATHALFgetattrKeyError
ValueError)r
    r   S/home/ubuntu/.local/lib/python3.10/site-packages/tensorrt_bindings/plugin/_utils.py_str_to_data_type(   s   r   F, c                 C   s2   t | dkrdS d}|r|d7 }||| 7 }|S )Nr    r   )lenjoin)lstmiddledelimretr   r   r   
_join_with3   s   r!   c                 C   s&   t | tjkpt| do| jtjkS )N
__origin__)typing
get_originnpndarrayhasattrr"   
annotationr   r   r   _is_npt_ndarray?   s   &r*   c                 C   s   | t jkpt| S )N)r%   r&   r*   r(   r   r   r   _is_numpy_arrayB   s   r+   c                 C   s\   t | sJ t| p| j}t|dkr*t|d p|d j}t|dkr*|d S td)N      r   zImproper annotation for numpy array. Annotate numpy array attributes using 'numpy.typing.NDArray[dtype]', where 'dtype' is the expected numpy dtype of the array.)r*   r#   get_args__args__r   AttributeError)r)   
annot_argsnp_typer   r   r   _infer_numpy_typeE   s   r3   )Fr   )tensorrtr   numpyr%   r#   r
   PluginFieldTypeINT32INT16INT8INT64FLOAT32FLOAT64FLOAT16_numpy_to_plugin_field_typeintfloatr   _built_in_to_plugin_field_typestrr   r   r!   r*   r+   r3   r   r   r   r   <module>   s*   
