
    JTh                     H   S SK r S SKrS SKJr  \" \R
                  S5      (       d>  \" S5      \R
                  R                  S'   \" S5      \R
                  R                  S'    " S S\R
                  R                  5      r " S S\R
                  R                  5      r
g)	    N)_dummy_type_XpuStreamBase_XpuEventBasec                      ^  \ rS rSrSrSU 4S jjrSS jrSS jrSS jrS\	4U 4S jjr
SU 4S	 jjr\S
 5       rU 4S jrS rS rSrU =r$ )Stream   au  Wrapper around a XPU stream.

A XPU stream is a linear sequence of execution that belongs to a specific
device, independent from other streams. It supports with statement as a
context manager to ensure the operators within the with block are running
on the corresponding stream.

Args:
    device(torch.device or int, optional): a device on which to allocate
        the stream. If :attr:`device` is ``None`` (default) or a negative
        integer, this will use the current device.
    priority(int, optional): priority of the stream, which can be positive, 0, or negative.
        A lower number indicates a higher priority. By default, the priority is set to 0.
        If the value falls outside of the allowed priority range, it will automatically be
        mapped to the nearest valid priority (lowest for large positive numbers or
        highest for large negative numbers).
c                    > Ub  SU;   a  SU;   a  [         TU ]  " U 4SU0UD6$ [        R                  R	                  U5         [         TU ]  " U 4SU0UD6sS S S 5        $ ! , (       d  f       g = f)N	stream_iddevice_indexpriority)super__new__torchxpudevice)clsr   r   kwargs	__class__s       I/var/www/auris/envauris/lib/python3.13/site-packages/torch/xpu/streams.pyr   Stream.__new__!   sc    >kV3&8P7?3DDVDD!!&)wsHXHH *))s   A  
A.returnc                 &    UR                  U 5        g)zzMake all future work submitted to the stream wait for an event.

Args:
    event (torch.xpu.Event): an event to wait for.
N)waitselfevents     r   
wait_eventStream.wait_event)   s     	

4    c                 B    U R                  UR                  5       5        g)zSynchronize with another stream.

All future work submitted to this stream will wait until all kernels
submitted to a given stream at the time of call complete.

Args:
    stream (Stream): a stream to synchronize.
N)r   record_event)r   streams     r   wait_streamStream.wait_stream1   s     	++-.r   c                 B    Uc
  [        5       nUR                  U 5        U$ )zRecord an event.

Args:
    event (torch.xpu.Event, optional): event to record. If not given, a new one
        will be allocated.

Returns:
    Recorded event.
)Eventrecordr   s     r   r!   Stream.record_event<   s!     =GETr   c                     > [         TU ]  5       $ )zCheck if all the work submitted has been completed.

Returns:
    A boolean indicating if all kernels in this stream are completed.
r   queryr   r   s    r   r+   Stream.queryK   s     w}r   c                 "   > [         TU ]  5         g)z4Wait for all the kernels in this stream to complete.Nr   synchronizer,   s    r   r0   Stream.synchronizeS   s    r   c                 B    [         R                  " U R                  5      $ N)ctypesc_void_p
sycl_queuer   s    r   _as_parameter_Stream._as_parameter_W       t//r   c                 N   > [        U[        5      (       a  [        TU ]  U5      $ g)NF)
isinstancer   r   __eq__)r   or   s     r   r=   Stream.__eq__[   s"    a  7>!$$r   c                 D    [        U R                  U R                  45      $ r3   )hashr6   r   r7   s    r   __hash__Stream.__hash__`   s    T__dkk233r   c                 >    SU R                    SU R                  S S3$ )Nztorch.xpu.Stream(device=z sycl_queue=#x))r   r6   r7   s    r   __repr__Stream.__repr__c   s$    )$++l4??SUBVVWXXr    )Nr   r   Nr3   )__name__
__module____qualname____firstlineno____doc__r   r   r#   r!   boolr+   r0   propertyr8   r=   rB   rG   __static_attributes____classcell__r   s   @r   r   r      sX    $I	/t  0 0
4Y Yr   r   c                      ^  \ rS rSrSrSU 4S jjrSSU 4S jjjrSSU 4S jjjrS\4U 4S jjr	U 4S jr
SU 4S	 jjr\S
 5       rS rSrU =r$ )r&   g   a  Wrapper around a XPU event.

XPU events are synchronization markers that can be used to monitor the
device's progress, and to synchronize XPU streams.

The underlying XPU events are lazily initialized when the event is first
recorded. After creation, only streams on the same device may record the
event. However, streams on any device can wait on the event.

Args:
    enable_timing (bool, optional): indicates if the event should measure time
        (default: ``False``)
c                    > [         TU ]  XS9$ )N)enable_timing)r   r   )r   rX   r   s     r   r   Event.__new__v   s    ws@@r   r   c                 f   > Uc  [         R                  R                  5       n[        TU ]  U5        g)zRecord the event in a given stream.

Uses ``torch.xpu.current_stream()`` if no stream is specified. The
stream's device must match the event's device.
N)r   r   current_streamr   r'   r   r"   r   s     r   r'   Event.recordy   s(     >YY--/Fvr   c                 f   > Uc  [         R                  R                  5       n[        TU ]  U5        g)zMake all future work submitted to the given stream wait for this event.

Use ``torch.xpu.current_stream()`` if no stream is specified.
N)r   r   r[   r   r   r\   s     r   r   
Event.wait   s(    
 >YY--/FVr   c                     > [         TU ]  5       $ )zCheck if all work currently captured by event has completed.

Returns:
    A boolean indicating if all work currently captured by event has
    completed.
r*   r,   s    r   r+   Event.query   s     w}r   c                 "   > [         TU ]  U5      $ )z|Return the time elapsed.

Time reported in milliseconds after the event was recorded and
before the end_event was recorded.
)r   elapsed_time)r   	end_eventr   s     r   rc   Event.elapsed_time   s     w#I..r   c                 "   > [         TU ]  5         g)zWait for the event to complete.

Waits until the completion of all work currently captured in this event.
This prevents the CPU thread from proceeding until the event completes.
Nr/   r,   s    r   r0   Event.synchronize   s     	r   c                 B    [         R                  " U R                  5      $ r3   )r4   r5   
sycl_eventr7   s    r   r8   Event._as_parameter_   r:   r   c                 H    U R                   (       a  SU R                   S S3$ g)Nztorch.xpu.Event(sycl_event=rE   rF   ztorch.xpu.Event(uninitialized))ri   r7   s    r   rG   Event.__repr__   s"    ??00DAFF3r   rI   )Fr3   rJ   )rK   rL   rM   rN   rO   r   r'   r   rP   r+   rc   r0   rQ   r8   rG   rR   rS   rT   s   @r   r&   r&   g   sV    A  t / 0 04 4r   r&   )r4   r   torch._utilsr   hasattr_C__dict__r   r   r   r&   rI   r   r   <module>rq      s      $ uxx)***56F*GEHH&')4_)EEHHo&VYUXX$$ VYrF4EHH"" F4r   