o
    Hۂi6                     @   s   U d dl mZmZ d dlmZ G dd deZG dd deZG dd dZe Zed	ed
Z	ee e
d	< deddfddZG dd dZeeZdee ddfddZdS )    )OptionalProtocol)
ContextVarc                   @   s   e Zd ZdefddZdS )Bufferreturnc                 C      d S N selfr	   r	   ]/home/ubuntu/maya3_transcribe/venv/lib/python3.10/site-packages/triton/runtime/_allocation.pydata_ptr      zBuffer.data_ptrN)__name__
__module____qualname__intr   r	   r	   r	   r   r      s    r   c                   @   *   e Zd Zdededee defddZdS )	Allocatorsize	alignmentstreamr   c                 C   r   r   r	   r   r   r   r   r	   r	   r   __call__   r   zAllocator.__call__Nr   r   r   r   r   r   r   r	   r	   r	   r   r          "r   c                   @   r   )NullAllocatorr   r   r   r   c                 C   s   t d)NzxKernel requires a runtime memory allocation, but no allocator was set. Use triton.set_allocator to specify an allocator.)RuntimeErrorr   r	   r	   r   r      s   zNullAllocator.__call__Nr   r	   r	   r	   r   r      r   r   
_allocator)default	allocatorr   Nc                 C   s   t |  dS )z
    The allocator function is called during kernel launch for kernels that
    require additional global memory workspace.
    N)r   setr    r	   r	   r   set_allocator   s   r#   c                   @   s`   e Zd ZdZdeddfddZdefddZdeddfd	d
Zdedede	e de
fddZdS )_AllocatorWrapperz
    Wrapper to provide ContextVar-like .get()/.set() methods. profile_allocator is
    used in same way as allocator so it is useful to maintain the interface.
    r    r   Nc                 C   
   || _ d S r   r   r   r    r	   r	   r   __init__+      
z_AllocatorWrapper.__init__c                 C   s   | j S r   r&   r
   r	   r	   r   get.   s   z_AllocatorWrapper.getc                 C   r%   r   r&   r'   r	   r	   r   r!   1   r)   z_AllocatorWrapper.setr   r   r   c                 C   s   |  |||S r   r&   r   r	   r	   r   r   4   s   z_AllocatorWrapper.__call__)r   r   r   __doc__r   r(   r*   r!   r   r   r   r   r	   r	   r	   r   r$   %   s    "r$   c                 C   s    t | dur|  dS t dS )z
    The profile allocator function is called before kernel launch for kernels
    that require additional global memory workspace.
    N)_profile_allocatorr!   _NULL_ALLOCATORr"   r	   r	   r   set_profile_allocator;   s    r.   )typingr   r   contextvarsr   r   r   r   r-   r   __annotations__r#   r$   r,   r.   r	   r	   r	   r   <module>   s    