forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BE][MPS] Add MPS to clang format (pytorch#96562)
I'm getting tired of asking to add space after if and all that jazz, so let's linter do that. Add section for Objective-C language, where column with is extended to 120 characters and `AlignAfterOpenBracket` is set to `Align` All `.mm` changes in this PR are made by running linter as follows: ``` lintrunner --take CLANGFORMAT --all-files --apply-patches ``` Pull Request resolved: pytorch#96562 Approved by: https://github.com/seemethere, https://github.com/janeyx99, https://github.com/ZainRizvi, https://github.com/izaitsevfb, https://github.com/PaliC, https://github.com/albanD
- Loading branch information
1 parent
a7689e7
commit 4242e69
Showing
48 changed files
with
8,308 additions
and
9,148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,47 @@ | ||
// Copyright © 2022 Apple Inc. | ||
|
||
#include <ATen/mps/MPSGuardImpl.h> | ||
#include <ATen/mps/MPSDevice.h> | ||
#include <ATen/mps/MPSGuardImpl.h> | ||
|
||
namespace at { | ||
namespace mps { | ||
|
||
void MPSGuardImpl::createEvent( | ||
mpsEvent_t* event, | ||
const EventFlag flag) const { | ||
} | ||
|
||
void MPSGuardImpl::destroyEvent( | ||
void* event, | ||
const DeviceIndex device_index) const noexcept { | ||
if (!event) return; | ||
auto mps_event = static_cast<mpsEvent_t>(event); | ||
mps_event->~MPSEvent(); | ||
|
||
} | ||
|
||
void MPSGuardImpl::record( | ||
void** event, | ||
const Stream& stream, | ||
const DeviceIndex device_index, | ||
const EventFlag flag) const { | ||
|
||
TORCH_CHECK(device_index == -1 || device_index == stream.device_index(), | ||
"Event device index ", | ||
device_index, | ||
" does not match recording stream's device index ", | ||
stream.device_index(), | ||
"."); | ||
|
||
auto mps_event = static_cast<mpsEvent_t>(*event); | ||
MPSStream mps_stream{stream}; | ||
mps_event->recordEvent(true); | ||
} | ||
|
||
void MPSGuardImpl::block( | ||
void* event, | ||
const Stream& stream) const { | ||
|
||
auto mps_event = static_cast<mpsEvent_t>(event); | ||
MPSStream mps_stream{stream}; | ||
|
||
mps_event->waitForEvent(true); | ||
} | ||
|
||
bool MPSGuardImpl::queryEvent(void* event) const { | ||
auto mps_event = static_cast<mpsEvent_t>(event); | ||
return mps_event->queryEvent(); | ||
} | ||
void MPSGuardImpl::createEvent(mpsEvent_t* event, const EventFlag flag) const {} | ||
|
||
void MPSGuardImpl::destroyEvent(void* event, const DeviceIndex device_index) const noexcept { | ||
if (!event) | ||
return; | ||
auto mps_event = static_cast<mpsEvent_t>(event); | ||
mps_event->~MPSEvent(); | ||
} | ||
|
||
void MPSGuardImpl::record(void** event, | ||
const Stream& stream, | ||
const DeviceIndex device_index, | ||
const EventFlag flag) const { | ||
TORCH_CHECK(device_index == -1 || device_index == stream.device_index(), | ||
"Event device index ", | ||
device_index, | ||
" does not match recording stream's device index ", | ||
stream.device_index(), | ||
"."); | ||
|
||
auto mps_event = static_cast<mpsEvent_t>(*event); | ||
MPSStream mps_stream{stream}; | ||
mps_event->recordEvent(true); | ||
} | ||
|
||
void MPSGuardImpl::block(void* event, const Stream& stream) const { | ||
auto mps_event = static_cast<mpsEvent_t>(event); | ||
MPSStream mps_stream{stream}; | ||
|
||
mps_event->waitForEvent(true); | ||
} | ||
|
||
bool MPSGuardImpl::queryEvent(void* event) const { | ||
auto mps_event = static_cast<mpsEvent_t>(event); | ||
return mps_event->queryEvent(); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.