
    Vh                        d dl Z d dlZd dlZd dlZ	 d dlZd dlmZ dZ	dZ
dZdZdZdZd	Z e j                   d
d      Ze
 edddez   dd      e edddez   dd      e edddez   dd      iZd Zd Zedk(  r e        yy# e$ r Y nw xY w)    N)Commandsz&/tmp/pytorch_blas_compare_environments
mkl_2020_3
mkl_2020_0	open_blaseigen)z
USE_CUDA=0z
USE_ROCM=0)cmake
hypothesisninjanumpypyyaml
setuptoolstyping_extensions
SubEnvSpec)generic_installsspecial_installsenvironment_variablesexpected_blas_symbolsexpected_mkl_version )intel)z
mkl=2020.3zmkl-include=2020.3)zBLAS=MKL)mkl_blas_sgemmz2020.0.3)r   )z
mkl=2020.0zmkl-include=2020.0z2020.0.0)openblas)zBLAS=OpenBLAS)	exec_blasc                      t        j                  j                  j                  |  \  }}}|rt	        dt        |        d| d|       |S )zConvenience method.zconda error: z  retcode: 
)condacli
python_apirun_commandOSErrorstr)argsstdoutstderrretcodes       a/home/dcms/DCMS/lib/python3.12/site-packages/torch/utils/benchmark/examples/blas_compare_setup.py	conda_runr'   R   sM    #ii22>>EFFGc$i[G9BvhOPPM    c            	         t         j                  j                  t              r$t	        d       t        j                  t               t        j                  t               t        j                  ddt         j                  j                  t         j                  j                  t                          j                  d      j                         } t        j!                         D ]  \  }}t         j                  j#                  t        |      }t	        d| d| d       t%        t&        j(                  d	d
|d       t	        d       t        j*                  d| ddd      }|j,                  rCt/        d|j0                  j                  d       d|j2                  j                  d             t	        d       t%        t&        j4                  d
|gt6        |j8                  z     |j:                  r;|j:                  \  }}t	        d|        t%        t&        j4                  d
|d|g|  |j<                  rt	        d       t        j*                  d| ddj#                  |j<                         ddd      }|j,                  rCt/        d|j0                  j                  d       d|j2                  j                  d             t        j*                  d| dddd      j0                  j                  d      j                         j?                         }|j<                  D ]  }	|	|v rJ |	 d        t	        d| d       t        j*                  d| d|  dddd       t	        d       t        j*                  d| d ddd      }
|
j,                  rCt/        d|
j0                  j                  d       d|
j2                  j                  d             |
j0                  j                  d      }t	        |       |j<                  D ]  }	d!|	v s|	|v rJ d"|	         |j@                  D ]  }||v rJ  |jB                  d#|jB                   |v sJ t	        d$|         y )%Nz$Cleaning: removing old working root.zgit rev-parse --show-toplevelT)shellcwdzutf-8zCreating env: z: ()z--no-default-packagesz--prefixzpython=3z"Testing that env can be activated:zsource activate F)r*   capture_outputcheckz-Failed to source base environment:
  stdout: z
  stderr: zInstalling packages:z"Installing packages from channel: z-czSetting environment variables.z && conda env config vars set  z/Failed to set environment variables:
  stdout: z && envz not in envszBuilding PyTorch for env: ``z && cd z# && python setup.py install --cmakezChecking configuration:a[   && python -c "import torch;from torch.utils.benchmark import Timer;print(torch.__config__.show());setup = 'x=torch.ones((128, 128));y=torch.ones((128, 128))';counts = Timer('torch.mm(x, y)', setup).collect_callgrind(collect_baseline=False);stats = counts.as_standardized().stats(inclusive=True);print(stats.filter(lambda l: 'blas' in l.lower()))"BLASz*PyTorch build did not respect `BLAS=...`: z'- Intel(R) Math Kernel Library Version zBuild complete: )"ospathexistsWORKING_ROOTprintshutilrmtreemakedirs
subprocesscheck_outputdirnamerealpath__file__decodestripSUB_ENVSitemsjoinr'   conda_commandsCREATErun
returncoder    r#   r$   INSTALLBASE_PKG_DEPSr   r   r   
splitlinesr   r   )git_rootenv_nameenv_specenv_pathbase_sourcechannelchannel_depsenv_setactual_env_varse	check_runcheck_run_stdoutss                r&   mainrX   [   s   	ww~~l#45l#KK&&'GGOOBGG,,X67 fWoeeg	  'nn. s-(77<<h7xjH:Q78!!#		
 	23 nnxj)	
 !!(//66w?@ A(//66w?@B  	$%""	
 h777	
 $$$,$=$=!G\6wi@A&&Hg !- ))23 !nn"8* ---0XXh6T6T-U,VX#G !!!!(!6!6w!? @ A!!(!6!6w!? @B  )nn"8*G4#	
 fVVG_UUWZZ\  33 @O+?s,-??+@ 	+H:Q78 	xj ) .. 	
 	'(NNxj )C C 
	 &--44W=> ?&--44W=>@ 
 %++227;// 	_A{,,^0Z[\Z].^^,	_ // 	)A((((	) ((4<X=Z=Z<[\`pppp 
+,gs-r(   __main__)collectionsr2   r7   r:   conda.cli.python_apir   r   rD   ImportErrorr5   
MKL_2020_3
MKL_2020_0	OPEN_BLASEIGENGENERIC_ENV_VARSrI   
namedtupler   rA   r'   rX   __name__r   r(   r&   <module>rd      s    	  	? 8

	 0  $[## 	
 
H+.>>1' 
H+.>>1' z&03CC,!#D-D zF e  	 		s   
B B
B