L i>ddlZddlZddlmZeej ds>edej j d<edej j d<Gddej jZGddej jZ y) N) _dummy_type_XpuStreamBase _XpuEventBasec~eZdZdZd fd ZddZddZddZdeffd Z dfd Z e d Z fd Z d Zd ZxZS)StreamaWrapper 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 |d|vrd|vrt||fd|i|Stjj |5t||fd|i|cdddS#1swYyxYw)N stream_id device_indexpriority)super__new__torchxpudevice)clsrr kwargs __class__s W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/xpu/streams.pyr zStream.__new__!sp >kV3&8P7?3DDVD D!!&) IwsHXHH I I Is AA"returnc&|j|y)zMake all future work submitted to the stream wait for an event. Args: event (torch.xpu.Event): an event to wait for. N)waitselfevents r wait_eventzStream.wait_event)s  4cB|j|jy)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)rstreams r wait_streamzStream.wait_stream1s ++-.rc@| t}|j||S)zRecord an event. Args: event (torch.xpu.Event, optional): event to record. If not given, a new one will be allocated. Returns: Recorded event. )Eventrecordrs rrzStream.record_event<s! =GE T rc t|S)zCheck if all the work submitted has been completed. Returns: A boolean indicating if all kernels in this stream are completed. r queryrrs rr&z Stream.queryKs w}rc"t|y)z4Wait for all the kernels in this stream to complete.Nr synchronizer's rr*zStream.synchronizeSs rc@tj|jSN)ctypesc_void_p sycl_queuers r_as_parameter_zStream._as_parameter_Wt//rcDt|trt| |Sy)NF) isinstancerr __eq__)rors rr5z Stream.__eq__[s a 7>!$ $rcDt|j|jfSr,)hashr/rr0s r__hash__zStream.__hash__`sT__dkk233rc>d|jd|jddS)Nztorch.xpu.Stream(device=z sycl_queue=#x))rr/r0s r__repr__zStream.__repr__cs$)$++l4??SUBVVWXXr)NrrNr,)__name__ __module__ __qualname____doc__r rr rboolr&r*propertyr1r5r9r= __classcell__rs@rrrsR$I / t00 4Yrrc|eZdZdZd fd Zd d fd Zd d fd Zdeffd ZfdZ d fd Z e d Z d Z xZS)r"aWrapper 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|||S)N) enable_timing)r r )rrIrs rr z Event.__new__vsws-@@rrcd|tjj}t||y)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)rrcurrent_streamr r#rrrs rr#z Event.recordys( >YY--/F vrcd|tjj}t||y)zMake all future work submitted to the given stream wait for this event. Use ``torch.xpu.current_stream()`` if no stream is specified. N)rrrKr rrLs rrz Event.waits( >YY--/F  Vrc t|S)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 rr&z Event.querysw}rc"t||S)zReturn the time elapsed. Time reported in milliseconds after the event was recorded and before the end_event was recorded. )r elapsed_time)r end_eventrs rrPzEvent.elapsed_times w#I..rc"t|y)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 rr*zEvent.synchronizes rc@tj|jSr,)r-r. sycl_eventr0s rr1zEvent._as_parameter_r2rc>|jrd|jddSy)Nztorch.xpu.Event(sycl_event=r;r<ztorch.xpu.Event(uninitialized))rTr0s rr=zEvent.__repr__s" ??00DAF F3r)Fr,r>)r?r@rArBr r#rrCr&rPr*rDr1r=rErFs@rr"r"gsG At/004rr") r-r torch._utilsrhasattr_C__dict__rrrr"rrr[s $uxx)**56F*GEHH&')4_)EEHHo&VYUXX $ $VYrF4EHH " "F4r