o
    oh                     @   sF   d dl m Z  d dl mZ dd ZG dd dZG dd dZe Zd	S )
   )backends)
DriverBasec                  C   s@   dd t  D } t| dkrtt|  d|  d| d  S )Nc                 S   s   g | ]
}|j  r|j qS  )driver	is_active).0xr   r   i/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/triton/runtime/driver.py
<listcomp>   s    z"_create_driver.<locals>.<listcomp>   z active drivers (z). There should only be one.    )r   valueslenRuntimeError)activesr   r   r	   _create_driver   s   
r   c                       sL   e Zd Zdd Zdd Zdd Z fddZd	d
 Zdd Zdd Z	  Z
S )	LazyProxyc                 C   s   || _ d | _d S N_init_fn_obj)selfinit_fnr   r   r	   __init__   s   
zLazyProxy.__init__c                 C   s   | j d u r|  | _ d S d S r   )r   r   r   r   r   r	   _initialize_obj   s   
zLazyProxy._initialize_objc                 C   s   |    t| j|S r   )r   getattrr   r   namer   r   r	   __getattr__   s   zLazyProxy.__getattr__c                    s4   |dv rt  || d S |   t| j|| d S )Nr   )super__setattr__r   setattrr   )r   r   value	__class__r   r	   r!      s   zLazyProxy.__setattr__c                 C   s   |    t| j| d S r   )r   delattrr   r   r   r   r	   __delattr__!   s   zLazyProxy.__delattr__c                 C   s,   | j d u rd| jj d| j dS t| j S )N<z for z not yet initialized>)r   r%   __name__r   reprr   r   r   r	   __repr__%   s   

zLazyProxy.__repr__c                 C   s   |    t| jS r   )r   strr   r   r   r   r	   __str__*   s   
zLazyProxy.__str__)r)   
__module____qualname__r   r   r   r!   r'   r+   r-   __classcell__r   r   r$   r	   r      s    r   c                   @   s*   e Zd Zdd ZdefddZdd ZdS )	DriverConfigc                 C   s   t t| _| j| _d S r   )r   r   defaultactiver   r   r   r	   r   1   s   
zDriverConfig.__init__r   c                 C   s
   || _ d S r   )r3   )r   r   r   r   r	   
set_active5   s   
zDriverConfig.set_activec                 C   s   | j | _d S r   )r2   r3   r   r   r   r	   reset_active8   s   zDriverConfig.reset_activeN)r)   r.   r/   r   r   r4   r5   r   r   r   r	   r1   /   s    r1   N)r   r   r   r   r1   r   r   r   r   r	   <module>   s    #
