Ë
    èÿæi†  ã                   ó°   — d dl mZmZ d dlmZmZmZ d dlmZ d dl	m
Z
 d dlmZmZmZmZ d dlmZmZmZ d dlmZ d dlmZ  G d	„ d
e«      Z G d„ de«      Zy)é    )ÚCompilerÚDefaultPassBuilder)ÚFunctionPassÚAnalysisPassÚregister_pass)ÚInlineInlinables)ÚIRLegalization)ÚjitÚobjmodeÚnjitÚcfunc)ÚtypesÚpostprocÚerrors)Ú
FunctionIR)ÚTestCasec                   ó0   ‡ — e Zd Zˆ fd„Zd„ Zd„ Zd„ Zˆ xZS )ÚTestCustomPipelinec                 ó\   •‡— t         t        | �  «         G ˆfd„dt        «      Š‰| _        y )Nc                   ó2   •‡ — e Zd Zg Zˆˆ fd„Zˆˆ fd„Zˆ xZS )ú0TestCustomPipeline.setUp.<locals>.CustomPipelinec                 óX   •— | j                   j                  |«       t        ‰| �  |«      S ©N)Úcustom_pipeline_cacheÚappendÚsuperÚcompile_extra)ÚselfÚfuncÚCustomPipelineÚ	__class__s     €€ún/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/numba/tests/test_pipeline.pyr   z>TestCustomPipeline.setUp.<locals>.CustomPipeline.compile_extra   s)   ø€ à×*Ñ*×1Ñ1°$Ô7Ü˜^¨TÑ@ÀÓFÐFó    c                 ó`   •— | j                   j                  |«       t        ‰| �  |g|¢­i |¤ŽS r   )r   r   r   Ú
compile_ir)r   Úfunc_irÚargsÚkwargsr    r!   s       €€r"   r%   z;TestCustomPipeline.setUp.<locals>.CustomPipeline.compile_ir   s>   ø€ à×*Ñ*×1Ñ1°'Ô:Ü˜^¨TÑ=Øð.Ø"ò.Ø&,ñ.ð .r#   )Ú__name__Ú
__module__Ú__qualname__r   r   r%   Ú__classcell__)r!   r    s   @€r"   r    r      s   ù„ Ø$&Ð!õG÷
.ñ .r#   r    )r   r   ÚsetUpr   Úpipeline_class)r   r    r!   s    @€r"   r-   zTestCustomPipeline.setUp   s'   ù€ ÜÔ  $Ñ-Ô/ö	.œXô 	.ð -ˆÕr#   c                 ó  — | j                  | j                  j                  g «       t        | j                  ¬«      d„ «       }| j	                   |d«      d«       | j                  | j                  j                  |j
                  g«       y )N©r.   c                 ó   — | S r   © ©Úxs    r"   Úfooz8TestCustomPipeline.test_jit_custom_pipeline.<locals>.foo$   ó   € àˆHr#   é   )ÚassertListEqualr.   r   r
   ÚassertEqualÚpy_func©r   r5   s     r"   Útest_jit_custom_pipelinez+TestCustomPipeline.test_jit_custom_pipeline!   sv   € Ø×Ñ˜T×0Ñ0×FÑFÈÔKä	˜D×/Ñ/Ô	0ñ	ó 
1ð	ð 	×Ñ™˜Q› Ô#Ø×Ñ˜T×0Ñ0×FÑFØ!Ÿk™k˜]õ	,r#   c                 ó^  — | j                  | j                  j                  g «       t        t	        j
                  t        j
                  «      | j                  ¬«      d„ «       }| j                   |d«      d«       | j                  | j                  j                  |j                  g«       y )Nr0   c                 ó   — | S r   r2   r3   s    r"   r5   z:TestCustomPipeline.test_cfunc_custom_pipeline.<locals>.foo/   r6   r#   r7   )r8   r.   r   r   r   Úint64r9   Ú__wrapped__r;   s     r"   Útest_cfunc_custom_pipelinez-TestCustomPipeline.test_cfunc_custom_pipeline,   s‡   € Ø×Ñ˜T×0Ñ0×FÑFÈÔKä	Œu�{‰{œ5Ÿ;™;Ó'¸×8KÑ8KÔ	Lñ	ó 
Mð	ð 	×Ñ™˜Q› Ô#Ø×Ñ˜T×0Ñ0×FÑFØ!Ÿo™oÐ.õ	0r#   c                 óè  — | j                  | j                  j                  g «       t        | j                  ¬«      d„ «       }d}| j	                   ||«      |dz   «       | j	                  t        | j                  j                  «      d«       | j                  j                  d   }| j                  ||j                  «       | j                  j                  d   }| j                  |t        «       y )Nr0   c                 óf   — t        d¬«      5  | t        d«      z  } d d d «       | S # 1 sw Y   | S xY w)NÚintpr3   é   )r   Úintr3   s    r"   r5   z<TestCustomPipeline.test_objmode_custom_pipeline.<locals>.foo:   s,   € ä˜6Ö"Ø”S˜“X‘�÷ #àˆH÷ #àˆHús   �&¦0é{   rE   é   r   )
r8   r.   r   r
   r9   ÚlenÚassertIsr:   ÚassertIsInstancer   )r   r5   ÚargÚfirstÚseconds        r"   Útest_objmode_custom_pipelinez/TestCustomPipeline.test_objmode_custom_pipeline7   sÉ   € Ø×Ñ˜T×0Ñ0×FÑFÈÔKä	˜D×/Ñ/Ô	0ñ	ó 
1ð	ð
 ˆØ×Ñ™˜S› 3¨¡7Ô+à×Ñœ˜T×0Ñ0×FÑFÓGÈÔKà×#Ñ#×9Ñ9¸!Ñ<ˆØ�‰�e˜SŸ[™[Ô)à×$Ñ$×:Ñ:¸1Ñ=ˆØ×Ñ˜f¤jÕ1r#   )r)   r*   r+   r-   r<   rA   rO   r,   )r!   s   @r"   r   r      s   ø„ ô-ò(	,ò	0ö2r#   r   c                   ó    — e Zd Zdd„Zd„ Zd„ Zy)ÚTestPassManagerFunctionalityNc                 ó¶   ‡‡‡— | j                  ‰du«       | j                  ‰du«       t        dd¬«       G ˆfd„d‰«      «       Š G ˆˆfd„dt        «      }|S )zŒ
        Creates a new compiler pipeline with the _InjectDelsPass injected after
        the pass supplied in kwarg 'inject_after'.
        NF)Úmutates_CFGÚanalysis_onlyc                   ó:   •— e Zd ZdZd eW ° «      z  Zˆ fd„Zd„ Zy)úLTestPassManagerFunctionality._create_pipeline_w_del.<locals>._InjectDelsPasszD
            This pass injects ir.Del nodes into the IR
            zinject_dels_%sc                 ó(   •— ‰j                  | «       y r   )Ú__init__)r   Úbases    €r"   rX   zUTestPassManagerFunctionality._create_pipeline_w_del.<locals>._InjectDelsPass.__init__]   s   ø€ Ø—‘˜dÕ#r#   c                 óf   — t        j                  |j                  «      }|j                  d¬«       y)NT)Ú	emit_dels)r   ÚPostProcessorr&   Úrun)r   ÚstateÚpps      r"   Úrun_passzUTestPassManagerFunctionality._create_pipeline_w_del.<locals>._InjectDelsPass.run_pass`   s'   € Ü×+Ñ+¨E¯M©MÓ:�Ø—‘ �Ô&Ør#   N)r)   r*   r+   Ú__doc__ÚstrÚ_namerX   r`   )rY   s   €r"   Ú_InjectDelsPassrV   V   s"   ø„ ñð %¡s©4£yÑ0ˆEô$ór#   rd   c                   ó   •— e Zd Zˆ ˆfd„Zy)úITestPassManagerFunctionality._create_pipeline_w_del.<locals>.TestCompilerc                 óŒ   •— t        j                  | j                  «      }|j                  ‰‰«       |j	                  «        |gS r   )r   Údefine_nopython_pipeliner^   Úadd_pass_afterÚfinalize)r   Úpmrd   Úinject_afters     €€r"   Údefine_pipelineszZTestPassManagerFunctionality._create_pipeline_w_del.<locals>.TestCompiler.define_pipelinesg   s7   ø€ Ü'×@Ñ@ÀÇÁÓL�Ø×!Ñ! /°<Ô@Ø—‘”Ø�t�r#   N)r)   r*   r+   rm   )rd   rl   s   €€r"   ÚTestCompilerrf   e   s   ø„ ör#   rn   )Ú
assertTruer   r   )r   rY   rl   rn   rd   s    `` @r"   Ú_create_pipeline_w_delz3TestPassManagerFunctionality._create_pipeline_w_delN   s[   ú€ ð
 	�‰˜¨DÐ0Ô1Ø�‰˜ DÐ(Ô)ä	 5¸Ô	>ö	˜dó 	ó 
?ð	÷	œ8ô 	ð Ðr#   c                 óF  — | j                  t        t        «      }t        |¬«      d„ «       }| j	                  t
        j                  «      5 } |d«       d d d «       t        j                  «      }| j                  d|«       | j                  d|«       y # 1 sw Y   ŒCxY w)Nr0   c                 ó   — | dz   S ©NrE   r2   r3   s    r"   r5   zYTestPassManagerFunctionality.test_compiler_error_on_ir_del_from_functionpass.<locals>.foos   ó   € à�q‘5ˆLr#   é
   zIllegal IR, del found at:zdel x)
rp   r   r   r   ÚassertRaisesr   ÚCompilerErrorrb   Ú	exceptionÚassertIn)r   Únew_compilerr5   ÚraisesÚerrstrs        r"   Ú/test_compiler_error_on_ir_del_from_functionpasszLTestPassManagerFunctionality.test_compiler_error_on_ir_del_from_functionpasso   s�   € Ø×2Ñ2´<Ü3CóEˆô 
˜\Ô	*ñ	ó 
+ð	ð ×Ñœv×3Ñ3Ô4¸Ù�ŒG÷ 5ô �V×%Ñ%Ó&ˆà�‰Ð1°6Ô:Ø�‰�g˜vÕ&÷ 5Ð4ús   Á	BÂB c                 óª   — | j                  t        t        «      }t        |¬«      d„ «       }| j	                   |d«      |j                  d«      «       y )Nr0   c                 ó   — | dz   S rs   r2   r3   s    r"   r5   z]TestPassManagerFunctionality.test_no_compiler_error_on_ir_del_after_legalization.<locals>.foo‹   rt   r#   ru   )rp   r   r	   r   ro   r:   )r   rz   r5   s      r"   Ú3test_no_compiler_error_on_ir_del_after_legalizationzPTestPassManagerFunctionality.test_no_compiler_error_on_ir_del_after_legalization   sO   € ð ×2Ñ2´<Ü3AóCˆô 
˜\Ô	*ñ	ó 
+ð	ð 	�‰™˜B› §¡¨R£Õ1r#   )NN)r)   r*   r+   rp   r}   r€   r2   r#   r"   rQ   rQ   L   s   „ óòB'ó 2r#   rQ   N)Únumba.core.compilerr   r   Únumba.core.compiler_machineryr   r   r   Únumba.core.untyped_passesr   Únumba.core.typed_passesr	   Únumbar
   r   r   r   Ú
numba.corer   r   r   Únumba.core.irr   Únumba.tests.supportr   r   rQ   r2   r#   r"   Ú<module>r‰      sE   ðß <÷:ñ :å 6Ý 2ß +Ó +ß .Ñ .Ý $Ý (ô=2˜ô =2ô@C2 8õ C2r#   