mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
# 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
20 lines
433 B
C
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
|