mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[XPU] Enhance XPUGeneratorImpl functionality to support XPUGraph (#163332)
As this [XPUGraph RFC](https://github.com/pytorch/pytorch/issues/162143) descripted. This PR enhances `XPUGeneratorImpl` to support XPUGraph. In this PR, we add `XPUGerneratorState` and `PhiloxXpuState`. Which makes XPUGraph update philox state during graph capture and replay correctly XPUGraph PR submission plan: - [ ] 1, Enhance XPUGenerator functionality. Add XPUGeneratorState and philoxState - [ ] 2, implemenet XPUGraph capture_begin/capture_end/instantiate functionality - [ ] 3, implemenet XPUGraph replay/debug_dump/reset functionality - [ ] 4, python APIs: is_current_stream_capturing/graph_pool_handle/graph - [ ] 5, python APIs: make_graphed_callables Pull Request resolved: https://github.com/pytorch/pytorch/pull/163332 Approved by: https://github.com/gujinghui, https://github.com/EikanWang, https://github.com/albanD
This commit is contained in:
committed by
PyTorch MergeBot
parent
8de85896e0
commit
59ad8f1ac6
42
c10/xpu/XPUGraphsC10Utils.h
Normal file
42
c10/xpu/XPUGraphsC10Utils.h
Normal file
@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <c10/xpu/XPUStream.h>
|
||||
#include <iostream>
|
||||
|
||||
// XPU Graphs utils used by c10 and aten.
|
||||
using namespace sycl::ext::oneapi::experimental;
|
||||
namespace c10::xpu {
|
||||
|
||||
static_assert(
|
||||
int8_t(queue_state::executing) == 0,
|
||||
"unexpected int(queue_state::executing) value");
|
||||
static_assert(
|
||||
int8_t(queue_state::recording) == 1,
|
||||
"unexpected int(queue_state::recording) value");
|
||||
|
||||
enum class CaptureStatus : int8_t {
|
||||
Executing = int8_t(queue_state::executing),
|
||||
Recording = int8_t(queue_state::recording)
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, CaptureStatus status) {
|
||||
switch (status) {
|
||||
case CaptureStatus::Executing:
|
||||
os << "Executing";
|
||||
break;
|
||||
case CaptureStatus::Recording:
|
||||
os << "Recording";
|
||||
break;
|
||||
default:
|
||||
TORCH_INTERNAL_ASSERT(
|
||||
false, "Unknown XPU graph CaptureStatus", int(status));
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
inline CaptureStatus currentStreamCaptureStatusMayInitCtx() {
|
||||
auto state = c10::xpu::getCurrentXPUStream().queue().ext_oneapi_get_state();
|
||||
return CaptureStatus(state);
|
||||
}
|
||||
|
||||
} // namespace c10::xpu
|
Reference in New Issue
Block a user