Commit a0bde1f4 authored by Bartlomiej Wroblewski's avatar Bartlomiej Wroblewski
Browse files

Include possible DataType -> ComputeDataType casting error in the threshold

parent cfcdb03e
...@@ -290,14 +290,18 @@ int profile_contraction_impl(ck::index_t do_verification, ...@@ -290,14 +290,18 @@ int profile_contraction_impl(ck::index_t do_verification,
// Comparing one to another can result in an absolute error as high as twice that // Comparing one to another can result in an absolute error as high as twice that
// value. // value.
double threshold = 2 * nelems_k * std::numeric_limits<AccDataType>::epsilon(); double threshold = 2 * nelems_k * std::numeric_limits<AccDataType>::epsilon();
// TODO: Add a generic solution in CK. // Handle the possible casting error of either AccDataType -> DataType or
if constexpr(ck::is_same_v<DataType, ck::bhalf_t>) // DataType -> ComputeDataType.
// TODO: Add a generic solution for calculating thresholds in CK.
if constexpr(ck::is_same_v<DataType, ck::bhalf_t> ||
ck::is_same_v<ComputeDataType, ck::bhalf_t>)
{ {
const double epsilon = std::pow(2, -7); const double epsilon = std::pow(2, -7);
// Maximum relative casting error when rounding to zero. // Maximum relative casting error when rounding to zero.
threshold += epsilon * 2; threshold += epsilon * 2;
} }
else if constexpr(ck::is_same_v<DataType, ck::half_t>) else if constexpr(ck::is_same_v<DataType, ck::half_t> ||
ck::is_same_v<ComputeDataType, ck::half_t>)
{ {
const double epsilon = std::pow(2, -10); const double epsilon = std::pow(2, -10);
// Maximum relative casting error when rounding to zero. // Maximum relative casting error when rounding to zero.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment