o
    nh                     @   s^   d dl mZmZ d dlmZmZmZmZ G dd deZG dd dedZ	G dd	 d	e	Z
d
S )    )ABCMetaabstractmethod)CallableListProtocolSequencec                   @   s*   e Zd Zdedee dee fddZdS )Benchmarkerkernel_call	quantilesreturnc                K      d S N )selfr	   r
   kwargsr   r   j/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/triton/backends/driver.py__call__      zBenchmarker.__call__N)__name__
__module____qualname__r   r   floatr   r   r   r   r   r   r      s    "r   c                   @   sP   e Zd Zeedd Zedd Zedd Zedefdd	Z	dddZ
d
S )
DriverBasec                 C   r   r   r   r   r   r   r   	is_active   s   zDriverBase.is_activec                 C   r   r   r   r   r   r   r   get_current_target      zDriverBase.get_current_targetc                 C   r   r   r   r   r   r   r   get_active_torch_device   r   z"DriverBase.get_active_torch_devicer   c                 C   s   t )z[
        Return the benchmarking function that this backend should use by default.
        )NotImplementedErrorr   r   r   r   get_benchmarker   s   zDriverBase.get_benchmarkerNc                 C   r   r   r   r   r   r   r   __init__!   r   zDriverBase.__init__)r   N)r   r   r   classmethodr   r   r   r   r   r   r    r   r   r   r   r      s    

r   )	metaclassc                   @   s   e Zd Zdd Zdd ZdS )	GPUDriverc                    sb   dd l   jj| _zddlm} || _W n ty$    fdd| _Y nw  jj| _ jj	| _
d S )Nr   )_cuda_getCurrentRawStreamc                    s    j | jS r   )cudacurrent_streamcuda_stream)idxtorchr   r   <lambda>/   s    z$GPUDriver.__init__.<locals>.<lambda>)r*   r%   get_device_capabilitytorch._Cr$   get_current_streamImportErrorcurrent_deviceget_current_device
set_deviceset_current_device)r   r$   r   r)   r   r    '   s   


zGPUDriver.__init__c                 C   s   |S r   r   )r   tensormaps_infoargsr   r   r   assemble_tensormap_to_arg4   r   z#GPUDriver.assemble_tensormap_to_argN)r   r   r   r    r6   r   r   r   r   r#   %   s    r#   N)abcr   r   typingr   r   r   r   r   r   r#   r   r   r   r   <module>   s
    