
    ёi                       S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKrS SK	rS SK
r
S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKJr   S SKJr  SSKJr  SSKJr  SS	KJrJr  \R>                  " S
5      r \ RC                  \RD                  5        \RF                  " SS9r$\RJ                  " 5       r&\&RO                  \$5        \ RQ                  \&5        \RR                  r*\*RW                  S5      r,/ SQr-/ SQr./ SQr/S/r0\Rb                  " 5       (       a  / SQr2OSS/r3Sr4Sr5Sr6Sr7\Rp                  Rs                  5       \Rp                  Ru                  5       \Rp                  Rw                  5       \Rp                  Ry                  5       \Rp                  R{                  5       \Rp                  R}                  5       /r?SSS jr@S rA\R                  " SSS/5      rC " S S5      rD\R                  " S / S!Q5      rE " S" S#5      rFS$ rGS% rHS& rIS' rJSTS( jrKS) rLS* rMS+ rNS, rOS- rPS. rQS/ rRS0 rSSTS1 jrTS2 rUS3 rVS4 rWS5 rXS6 rYS7 rZ    SUS8 jr[STS9 jr\S: r]S; r^SVS< jr_S= r`S> raSTS? jrbS@ rcSA rdSB reSTSWSC jjrfSXSD jrgSTSE jrh STSF jriSG rjSH rkSTSI jrlSJ rm STSK jrnSL roSTSM jrpSN rqSTSO jrrSTSP jrsSQ rtSYSR jrug! \ a    \" \R0                  S5      r GNf = f)Z    )annotationsN)	machinery)DEVNULLwb   )core)OpProtoHolder)get_includeget_libzutils.cpp_extensionz)%(asctime)s - %(levelname)s - %(message)s)fmtwin)z/MTz/wd4819z/wd4251z/wd4244z/wd4267z/wd4275z/wd4018z/wd4190z/EHscz/wz/DGOOGLE_GLOG_DLL_DECLz/DBOOST_HAS_STATIC_ASSERTz/DNDEBUGz/DPADDLE_USE_DSO)
z-fno-commonz-dynamicz-DNDEBUGz-gz-fwrapvz-O3-archx86_64r   arm64)z-dynamiclibz
-undefineddynamic_lookupr   r   r   r   z/MACHINE:X64)z-DPADDLE_WITH_HIP-DEIGEN_USE_GPUz-DEIGEN_USE_HIPz-DPADDLE_WITH_CUDAr   )      r   )   r   i^  a  
                        *************************************
                        *  Compiler Compatibility WARNING   *
                        *************************************

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Found that your compiler ({user_compiler}) is not compatible with the compiler
built Paddle for this platform, which is {paddle_compiler} on {platform}. Please
use {paddle_compiler} to compile your custom op. Or you may compile Paddle from
source using {user_compiler}, and then also use it compile your custom op.

See https://www.paddlepaddle.org.cn/documentation/docs/zh/install/compile/fromsource.html
for help with compiling Paddle from source.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ax  
                            **********************************
                            *    ABI Compatibility WARNING   *
                            **********************************

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Found that your compiler ({user_compiler} == {version}) may be ABI-incompatible with pre-installed Paddle!
Please use compiler that is ABI-compatible with GCC >= 5.4 (Recommended 8.2).

See https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html for ABI Compatibility
information

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
c                z    [         R                  " U 5      n[        R                  " 5       R	                  U5      nU$ N)r   !load_op_meta_info_and_register_opr	   instanceupdate_op_proto)lib_filenamenew_listproto_sync_opss      j/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/utils/cpp_extension/extension_utils.pyr   r      s1    55lCH"++-==hGN    c           	        [         R                  " S5      R                  5       n[        R                  R                  U 5      u  p4US-   U-   n / n[        R                  5       R                  5       (       a  [        S5        Ov[        R                  5       R                  5       u  pgUR                  n[        U5      n	U	 H  n
UR                  [        U
5      5        M     [        S[        U	5       S35        [!        US5       nUR#                  UR%                  [        R                  R'                  U 5      SR)                  U5      S95        S	S	S	5        g	! , (       d  f       g	= f)
zg
Customized write_stub function to allow us to inject generated python
api codes into egg python file.
a  
        {custom_api}

        import os
        import sys
        import types
        import paddle
        import importlib.abc
        import importlib.util

        cur_dir = os.path.dirname(os.path.abspath(__file__))
        so_path = os.path.join(cur_dir, "{resource}")

        def __bootstrap__():
            assert os.path.exists(so_path)
            # load custom op shared library with abs path
            custom_ops = paddle.utils.cpp_extension.load_op_meta_info_and_register_op(so_path)

            if os.name == 'nt' or sys.platform.startswith('darwin'):
                # Cpp Extension only support Linux now
                mod = types.ModuleType(__name__)
            else:
                try:
                    spec = importlib.util.spec_from_file_location(__name__, so_path)
                    assert spec is not None
                    mod = importlib.util.module_from_spec(spec)
                    assert isinstance(spec.loader, importlib.abc.Loader)
                    spec.loader.exec_module(mod)
                except ImportError:
                    mod = types.ModuleType(__name__)

            for custom_op in custom_ops:
                setattr(mod, custom_op, eval(custom_op))

        __bootstrap__()

        _pd_z6Received len(custom_op) =  0, using cpp extension onlyzReceived len(custom_op) = z, using custom operatorw

)resource
custom_apiN)textwrapdedentlstripospathsplitextCustomOpInfor   emptyprintlastso_pathr   append_custom_api_contentlenopenwriteformatbasenamejoin)r$   pyfile_stub_templatefilenameextapi_content_op_infor0   new_custom_opsop_namefs               r   custom_write_stubrC      s1   
 __$	&L fhM T GG$$X.MH& 3&HK$$&&FG "**,113
//:7C%G27;< &(^)<(==TU	
 
fc	a	!!))(3!;;{3 " 	
 
		s   AE
E(OpInfoso_namer0   c                  D    \ rS rSrSr\S 5       rS rS
S jrS r	S r
S	rg)r,      zG
A global Singleton map to record all compiled custom ops information.
c                T    [        U S5      (       d  U " 5       U l        U R                  $ )N	_instance)hasattrrI   )clss    r   r   CustomOpInfo.instance   s"    sK((ECM}}r   c                |    [        U R                  S5      (       a   S5       e[        R                  " 5       U l        g )NrI   z3Please use `instance()` to get CustomOpInfo object!)rJ   	__class__collectionsOrderedDictop_info_mapselfs    r   __init__CustomOpInfo.__init__   s6    4>>;77 	
A	
7 '224r   Nc                4    [        X#5      U R                  U'   g r   )rD   rQ   )rS   rA   rE   r0   s       r   addCustomOpInfo.add   s    $*7$<!r   c                    [        U R                  5      S:  d   e[        [        U R                  R	                  5       5      5      $ )z*
Return the last inserted custom op info.
r   )r3   rQ   nextreverseditemsrR   s    r   r/   CustomOpInfo.last   s<     4##$q(((HT--335677r   c                (    U R                   (       a  gg)NFTrQ   rR   s    r   r-   CustomOpInfo.empty  s    r   r_   r   )__name__
__module____qualname____firstlineno____doc__classmethodr   rT   rW   r/   r-   __static_attributes__ r   r   r,   r,      s/      
5=8r   r,   VersionFields)sourcesextra_compile_argsextra_link_argslibrary_dirsruntime_library_dirsinclude_dirsdefine_macrosundef_macrosc                  0    \ rS rSrS rS r\S 5       rSrg)VersionManageri  c                <    Xl         U R                  U5      U l        g r   )version_fieldhasherversion)rS   ru   s     r   rT   VersionManager.__init__  s    *{{=1r   c                V   SSK Jn  [        R                  " 5       nUR                   Ho  n[        X5      nU(       d  M  [        U[        [        [        45      (       a  U" U5      n[        U[        U5      5      nMV  [        S[        U5       SU S35      e   UR                  5       $ )Nr   )flattenz6Support types with list, tuple and dict, but received z with .)paddle.utilsrz   hashlibmd5_fieldsgetattr
isinstancelisttupledictcombine_hashRuntimeErrortype	hexdigest)rS   ru   rz   r~   fieldelem	flat_elems          r   rv   VersionManager.hasher   s    (kkm"**E=0D$ud 344#DM	"3i(89"LTRVZLX^_c^ddef  + }}r   c                6    U R                   R                  5       $ r   )ru   _asdictrR   s    r   detailsVersionManager.details2  s    !!))++r   )rw   ru   N)	ra   rb   rc   rd   rT   rv   propertyr   rg   rh   r   r   rs   rs     s     2$ , ,r   rs   c                V    U R                  [        U5      R                  5       5        U $ )z
Return new hash value.
DO NOT use `hash()` because it doesn't generate stable value between different process.
See https://stackoverflow.com/questions/27522626/hash-function-in-python-3-3-returns-different-results-between-sessions
)updatereprencode)r~   values     r   r   r   7  s"     JJtE{!!#$Jr   c           	        S nS nSn[         R                  R                  U 5      n[         R                  R                  U 5      n[         R                  R	                  XT5      n[
        R                   Vs/ s H  n[        XS5      PM     n	n[
        R                  U	5      n
[        U
5      n[         R                  R                  U 5      (       a  [         R                  R                  U5      (       a  U" U5      nUR                  US5      nUbh  XR                  :w  aX  [        SU SUR                   SU S35        [         R                  " U 5        UR                  nUR                  X'   U" X~5        ggg[         R                  R                  U5      (       d  [         R                   " U5        UR                  nUR                  X'   U" X5        gs  snf )	z
If already compiling source before, we should check whether cflags
have changed and delete the built object to re-compile the source
even though source file content keeps unchanged.
c           	         [        U[        5      (       d   e[        U S5       nUR                  [        R
                  " USSS95        S S S 5        g ! , (       d  f       g = f)Nr"   r   T)indent	sort_keys)r   r   r4   r5   jsondumps)r*   version_inforB   s      r   	serialize0clean_object_if_change_cflags.<locals>.serializeH  sC    ,----$_GGDJJ|AFG __s   &A
A!c                    [         R                  R                  U 5      (       d   e[        U S5       nUR	                  5       n[
        R                  " U5      sS S S 5        $ ! , (       d  f       g = f)Nr)r)   r*   existsr4   readr   loads)r*   rB   contents      r   deserialize2clean_object_if_change_cflags.<locals>.deserializeM  sG    ww~~d####$_ffhG::g& __s   &A##
A1zversion.txtNzRe-Compiling z<, because specified cflags have been changed. New signature z has been saved into r{   )r)   r*   dirnamer7   r8   ri   r   r   _makers   r   getrw   log_vremover   makedirs)r0   	extensionr   r   VERSION_FILEbase_dirrE   version_filer   argsru   	versionerold_version_info
so_versionnew_version_infor   s                   r   clean_object_if_change_cflagsr   A  s   H
' !Lwww'Hggw'G77<<7L :G9N9NO9NGId+9NDO!''-M}-I	ww~~g277>>,#?#?&|4%))'48
!j4E4E&Ey(denevevdw  xM  NZ  M[  [\  ] IIg(00(1(9(9%l5 'F! ww~~h''KK!##$,,,(/ Ps   8Gc                   [         R                  " 5       (       a  / [        QSPSPU Q[        U 5      Qn U $ [         R                  " S5      (       a  / [
        QSPSPU Qn U $ / [
        QSPSPSPSPSPSPU Q[        U 5      Qn U $ )	E
Prepare all necessary compiled flags for nvcc compiling CUDA files.
z
-Xcompilerz-fPICiluvatar_gpuz-DPADDLE_WITH_COREXz-ccbinccz--expt-relaxed-constexprz-DNVCC)r   is_compiled_with_rocmCOMMON_HIPCC_FLAGSget_rocm_arch_flagsis_compiled_with_custom_deviceCOMMON_NVCC_FLAGSget_cuda_arch_flagscflagss    r   prepare_unix_cudaflagsr   t  s     !!##


 
 	

 !(
, M 
	,	,^	<	<N$NgN/DNvN M





 

 	


 

 '

 

 

 !(

 Mr   c                4    / [         QSPU Q[        U 5      Qn U $ )r   -w)r   r   r   s    r   prepare_win_cudaflagsr     s*     O N$NN2Ef2MNFMr   c                   ^ US:X  a  SOSm[        U4S jU  5       5      (       d"  U(       a  SOSnTU-   nU R                  U5        gg)z?
Append -std=c++14/17 in cflags if without specific it before.
msvcz/std:z-std=c              3  .   >#    U  H
  nTU;   v   M     g 7fr   rh   ).0flagcpp_flag_prefixs     r   	<genexpr>)add_std_without_repeat.<locals>.<genexpr>  s     :64$&6   zc++17zc++14N)anyr1   )r   compiler_type	use_std17suffixcpp_flagr   s        @r   add_std_without_repeatr     sH     "/&!8ggO:6:::%7"V+h ;r   c                    / $ )z
For an arch, say "6.1", the added compile flag will be
``-gencode=arch=compute_61,code=sm_61``.
For an added "+PTX", an additional
``-gencode=arch=compute_xx,code=compute_xx`` is added.
rh   r   s    r   r   r     s	     Ir   c                    / U QSPSPSPSPn U $ )z=
For ROCm platform, amdgpu target should be added for HIPCC.
z-fno-gpu-rdcz-amdgpu-target=gfx906z-amdgpu-target=gfx926z-amdgpu-target=gfx928rh   r   s    r   r   r     s>    	 	  	 	
 	 F Mr   c                     SSK n [        R                  R                  [        R                  R	                  U R
                  5      S5      $ )z!
Return installed base dir path.
r   Nbase)paddler)   r*   r8   r   __file__)r   s    r   _get_base_pathr     s-     77<<8&AAr   c                 *    [         (       a  SOSn SU -   $ )z 
Return pybind DSO module name.
.pyd.so	libpaddle)
IS_WINDOWS)ext_names    r   _get_core_namer     s     $vH!!r   c                 x    [        5       n SU SS  S3n[        R                  R                  [	        5       U5      $ )z5
Return real path of libcore_(no)avx.dylib on MacOS.
libN.dylib)r   r)   r*   r8   r   )raw_core_namelib_core_names     r   _get_lib_core_pathr     s:     #$M-,-V4M77<<(-88r   c                 R    [         R                  R                  [        5       S5      $ )z+
Return real path of libpaddle on Windows.
zlibpaddle.dll)r)   r*   r8   r   rh   r   r   _get_dll_core_pathr     s     77<<(/::r   c                    [         R                  R                  U 5      (       d   e[        R	                  S5      (       a&  SnS[        5        3nSU SU SU  3n[        U5        gg)a  
NOTE(Aurelius84): Runtime path of libpaddle.so is modified into `@loader_path/../libs`
in setup.py.in. While loading custom op, `@loader_path` is the dirname of custom op
instead of `paddle/base`. So we modify `@loader_path` from custom dylib into `@rpath`
to ensure dynamic loader find it correctly.

Moreover, we will add `-rpath site-packages/paddle/base` while linking the dylib so
that we don't need to set `LD_LIBRARY_PATH` any more.
darwinz@loader_path/../libs/z@rpath/zinstall_name_tool -change  N)r)   r*   r   OS_NAME
startswithr   run_cmd)r0   origin_runtime_pathrpathcmds       r   _reset_so_rpathr     so     77>>'""""(##5.*+,()<(=QugQwiP 	 	 $r   c                   Sn[         R                  R                  U 5      n[         R                  R                  X!5      n[         R                  R	                  U5      (       d   SU S35       e[        US5       nU Vs/ s H)  oDR                  5       (       d  M  UR                  5       PM+     nnSSS5        S/n[        W5      nU Hb  nU HY  n	[         R                  R                  X5      n
[         R                  R                  U
5      (       d  MH  UR                  U
5        M[     Md     UR                  U5        UR                  5         U$ s  snf ! , (       d  f       N= f)zJ
Get all include directories when compiling the PaddlePaddle
source code.
zincludes.txtzFile z does not existr   Nzpaddle/base/platform)r)   r*   abspathr8   isfiler4   stripr   isdirr1   sort)compile_dirinclude_dirs_filer*   rB   linero   
extra_dirsall_include_dirs	extra_dirinclude_dirds              r    _get_include_dirs_when_compilingr    s!   
 '77??;'DT=77>>+,, 
!"/2, 
	%12Cjjl

C 
& ))JL)	'K[4Aww}}Q ''* (  
 D! D 
&	%s$   <EEE1EE
E'c                   [        U [        5      (       d   e/ nU R                  SS5      nU(       a  [        U5      n[	        U R                  S/ 5      5      nU Vs/ s H  n[
        R                  " U5      PM     nnUR                  U5        UR                  [        5       5        UR                  [        U5      5        UR                  [        5       5        X@S'   U R                  S/ 5      nUR                  [        U5      5        X`S'   U R                  S/ 5      n[        U[        5      (       a  S H  nX;  d  M
  / Xx'   M     [        (       ac  U R                  S/ 5      n	U	R                  [        5        [        5       n
U	R                  U
 5        U(       a  U	R                  SS	/5        XS'   GOU R                  S/ 5      n	[         R#                  S
5      (       a   U	R                  SS[%        5        3S/5        O:U	R                  S['        5        35        [        5       n
U	R                  SU
 35        [)        US/5        U(       a=  [*        R,                  " 5       (       a  U	R                  S5        OU	R                  S5        XS'   U R                  S/ 5      nUR                  [        U5      5        XS'   Uc  [)        US/5        [*        R.                  " 5       (       Ga_  [
        R0                  " S5      nU(       GaA  [2        R4                  " SU5       Vs/ s H)  oR7                  5       (       d  M  UR7                  5       PM+     nn[	        UR                  S/ 5      5      n/ nU H  nUR5                  S5       Vs/ s H  nU(       d  M  [9        U5      PM     nn[;        U5      S;   d
   SU 35       e[;        U5      S:X  a  US   S-  US   -   nOUS   nUR                  U5        M     [=        [?        U5      5      nU H  nUR                  SS U S!U 3/5        M     [@        RB                  " U5      nXS'   XpS'   S"U S#'   U $ s  snf s  snf s  snf )$zE
Normalize include_dirs, library_dir and other attributes in kwargs.
_compile_dirNro   rm   rk   )cxxnvccrl   zcudadevrt.libzcudart_static.liblinuxz-Wl,--no-as-neededz-l:z-Wl,--as-neededz-Wl,-rpath,z-lr   z
-lamdhip64z-lcudartrn   z-DPADDLE_WITH_CUSTOM_KERNELPADDLE_CUDA_ARCH_LISTz;|\s|\,r
  r{   )      zinvalid sm format: r  r   
   r  z-gencodezarch=compute_z	,code=sm_zc++language)"r   r   r   r  r   r)   fsdecodeextend"find_paddle_custom_device_includesfind_paddle_includesfind_python_includesfind_paddle_librariesr   MSVC_LINK_FLAGScreate_sym_link_if_not_existr1   r   r   r   r   add_compile_flagr   r   is_compiled_with_cudagetenvresplitr   intr3   sortedsetcopydeepcopy)kwargsuse_cudacompile_include_dirsr   ro   r  rm   rk   compilerrl   r   rn   	arch_listsnvcc_optionssmssssms                     r   normalize_extension_kwargsr-    s    fd#### **^T2K?L 

>267L@LMBKK,LM,-:<=,X67,./)> ::nb1L-h78)>  $8"=$d++'H1/1", ( z **%6;/46-2""O5H#IJ$3 ! !**%6; g&& ""(.*+,% ""[1A0B#CD 9:M""R#78 	+dV4))++&&|4&&z2$3 !  &zz*@"E##$9($CD)=%&+.K-LM!!##II56	#%88J	#B#Baggi		#B     2 6 6vr BCLC();"gc"g;2w&(C,?s*CC(r7a<Abe+BAB

2  S"C##=IbT!BC  "&/A!B)5v&#5 F:MK NX <s    Q&QQQ#Q#c                 `   [         R                  S5      (       d  [        (       d   e[        5       n [        R
                  R                  [        5       U 5      n[        (       as  [        5       n[        R
                  R                  U5      (       d   [        R                  " X5        [        R
                  R                  U5      (       d   eU SS	 S
-   $ [        5       n[        R
                  R                  U5      (       d>   [        R                  " X5        [        R
                  R                  U5      (       d   e U SS $ ! [         a7    [        R                  " SU  SU SU SU  S3	5        [        SU SU 35         Nf = f! [         a    [!        SU  SU SU S35      ef = f)z+
Create soft symbol link of `libpaddle.so`
r   z&Failed to create soft symbol link for z[.
 You can run prompt as administrator and execute the following command manually: `mklink r   z$`. Now it will create hard link for z	 trickly.z
mklink /H Nz.libz9.
 Please execute the following command manually: `ln -s `r   )r   r   r   r   r)   r*   r8   r   r   r   symlink	Exceptionwarningswarnr   r   r   )r   	core_pathnew_dll_core_pathnew_lib_core_paths       r   r  r    s    h''::55"$M^-}=Iz.0ww~~/00F

98 ww~~/0000Sb!F** /0ww~~/00

98ww~~&78888 Sb!!/  F<]O L;;L:MQykY}  L  ~M  MVW *%6$7qDEF"  "<]O  LF  GP  FQ  QR  Sd  Re  ef  g s   E	 <F 	>F
	F
 F-c                    Sn [         R                  R                  SS5      R                  [         R                  5      nU HK  n[         R
                  R                  US5      n[         R
                  R                  U5      (       d  MI  Un   O   U cM  [         R                  S:X  a  SOSn [        R                  " US/5      R                  5       R                  5       n U c  SnUS	-  n[        R                  " U5        U $ !   Sn  N(= f)
z*
Use heuristic method to find ccache path
NPATH ccachentwherewhichzTNo ccache found. Please be aware that recompiling all source files may be required. zeYou can download and install ccache from: https://github.com/ccache/ccache/blob/master/doc/INSTALL.md)r)   environr   r  pathsepr*   r8   r   name
subprocesscheck_outputdecoder   r3  r4  )ccache_pathpathsr*   ccache_candidate	which_cmdwarning_messages         r   find_ccache_homerJ    s     KJJNN62&,,RZZ8E77<<h777>>*++*K	  !ww$GG		''H(=>EEGMMO  p  C  	Co&	Ks   -4D D	c                    [         R                  R                  S5      =(       d    [         R                  R                  S5      n U c  [        (       a  SOSn [	        [         R
                  S5       n[        R                  " US/US9nUR                  5       nUR                  S	5      S
   n[         R                  R                  [         R                  R                  U5      5      n SSS5        U (       a@  [         R                  R                  U 5      (       d  [        R                   " 5       (       a  Sn U $ ! , (       d  f       NW= f!   [        (       a,  [        R                  " S5      n[        U5      S
:  a  US
   n  NSn  N= f)z(
Use heuristic method to find cuda path
	CUDA_HOME	CUDA_PATHNr=  r>  r"   r
  stderr
r   z7C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v*.*z/usr/local/cuda)r)   r?  r   r   r4   devnullrB  rC  rD  r  r*   r   globr3   r   r   r  )	cuda_homerH  rQ  	nvcc_pathcandidate_pathss        r   find_cuda_homerV    s)   
 

{+Jrzz~~k/JI )zGw		.bjj#&'&33'	 &,,.	%OOF3A6	 GGOOBGGOOI,FG	 ', 	y))&&((	9 '&		.z"&))Q# '!+ / 2I-	s1   E 3A8D<+E <
E
E 
E 7F
F
c                    [         R                  R                  S5      =(       d    [         R                  R                  S5      n U c  [        (       a  SOSn [	        [         R
                  S5       n[        R                  " US/US9nUR                  5       nUR                  S	5      n[         R                  R                  [         R                  R                  U5      5      n SSS5        U (       a@  [         R                  R                  U 5      (       d  [        R                  " 5       (       a  Sn U $ ! , (       d  f       NW= f!   S
n  N`= f)z(
Use heuristic method to find rocm path
	ROCM_HOME	ROCM_PATHNr=  r>  r"   hipccrN  rP  z	/opt/rocm)r)   r?  r   r   r4   rQ  rB  rC  rD  rstripr*   r   r   r   r   )	rocm_homerH  rQ  
hipcc_paths       r   find_rocm_homer^    s    
 

{+Jrzz~~k/JI )zGw		$bjj#&''44(
 (..0
'..v6
 GGOOBGGOOJ,GH	 ' 	y))&&((	' '&	$#Is+   E
 3A5D9(E
 9
EE
 E
 
Ec                 ^   [        5       n U c  [        S5      e[        R                  R	                  U S5      n/ SQnU Vs/ s H"  n[        R                  R	                  X5      PM$     nnU Vs/ s H+  n[        R                  R                  U5      (       d  M)  UPM-     sn$ s  snf s  snf )z0
Use heuristic method to find cuda include path
INot found CUDA runtime, please use `export CUDA_HOME=XXX` to specific it.include)r:  ccclnvtx3)rV  
ValueErrorr)   r*   r8   r   )rS  base_includesub_dirssubrF  ps         r   find_cuda_includesri    s      IW
 	
 77<<	95L$H8@ARWW\\,,EA2u!q 1Au22 B2s   )B%0(B*B*c                 t    [        5       n U c  [        S5      e[        R                  R	                  U S5      /$ )z0
Use heuristic method to find rocm include path
zJNot found ROCM runtime, please use `export ROCM_PATH= XXX` to specific it.ra  r^  rd  r)   r*   r8   )r\  s    r   find_rocm_includesrl  )  s<      IX
 	
 GGLLI.//r   c                   [         R                  R                  U S5      nX/n[        (       dR  [         R                  R                  U S5      n[         R                  R                  U S5      nUR	                  X4/5        U$ )zJ
Get all paddle include directories from include root (packaged in wheel)
third_partyzpaddle/phi/api/include/compatz4paddle/phi/api/include/compat/torch/csrc/api/include)r)   r*   r8   r   r  )include_rootthird_party_dirro   compat_dir_rootcompat_dir_api_includes        r   *_get_all_paddle_includes_from_include_rootrs  6  sq     ggll<?O 2L:'',,9
 "$B"
 	_EFr   c                   [        5       n[        U5      nU (       aQ  [        R                  " 5       (       a  [	        5       nUR                  U5        O[        5       nUR                  U5        [        R                  S5      (       aB  [        5       nUb5  [        R                  R                  U5      (       a  UR                  U5        U$ )z+
Return Paddle necessary include dir path.
r   )r
   rs  r   r   rl  r  ri  r   r   find_clang_cpp_includer)   r*   r   r1   )r$  paddle_include_dirro   rocm_include_dircuda_include_dirstd_v1_includess         r   r  r  J  s    
 %=L %%''13 0113 01(##02&277>>/+J+J0r   c                    / n [         R                  " 5       nU(       d  U $ US   n[         R                  " U5      (       a  [        R                  " S5      nU(       aW  [        R
                  R                  US5      n[        R
                  R                  U5      (       a  U R                  U5        U $ [        S5      eU $ )z9
Return Paddle Custom Device necessary include dir path.
CUSTOM_DEVICE_ROOTra  zXNot found CUSTOM_DEVICE_ROOT, please use `export CUSTOM_DEVICE_ROOT=XXX` to specific it.)
r   get_all_device_typer   r)   r  r*   r8   r   r1   rd  )ro   devicesdevicecustom_device_rootr  s        r   r  r  e  s     L&&(GR[F**622YY';<'',,'99EKww~~k**##K0
  j  r   c                     [         R                  " S[        (       a  SOSS9n U b  [        U [        5      (       d   eU /$ / $ )z0
Return necessary include dir path of Python.h.
ra  r<  posix_prefix)scheme)	sysconfigget_pathr   r   str)python_include_paths    r   r  r  ~  sJ     $,,**$. &-s3333#$$Ir   c                
   S n [         R                  " U S/5      nUR                  5       nUR                  S5      nU H  nSU;   d  M  UR                  S5      S   R	                  5       nU(       d  M6  [
        R                  R                  U5      (       d  M\  [
        R                  R                  [
        R                  R                  U5      S5      nM     U$ ! [         a    [        R                  " S5         U$ f = f)Nz	--version
InstalledDir:r{  zinclude/c++/v1zWFailed to search `include/c++/v1/` include dirs. Don't worry because it's not required.)rB  rC  rD  r  r   r)   r*   r   r8   r   r2  r3  r4  )r&  ry  compiler_versioninfosinfov1_paths         r   ru  ru    s    O
%22Hk3JK+224 &&t,D%**S/"-3357rww~~g66&(ggll02B'O	    
e	
 
s%   AC 
'C 5"C AC  DDc                     [        5       n U c  [        S5      e[        (       a$  [        R                  R                  U SS5      /nU$ [        R                  R                  U S5      /nU$ )z3
Use heuristic method to find cuda static lib path
r`  r   x64lib64)rV  rd  r   r)   r*   r8   )rS  cuda_lib_dirs     r   find_cuda_librariesr    si      IW
 	
 zYu=>  Y89r   c                 x    [        5       n U c  [        S5      e[        R                  R	                  U S5      /nU$ )z4
Use heuristic method to find rocm dynamic lib path
zINot found ROCM runtime, please use `export ROCM_PATH=XXX` to specific it.r   rk  )r\  rocm_lib_dirs     r   find_rocm_librariesr    sA      IW
 	
 GGLLE23Lr   c                    [        5       /nU (       aQ  [        R                  " 5       (       a  [        5       nUR	                  U5        O[        5       nUR	                  U5        UR                  [        5       5        U$ )z+
Return Paddle necessary library dir path.
)r   r   r   r  r  r  r1   r   )r$  paddle_lib_dirsr  r  s       r   r  r    sd    
 ykO%%''.0L""<0.0L""<0 >+,r   c                    [        U[        5      (       d   e[        U [        5      (       a)  U R                  5        H  nUR	                  U5        M     g U R	                  U5        g r   )r   r   r   valuesr  )rk   flagsr   s      r   r  r    sR    eT""""$d++&--/DKK 0 	!!%(r   c                |    U R                   R                  S5      nUS   nSU 3n[        U R                  U/5        g )Nr{   r{  z-DPADDLE_EXTENSION_NAME=)rA  r  r  rk   )r   namesrA  defines       r   define_paddle_extension_namer    s=    NN  %E9D'v.FY11F8<r   c                x    S1n[         R                  R                  U 5      n[        U5      S:  d   eUS   U;   $ )Nz.cur  r{  )r)   r*   r+   r3   )r*   cuda_suffixr\   s      r   is_cuda_filer    s<    'KGGT"Eu:>>9##r   c                   [         R                  R                  S5      nUcy  Sn[         R                  R	                  [         R                  R                  S5      U5      n[        (       a  [         R                  R                  U5      n[        SU S3U 5        [         R                  R                  U5      (       d  [         R                  " U5        U$ )a  
Return paddle extension root directory to put shared library. It could be specified by
``export PADDLE_EXTENSION_DIR=XXX`` . If not set, ``~/.cache/paddle_extension`` will be used
by default.

Returns:
    The root directory of compiling customized operators.

Examples:

.. code-block:: python

    >>> from paddle.utils.cpp_extension import get_build_directory

    >>> build_dir = get_build_directory()
    >>> print(build_dir)

PADDLE_EXTENSION_DIRpaddle_extensionsz~/.cachez.$PADDLE_EXTENSION_DIR is not set, using path: z by default.)r)   r?  r   r*   r8   
expanduserr   normpathr   r   r   )verboseroot_extensions_directorydir_names      r   get_build_directoryr    s    & !#

/E F (&$&GGLLGGz*H%
! :(*(8(8))% 	<=V<WWcd	

 77>>344
-.$$r   c                   U [         R                  " 5       R                  ;  a  [        SU  S35      e[         R                  " 5       R	                  U 5      nUR
                   Vs/ s H  o"R                  PM     nnUR                   Vs/ s H$  o"R                  [        ;  d  M  UR                  PM&     nnUR                   Vs/ s H  o"R                  PM     nnX4U4$ s  snf s  snf s  snf )z\
Parse input names and outputs detail information from registered custom op
from OpInfoMap.
zPlease load zc shared library file firstly by `paddle.utils.cpp_extension.load_op_meta_info_and_register_op(...)`)
r	   r   op_proto_maprd  get_op_protoinputsrA  attrsDEFAULT_OP_ATTR_NAMESoutputs)rA   op_protoxin_names
attr_names	out_namess         r   parse_op_infor    s    
 m,,.;;;7)  $G  H
 	
 %%'44W=H (01H0 &1&&8M*M   "*!1!12!1A!1I2** 1 3s   %C 
C%%C%C*c           	        [         (       a  SnO[        R                  S5      (       a  SnOSn[        R                  R                  XU-   5      n[        R                  R                  U5      (       d  [        SU S35      e[        SU 3U5        [        U5      n[        R                  S:X  d$  [        R                  R                  S5      (       a  [        XX5      $  [        R                  R!                  X5      nUc   e[        R                  R#                  U5      n[%        UR&                  [        R(                  R*                  5      (       d   eUR&                  R-                  U5        [        XX5      nU H  n	[1        Xy[3        X5      5        M     U$ ! [.         a    [        S	5        [        XX5      s $ f = f)
z>
Load shared library and import it as callable python module.
r   r   r   r   zExtension path:  does not exist.zloading shared library from: r<  zusing custom operator only)r   r   r   r)   r*   r8   r   FileNotFoundErrorr   r   rA  sysplatform_generate_python_module	importlibutilspec_from_file_locationmodule_from_specr   loaderabcLoaderexec_moduleImportErrorsetattrr   )
module_namebuild_directoryr  dynamic_suffixext_pathop_namesspecmodule	op_modulerA   s
             r   _import_module_from_libraryr  ,  s    z			H	%	%!ww||O>-IJH77>>(##"28*<L MNN 
)(
4g>0:H	ww$#,,11(;;&?
 	


~~55kL006$++y}}';';<<<<' (I !<=  M  
*+&?
 	

s   "BF! !!GGc                  ^	^
 S m
[        [        R                  " 5       R                  5      n[        R
                  R                  X S-   U-   S-   5      m	[        ST	 3U5        [        R                  " U	U
4S j5        U Vs/ s H  n[        U5      PM     nn[        T	S5       nUR                  SR                  U5      5        SSS5        [        T	X5      nU$ s  snf ! , (       d  f       N!= f)	zK
Automatically generate python file to allow import or load into as module
c                z    [         R                  R                  U 5      (       a  [         R                  " U 5        g g r   )r)   r*   r   r   )filepaths    r   remove_if_exit/_generate_python_module.<locals>.remove_if_exita  s&    77>>(##IIh $r   r>   z.pyzgenerate api file: c                    > T" T 5      $ r   rh   )api_filer  s   r   <lambda>)_generate_python_module.<locals>.<lambda>n  s
    N84r   r"   r#   N)r  	threadingcurrent_threadidentr)   r*   r8   r   atexitregisterr2   r4   r5   _load_module_from_file)r  r  r  r  	thread_idrA   r=   rB   custom_moduler  r  s            @@r   r  r  Z  s      I,,.445Iww||s*Y6>H 
z
*G4 OO45 @HHxG&w/xKH	h		K() 
 +8[JM I		s   C'!C##
C1c                   SnSU S3nSU SU SU SU SU SU S	U S
U SU SU SU  S3n	[        U5       GH  u  pSnX;   a  Xj   nUS:w  a  SX   ;   a  SX   ;   a}  X   R                  S5      S   R                  5       nUSU SU SU SU SU SU SU SU SU S3-  n[        (       a  U	SU SU SU SU SU S3-  n	M  U	SU SU SU SU S U 3
-  n	M  US:w  al  SX   ;   ad  X   R                  S5      S   R                  5       nUSU S!U SU S"U S#3	-  n[        (       a  U	SU S$U SU S3-  n	GM  U	SU S$U S U 3-  n	GM  US:w  a{  SX   ;   as  X   R                  S5      S   R                  5       nUSU SU SU S%U SU SU S&3-  n[        (       a  U	SU SU SU SU S'3	-  n	GM  U	SU SU SU SU S U 3
-  n	GM  US:w  a:  [        (       d/  X   R                  5       nUSU S(U S&3-  nU	SU S$U S U 3-  n	GM  USU S(U S&3-  nU	SU S$U S'3-  n	GM     USU S)3-  nU	SU S*U  S+U SU S,U S)3-  n	X4$ )-Nz        z	res = []
zstart_idx = 0z	ins = {}
z
ins_map = r  z
outs = {}
zouts_list = z#for key, value in ins_map.items():
z    # handle optional inputs
z    if value is not None:
z        ins[key] = value
zhelper = LayerHelper("z", **locals())
r{  z@VECTORz	@OPTIONAL@r   zif z is not None:
z/    res.append(outs[start_idx: start_idx + len(z)])
z    start_idx += len(z)
zelse:
z    res.append(None)
z    start_idx += 1z
    outs['zA'] = [helper.create_variable(dtype='float32') for _ in range(len(z))]z'] = z+res.append(outs[start_idx: start_idx + len(zstart_idx += len()zouts['z     res.append(outs[start_idx])
zstart_idx += 1z,'] = helper.create_variable(dtype='float32')zres.append(outs[start_idx])
z%return res[0] if len(res)==1 else reszhelper.append_op(type="z#", inputs=ins, outputs=outs, attrs=zVres = [outs[out_name] if out_name in outs.keys() else None for out_name in outs_list]
)	enumerater  lowerr   )rA   r  r  ins_map	attrs_map	outs_listinplace_reverse_idxr   dynamic_contentstatic_contentout_idxout_namein_idxlower_in_namess                 r   _gen_output_contentr  z  s    FO
7)  	YK   	 	 	 	wi (	N 'y1)(1FbLX--x// &-33C8;AACN $N 77G Hn- . 	 	  O z 'N 
8*]^l]mmp#t t  'N 
8*E.!1#5 5
 bLY(*::%-33C8;AACN $3N3C D.) . .O z 'xjYZhYiil#p p  'xjn-#1 1 bL[H,<<%-33C8;AACN $N  	 	 	  O z 'N 
8*H#L L  'N 
8*E.!1#5 5 bL%-335N $ 	  O  #xjn-1 1N  $ 	  O  #xjDH HNO 2T  -1 1O  y(KI; W 	-1 1N
 **r   c           	         [        U 5      u  nnnnnnnn[        U UUUUUU5      u  p[        R                  " S5      R	                  5       nUR                  U UU	U
S9nU$ )Nak  
        from paddle import _C_ops
        from paddle.framework import in_dynamic_or_pir_mode
        from paddle.base.layer_helper import LayerHelper
        from paddle.jit.marker import unified

        @unified
        def {op_name}({params_list}):
            # The output variable's dtype use default value 'float32',
            # and the actual dtype of output variable will be inferred in runtime.
            if in_dynamic_or_pir_mode():
                outs = _C_ops._run_custom_op("{op_name}", {params_list})
                {dynamic_content}
            else:
                {static_content}
            )rA   params_listr  r  )_get_api_inputs_strr  r&   r'   r(   r6   )rA   r  r  r  r  r  r  r  r  r  r  API_TEMPLATEr=   s                r   r2   r2     s     	G$	&9'#O ??	" fh# ( %%'%	 & K r   c                t   [         R                  R                  U 5      (       d  [        SU  S35      e[	        SU  3U5        SU-   n[
        R                  " X05      n[        R                  R                  UR                  U5      n[        R                  R                  U5      nUR                  U5        U$ )z
Load module from python file.
zFile : r  zimport module from file: _paddle_cpp_extension_)r)   r*   r   r  r   r   SourceFileLoaderr  r  spec_from_loaderrA  r  r  )api_file_pathr  r  r   r  r  r  s          r   r  r    s     77>>-(('-8H IJJ 
%m_
5w?'+5H ''@F>>**6;;?D^^,,T2F
vMr   c                   [        U 5      u  pnX-   nSR                  U Vs/ s H$  oUR                  S5      S   R                  5       PM&     sn5      nSR	                  SR                  U Vs/ s H4  nSR	                  XwR                  S5      S   R                  5       5      PM6     sn5      5      nSR	                  SR                  U V	s/ s H4  n	SR	                  XR                  S5      S   R                  5       5      PM6     sn	5      5      n
SR	                  SR                  U Vs/ s H	  nSU S3PM     sn5      5      n[
        R                  R                  U 5      nUUU
UUUUU4$ s  snf s  snf s  sn	f s  snf )z3
Returns string of api parameters and inputs dict.
,r  r   z{{{}}}z	'{}' : {}z[{}]')r  r8   r  r  r6   r   eager _get_custom_operator_inplace_map)rA   r  r  r  param_namesrh  r  in_namer  	attr_namer  rA  r  r  s                 r   r  r  ,  s    '4G&<#H)'K (([I[GGCLO113[IJKoo  ('G ""7MM#,>q,A,G,G,IJ'	
G  ",!+I ""9ooc.B1.E.K.K.MN!+	
I chh	'J	!D6	'JKLI**EEgN 		 	1 J (Ks   +E2.;E7;E<.Fc
                   [         R                  " S5      R                  5       n
Sn[        S U 5       5      (       a  Sn[	        SU 3U	5        U
R                  U U(       a  SOS[        U5      [        U5      [        U5      [        U5      [        U5      [        U5      US9	n[	        S	U 3U	5        [        US
5       nUR                  U5        SSS5        g! , (       d  f       g= f)zD
Automatically generate setup.py and write it into build directory.
a  
    import os
    from paddle.utils.cpp_extension import CppExtension, CUDAExtension, BuildExtension, setup
    from paddle.utils.cpp_extension import get_build_directory


    setup(
        name='{name}',
        ext_modules=[
            {prefix}Extension(
                sources={sources},
                include_dirs={include_dirs},
                library_dirs={library_dirs},
                extra_compile_args={{'cxx':{extra_cxx_cflags}, 'nvcc':{extra_cuda_cflags}}},
                extra_link_args={extra_link_args})],
        cmdclass={{"build_ext" : BuildExtension.with_options(
            output_dir=r'{build_dir}',
            no_python_abi_suffix=True)
        }})Fc              3  8   #    U  H  n[        U5      v   M     g 7fr   )r  )r   sources     r   r   $_write_setup_file.<locals>.<genexpr>  s     
6gF<gs   Tzwith_cuda: CUDACpp)	rA  prefixrj   ro   rm   extra_cxx_cflagsextra_cuda_cflagsrl   	build_dirzwrite setup.py into r"   N)	r&   r'   r(   r   r   r6   list2strr4   r5   )rA  rj   	file_pathr  ro   rm   r  r  	link_argsr  template	with_cudar   rB   s                 r   _write_setup_filer  Z  s     	( fh) , I

6g
666		K	{
#W-oo"v!l+l+!"23"#45 +  
G 
 
,g6	i		 
		s    C
C)c                    U c  g[        U [        [        45      (       d   eU  Vs/ s H  o PM     n n[        U 5      $ s  snf )zH
Convert list[str] into string. For example: ['x', 'y'] -> "['x', 'y']"
z[])r   r   r   r   )r   args     r   r  r    sH     |dT5M**** $%eHD%: &s   ?c                `   [         R                  R                  U 5      (       d   e[         R                  R                  U 5      n[         R                  R	                  U 5      n[
        R                  n [        R                  " US/5      nUR                  5       n[        SU SUR                  5        3U5        [        (       a  SU SU SU S	3nOS
U SU SU S	3n[!        S5        [#        X5        g! [         a*    [
        R                  " 5       u  pgn[        SU SU 35      ef = f)z$
Build shared library in subprocess
z-VzUsing Python interpreter: z, version: z)Failed to check Python interpreter with `z`, errors: zcd /d z && r   z buildzcd z9Compiling user custom op, it will cost a few seconds.....N)r)   r*   r   r   r7   r  
executablerB  rC  rD  r   r   r2  exc_infor   r   r.   r   )	r  r  ext_dir
setup_fileinterpreter
py_versionr>   errorcompile_cmds	            r   _jit_compiler     s%    77>>)$$$$ggooi(G!!),J ..K
,,k4-@A
&&(
([AQAQAS@TU	
 zwitK=*VLG9DQzl&I	
EFK!  
lln!7}KPUwW
 	

s   6AC9 94D-c                    S n[        5       nU  H2  n[        US5       nUR                  5       nX!" U5      -  nSSS5        M4     [        U5      $ ! , (       d  f       MP  = f)z0
Parse registering custom op name from sources.
c                    [         R                  " S5      n[         R                  " SSU 5      n UR                  U 5      nU Vs1 s H  n[         R                  " SSU5      iM     nnU$ s  snf )NzPD_BUILD_OP\(([^,\)]+)\)z\s|\t|\nr:  _grad)r  compilerg  findall)r   patternrA   rA  s       r   regex!parse_op_name_from.<locals>.regex  s]    **89&&b'2//'*9@A266'2t,A Bs   "A*r   N)r   r4   r   r   )rj   r'  r  r  rB   r   s         r   parse_op_name_fromr)    s\    
 uH&#!ffhGg&H  
 >	 s   A
A 	c                "   [        SU  3U5         U(       a$  [        R                  " U S[        R                  S9$ [        R                  " U S[        S9$ ! [
         a.    [        R                  " 5       u  p#n[        S[         SU 35      ef = f)z"
Execute command with subprocess.
zexecute command: T)shellrO  )r+  stdoutzFailed to run command: z
, errors: )
r   rB  
check_callSTDOUTr   r2  r  r  r   r$  )commandr  r>   r  s       r   r   r     s    
 
gY
'1	Q((tJ,=,=  ((WMM Qlln!4WIZwOPPQs   *A A 8Bc                z  ^
 [         R                  R                  S5      S;   a  g[        (       d  [        R
                  " SU /[        R                  S9n[         R                  R                  UR                  5       5      R                  5       m
[        U
4S j[        5        5       5      (       d9  [        R                  " [        R!                  U [        5       S   ["        S95        g	S
n["        R%                  S5      (       a  g ["        R%                  S5      (       aO  [&        n[        R
                  " U SS/5      nUR                  5       nUR                  5       R)                  S5      nO~[        (       as  [*        n[        R
                  " U [        R                  S9n UR                  S5      n[.        R0                  " SUR                  5       5      nUb  UR3                  5       n[;        U5      S:X  d   e[=        [?        [@        U5      5      W:  a  g[        R                  " [B        R!                  U SRE                  U5      S95        g	! [,         a    UR                  S5      n Nf = f! [4         a7    [6        R8                  " 5       u  pn[        R                  " SU  SU	 35         g	f = f)z]
Check whether GCC version on user local machine is compatible with Paddle in
site-packages.
PADDLE_SKIP_CHECK_ABI)Truetrue1Tr>  rN  c              3  .   >#    U  H
  nUT;   v   M     g 7fr   rh   )r   rA  compiler_paths     r   r   *check_abi_compatibility.<locals>.<genexpr>  s      
= M!=r   r   )user_compilerpaddle_compilerr  F)r   r   r   r   r  z-dumpfullversionz-dumpversionr{   zUTF-8gbkz(\d+)\.(\d+)\.(\d+)z%Failed to check compiler version for z: r   )r8  rw   )#r)   r?  r   r   rB  rC  r.  r*   realpathrD  r   r   #_expected_compiler_current_platformr3  r4  WRONG_COMPILER_WARNINGr6   r   r   GCC_MINI_VERSIONr  MSVC_MINI_VERSIONUnicodeDecodeErrorr  searchgroupsr2  r  r  r3   r   mapr  ABI_INCOMPATIBILITY_WARNINGr8   )r&  r  cmd_outrw   mini_required_versionr   compiler_infomatchr>   r  r6  s             @r   check_abi_compatibilityrI    s^   
 
zz~~-.2GG:))h
(9(9
 (()9:@@B 
;=
 
 
 MM&--"*$G$I!$L$ .  G(##g&&$4!%22-~>L (..0L"((*005GZ$5!&33!2!2M< - 4 4W = II4m6I6I6KLE ,,. w<1Sg#88MM#**"CHHW,= 	+ 	

 - & < - 4 4U ;<
  lln!3H:RwG	
 s=   
A(I9 34I9 (I 98I9 I63I9 5I66I9 9>J:9J:c                     [         R                  S5      (       a  SS/n U $ [         R                  S5      (       a  / SQn U $ [        (       a  S/n W $ )z7
Returns supported compiler string on current platform
r   clangzclang++r  )gcczg++zgnu-c++zgnu-cccl)r   r   r   )expect_compilerss    r   r<  r<  2  s^     (###Y/
 	 
		G	$	$>  
 6r   c                >    U(       a  [         R                  U 5        gg)z"
Print log information on stdout.
N)loggerr  )r  r  s     r   r   r   ?  s     D r   )r   r  return	list[str])F)ro  zos.PathLike[str] | strrQ  rR  )rK  )r  boolrQ  r  )rA   r  rQ  z&tuple[list[str], list[str], list[str]])T)v
__future__r   r  rO   r!  rR  r}   importlib.abcr  importlib.utilr   loggingr)   r  rB  r  r  r&   r  r3  r   r   r  r4   rQ  r   r   base.frameworkr	   r
   r   	getLoggerrP  setLevelINFO	Formatter	formatterStreamHandlerchsetFormatter
addHandlerr  r   r   r   MSVC_COMPILE_FLAGSCLANG_COMPILE_FLAGSCLANG_LINK_FLAGSr  r   r   r   r>  r?  r=  rD  op_proto_and_checker_makerkOpRoleAttrNamekOpRoleVarAttrNamekOpNameScopeAttrNamekOpCreationCallstackAttrNamekOpDeviceAttrNamekOpWithQuantAttrNamer  r   rC   
namedtuplerD   r,   ri   rs   r   r   r   r   r   r   r   r   r   r   r   r   r  r-  r  rJ  rV  r^  ri  rl  rs  r  r  r  ru  r  r  r  r  r  r  r  r  r  r  r  r2   r  r  r  r  r   r)  r   rI  r<  r   rh   r   r   <module>rm     s-   #          	 	  
     %"  + -			0	1  "MN	 	    " 
,,&
     "" ./@A "  $ " 	##335##668##88:##@@B##557##88: G
T 
		9i*@	A D &&	, ,80)f< B"9;*4tn%"P>'TB3"
0((62 *"*)=$&%R+(+^ 5:@i+X/d(+p 8v"B,Q(DN
s0  %2::t$G%s   K K K 