
    ϑi                         S SK r S SKrS SKrS SKrS rS rS r\S:X  aC  \" 5       r\R                  r	\R                  r
\R                  r\R                  r\" \	\
\\5        gg)    Nc                      [         R                  " SS9n U R                  S[        SS9  U R                  S[        SS9  U R                  S[        S	S9  U R                  S
[        SSS9  U R	                  5       nU$ )Nz#prim ops Code Generator Args Parser)descriptionz--ops_yaml_pathzpath to ops.yaml)typehelpz--ops_legacy_yaml_pathzpath to dygraph_ops.yamlz--ops_compat_yaml_pathzpath to op_compat.yamlz--phi_ops_map_pathz./phi_ops_map.pyzpath to target phi_ops_map.py)r   defaultr   )argparseArgumentParseradd_argumentstr
parse_args)parserargss     h/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/incubate/autograd/generate_op_map.pyParseArgumentsr      s    $$9F ):LM
 s1K    s1I   ",	   DK    c                 v    U R                  5        H%  nX    H  n[        X   U   5      nX0U   U'   M     M'     g )N)keysr   )itemkeysubkeyvalues       r   _trans_value_typer   /   s;    yy{iF	&)*E %If   r   c           
         0 n0 nX4 GH"  n[         R                  " S[         R                  5      n[        US5       n[        R
                  " U5      n	U	 H?  n
U
S   nX;   a  [        SU 35      e[         R                  " XzS   5      S   U
S   S.XK'   MA     S	S	S	5        [        US5       n[        R
                  " U5      nU H  n
U
S   nUR                  S
5      (       aO  [         R                  " SUR                  SS5      5      nUR                  S5      UR                  S5      pSU0X_'   OUnSU0X_'   S H#  nUU
R                  5       ;   d  M  U
U   X_   U'   M%     S H1  nUU
R                  5       ;   d  M  [        U
U   5        U
U   X_   U'   M3     M     S	S	S	5        [        US5       nUR                  S5        [        R                   " XXSS9  UR                  S5        UR                  S5        [        R                   " XHSS9  UR                  S5        S	S	S	5        GM%     g	! , (       d  f       GN= f! , (       d  f       N= f! , (       d  f       GM[  = f)z
Generate dictionary and save to file phi_ops_map.py. The target file records gap
of description between current op and standard ones.
z
[(](.*)[)]rtopzThere already exists op r   r   output)r   r   N)z(.*)\((.*)\)        phi_name)inputsoutputsattrs)scalar	int_arraywz	op_map =    )indent
z
op_info = )recompileDOTALLopenyaml	safe_load
ValueErrorfindallendswithmatchreplacegroupr   r   writejsondump)ops_yaml_pathops_legacy_yaml_pathops_compat_yaml_pathphi_ops_map_pathdctmap_dctop_pathpatternfopsr   r   
ops_compattmpr"   op_nameelements                    r   generate_coderI   6   s    CG!8**]BII6'4 A..#C4j:$'?u%EFFJJwV=a@"8n	  ! &-*J"4j<<$$((#3S[[b5IJC(+		!ciilg(2H'=G$!G(2G'<G$=G$))+-48M(1  >  7G$))+-)$w-848M(1  7 # .& "C(AGGK IIg+GGDMGGL!IIcQ'GGDM )(A 9   .-& )(s2   AH0-B%I%I? I3A/I0
H?	
I	
I#	__main__)r   r9   r,   r0   r   r   rI   __name__r   r;   r<   r=   r>    r   r   <module>rM      s}   $   	 ,&/d zD&&M4444,,	 r   