forked from PaddlePaddle/Paddle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request PaddlePaddle#52 from bob80333/main
Make flash attention compile on Windows.
- Loading branch information
Showing
4 changed files
with
34 additions
and
5 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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Inspired by https://github.com/NVIDIA/DALI/blob/main/include/dali/core/static_switch.h | ||
// and https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/Dispatch.h | ||
|
||
// modified from static_switch.h | ||
// because MSVC cannot handle std::conditional with constexpr variable | ||
|
||
#pragma once | ||
|
||
/// @param COND - a boolean expression to switch by | ||
/// @param ... - code to execute for true and false | ||
/// | ||
/// Usage: | ||
/// ``` | ||
/// FP16_SWITCH(flag, [&] { | ||
/// some_function(...); | ||
/// }); | ||
/// ``` | ||
#define FP16_SWITCH(COND, ...) \ | ||
[&] { \ | ||
if (COND) { \ | ||
using elem_type = __nv_bfloat16; \ | ||
return __VA_ARGS__(); \ | ||
} else { \ | ||
using elem_type = __half; \ | ||
return __VA_ARGS__(); \ | ||
} \ | ||
}() |
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