pytorch/torch/csrc/cuda/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

20 lines
433 B
C

#ifndef THCP_EVENT_INC
#define THCP_EVENT_INC
#include <ATen/cuda/CUDAEvent.h>
#include <torch/csrc/Event.h>
#include <torch/csrc/python_headers.h>
struct THCPEvent : THPEvent {
at::cuda::CUDAEvent cuda_event;
};
extern PyObject* THCPEventClass;
void THCPEvent_init(PyObject* module);
inline bool THCPEvent_Check(PyObject* obj) {
return THCPEventClass && PyObject_IsInstance(obj, THCPEventClass);
}
#endif // THCP_EVENT_INC