[go: nahoru, domu]

Skip to content

Commit

Permalink
Test down-conversion of maximum power of 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Marat Dukhan committed Jul 8, 2017
1 parent 383cac2 commit 0ea6095
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/alt-from-fp32-value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ TEST(FP16_ALT_FROM_FP32_VALUE, normalized_powers_of_2) {
"F32 = 0x" << std::setw(8) << sixtyfour_f32 << ", " <<
"F16(F32) = 0x" << std::setw(4) << fp16_alt_from_fp32_value(sixtyfour_value) << ", " <<
"F16 = 0x" << std::setw(4) << sixtyfour_f16;

float max_po2_value;
memcpy(&max_po2_value, &max_po2_f32, sizeof(max_po2_value));
EXPECT_EQ(max_po2_f16, fp16_ieee_from_fp32_value(max_po2_value)) <<
std::hex << std::uppercase << std::setfill('0') <<
"F32 = 0x" << std::setw(8) << max_po2_f32 << ", " <<
"F16(F32) = 0x" << std::setw(4) << fp16_ieee_from_fp32_value(max_po2_value) << ", " <<
"F16 = 0x" << std::setw(4) << max_po2_f16;
}

TEST(FP16_ALT_FROM_FP32_VALUE, denormalized_powers_of_2) {
Expand Down
8 changes: 8 additions & 0 deletions test/ieee-from-fp32-value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ TEST(FP16_IEEE_FROM_FP32_VALUE, normalized_powers_of_2) {
"F32 = 0x" << std::setw(8) << sixtyfour_f32 << ", " <<
"F16(F32) = 0x" << std::setw(4) << fp16_ieee_from_fp32_value(sixtyfour_value) << ", " <<
"F16 = 0x" << std::setw(4) << sixtyfour_f16;

float max_po2_value;
memcpy(&max_po2_value, &max_po2_f32, sizeof(max_po2_value));
EXPECT_EQ(max_po2_f16, fp16_ieee_from_fp32_value(max_po2_value)) <<
std::hex << std::uppercase << std::setfill('0') <<
"F32 = 0x" << std::setw(8) << max_po2_f32 << ", " <<
"F16(F32) = 0x" << std::setw(4) << fp16_ieee_from_fp32_value(max_po2_value) << ", " <<
"F16 = 0x" << std::setw(4) << max_po2_f16;
}

TEST(FP16_IEEE_FROM_FP32_VALUE, denormalized_powers_of_2) {
Expand Down

0 comments on commit 0ea6095

Please sign in to comment.