U
    d                     @   sd   d dl mZmZmZmZ d dlmZ ejdd Zedkr`e	 
 Zedddd	g ee d
S )    )	workspacecorelstm_benchmarkutils)copyc           
      C   sn  g }d}d| _ tttjd dD ]}dD ]}dD ]}|| _|| _|| _|| | | _	|d | _
d| _t| }t  d	| _t| }t  |t| t|t|f t|  td
||  q8q0q(W 5 Q R X |D ]&\} }}tdt| ||||  qd}|D ]B\} }}t|| }	||	7 }td| j| j| j| j|||	 qtd|t|  d S )Ni  Tr   )@         )   d   )(   r   i  i      ZownZcudnnzt_cudnn / t_own: {}z+{}: cudnn time: {}, own time: {}, ratio: {}zhhidden_dim: {}, seq_lengths: {}, batch_size: {}, num_layers: {}: cudnn time: {}, own time: {}, ratio: {}zRatio average: {})Zgpur   ZDeviceScopeZDeviceOptionr   ZGpuDeviceType
batch_size
seq_length
hidden_dim	data_sizeZiters_to_reportimplementationr   Z	BenchmarkZResetWorkspaceappendr   floatprintformatstrZ
num_layerslen)
argsresultsZ	num_itersr   r   r   Zt_ownZt_cudnnZ	ratio_sumZratio r   E/tmp/pip-unpacked-wheel-ua33x9lu/caffe2/python/rnn/lstm_comparison.pyCompare   sT    


"        
r   __main__Zcaffe2z--caffe2_log_level=0z#--caffe2_print_blob_sizes_at_exit=0z--caffe2_gpu_memory_tracking=1N)Zcaffe2.pythonr   r   r   r   r   debugr   __name__ZGetArgumentParser
parse_argsr   Z
GlobalInitr   r   r   r   <module>   s   
(