Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
richagadgil committed Oct 18, 2024
1 parent 1791092 commit a2eb005
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/include/migraphx/generic_float.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ struct generic_float
float32_parts f{};
f.sign = sign;
f.mantissa = mantissa << (float32_parts::mantissa_width() - MantissaSize);
if(exponent == all_ones<ExponentSize>())

if(exponent == 1 and mantissa == 0)
{
f.exponent = 1;
}
else if(exponent == all_ones<ExponentSize>())
{
f.exponent = float32_parts::max_exponent();
}
Expand All @@ -125,6 +130,10 @@ struct generic_float
{
exponent = 0;
}
else if (f.exponent == 1 and f.mantissa == 0)
{
exponent = 1;
}
else if(f.exponent == float32_parts::max_exponent())
{
exponent = all_ones<ExponentSize>();
Expand All @@ -133,7 +142,8 @@ struct generic_float
{
constexpr const int diff = float32_parts::exponent_bias() - exponent_bias();
auto e = int(f.exponent) - diff;
if(e >= all_ones<ExponentSize>())

if(e >= static_cast<int>(all_ones<ExponentSize>()))
{
exponent = all_ones<ExponentSize>();
mantissa = 0;
Expand Down
3 changes: 1 addition & 2 deletions test/float16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <migraphx/float_equal.hpp>
#include <migraphx/ranges.hpp>
#include "test.hpp"
#define HIP_ENABLE_PRINTF

#include <limits>

Expand All @@ -43,7 +42,7 @@ TEST_CASE(fp16_values)

CHECK_FLOAT(1.0f, fp16{1.0f});
CHECK_FLOAT(-1.0f, fp16{-1.0f});
// CHECK_FLOAT(std::numeric_limits<float>::min(), fp16::min());
CHECK_FLOAT(std::numeric_limits<float>::min(), fp16::min());
// CHECK_FLOAT(std::numeric_limits<float>::lowest(), fp16::lowest());
// CHECK_FLOAT(std::numeric_limits<float>::max(), fp16::max());
// CHECK_FLOAT(std::numeric_limits<float>::epsilon(), fp16::epsilon());
Expand Down
1 change: 1 addition & 0 deletions test/float32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ TEST_CASE(fp32_values_working)
CHECK_FLOAT(std::numeric_limits<float>::max(), fp32::max());
CHECK_FLOAT(std::numeric_limits<float>::epsilon(), fp32::epsilon());
CHECK_FLOAT(std::numeric_limits<float>::denorm_min(), fp32::denorm_min());

// CHECK_FLOAT(std::numeric_limits<float>::infinity(), fp32::infinity());
// CHECK_FLOAT(std::numeric_limits<float>::quiet_NaN(), fp32::qnan());
// CHECK_FLOAT(std::numeric_limits<float>::signaling_NaN(), fp32::snan());
Expand Down

0 comments on commit a2eb005

Please sign in to comment.