Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/cutlass/platform/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,8 @@ struct numeric_limits<float> {
static constexpr float infinity() noexcept { return bit_cast<float, int32_t>(0x7f800000);}
CUTLASS_HOST_DEVICE
static constexpr float max() noexcept { return bit_cast<float, int32_t>(0x7f7fffff);}
CUTLASS_HOST_DEVICE
static constexpr float lowest() noexcept { return -max();}
static constexpr bool is_integer = false;
static constexpr bool has_infinity = true;
};
Expand Down
26 changes: 26 additions & 0 deletions test/unit/core/functional.cu
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

#include "cutlass/functional.h"
#include "cutlass/core_io.h"
#include "cutlass/epilogue/thread/linear_combination_clamp.h"

#include "cutlass/layout/matrix.h"
#include "cutlass/util/host_tensor.h"
Expand Down Expand Up @@ -428,6 +429,31 @@ TEST(Functional, multiply_add_bf16x17) {

/////////////////////////////////////////////////////////////////////////////////////////////////

TEST(Functional, linear_combination_clamp_float) {
using Fragment = cutlass::Array<float, 1>;
using Operator =
cutlass::epilogue::thread::LinearCombinationClamp<float, 1, float, float>;
using Tensor = cutlass::HostTensor<float, cutlass::layout::RowMajor>;

Fragment accumulator;
accumulator[0] = 2.0f;
EXPECT_EQ(Operator()(accumulator)[0], 2.0f);

Tensor output({1, 1});
Tensor input({1, 1});
input.host_data()[0] = 2.0f;
input.sync_device();

test::core::kernel::unary_operator<Fragment, Operator><<<1, 1>>>(
reinterpret_cast<Fragment *>(output.device_data()),
reinterpret_cast<Fragment const *>(input.device_data()));
output.sync_host();

EXPECT_EQ(output.host_data()[0], 2.0f);
}

/////////////////////////////////////////////////////////////////////////////////////////////////

template <typename T>
cutlass::Quaternion<T> random_quaternion(int range) {
return cutlass::Quaternion<T>{
Expand Down