mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
fix c10::Event UT failure on XPU backend (#141800)
# Motivation Fix this UT failure introduced by https://github.com/pytorch/pytorch/pull/140865. The unrelated failure suppressed this UT failure. It goes to happen since https://github.com/pytorch/pytorch/pull/141546 is landed. Pull Request resolved: https://github.com/pytorch/pytorch/pull/141800 Approved by: https://github.com/EikanWang
This commit is contained in:
committed by
PyTorch MergeBot
parent
09ce760fef
commit
77748ed8ec
@ -54,7 +54,7 @@ TEST(XPUGuardTest, EventBehavior) {
|
||||
c10::impl::VirtualGuardImpl impl(device.type());
|
||||
c10::Stream stream1 = impl.getStream(device);
|
||||
c10::Stream stream2 = impl.getStream(device);
|
||||
c10::Event event1(device.type());
|
||||
c10::Event event1(device.type(), c10::EventFlag::BACKEND_DEFAULT);
|
||||
// event is lazily created.
|
||||
EXPECT_FALSE(event1.eventId());
|
||||
|
||||
@ -99,7 +99,7 @@ TEST(XPUGuardTest, EventBehavior) {
|
||||
// ensure deviceData1 and deviceData2 are different buffers.
|
||||
int* deviceData2 = sycl::malloc_device<int>(numel, xpu_stream1);
|
||||
sycl::free(deviceData1, c10::xpu::get_device_context());
|
||||
c10::Event event2(device.type());
|
||||
c10::Event event2(device.type(), c10::EventFlag::BACKEND_DEFAULT);
|
||||
|
||||
// Copy hostData1 to deviceData2 via stream1, and then copy deviceData2 to
|
||||
// hostData1 via stream1.
|
||||
@ -113,6 +113,10 @@ TEST(XPUGuardTest, EventBehavior) {
|
||||
event2.synchronize();
|
||||
EXPECT_TRUE(event2.query());
|
||||
EXPECT_NE(event1.eventId(), event2.eventId());
|
||||
#if SYCL_COMPILER_VERSION < 20250000
|
||||
ASSERT_THROW(event1.elapsedTime(event2), c10::Error);
|
||||
#else
|
||||
event1.elapsedTime(event2);
|
||||
#endif
|
||||
sycl::free(deviceData2, c10::xpu::get_device_context());
|
||||
}
|
||||
|
Reference in New Issue
Block a user