o
    "j+                     @   s   d dl mZmZ d dlmZmZ ddddddd	d
dddddddddddddddddddddddddddddddddd d!	d"Ze Ze	 Z
e ZG d#d$ d$ejZd%S )&    )_C_ops_legacy_C_ops)core	frameworkgraph_send_recvXZ	Src_indexZ	Dst_indexZOutZ	Dst_count)final_op_namexZ	src_indexZ	dst_indexoutZ	dst_countmatmulZtrans_xZtrans_yY)r   Ztranspose_xZtranspose_yr	   yr
   trunc)r   r	   r
   absdigammadiagonalZInputoffsetaxis1axis2)r   r	   r   r   r   r
   	roi_alignZROIsZRoisNumpooled_heightpooled_widthspatial_scalesampling_ratioaligned)	r   r	   ZboxesZ	boxes_numr   r   r   r   r   )r   Z	matmul_v2r   r   r   r   r   c                       sZ   e Zd ZdZ fddZ		dddZ		ddd	Z		dd
dZdd Zdd Z	  Z
S )Tracera  
    :api_attr: imperative

    Tracer is used to execute and record the operators executed, to construct the
    computation graph in dygraph model. Tracer has two mode, :code:`train_mode`
    and :code:`eval_mode`. In :code:`train_mode`, Tracer would add backward network
    automatically and perform AutoGrad by method :code:`loss.backward()`.
    In :code:`eval_mode`, Tracer would not add backward network.

    This is a low level API, users don't need to use it directly.
    c                    s   t    d| _d S NT)super__init___train_modeself	__class__ [/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddle/base/dygraph/tracer.pyr   k   s   

zTracer.__init__FNc                 C   s  t j| }t| }t| }	t| }
g }tt|D ]}d }|| }|	| }|| v r0|| }nQ|| v r;|| }nFd|dd  v rZ|d d }|| v sQJ t|| }|}n'd|dd  v r|d d }t| || v rw|| }n
|| v r|| }|d u r|	| q|dkrt
|tr|	|d  q|	| q|dkrt
|tsJ |	| q|dksJ t
|tsJ |	| qg }| D ]\}}|	| |	| q|g ||R  }|dkrt| d	ksJ t| d }tt|D ]}|| || |  qd S t
|trstt|
D ]R}|
| }|| v rot
|| trOtt|| D ]}|| | || | d
 q;qt
|| tre|| d || d
 q|| || d
 qd S t
|trt| d	ksJ t| d }tt|D ]}|| | || d
 qd S t| d	ksJ t| d }t
|| tr|| d |d
 d S || |d
 d S )NNumZVartensorr   listintZload_combine   F)r   __dict__core_ops_args_infocore_ops_args_type_infocore_ops_returns_inforangelenkeysprintappend
isinstancer)   r*   itemsZ_share_underline_tensor_totuplereconstruct_from_)r!   op_typeinputsoutputsattrsstop_gradientinplace_mapfunction_ptrop_argsop_args_type
op_returnsarg_listiarg_to_appendarg_namearg_typeZout_nameZnum_outsZ
attrs_listkvreturnskeyjretnamer$   r$   r%   eager_legacy_trace_opp   s   
	





zTracer.eager_legacy_trace_opc                 C   s  |t  v sJ t | d }tj| }t }t }	t }
|| }|	| }|
| }g }tt|D ]~}|| }|| }|t |  v sGJ t | | }|| v rX|| }n|| v rc|| }n|| v rr|dkrr|| }nd }|dkr~|	| q3|dkrt
|tr|	|d  q3|	| q3|dkrt
|tsJ |	| q3|d u sJ |	| q3|| }t
|trtt|D ]K}|| }|t |  v sJ t | | }|| v rt
|| trtt|| D ]}|| | || | d qq|| d || d qd S t
|trAt| dks!J t| d }tt|D ]}|| | || d q/d S t| dksLJ t| d }t
|| trh|| d |d d S || |d d S )Nr    r(   r   r)   Fr+   )name_mappingr2   r   r,   get_core_ops_args_infoget_core_ops_args_type_infoget_core_ops_returns_infor0   r1   r4   r5   r)   r7   r8   )r!   r9   r:   r;   r<   r=   r>   r?   r-   r.   r/   r@   rA   rB   rC   rD   Zeager_arg_namerG   rF   rE   rJ   Zeager_retnamerM   rL   rK   r$   r$   r%   eager_trace_op   sx   	




zTracer.eager_trace_opc                 C   sf   t  r/|t v r#t| d }|tjv sJ | |||||| d S | |||||| d S td)Nr   z#trace_op only  work in dygraph mode)	r   Zin_dygraph_moderP   r2   r   r,   rT   rN   
ValueError)r!   typer:   r;   r<   r=   r>   r$   r$   r%   trace_op+  s   	zTracer.trace_opc                 C   
   d| _ d S r   r   r    r$   r$   r%   
train_modeE     
zTracer.train_modec                 C   rX   )NFrY   r    r$   r$   r%   	eval_modeH  r[   zTracer.eval_mode)FN)__name__
__module____qualname____doc__r   rN   rT   rW   rZ   r\   __classcell__r$   r$   r"   r%   r   ^   s    
l
[
r   N)Zpaddler   r   Zpaddle.baser   r   rP   rQ   r-   rR   r.   rS   r/   r   r$   r$   r$   r%   <module>   sd   		F