pytorch/torch/csrc/xpu/Event.h
Yu, Guangye df5bbc09d1 Make device-specific event inherits from torch.Event (#134845)
# Motivation
This PR intends to make device-specific Event inherit from the generic torch.Event. The benefit is providing a generic abstract class `torch.Event` for different devices, like `torch.Stream`. This make it easier for Dynamo to capture the Event of different devices, like torch.cuda.Event and torch.xpu.Event.
And the next PR would like to remove previous useless base class `_StreamBase` and `_EventBase` to avoid multiple Inheritance.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/134845
Approved by: https://github.com/albanD, https://github.com/EikanWang
2024-10-01 06:28:41 +00:00

17 lines
369 B
C

#pragma once
#include <ATen/xpu/XPUEvent.h>
#include <torch/csrc/Event.h>
#include <torch/csrc/python_headers.h>
struct THXPEvent : THPEvent {
at::xpu::XPUEvent xpu_event;
};
extern PyObject* THXPEventClass;
void THXPEvent_init(PyObject* module);
inline bool THXPEvent_Check(PyObject* obj) {
return THXPEventClass && PyObject_IsInstance(obj, THXPEventClass);
}