ex42: Fused MHA imported from xFormers (#662)
* ex42: Fused MHA imported from xFormers * Remove std:: references * Support K>128 in the example * Support causal option * Support different head size for V, and different seqlength for KV * Update FLOPS counter * Remove bit_cast * fix build: Replace M_LOG2E * Add doc * Revert "Remove bit_cast" This reverts commit 9662fa86bb7c57c1a015ac0bf52cb52940fbbf80. * Explicit casts to int32_t for windows build Co-authored-by: danthe3rd <danthe3rd>
This commit is contained in:
@@ -574,6 +574,21 @@ using std::is_trivially_copyable;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// bit_cast <bit>
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
template< class To, class From >
|
||||
constexpr To CUTLASS_HOST_DEVICE bit_cast(const From& from ) noexcept;
|
||||
|
||||
template <class To, class From>
|
||||
constexpr To CUTLASS_HOST_DEVICE bit_cast(const From& src) noexcept
|
||||
{
|
||||
static_assert(sizeof(To) == sizeof(From), "sizes must match");
|
||||
return reinterpret_cast<To const &>(src);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Alignment and layout utilities
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -865,5 +880,13 @@ struct numeric_limits<uint8_t> {
|
||||
static constexpr bool is_integer = true;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct numeric_limits<float> {
|
||||
CUTLASS_HOST_DEVICE
|
||||
static constexpr float infinity() noexcept { return bit_cast<float, int32_t>(0x7f800000);}
|
||||
static constexpr bool is_integer = false;
|
||||
static constexpr bool has_infinity = true;
|
||||
};
|
||||
|
||||
} // namespace platform
|
||||
} // namespace cutlass
|
||||
|
||||
Reference in New Issue
Block a user