o
    œýi  ã                   @   s0   d Z ddlZG dd„ deƒZG dd„ deƒZdS )z9Data structures and algorithms for profiling information.é    Nc                   @   s$   e Zd ZdZdd„ Zedd„ ƒZdS )ÚProfileDatumzProfile data point.c                 C   sp   || _ || _|| _|| _|| _| jr"dtj | j¡| j| jf | _nd| _|| _	| jj
| _| jj| jj | _dS )ap  Constructor.

    Args:
      device_name: (string) name of the device.
      node_exec_stats: `NodeExecStats` proto.
      file_path: path to the source file involved in creating the op.
      line_number: line number in the file involved in creating the op.
      func_name: name of the function that the line belongs to.
      op_type: (string) Operation type.
    z	%s:%d(%s)Ú N)Údevice_nameÚnode_exec_statsÚ	file_pathÚline_numberÚ	func_nameÚosÚpathÚbasenameÚfile_line_funcÚop_typeÚall_start_microsÚ
start_timeÚop_end_rel_microsÚop_start_rel_microsÚop_time)Úselfr   r   r   r   r   r   © r   ú[/mnt/sdb/aimis/docanh/lib/python3.10/site-packages/tensorflow/python/debug/lib/profiling.pyÚ__init__   s   
ÿ

ÿzProfileDatum.__init__c                 C   s   | j jS )z0Op execution time plus pre- and post-processing.)r   Úall_end_rel_micros©r   r   r   r   Ú	exec_time7   s   zProfileDatum.exec_timeN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r   r   r   r   r      s
     r   c                   @   s8   e Zd ZdZdd„ Zdd„ Zedd„ ƒZedd	„ ƒZd
S )ÚAggregateProfilez>Profile summary data for aggregating a number of ProfileDatum.c                 C   s0   |j | _|j| _d|j|jjf }|di| _dS )zˆConstructor.

    Args:
      profile_datum: (`ProfileDatum`) an instance of `ProfileDatum` to
        initialize this object with.
    ú%s:%sé   N)r   Útotal_op_timer   Útotal_exec_timer   r   Ú	node_nameÚ_node_to_exec_count©r   Úprofile_datumÚdevice_and_noder   r   r   r   @   s   ÿzAggregateProfile.__init__c                 C   sr   |  j |j7  _ |  j|j7  _d|j|jjf }d|j|jjf }|| jv r2| j|  d7  < dS d| j|< dS )z¤Accumulate a new instance of ProfileDatum.

    Args:
      profile_datum: (`ProfileDatum`) an instance of `ProfileDatum` to
        accumulate to this object.
    r    r!   N)r"   r   r#   r   r   r   r$   r%   r&   r   r   r   ÚaddN   s   ÿÿ
zAggregateProfile.addc                 C   s
   t | jƒS ©N)Úlenr%   r   r   r   r   Ú
node_countb   s   
zAggregateProfile.node_countc                 C   s   t | j ¡ ƒS r*   )Úsumr%   Úvaluesr   r   r   r   Únode_exec_countf   s   z AggregateProfile.node_exec_countN)	r   r   r   r   r   r)   r   r,   r/   r   r   r   r   r   =   s    
r   )r   r	   Úobjectr   r   r   r   r   r   Ú<module>   s   )