o
    toi                     @  sn   d dl mZ d dlZd dlmZ dddZG dd deZG d	d
 d
eZG dd deZ	G dd deZ
dS )    )annotationsN)OpRun        c                   s   | j  |d u rtt }n	 fdd|D }t|}|d t|kr'tddg  }t|D ]\}}|| }	|||  }
|	|
f||< q0|dkrVtj| |||d| j	S tj| ||d| j	S )	Nc                   s    g | ]}|d kr
|n|  qS )r    ).0axis
input_rankr   M/home/ubuntu/.local/lib/python3.10/site-packages/onnx/reference/ops/op_pad.py
<listcomp>   s     z_pad_impl.<locals>.<listcomp>   zGThe number of elements in raw_pads should be 2 times the number of axes)r   r   constant)	pad_widthmodeconstant_values)r   r   )
ndimlistrangelenRuntimeError	enumeratenppadastypedtype)dataraw_padsr   r   axesnum_axesr   ir   	pad_beginpad_endr   r   r
   	_pad_impl   s*   
r"   c                   @     e Zd ZdddZdS )Pad_1Nc                 C     |d u rd}t ||||dfS Nr   )r   r   r"   )selfr   paddingsr   valuer   r   r
   _run%      z
Pad_1._runNNN__name__
__module____qualname__r+   r   r   r   r
   r$   $       r$   c                   @  r#   )Pad_2Nc                 C  r%   r&   r'   )r(   r   padsr   r*   r   r   r
   r+   ,   r,   z
Pad_2._runr-   r.   r   r   r   r
   r3   +   r2   r3   c                   @  r#   )Pad_11Nc                 C  s    |d u rd}t ||||d dfS Nr   )r   r   r   r'   )r(   r   r4   constant_valuer   r   r   r
   r+   3      zPad_11._run)NNr.   r   r   r   r
   r5   2   r2   r5   c                   @  r#   )Pad_18Nc                 C  s    |d u rd}t |||||dfS r6   r'   )r(   r   r4   r7   r   r   r   r   r
   r+   <   r8   zPad_18._runr-   r.   r   r   r   r
   r9   ;   r2   r9   )r   N)
__future__r   numpyr   onnx.reference.op_runr   r"   r$   r3   r5   r9   r   r   r   r
   <module>   s   
	