
    Ph                        d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
mZmZmZmZmZmZmZ d dlZd dlZd dlmc mZ d dlmZ d dlmZ d dlmZ d dlmZ d dl m!Z!m"Z"m#Z# de$fd	Z%d
ejL                  de'fdZ(dddejR                  jT                  deedf   dee$ef   de'def
dZ+dddejR                  jT                  deedf   dee$ef   de'ddf
dZ,dddejR                  jT                  deedf   dee$ef   de'ddf
dZ-dddejR                  jT                  deedf   dee$ef   de'de'defdZ.dedefdZ/e+e,e- ej`                  e.d       ej`                  e.d      dZ1dZ2g dZ3dde3fded ee$   d!ee$   d"ee$ef   d#ee$   ddfd$Z4d% Z5d&Z6d!e$ddfd'Z7d(d)d#ee$   deddfd*Z8de'fd+Z9 ejt                         Z;de;_<        d, Z= G d- d.e      Z>dAd/Z?	 dBd0dd1dejR                  j                  deedf   deee$ef      d#ee$ee$   f   d2e'dee$e$f   fd3ZA G d4 d5eB      ZCdd6d7e$dejR                  jT                  deedf   dee$ef   d8e'd9e'de$fd:ZDdejR                  j                  dejR                  jT                  fd;ZFd<dd=ZGee$ee$ee$e$f   f   f   ZHd>ZId?e2 ZJ G d@ d)      ZKy)C    N)AnyCallableDictListOptionalTupleUnion)clone_input)SchemaCheckMode)get_file_path_2)TorchFunctionMode)aot_autograd_checkautograd_registration_check
fake_checkreasonc                     d }|S )Nc                     d| _         | S )NT)"_torch_dont_generate_opcheck_tests)funs    yC:\Users\daisl\Desktop\realtime-object-detection\venv\Lib\site-packages\torch/testing/_internal/optests/generate_tests.pyinnerz'dontGenerateOpCheckTests.<locals>.inner   s    15.
     )r   r   s     r   dontGenerateOpCheckTestsr      s     Lr   tensorreturnc                 r    | j                   ryt        j                  j                  j	                  |       ryy)NTF)is_metatorch_subclassesfake_tensoris_fake)r   s    r   is_abstractr#   %   s,    ~~$$,,V4r   Tcopy_inputsopargs.kwargsr%   c                    |rt        ||f      \  }}t        j                  t        j                  t
        ||f      ry t               5   | |i |}|cd d d        S # 1 sw Y   y xY wN)deepcopy_tensorspytreetree_any_onlyr   Tensorr#   r   )r&   r'   r(   r%   results        r   safe_schema_checkr0   -   sZ     'v7fELL+f~F		T$V$ 
		s   	
AA&c                    t        j                  t        j                  t        ||f      ry |rt        ||f      \  }}t        j                  t        j                  d ||f      sy t        | ||      S )Nc                     | j                   S r*   )requires_grad)xs    r   <lambda>z2safe_autograd_registration_check.<locals>.<lambda>J   s    r   )r,   r-   r   r.   r#   r+   r   r&   r'   r(   r%   s       r    safe_autograd_registration_checkr7   =   sh     ELL+f~F'v7f/$ 	&r488r   c                    t        j                  t        j                  t        ||f      ry |rt        ||f      \  }}t        | ||      S r*   )r,   r-   r   r.   r#   r+   r   r6   s       r   safe_fake_checkr9   P   sE     ELL+f~F'v7fb$''r   dynamicc                     t        j                  t        j                  t        ||f      ry  fd}t        ||||d      S )Nc                      t        j                  t        j                  t        j                  | |f      \  } } | i |S r*   )r,   tree_map_onlyr   r.   clone)r'   r(   r&   s     r   funcz%safe_aot_autograd_check.<locals>.funck   s7    ++ELL%++f~Vf4"6""r   auto)check_gradients)r,   r-   r   r.   r#   r   )r&   r'   r(   r:   r%   r?   s   `     r   safe_aot_autograd_checkrB   ^   s<     ELL+f~F# dD&'6RRr   inputsc                 T    t        j                  t        j                  t        |       S r*   )r,   r=   r   r.   r
   )rC   s    r   r+   r+   t   s    k6BBr   F)r:   )test_schematest_autograd_registrationtest_faketensortest_aot_dispatch_statictest_aot_dispatch_dynamiczThttps://docs.google.com/document/d/1Pj5HRZvdOq3xpFpbEjUZp2hBovhy7Wnxw14m6lF2154/edittestcase
namespacesfailures_dict_pathadditional_decorators
test_utilsc           	          i t               D cg c]*  }|j                  d      rt        t         |            r|, }}_t	        j
                         j                  }t	        j                  |      d   }t        t        j                  j                  |      d      t        j                  t                     t        |        t!                fd}	|D 
ci c]  }
|
t"        |
    }}
|D ]$  }|j%                         D ]  \  }} |	|||        & t'                yc c}w c c}
w )a  Given an existing TestCase, use the existing tests to generate
    additional validation tests for custom operators.

    For {all existing tests in the TestCase} x {all test utils},
    we will generate one new test. The new test runs a TorchFunctionMode
    that intercepts ``op(*args, **kwargs)`` calls and invokes
    ``test_util(op, *args, **kwargs)``, where ``op`` is an operator.

    The test_util that we support are in ALL_TEST_UTILS. They are:
    - test_schema: This runs SchemaCheckMode.
    - test_autograd_registration: This runs autograd_registration_check.
    - test_faketensor: This runs CrossRefFakeMode.
    - test_aot_dispatch_static: This runs aot_autograd_check, which:
        checks that the outputs (and gradients, if they are computable)
        are the same under eager-mode PyTorch and using AOTAutograd.
    - test_aot_dispatch_dynamic: Same as aot_dispatch_static, but
        runs AOTAutograd using dynamic shapes instead of static shapes.

    The generated test will have name ``{test_util}__{original_name}``.
    For example, if there is a method named ``test_cumsum``, then
    we will generate a ``test_schema__test_cumsum``,
    ``test_faketensor__test_cumsum``, etc.

    For more details, see https://docs.google.com/document/d/1Pj5HRZvdOq3xpFpbEjUZp2hBovhy7Wnxw14m6lF2154/edit

    Args:
        testcase: The testcase we will modify and generate additional tests for.
        namespaces: We will only intercept calls to custom operators with these
                    namespaces.
        failures_dict_path: See ``validate_failures_dict_structure`` for more details
        test_utils: a list of test_utils to generate. Example: ["test_schema", "test_faketensor"]
    Ntest_r   zfailures_dict.jsoncreate_filec                 4   t        |       t        dd      ry dz   | z   t        j                        fd       }|j                  j	                  d      x}rdd l}d}|D ]+  }t        ||j                        s|j                  dk(  s*d}- |rg }|D ]  }t        ||j                        ru|j                  d	k(  rf|j                  \  }	}
|j                  rJ d
       |	dk7  r?|j                  |j                  j                  |	t        t        |
            f             |j                  |        ||j                  d<   v r   D ]
  } ||      } t!              rt#        d d d d      t%        |       y )Nr   F__c            	          t        
	j                   d       5   | i |}d d d        |S # 1 sw Y   S xY w)N.)OpCheckMode__name__)r'   r(   r/   failures_dictrL   methodrK   new_method_nameprefixrJ   testers      r   
new_methodzDgenerate_opcheck_tests.<locals>.construct_method.<locals>.new_method   sZ    $$%Q&78"  00 M Ms   	4>
pytestmarkr   opcheck_only_oneTparametrizeNYIdevicezTried to autogenerate z but z already has method named z4. Please rename the original method on the TestCase.)getattr	functoolswraps__dict__getpytest
isinstanceMarknamer'   r(   appendmarkra   nextiterhasattrRuntimeErrorsetattr)attrr\   r]   r^   r_   ri   r`   rn   new_pytestmarkargnames	argvaluesdecrZ   r[   rM   rY   rL   rK   rJ   s    ``         @@r   construct_methodz0generate_opcheck_tests.<locals>.construct_method   s   4(6?G 4-$.		 
	 
	 
!
	 $,,00>>:>  %"dFKK0TYYBT5T'+$ #  !#&D!$4m9S.2ii+)#';;55 $x/*11 & 7 7$,tDO/D.F!"
 %"))$/ ' 5C
##L133,_= _
 > 8_-((9xj I$$3#4 5*+ 
 	/:6r   )dir
startswithcallablerd   inspectcurrentframef_backgetframeinfor   ospathdirnameFailuresDictloadshould_update_failures_dict validate_failures_dict_structure!validate_failures_dict_formattingALL_TEST_UTILSitemsgenerate_tag_tests)rJ   rK   rL   rM   rN   mtest_methods
prev_framefilenamery   rl   rt   r\   r]   rY   s   ````          @r   generate_opcheck_testsr      sO   N $ " XA<< Xgh.B%C 	
  
 ! ))+22
''
3A6,GGOOH%';
 !%%(C(E & M %]JI%&8997 97v :DD$t,,JD(..0NFFT662 1  x0EFg\ Es   /D7-D<c                    d }|j                   j                         D ]  \  }}|j                         D cg c]  \  }}d|vr
|d   dk(  r| }}}t        |      dkD  }	 |||	|      }
|j                  dd      j                  dd      }d	|z   }||v r||   D ]
  } ||
      }
 t	        | |      rt        d
| d      t        | ||
        y c c}}w )Nc                       fd}|S )Nc                 (   	 t         j                  j                  j                        }t         j                  j                  |j                  v }|sy sy t        d d d      # t        $ r}t        j                  d       |d }~ww xY w)NzCan't import operator zop 'za' was tagged with torch.Tag.pt2_compliant_tag but it failed some of the generated opcheck tests (z?). This may lead to silent correctness issues, please fix this.)r   _libraryutils	lookup_opAttributeErrorunittestSkipTestTagpt2_compliant_tagtagsAssertionError)selfr&   eop_marked_as_compliantdefinitely_not_pt2_compliantqualnamexfailed_testss       r   r   z8generate_tag_tests.<locals>.generate_test.<locals>.inner  s    T^^))33H= &+YY%@%@BGG%K")/ xj !!? ##$  " T''*@
(KLRSSTs   )A* *	B3BBr   )r   r   r   r   s   ``` r   generate_testz)generate_tag_tests.<locals>.generate_test  s    	$ r   rH   statusxfailr   ::_rV   test_pt2_compliant_tag_zTried to generate a test named z, but it exists already. This could be because of a name collision (where we generated two tests with the same name), or where we generated a test with the same name as an existing test.)datar   lenreplacerq   rr   rs   )rJ   rY   rM   r   r   	test_dictteststatus_dictr   r   	generatedmangled_qualname	test_name	decorators                 r   r   r     s   *  -11779) &/__%6
%6!k *5H%0 %6 	 
 (+='9A'=$!(,H-X	 $++D#6>>sCH-0@@	 --29=	%i0	 > 8Y'1) =K L  	)Y/;  :
s   C)r   skipxsuccessc                    t        |       5 }|j                         }d d d        t        j                  |       }|j	                  d      }|k(  ry t               r&t        j                  |       }|j                          y |j                  d      }|j                  d      }t        j                  ||      }dj                  |      }t        d| d      # 1 sw Y   xY w)NT)to_str    
z

Expected the failures dict to be formatted a certain way. Please see the above diff; you can correct this either manually or by re-running the test with PYTORCH_OPCHECK_ACCEPT=1)openreadr   r   _saver   save
splitlinesdifflibunified_diffjoinrr   )rL   fpactualrY   expecteddiffs         r   r   r   P  s    	 	!R 
" %%&89M""$"/H"$$))*<=""1%Hq!F1D774=D

TF # 	$  
"	!s   CC#failure_dictr   c                    | j                   } t        | j                               }| j                         D ]E  }t        |j                               }|j	                         D ]  \  }}t        |j                               t        ddh      k7  rt        d      |d   }|t        vrt        d| dt               |j                  d      \  }	t        fd|D              st        d| d	|       |D ]}  }
j                  |
      st        |
      d
z   d }t        j                  dd|      }|j                  |	k7  rMt        ||      rZt        d| d|
 d| d| d|j                   d        H y)a  Validates the failures dict.

    The failure dict looks something like the following.
    It maps operator name (qualname) to a list of autogenerated tests.
    Each autogenerated test may have a check for the operator (if the operator is
    called by the test); the dictionary specifies if we should skip the check,
    or if we expect some check to fail.

    {
        "fbgemm::split_lengths": {
            "test_schema__test_split_lengths": {
                "comment": "you can put whatever you want into the comment section",
                "status": "xfail",
            }
            "test_schema__test_split_lengths_empty": {
                "comment": "",
                "status": "skip",
            },
        },
        "fbgemm::gather_lengths": {
            "test_schema__test_gather_lengths": {
                "comment": "",
                "status": "skip",
            },
        },
    }

    commentr   zGin failures_dict, expected sub-dict to have keys 'comment' and 'status'zIn failures_dict, got status=z but it needs to be in rV   c              3   @   K   | ]  }j                  |        y wr*   )r{   ).0r   actual_test_names     r   	<genexpr>z3validate_failures_dict_structure.<locals>.<genexpr>  s     PZT'2248Zs   zIn failures_dict, test name 'z' should begin with one of    Nz\[.*\]r   z!In failures dict, got test name 'z#'. We parsed this as running test 'z' on 'z', but z! does not exist on the TestCase 'z*]. Maybe you need to change the test name?)r   listkeysvaluesr   setrr   TEST_OPTIONSsplitanyr{   r   resubrX   rq   )r   rN   rJ   	qualnamestest_to_option
test_namesr   r   test_option
test_classr   base_test_namer   s               @r   r   r   g  s   >  $$L\&&()I&--/.--/0
$2$8$8$: Iy9>>#$Y,A(BB"]  $H-K,."3K=@WXdWef  ,5??3+?(J(PZPP"3I;>YZdYef  #'2248!1#d)a-/!B!#	2~!F$$
28^4"7	{ C%%)F&0@%&&GHYHYGZ [>?  # %; 0r   c                  Z    d} | t         j                  v xr t         j                  |    dk(  S )NPYTORCH_OPCHECK_ACCEPT1r   environ)keys    r   r   r     s(    
"C"**7CC!77r   c                  "    t         j                  S r*   )_is_inside_opcheck_modevaluer   r   r   is_inside_opcheck_moder     s    "(((r   c                   h     e Zd ZdZdee   dededddedefd	Zdd
Z fdZ	 fdZ
d ZddZ xZS )rW   z
    For a given test, OpCheckMode intercepts calls to operators and runs
    test_util(op, args, kwargs) for each intercepted (op, args, kwargs).
    rK   test_util_name	test_utilrY   r   r   rL   c                 f    || _         || _        || _        || _        || _        || _        i | _        y r*   )rK   r   r   r   rY   rL   seen_ops_to_errors)r   rK   r   r   rY   r   rL   s          r   __init__zOpCheckMode.__init__  s?     % #," +"4 #%r   c                    | j                   j                         D ]  }| j                  j                  || j                        }t        | j                   |         dk(  sEt               r*| j                  j                  || j                  dd       n4|dk(  r/t        d| d| j                   d| j                   d	t                g }| j                   j                         D ][  }| j                  j                  || j                        }|dk7  r/t        | j                   |         dk(  rK|j                  |       ] |sy t               r/|D ])  }| j                  j                  || j                  d       + y | j                   |d      d   \  }}}}t        | j                  |||t               
      }t        d| j                   d| dt         d|       |)Nr   r   r   r   r   z8generate_opcheck_tests: Unexpected success for operator z	 on test z. This may mean that you have fixed this test failure. Please rerun the test with PYTORCH_OPCHECK_ACCEPT=1 to automatically update the test runner or manually remove the expected failure in the failure dict at zFor more details, see )	save_dataz,Test generated by `generate_opcheck_tests`, z, failed on operators z. This usually means that the operators are not implemented correctly and may lead to silently incorrect behavior. Set PYTORCH_OPCHECK_PRINT_BETTER_REPRO=1 for a standalone repro, or please see zX for more recommendations. To reproduce this problem locally, try to run the following:
)r   r   rY   
get_statusr   r   r   
set_statusOpCheckErrorrL   GDOCrm   generate_repror   should_print_better_repro)	r   r   option
failed_opsr&   exr'   r(   repro_commands	            r   maybe_raise_errors_on_exitz&OpCheckMode.maybe_raise_errors_on_exit  s   //446H''228T^^LF4**845:.0&&11 $..*b 2  (*V'j	$..1A BG
  $6674#f&
 
 ) 7* 
//446H''228T^^LF#4**845:h' 7 &( ""--b$..'J !  $66z!}EaHBf&T6=V=X
 :4>>:J K##-, / f MMZO]	
 		r   c                     t         j                  | _        t        j                  j                  dd      | _        dt         _        dt        j                  d<   t        |    |i |S )NTORCHDYNAMO_DISABLEr   Tr   )	r   r   prev_is_opcheck_moder   r   rh   prev_dynamo_disablesuper	__enter__)r   r'   r(   	__class__s      r   r  zOpCheckMode.__enter__  sV    $;$A$A!#%::>>2G#L (,%,/

()w $1&11r   c                    | j                   t        _        | j                  t        j
                  d<   	 | j                          t               r| j                  j                          t        | ,  |i |}|S # t        | ,  |i |}w xY w)Nr   )r   r   r   r   r   r   r   r   rY   r   r   __exit__)r   r'   r(   r/   r  s       r   r  zOpCheckMode.__exit__  s    (,(A(A%,0,D,D

()	7++-*,""'')W%t6v6F W%t6v6Fs   4A: :Bc                     	 | j                  |||d       y # t        j                  j                  j                  $ r Y y w xY w)NFr$   )r   r   r    r!   UnsupportedFakeTensorException)r   r&   r'   r(   s       r   run_test_utilzOpCheckMode.run_test_util#  sA    	NN2tVN?  ,,KK 	
 	s    'AAc                    |r|ni }t        |t        j                  j                  t        j                  j                  f      s ||i |S t        j
                  j                         s<t        j
                  j                         st        j                  j                         r ||i |S t        |t        j                  j                        rt        |      }|j                         }|j                  d      d   }|| j                  vr ||i |S t        ||f      \  }} ||i |}	| j                  j!                  || j"                        }
|
dk(  s|
dk(  r3	 || j$                  vrg | j$                  |<   | j'                  |||       |	S |
dk(  r	 |	S # t(        $ rZ}t+               r#| j$                  |   j-                  ||||f       n"| j$                  |   j-                  ||d d f       Y d }~|	S d }~ww xY w)Nr   r   r   r   r   )rj   r   _opsOpOverloadPacket
OpOverloadjit
is_tracingis_scripting_dynamois_compiling resolve_unique_overload_or_throwrl   r   rK   r+   rY   r   r   r   r  	Exceptionr   rm   )r   r?   typesr'   r(   r   nsargs_ckwargs_cr/   r   r   s               r   __torch_function__zOpCheckMode.__torch_function__-  s   !r $!<!<ejj>S>S TU(((II  "yy%%'}}))+((( dEJJ7783D9D99;^^D!!$T__$(((+T6N;t&v&##..xHZ6W#4U4#:#::8:D++H5""4:  v  U,.++H5<<b$f=UV++H5<<b$d=ST Us   !0F 	G>$AG99G>r   N)r   N)rX   
__module____qualname____doc__r   strr   r   r   r  r  r  r  __classcell__)r  s   @r   rW   rW     se    
%I% % 	%
 &% %  %66p2	'r   rW   c                  j    d} | t         j                  vryt         j                  |    }|dk(  xs |dk(  S )a  If set, the tests generated by `generate_opcheck_tests` will print a
    repro command on failure.

    In order to print the repro command, we need to save some tensors to disk.
    These will be saved under the following directory:
    {tempfile.gettempdir()}/pytorch_opcheck_safe_to_delete/.

    Although this is a temp folder, it will usually not automatically get cleaned
    up, so you'll need to manually delete it.
    "PYTORCH_OPCHECK_PRINT_BETTER_REPROFr   r   r   )r   r   s     r   r   r   W  s8     /C
"**JJsOEC<%5A:%r   ALL)rN   raise_exceptionr!  c          	         |i }t        | t        j                  j                        rt	        |       } t        | t        j                  j
                        st        dt        |              |dk(  rt        t        j                               }t        |t              r|f}t        |t        t        f      r,t        |      j                  t        j                               s-t        d| dt        t        j                                d      i }|D ]  }t        |   }	  || ||       d||<    |S # t        $ r$}|rt!        d| d	| d
      ||||<   Y d}~Hd}~ww xY w)a   Given an operator and some sample arguments, tests if the operator is
    registered correctly.

    We test the following (which are important for correctness in eager-mode
    PyTorch and with torch.compile):
    - test_schema: if the operator's schema is correct.
    - test_autograd_registration: if autograd was registered correctly,
        i.e. to the correct DispatchKey.
    - test_faketensor: If the operator has a FakeTensor implementation
        (and if it is correct).
    - test_aot_dispatch_static: If the operator works with
        AOTAutograd/AOTDispatch, which is one of the parts in the PT2 stack.
        Checks that the outputs (and gradients, if they are computable)
        of the operator are the same under eager-mode PyTorch and torch.compile.
    - test_aot_dispatch_dynamic: Same as aot_dispatch_static, but
        tests dynamic shapes instead of static shapes.

    For best results, please call ``opcheck`` multiple times with a
    representative set of inputs. For example, if your operator supports
    autograd, please use ``opcheck`` with inputs that require_grad.

    Args:
        op: The operator. Should look like torch.ops.aten.foo
        args: The args to the operator
        kwargs: The kwargs to the operator
        test_utils: Tests that we should run. Default: all of them.
            Example: ["test_schema", "test_faketensor"]
        raise_exception: If we should raise an exception on the first
            error. If False, we will return a dict with information
            on if each test passed or not.

    Nzeopcheck(op, ...): op must be instance of torch._ops.OpOverload, e.g. torch.ops.aten.sin.default, got r   zopcheck(op, ..., test_utils=z'), expected test_utils to be subset of z but it was notSUCCESSzopcheck(op, ...): z failed with z (scroll up for stack trace))rj   r   r	  r
  r  r  
ValueErrortypetupler   r   r  r   r   issubsetr  r   )	r&   r'   r(   rN   r!  results_dictr   r]   r   s	            r   opcheckr)  i  sz   R ~"ejj112-b1b%**//0448H:?
 	
 U>..01
*c" ]
j5$-0J8P8P9 *:, 7$^%8%8%:;<OM
 	

 L		*		)2tV$&/L#	     	)"(= E2 3  ')L#	)s   $D77	E$ EE$c                       e Zd Zy)r   N)rX   r  r  r   r   r   r   r     s    r   r   )dry_runr   r   r+  c                p   |rt         j                   j                         }t        j                  j	                  t        j                         d      }t         j                   j                  |      dz  }t        j                  j	                  |d| d      }	|sLt        j                  j                  |      st        j                  |       t        j                  ||f|	       d|	 d}
nd}
|j                  j                  j                  d      \  }}|j                  }d	| d
| d
| d|
 d|  d}|S )Npytorch_opcheck_safe_to_deletei repro_z.ptzargs, kwargs = torch.load("z")z# If you rerun your test with PYTORCH_OPCHECK_PRINT_BETTER_REPRO=1
# we will fill them in same (args, kwargs) as in your test
args = ()  # args to the operator
kwargs = {}  # kwargs to the operatorr   aJ  # =========================================================
# BEGIN REPRO SCRIPT
# =========================================================
import torch
from torch.testing._internal.optests import opcheck

# Make sure you have loaded the library that contains the op
# via an import or torch.ops.load_library(...)
op = torch.ops.rV   z

z'
opcheck(op, args, kwargs, test_utils="z")
# =========================================================
# END REPRO SCRIPT
# =========================================================
)datetimenowr   r   r   tempfile
gettempdir	timestampexistsmakedirsr   r   _schemarl   r   _overloadname)r   r&   r'   r(   r   r+  r0  r   unix_timestampfilepathargs_kwargsr  rl   overloadr   s                  r   r   r     s)    ##%ww||H//13ST!**44S9FB77<<~.>c&BC77>>$'D!JJf~x03H:R@4 	 zz$$T*HBH QtfAhZ 0- 115 7H	I " r   c           	      8   t         j                  j                  | j                        }t	        |      dk7  r3t        d| j                   d|D cg c]  }|j                   c}       |d   j                  }|dk(  r| j                  S t        | |      S c c}w )Nr   zSopcheck can only test operators without overloads. Got the following overloads for z: r   r   )	r   _C_jit_get_schemas_for_operator_qualified_op_namer   rr   overload_namedefaultrd   )r&   all_schemasschemar@  s       r   r  r    s     ((889N9NOK
;1//1/D/D.ER3>?;$$;?@B
 	
  N00Mzz2}%% @s   Br   )indent	sort_keysr   zsThis is a dict containing failures for tests autogenerated by generate_opcheck_tests. For more details, please see c            
           e Zd ZdedefdZedddd       Zddee   fdZ	dd
Z
dededefdZd	ddedededee   fdZy	)r   r   r   c                      || _         || _        y r*   )r   r   )r   r   r   s      r   r   zFailuresDict.__init__  s    		r   FrQ   r   c                   |rAt         j                  j                  |       s"t        | i       }t        j	                          |S t        |       5 }|j                         }|j                         dk(  rt        i t        d}n-t        j                  |      }d|v sJ d|v r|d   t        k(  sJ d d d        t        | d         S # 1 sw Y   xY w)Nr   _descriptionr   _versionr   rK  )r   r   r4  r   r   r   r   stripDESCRIPTIONVERSIONjsonloads)r   rR   r/   r   contentsdcts         r   r   zFailuresDict.load  s    rww~~d3!$+FM$Z2wwyH~~2%$/ ' jj*}$}!S(S_-GGG  D#f+.. Zs   A CCc                     t         | j                  t        d}t        j                  |fi t
        dz   }|r|S t        | j                  d      5 }|j                  |       d d d        y # 1 sw Y   y xY w)NrI  r   w)	rM  r   rN  rO  dumpsDUMP_OPTIONSr   r   write)r   r   to_dump
serializedr   s        r   r   zFailuresDict._save%  sf    'II
 ZZ8<84?
$))S!RHHZ  " "s   A++A4Nc                 "    | j                         S r*   )r   )r   s    r   r   zFailuresDict.save4  s    zz|r   r   r   c                 X    || j                   vry| j                   |   }||vry||   d   S )Nr   r   r   )r   r   r   rR  s       r   r   zFailuresDict.get_status7  s9    499$ii!C9~h''r   r   r   r   c                    || j                   vri | j                   |<   | j                   |   }||vrd dd||<   |dk(  r||= y |||   d<   |	|||   d<   y y )Nr   )r   r   r   r   r   r\  )r   r   r   r   r   rR  s         r   r   zFailuresDict.set_status?  sx     499$"$DIIhii!C(,<C	NZI'-C	N8$",3Iy) #r   )r   r   )Fr  )rX   r  r  r  FailuresDictDatar   staticmethodr   r   r   r   r   r   r   r   r   r   r     s    S (8  "' / /&Xc] (3 (3 (3 ( "&44 4 	4 #4r   r  r*   )Lr/  r   re   r}   rO  r   r   r1  	threadingr   typingr   r   r   r   r   r   r	   r   torch._dynamotorch.utils._pytreer   _pytreer,   torch._dynamo.utilsr
   #torch._subclasses.schema_check_moder   torch._utils_internalr   torch.overridesr   torch.testing._internal.optestsr   r   r   r  r   r.   boolr#   r	  r  r0   r7   r9   rB   r+   partialr   r   DEFAULT_TEST_UTILSr   r   r   r   r   r   localr   r   r   rW   r   OperatorBaser)  r  r   r   r
  r  rV  r^  rN  rM  r   r   r   r   <module>ro     s        	 	    D D D   $ $ + ? 1 - S    


S/ cN
  	* 9

9
S/9 cN9
 9 
90 (

(
S/( cN(
 ( 
(( S

S
S/S cNS 	S S 	S,CS CS C %"B& 1	 1 1! "3!2!2" ^  )-15.|G|GS	|G !|G  X.	|G
 S	|G 
|G~30l -# $ .A A.23iACFA	AH8T 8
 *)//+  %  )\# \~&* (,K
 ). K

K
S/K T#s(^$K
 c49n%K K 
#s(^K\	9 	 /
/

/ S// cN	/ / / 	/d&

##&
ZZ&" $/ T#tCH~"5667  $$(6+ G4 G4r   