o
    –hÆ  ã                   @   s(   d Z ddlZddlZdd„ Zdd„ ZdS )z
Utility methods to check that all processors are on the expected device

Refactored since it can be used for multiple pipelines
é    Nc                 C   s€   t j ¡ st d¡ dS | j ¡ D ](\}}|jdur$t|jj	 
¡ ƒj}nt|j 
¡ ƒj}t|ƒ d¡s9J d| ƒ‚q| dƒ dS )zU
    Check that the processors are all on the GPU and that basic execution works
    z\Unable to run the test that checks the pipeline is on the GPU, as there is no GPU available!NÚcudazProcessor %s was not on the GPUúThis is a small test)Útorchr   Úis_availableÚwarningsÚwarnÚ
processorsÚitemsÚtrainerÚnextÚmodelÚ
parametersÚdeviceÚ_modelÚstrÚ
startswith©ÚpipelineÚnameÚprocr   © r   úf/var/www/html/env_mimamsha/lib/python3.10/site-packages/stanza/tests/pipeline/pipeline_device_tests.pyÚcheck_on_gpu   s   


r   c                 C   sh   | j  ¡ D ](\}}|jdurt|jj ¡ ƒj}nt|j ¡ ƒj}t|ƒ 	d¡s-J d| ƒ‚q| dƒ dS )zU
    Check that the processors are all on the CPU and that basic execution works
    NÚcpuzProcessor %s was not on the CPUr   )
r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   Úcheck_on_cpu   s   
r   )Ú__doc__r   r   r   r   r   r   r   r   Ú<module>   s
    