Skip to content

Commit

Permalink
Improve CPU reference accurary
Browse files Browse the repository at this point in the history
The relative difference between contraction result and CPU reference is
less than 0.1% after the improvement.
  • Loading branch information
CongMa13 committed Dec 6, 2023
1 parent 1d7aeee commit 89d5c93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion library/src/contraction/contraction_cpu_reference_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ namespace hiptensor
arg.mOpB(valB, ((BDataType*)arg.mB)[indexB]);

// Mult / accum
accum += ck::type_convert<float>(valA) * ck::type_convert<float>(valB);
accum += ck::type_convert<float>(ck::type_convert<ComputeDataType>(
ck::type_convert<float>(valA) * ck::type_convert<float>(valB)));
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ template <typename DDataType>
std::pair<bool, double> compareEqual(DDataType const* deviceD,
DDataType const* hostD,
std::size_t elementsD,
double tolerance = 0.005)
double tolerance = 0.001)
{
bool retval = true;
double max_relative_error = 0.0;
Expand Down Expand Up @@ -214,7 +214,7 @@ template <typename DDataType>
std::pair<bool, double> compareEqualLaunchKernel(DDataType* deviceD,
DDataType* hostD,
std::size_t elementsD,
double tolerance = 0.005)
double tolerance = 0.001)
{
auto blockDim = dim3(1024, 1, 1);
auto gridDim = dim3(ceilDiv(elementsD, blockDim.x), 1, 1);
Expand Down

0 comments on commit 89d5c93

Please sign in to comment.