// Copyright Advanced Micro Devices, Inc., or its affiliates. // SPDX-License-Identifier: MIT #include #include #include #include "CustomSections.hpp" #include "SimpleTest.hpp" using namespace rocRoller; using namespace Catch::Matchers; // TODO Fix this on main to be able to support E4M3 and E5M3. // The prevValue != 0 check is currently specialized for E8M0. TEMPLATE_TEST_CASE("ConvertScales", "[datatypes]", E8M0 /*, E5M3, E4M3*/) { float prevValue = 0; for(int i = 0; i < 255; i++) { uint8_t scale = i; auto curValue = scaleToFloat(static_cast(scale)); if(prevValue != 0) CHECK(curValue == prevValue * 2.0f); auto convertBack = static_cast(floatToScale(curValue)); CHECK(scale == convertBack); prevValue = curValue; } }