
    Ng                     R    d dl Zd dlZd dlmZ d dlmZ ddZ G d de          ZdS )	    N)Base)expect        c                    | j         |t          t                              }nfd|D             }t          |          }|dz  |j        k    rt          d          g }t                    D ]
}|ddggz  }t          |          D ]+}||         }	|	dk     r|	z   }	||         |||z            g||	<   ,|dk    rt          j        | |||          }
|
S t          j        | ||          }
|
S )Nc                 *    g | ]}|d k    r|n|z   S )r    ).0axis
input_ranks     [/var/www/html/ai-engine/env/lib/python3.11/site-packages/onnx/backend/test/case/node/pad.py
<listcomp>zpad_impl.<locals>.<listcomp>   s*    JJJT		tj'8JJJ       z9The number of elements in raw_pads should be 2 * num_axesr   constant)	pad_widthmodeconstant_values)r   r   )ndimlistrangelensize	Exceptionnppad)dataraw_padsr   r   axesnum_axesr   _ir
   yr   s              @r   pad_implr#      sD   J|E*%%&&JJJJTJJJ4yyH!|x}$$STTTI:  q!fX		 8__ @ @Aw!88$D#A;X(>?	$zF+	
 
 
 
	 	 	A Hr   c                   n    e Zd Zedd            Zedd            Zedd            Zedd            ZdS )PadreturnNc                     t           j                            dg ddgd          } t          j                            dddd	                              t          j                  }t          j        g d
                              t          j	                  }t          j        d          }t          ||dd          }t          | |||g|gd           d S )Nr%   )xpadsvaluer"   r   inputsoutputsr               )r   r   r.   r/   r   r   r   r0   333333?test_constant_padr,   r-   nameonnxhelper	make_noder   randomrandnastypefloat32arrayint64r#   r   )noder(   r)   r*   r"   s        r   export_constant_padzPad.export_constant_pad5   s    {$$0003%j % 
 
 IOOAq!Q''..rz::x0001188H
 
 
3Qj#..tQe,qc@STTTTTTr   c            	         dD ]} t           j                            dddgdg|           }t          j                            ddd	d
                              t          j                  }t          j        g d                              t          j	                  }t          |||           }t          |||g|gd|  d           d S )N)edgereflectwrapr%   r(   r)   r"   r+   r.   r/   r0   r1   )r   r   r.   r.   r   r   r.   r.   test__padr4   )r7   r8   r9   r   r:   r;   r<   int32r>   r?   r#   r   )r   r@   r(   r)   r"   s        r   #export_reflection_edge_and_wrap_padz'Pad.export_reflection_edge_and_wrap_padC   s    / 
	Q 
	QD;((sFmcU )  D 	1a++2228<<A844455<< D D$''A4D	A3=OT=O=O=OPPPPP
	Q 
	Qr   c                     t           j                            dg ddgd          } t          j                            dddd	                              t          j                  }t          j        g d
                              t          j	                  }t          j        d          }t          j        ddgt          j	                  }t          ||ddddg          }t          | ||||g|gd           d S )Nr%   r(   r)   r*   r   r"   r   r+   r.   r/   r0   r1   r   r/   r   r0   r2   dtypetest_constant_pad_axesr4   r6   r@   r(   r)   r*   r   r"   s         r   export_constant_pad_axeszPad.export_constant_pad_axesQ   s   {$$8883%j % 
 
 IOOAq!Q''..rz::x%%,,H
 
 
3xAbh///F
 
 	tUD)C)		
 	
 	
 	
 	
 	
r   c                     t           j                            dg ddgd          } t          j                            dddd	                              t          j                  }t          j        g d
                              t          j	                  }t          j        d          }t          j        ddgt          j	                  }t          ||ddddg          }t          | ||||g|gd           d S )Nr%   rK   r"   r   r+   r.   r/   r0   r1   rL   r2   rM   test_constant_pad_negative_axesr4   r6   rP   s         r   !export_constant_pad_negative_axesz%Pad.export_constant_pad_negative_axesk   s   {$$8883%j % 
 
 IOOAq!Q''..rz::x%%,,H
 
 
3xR111H
 
 	tUD)C2		
 	
 	
 	
 	
 	
r   )r&   N)__name__
__module____qualname__staticmethodrA   rI   rQ   rV   r   r   r   r%   r%   4   s        U U U \U Q Q Q \Q 
 
 
 \
2 
 
 
 \
 
 
r   r%   )r   N)	numpyr   r7   onnx.backend.test.case.baser   onnx.backend.test.case.noder   r#   r%   r   r   r   <module>r^      s   
      , , , , , , . . . . . .% % % %PO
 O
 O
 O
 O
$ O
 O
 O
 O
 O
r   