
    bIg                    V    d dl mZ 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
y)	    )annotationsN)Base)expectc                   | j                   }|t        t        |            }n|D cg c]  }|dk\  r|n||z    }}t        |      }|dz  |j                  k7  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 c c}w )Nr      z9The number of elements in raw_pads should be 2 * num_axesconstant)	pad_widthmodeconstant_values)r	   r
   )ndimlistrangelensize
ValueErrornppad)dataraw_padsr
   r   axes
input_rankaxisnum_axesr	   _iys               \/var/www/html/answerous/venv/lib/python3.12/site-packages/onnx/backend/test/case/node/pad.pypad_implr      s,   J|E*%&EIJT	tj'88JJ4yH!|x}}$TUUI: q!fX	 8_ @Aw!8$D#A;X(>?	$	@ zFF+	
 
	A HA Ks   C(c                  T    e Zd Zedd       Zedd       Zedd       Zedd       Zy)Padc                    t         j                  j                  dg ddgd      } t        j                  j                  dddd	      j                  t        j                        }t        j                  g d
      j                  t        j                        }t        j                  d      }t        ||dd      }t        | |||g|gd       y )Nr    )xpadsvaluer   r   inputsoutputsr
               )r   r   r(   r)   r   r   r   r*   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_pad6   s    {{$$03%j % 
 IIOOAq!Q'..rzz:xx0188HH
 

3Qj#.tQe,qc@ST    c            	        dD ]  } t         j                  j                  dddgdg|       }t        j                  j                  ddd	d
      j                  t        j                        }t        j                  g d      j                  t        j                        }t        |||       }t        |||g|gd|  d        y )N)edgereflectwrapr    r"   r#   r   r%   r(   r)   r*   r+   )r   r   r(   r(   r   r   r(   r(   test__padr.   )r1   r2   r3   r   r4   r5   r6   int32r8   r9   r   r   )r
   r:   r"   r#   r   s        r   #export_reflection_edge_and_wrap_padz'Pad.export_reflection_edge_and_wrap_padD   s    / 
	QD;;((sFmcU ) D 		1a+22288<A8845<<D D$'A4D	A3uTF$=OP
	Qr<   c                    t         j                  j                  dg ddgd      } t        j                  j                  dddd	      j                  t        j                        }t        j                  g d
      j                  t        j                        }t        j                  d      }t        j                  ddgt        j                        }t        ||ddddg      }t        | ||||g|gd       y )Nr    r"   r#   r$   r   r   r   r%   r(   r)   r*   r+   r   r)   r   r*   r,   dtypetest_constant_pad_axesr.   r0   r:   r"   r#   r$   r   r   s         r   export_constant_pad_axeszPad.export_constant_pad_axesR   s    {{$$83%j % 
 IIOOAq!Q'..rzz:xx%,,HH
 

3xxAbhh/F
 	tUD)C)		
r<   c                    t         j                  j                  dg ddgd      } t        j                  j                  dddd	      j                  t        j                        }t        j                  g d
      j                  t        j                        }t        j                  d      }t        j                  ddgt        j                        }t        ||ddddg      }t        | ||||g|gd       y )Nr    rF   r   r   r%   r(   r)   r*   r+   rG   r,   rH   test_constant_pad_negative_axesr.   r0   rK   s         r   !export_constant_pad_negative_axesz%Pad.export_constant_pad_negative_axesl   s    {{$$83%j % 
 IIOOAq!Q'..rzz:xx%,,HH
 

3xxR1H
 	tUD)C2		
r<   N)returnNone)__name__
__module____qualname__staticmethodr;   rD   rL   rQ    r<   r   r    r    5   sT    U U Q Q 
 
2 
 
r<   r    )g        N)
__future__r   numpyr   r1   onnx.backend.test.case.baser   onnx.backend.test.case.noder   r   r    rX   r<   r   <module>r]      s*    #   , .%PO
$ O
r<   