
    i                     ~    S SK r S SKrS SKrS SKJr  S SKrS SKJrJrJ	r	  S SK
JrJr   " S S\R                  5      rg)    N)Path)create_program	ModuleAddModuleMulti)RuntimeVerificationc                   2    \ rS rSrS rS rS rS rS rSr	g)	RuntimeTest   c                    [        [        5       5      u  p[        R                  " 5       n[        R                  " 5       nU R	                  X4L 5        UR                  UR                  [        R                  S9nUR                  S5      nUR                  U5      nU R	                  [        R                  " US   US   US   -   5      5        g )Nverificationforwardr      )r   r   r   get
assertTrueload_programbufferr   Minimalload_methodexecutetorchallclose)selfepinputsruntimeruntime2programmethodoutputss           c/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/executorch/runtime/test/test_runtime.py
test_smokeRuntimeTest.test_smoke   s    #IK0
++-;;=+,&&ryy|?S?S&T$$Y/..(wqz6!9vay3HIJ    c                 L   [        [        5       5      u  p[        R                  " 5       nUR	                  UR
                  [        R                  S9nU R                  UR                  [        SS15      5        UR                  S5      nUR                  U5      nU R                  [        R                  " US   US   US   -   5      5        UR                  S5      nUR                  U5      nU R                  [        R                  " US   US   US   -   S-   5      5        g )Nr   r   forward2r   r   )r   r   r   r   r   r   r   r   assertEqualmethod_namessetr   r   r   r   r   )r   r   r   r   r   r    r!   s          r"   &test_module_with_multiple_method_names2RuntimeTest.test_module_with_multiple_method_names"   s    #KM2
++-&&ryy|?S?S&T--sIz3J/KL$$Y/..(wqz6!9vay3HIJ$$Z0..(wqz6!9vay3H13LMNr%   c                     [        [        5       5      u  p[        R                  " 5       nUR                  R
                  nU R                  [        U5      S5        U R                  SU5        g )Nr   zaten::add.out)	r   r   r   r   operator_registryoperator_namesassertGreaterlenassertIn)r   r   r   r   r/   s        r"   test_print_operator_names%RuntimeTest.test_print_operator_names0   sO    #IK0
++- 22AA3~.2o~6r%   c                 p  ^ ^ [        [        5       5      u  nm[        R                  " 5       nUU 4S jn[        R
                  " 5        nUR                  UR                  5        UR                  5         UR                  UR                  5      nU" U5        [        UR                  5      nUR                  U5      nU" U5        [        UR                  S5       nUR                  UR                  5       5      nU" U5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nc                    > U R                  S5      nUR                  T5      nTR                  [        R                  " US   TS   TS   -   5      5        g Nr   r   r   r   r   r   r   r   r   r    r!   r   r   s      r"   test_add9RuntimeTest.test_load_program_with_path.<locals>.test_add=   I    ((3FnnV,GOOENN71:vay6!97LMNr%   rb)r   r   r   r   tempfileNamedTemporaryFilewriter   flushr   namer   openread)r   r   r   r:   fr   pathr   s   `      @r"   test_load_program_with_path'RuntimeTest.test_load_program_with_path9   s    #IK0
F++-	O
 ((*aGGBIIGGI**1662GW<D**40GWaffd#q!..qvvx8! $ +* $# +*s%   
BD'(DD'
D$	 D''
D5c                   ^ ^ [        [        5       5      u  nm[        R                  " 5       nUU 4S jn[        R
                  " UR                  5      nUR                  U5      nU" U5        UR                  [        UR                  5      5      nU" U5        UR                  [        UR                  5      5      nU" U5        g)zRegression test: Ensure file-like objects (BytesIO, etc.) work correctly.

Previously, isinstance(data, BinaryIO) check didn't work because BinaryIO
is a typing protocol. Fixed by using hasattr(data, 'read') duck-typing.
c                    > U R                  S5      nUR                  T5      nTR                  [        R                  " US   TS   TS   -   5      5        g r7   r8   r9   s      r"   r:   FRuntimeTest.test_load_program_with_file_like_objects.<locals>.test_addZ   r<   r%   N)
r   r   r   r   ioBytesIOr   r   bytes	bytearray)r   r   r   r:   bytesior   r   s   `     @r"   (test_load_program_with_file_like_objects4RuntimeTest.test_load_program_with_file_like_objectsQ   s     $IK0
F++-	O **RYY'&&w/ &&uRYY'78 &&y';<r%    N)
__name__
__module____qualname____firstlineno__r#   r+   r3   rG   rQ   __static_attributes__rS   r%   r"   r
   r
      s    	KO7"0r%   r
   )rL   r>   unittestpathlibr   r   .executorch.extension.pybindings.test.make_testr   r   r   executorch.runtimer   r   TestCaser
   rS   r%   r"   <module>r^      s9    
     
 5T(## Tr%   