
    9j                     6   d dl Z d dlmZ d dlZddlmZ ddlmZmZ ej                  j                  j                         r;	 	 	 ddee   dedee   dz  d	ed
ee   f
dZdee   d
ee   fdZdee   d
ee   fdZy	 	 	 ddee   dedee   dz  d	ed
ee   f
dZy)    N)Sequence   )MACOS_VERSION)DecorateInfoOpInfoopsdevice_typexfail_exclusionsparsereturnc                 X+   |g }h d}dt         j                  gi}i dd dd dd dd dd dd d	d d
d dd dd dd dd dd dd dd dd dd i dd dd dt         j                  gdt         j                  gdt         j                  gdd dd dd dt         j                  t         j                  t         j
                  t         j                  t         j                  gdt         j                  gdd dt         j                  gd t         j                  t         j                  t         j                  t         j                  t         j
                  gd!d d"t         j                  t         j
                  t         j                  t         j                  t         j                  gd#t         j                  t         j
                  t         j                  t         j                  t         j                  gd$t         j                  t         j
                  t         j                  t         j                  gi d%t         j                  t         j                  t         j                  t         j                  t         j
                  gd&d d'd d(t         j                  t         j
                  gd)t         j
                  t         j                  t         j                  t         j                  t         j                  gd*t         j                  t         j                  t         j                  t         j                  t         j
                  gd+d d,t         j                  t         j
                  t         j                  t         j                  t         j                  t         j                  gd-t         j                  t         j
                  t         j                  t         j                  t         j                  t         j                  gd.d d/d d0t         j                  gd1d d2t         j                  t         j                  t         j
                  t         j                  t         j                  gd3t         j                  t         j
                  t         j                  t         j                  t         j                  gd4t         j                  t         j                  t         j                  t         j                  t         j
                  t         j                  gd5t         j                  gi d6t         j                  gd7t         j                  t         j
                  t         j                  t         j                  t         j                  t         j                  gd8t         j                  t         j
                  t         j                  t         j                  t         j                  t         j                  gd9t         j                  t         j
                  t         j                  t         j                  t         j                  t         j                  gd:t         j                  t         j
                  t         j                  t         j                  t         j                  t         j                  gd;t         j                  t         j
                  t         j                  t         j                  t         j                  t         j                  gd<t         j                  t         j
                  t         j                  t         j                  t         j                  t         j                  gd=t         j
                  t         j                  t         j                  t         j                  t         j                  gd>d d?t         j                  t         j                  t         j
                  t         j                  t         j                  gd@t         j                  t         j                  t         j
                  t         j                  gdAt         j                  t         j
                  t         j                  t         j                  t         j                  t         j                  gdBt         j                  gdCd dDt         j                  gdEd dFt         j                  t         j
                  t         j                  t         j                  gi dGt         j
                  t         j                  t         j                  t         j                  t         j                  gdHd dId dJt         j                  t         j                  t         j                  t         j
                  t         j                  gdKt        dLk  r t         j
                  t         j                  gnt         j                  gdMt        dLk  r t         j
                  t         j                  gnt         j                  gdNt         j                  gdOd dPd dQd dRd dSd dTd dUd dVd dWd dXd i dYd dZd d[d d\d d]d d^d d_t         j                  t         j                  gd`d dad dbd dcd ddt         j                  t         j                  t         j
                  t         j                  t         j                  gdet         j                  t         j                  t         j
                  t         j                  t         j                  gdft         j                  t         j                  t         j
                  t         j                  t         j                  gdgt         j                  t         j                  t         j
                  t         j                  t         j                  gdhd dit         j                  gi djt         j                  gdkd dld dmt         j                  t         j                  t         j
                  t         j                  t         j                  t         j                  gdnd dod dpd dqd drd dst         j                  gdtt         j                  gdut         j                  gdvt         j                  gdwt         j                  t         j                  gdxt         j                  t         j                  t         j                  gdyt         j                  t         j
                  t         j                  t         j                  t         j                  gdzt         j                  t         j
                  t         j                  t         j                  t         j                  gd{t         j                  t         j
                  t         j                  t         j                  t         j                  gi}d d d d d d|}t        dLk  r|j                  d d d}       |r|j                  |       i d~t         j                  t         j
                  t         j                  t         j                  t         j                  gdt         j                  t         j                  t         j                  gdt         j                  t         j                  t         j                  gdt         j                  t         j                  t         j                  gdd dd dd dd dt         j                  t         j                  t         j                  gdt         j                  t         j                  t         j                  gdt         j                  t         j                  t         j                  gdt         j                  t         j                  t         j                  gdt         j                  t         j                  t         j                  t         j
                  t         j                  t         j                  t         j                  t         j                  gdt         j                  t         j                  t         j                  gdt         j                  t         j                  t         j                  gdt         j                  t         j                  t         j                  gdt         j                  t         j                  t         j                  gt         j                  t         j                  t         j                  gt         j                  t         j                  t         j                  t         j                  gt         j                  t         j                  t         j                  gt         j                  t         j                  t         j                  gt         j                  t         j                  t         j                  gt         j                  t         j                  t         j
                  t         j                  gt         j                  t         j                  t         j                  gt         j                  t         j                  t         j                  gt         j                  t         j                  t         j
                  t         j                  t         j                  t         j                  gd t         j                  t         j                  t         j                  gd}d t         j                  gt         j                  t         j                  t         j                  t         j                  t         j                  gt         j                  t         j                  t         j                  t         j                  t         j                  gd}	d d d d d d d}
dud i}dt        dt        dd ffd}| D ]  }|j                  |j                   z   } ||t        t"        j$                  t         j&                  t         j(                  g             |r6 ||t        t#        j*                  d      t         j,                  g             ||
v r* ||t        t#        j*                  d      |
|                ||v r* ||t        t#        j*                  d      ||                |||	fD ]1  }||v s||vs ||t        t"        j$                  ||                3 ||v r2||vr.t        dk  r% ||t        t"        j$                  ||                ||vsf ||t        t"        j$                  t         j.                  t         j                  g              | S )N>3  fft.fftfft.fft2fft.fftnfft.hfftfft.ifft	fft.hfftn	fft.ifft2	fft.ifftn	fft.irfft
fft.irfft2
fft.irfftn
linalg.svd
masked.std
masked.sum
masked.varlinalg.pinvmasked.meanmasked.prodfft.fftshiftlinalg.crossspecial.entrfft.ifftshiftlinalg.vanderlinalg.vecdotmasked.cumsummasked.cumprodlinalg.diagonalspecial.xlog1pylinalg.multi_dotmasked.logsumexpmasked.normalizelinalg.vector_normnn.functional.unfoldnn.functional.l1_lossnn.functional.rms_normnn.functional.softsignnn.functional.normalizenn.functional.padreflectnn.functional.tanhshrinknn.functional.padcircularnn.functional.padconstantnn.functional.padreplicatenn.functional.pixel_shufflespecial.spherical_bessel_j0nn.functional.pixel_unshufflenn.functional.softminwith_dtype!nn.functional.triplet_margin_loss/nn.functional.triplet_margin_with_distance_loss0nn.functional.feature_alpha_dropoutwithout_trainHTteqmHmTmmmvneabsaddallanybmmcatcoscovdivdotexpeyeintlogmulnegsgnsinsubsumsvdtanacosasinatanboolbytecharconjcoshdiagdiffdistexp2fillflipfullhalfimagitemkronlerplog2longmeannormonesprodrealrollrsubsincsinhsqrtstfttanhtiletriltriuvdotviewacoshaddmvangleasinhatanhchalfchunkclonecrossemptyequalexpm1floatinnerisinfisnanistftldexplog10log1pouterrandnravelrot90rsqrtshortslicesplitstacktracetrapzwherezero_zerosaddbmmcfloatcumsumdsplitdstackeinsumexpandfliplrflipudgatherhsplithstackisrealmatmulnarrowrepeatselectsquaret_copyunbindunfoldvsplitvstackaddcdivaddcmulbaddbmmcumprodflattenisclosemovedimnonzeronormfronorminfpermutereshapescattersigmoidsqueezeview_as__radd____rdiv____rmul____rsub__allcloseargwherebfloat16corrcoefdiagflatdiagonalgradientisfinitelinspacenew_fullnew_onespinversepositive	expand_as	full_like	index_add	index_put	logaddexp	logsumexp	new_zeros	ones_like	tensordot	transpose	trapezoid	unflatten	unsqueeze	view_copy
_chunk_cat
alias_copy
as_strided
atleast_1d
atleast_2d
atleast_3d
block_diag
contiguous
diag_embed
index_copy
index_fill
logaddexp2
logical_or
reciprocal
reshape_as
zeros_like__getitem____rmatmul__expand_copylogical_andlogical_notlogical_xormasked_fillnarrow_copyresolve_negscatter_addsum_to_sizetrue_divideunbind_copyunfold_copybroadcast_tocolumn_stackcombinationsindex_selectlogcumsumexppermute_copyresolve_conjsqueeze_copytensor_splitunsafe_chunkunsafe_splitview_as_realconj_physicalcount_nonzerodiagonal_copyempty_stridedmasked_selectscalar_tensorcartesian_prodempty_permutedmasked_scatternonzero_staticsplitlist_argstake_along_dimtranspose_copyunsqueeze_copyaddmmdecomposedas_strided_copyconstant_pad_ndsqueezemultiplediagonal_scattersplit_with_sizesbroadcast_tensorsrepeat_interleavesoftmaxwith_dtypeas_strided_scatterdivno_rounding_mode_unsafe_masked_indexcumulative_trapezoidsplit_with_sizes_copylinspacetensor_overloadmeshgridlist_of_tensorsmeshgridvariadic_tensors#_unsafe_masked_index_put_accumulate	fft.hfft2special.zetann.functional.conv1dnn.functional.conv2dnn.functional.linearlinalg.householder_productnn.functional.conv_transpose1dnn.functional.conv_transpose2dnn.functional.conv_transpose3dnn.functional.pairwise_distancer7  logspacelogspacetensor_overload
linalg.eiglinalg.eigvalsputfrexpgeqrfznn.functional.grid_samplehash_tensor	heavisidelcmzlinalg.condzlinalg.eighzlinalg.eigvalshzlinalg.ldl_factorzlinalg.ldl_factor_exzlinalg.ldl_solvezlinalg.lstsqzlinalg.lstsqgrad_orientedzlinalg.matrix_normzlinalg.normzlinalg.normsubgradients_at_zerozlinalg.svdvalszmasked.median
matrix_exp max_pool2d_with_indices_backwardmedianmode	nanmediannative_batch_normnormnucznn.functional.avg_pool1dznn.functional.avg_pool2dznn.functional.avg_pool3dznn.functional.batch_normz#nn.functional.fractional_max_pool2dz#nn.functional.fractional_max_pool3dznn.functional.group_normznn.functional.gluznn.functional.huber_lossz!nn.functional.adaptive_avg_pool3dz!nn.functional.adaptive_max_pool1dz!nn.functional.adaptive_max_pool2dz!nn.functional.adaptive_max_pool3dznn.functional.interpolateareaz nn.functional.interpolatebicubicznn.functional.ctc_lossz!nn.functional.local_response_normznn.functional.logsigmoidznn.functional.max_pool1dznn.functional.max_pool2dznn.functional.max_pool3dznn.functional.max_unpool1dznn.functional.max_unpool1dgradznn.functional.max_unpool2dznn.functional.max_unpool2dgradznn.functional.max_unpool3dznn.functional.max_unpool3dgradznn.functional.mishznn.functional.multi_margin_lossz$nn.functional.multilabel_margin_lossz)nn.functional.multilabel_soft_margin_lossznn.functional.nll_lossz#nn.functional.padreplicate_negativeznn.functional.pdistznn.functional.reluznn.functional.rreluznn.functional.siluznn.functional.softplusznn.functional.normormqrrounddecimals_0scatter_reduceamaxg      .@scatter_reduceaminscatter_reducemeansegment_reducez_segment.reducezsegment.reducesegment_reduce_offsets_segment_reduce_offsets_segment_reduce_lengths_segment_reducelengths_segment_reduceoffsetsz	sparse.mmzsparse.sampled_addmmsparse.mmreducezspecial.airy_aizspecial.laguerre_polynomial_lzspecial.legendre_polynomial_pzspecial.log_ndtrzspecial.ndtrir~   svd_lowranksymeigtaketovar_meanunbiasedvar_meanstd_meanstd_meanunbiasedsegment_reduce__upsample_bilinear2d_aa_upsample_bicubic2d_aacdoubledoublelog_softmaxwith_dtypefloat_powerzlinalg.matrix_rankhermitianzlinalg.pinvhermitianz!nn.functional.adaptive_avg_pool1dz!nn.functional.adaptive_avg_pool2dr9  r:  nn.functional.conv3dr=  r>  r?  r;  matbincount)rA  rB  rC  rD  rE  )quantilenanquantiletopkmultinomialuniform	rand_likerandintrandint_liker   
randn_like	bernoulliexponential
log_normalcauchy	geometricz-nn.functional.feature_alpha_dropoutwith_trainnormalnormalin_placenormalnumber_mean)znn.functional.alpha_dropoutznn.functional.dropoutznn.functional.dropout2dznn.functional.dropout3dz*nn.functional.multi_head_attention_forward__rpow__resize_
resize_as_addras_stridedpartial_viewsz*nn.functional.scaled_dot_product_attention)linalg.matrix_rankarangeargsortsort)	new_emptynew_empty_stridedr  r   
empty_liker  opdr   c                 B    |_         | j                  |fz   | _        y N)r	   
decorators)r  r  r	   s     b/media/conek/DATA/Code/OCR/venv/lib/python3.12/site-packages/torch/testing/_internal/common_mps.pyaddDecoratorz&mps_ops_modifier.<locals>.addDecoratorD  s"    & +MMQD0BM    dtypesz4Skipped due to MPS not supporting complex128 tensorszSkipping empty ops.zSkipped!g,@)torch	complex64float32int8int16int32int64uint8ra   r   float16r   updater   r   namevariant_test_nameunittestexpectedFailurerj  ri  skip
complex128	complex32)r   r	   r
   r   SUPPORTED_COMPLEX_OPSMACOS_BEFORE_14_4_XFAILLISTUNIMPLEMENTED_XFAILLISTUNIMPLEMENTED_XFAILLIST_SPARSEUNDEFINED_XFAILLISTON_MPS_XFAILLISTEMPTY_OPS_SKIPLISTSKIPLISTr  r  key	xfaillists    `              r  mps_ops_modifierr     s5    " Ot!
p	 %//*'
#J;
J;
 &tJ;
 $	J;

 dJ;
 4J;
 TJ;
 TJ;
 (J;
 4J;
 J;
 4J;
 4J;
 4J;
  t!J;
"  #J;
$ #D%J;
& 'J;
( D)J;
* (+J;
, !5==/-J;
. EMM?/J;
0 .1J;
2 d3J;
4 T5J;
6 $7J;
8 /

19J;
F uzzlGJ;
H DIJ;
J %**KJ;
L  



"MJ;
Z t[J;
\ '



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-u}}enn'U ; U[[%++u{{Ku}}ennE ==%--H 



 (, ;o\7
B #'{{m 



 



3 4
L !%! "
$ #D
	1V 	1 	1 	1  F	B''B000C,,	    R ",, 	
 ((  &;<1#6 hX]]:%>xPS}U (#  		
 )#?(B $X%=%=iPSnU	 22."T)  00:3? //  00 %AAF	P 
r  c                 	   i dt         j                  t         j                  gdt         j                  t         j                  gdd dd dt         j                  gdd dt         j                  t         j                  gdt         j                  t         j                  gd	d d
t         j                  t         j                  gdd dd dd dd dt         j                  gdt         j                  gdt         j                  gi dt         j                  t         j                  gdt         j                  t         j                  gdt         j                  t         j                  gdt         j                  t         j                  gdd dd dt         j                  t         j                  gdt         j                  t         j                  gdt         j                  t         j                  gdt         j                  t         j                  gdt         j                  t         j                  gdt         j                  t         j                  gdt         j                  t         j                  gdt         j                  gd t         j                  gd!t         j                  gd"t         j                  gt         j                  gt         j                  gt         j                  gt         j                  gt         j                  gt         j                  gt         j                  gt         j                  t         j                  gd d d#
}t         j                  gt         j                  gt         j                  gt         j                  gt         j                  gt         j                  gt         j                  gd$}d t         j                  gd%}d&t        d't        d(d fd)}| D ]  }|j
                  |j                  z   }||v r% ||t	        t        j                  ||   *             ||v r% ||t	        t        j                  ||   *             ||v ss ||t	        t        j                  ||   *              | S )+N_segment_reducer   rg  rh  r]  r<  unique_consecutiver  cdistzmasked.scattergrid_sampler_2dgrid_sampler_3digammaigammacz
special.i1zspecial.i1emsortrz  r{  r|  r}  r8  	nextafterfloor_dividehistogramdd	histogramr   r   ro   r   zsignal.windows.bartlettzsignal.windows.blackmanzsignal.windows.cosinezsignal.windows.exponential)
zsignal.windows.gaussianzsignal.windows.general_cosinezsignal.windows.general_hammingzsignal.windows.hammingzsignal.windows.hannzsignal.windows.kaiserzsignal.windows.nuttallrS   	to_sparseunique)r@  r9  r:  rm  r=  r>  r?  )r  rm  r  r  r   c                 .    | j                   |fz   | _         y r  r  r  r  s     r  r  z+mps_ops_grad_modifier.<locals>.addDecorator      MMQD0BMr  r  )
r  r  r  r   r   r  r  r  r  r  )r   XFAILLIST_GRADSKIPLIST_GRADr  r  r  r  s          r  mps_ops_grad_modifierr    s5   ?
u}}=?
 5==%--8?
 &t	?

 %d?
 ?
 )$?
 !5==%--"@?
 emmU]];?
 T?
 u}}emm<?
 t?
 t?
 d?
 t?
  5==/!?
" EMM?#?
. emm_/?
2 EMM5==93?
4 5==%--85?
6 u}}emm47?
8 %--79?
> D??
B C?
F U]]EMM:G?
J EMM5==9K?
N %--7O?
R 6S?
T emmU]]3U?
X U]]EMM2Y?
\ emmU]]3]?
^ &_?
` &a?
b $emm_c?
d )5==/e?
f )..3mm_/4}}o',}}o$)MM?&+mm_',}}oMM5==1}?
D 16%*]]O%*]]O%*]]O/4}}o/4}}o/4}}o	
 #'%*]]O
	1V 	1 	1 	1  	B''B000Cn$ !9!9.QTBUV
 m#RhmmMRUDV!WX&&  009I#9N	& 
r  c                     h d}dt         dt        dd fd}| D ]@  }|j                  |j                  z   }||v s! ||t        t        j
                               B | S )N>	   amaxaminaminmax__rmod__r  r   	clamp_max	clamp_minr  r  r  r   c                 .    | j                   |fz   | _         y r  r  r  s     r  r  z3mps_ops_error_inputs_modifier.<locals>.addDecorator  r  r  )r   r   r  r  r  r  )r   	XFAILLISTr  r  r  s        r  mps_ops_error_inputs_modifierr    sn    
		1V 	1 	1 	1  	IB''B000CiRh.F.F!GH	I
 
r  c                     | S r   )r   r	   r
   r   s       r  r  r    s	     
r  )mpsNF)r  collections.abcr   r  common_utilsr   opinfo.corer   r   backendsr  is_availablestrlistra   r  r  r  r  r  r  <module>r     s    $  ' - 	>>""$ !,0	FfFF cT)F 	F
 
&	FPk8F#3 k8H kZ8F+; @P : !,0	f cT) 	
 
&	r  