o
    iV                     @   sZ   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZdefddZdd Z	dd Z
dS )	    Nreturnc                   C   s   t j r
t j S t S )N)torchcudais_availableget_device_nameplatformmachine r	   r	   I/home/ubuntu/.local/lib/python3.10/site-packages/torchao/_models/utils.pyget_arch_name   s   

r   c                    s    fddt |D }dd|d |d |d |d |d	 d
d|d ddgd|d |d g|d dd}ttj| d  dd}tt||d W d   dS 1 sZw   Y  dS )aM  
    Write the result into JSON format, so that it can be uploaded to the benchmark database
    to be displayed on OSS dashboard. The JSON format is defined at
    https://github.com/pytorch/pytorch/wiki/How-to-integrate-with-PyTorch-OSS-benchmark-database

    OSS CI version, that will leave many fields to be filled in by CI
    c                       i | ]	\}} | |qS r	   r	   .0ivheadersr	   r
   
<dictcomp>        z+write_json_result_ossci.<locals>.<dictcomp>TorchAO benchmark	inferencedtypedevicearchmin_sqnrcompiler   r   r   r   namemoder   
extra_infor   modeltorchaor   typeoriginsmetricactualtargetr   benchmark_valuestarget_value)	benchmarkr!   r&   r   .jsonafileN)	enumerateopenospathsplitextprintjsondumps)output_json_pathr   rowmapping_headersrecordfr	   r   r
   write_json_result_ossci   s,   "r>   c                    s$   fddt |D }tj }tt|d }tj	|tj
j}t| }|d }tt

 dddd||d|d	d
|d |d |d |d |d dd|d ddgd|d |d g|d dd}	ttj| d  dd}
tt|	|
d W d   dS 1 sw   Y  dS ) a]  
    Write the result into JSON format, so that it can be uploaded to the benchmark database
    to be displayed on OSS dashboard. The JSON format is defined at
    https://github.com/pytorch/pytorch/wiki/How-to-integrate-with-PyTorch-OSS-benchmark-database

    Local version (filling in dummy values for fields that should be populated by CI)
    c                    r   r	   r	   r   r   r	   r
   r   F   r   z+write_json_result_local.<locals>.<dictcomp>zutf-8   v3zdevvm local benchmarkz
pytorch/aomainr   r   r   r   r   r   r   r   r   r   r!   r"   r#   r&   r'   r(   r)   )	timestampschema_versionr   repohead_branchhead_shaworkflow_idrun_attemptjob_idr,   r!   r&   r   r-   r.   r/   N)r1   datetimedatetodayhashlibsha256strencode	hexdigestcombinetimeminintrB   r2   r3   r4   r5   r6   r7   r8   )r9   r   r:   r;   rL   sha_hashfirst_secondrG   rI   r<   r=   r	   r   r
   write_json_result_local>   sH   

""rX   )rJ   rM   r7   r3   r   rS   r   rO   r   r>   rX   r	   r	   r	   r
   <module>   s   &