Unit Test: use range from 0 to 1 for floating point test data (#459)
* Unit Test: use range from 0 to 1 for floating point test data * gtest: Update init data and bfloat16 threshold
This commit is contained in:
@@ -689,15 +689,15 @@ dropback:
|
|||||||
// NOTE: Currently half-precision float tests are unsupported due to half being supported
|
// NOTE: Currently half-precision float tests are unsupported due to half being supported
|
||||||
// on GPU only and not host
|
// on GPU only and not host
|
||||||
|
|
||||||
// Fills input data[i][j] with (i + j) % 6
|
// Fills input data[i][j] with (i + j) % 256
|
||||||
// - Keeping range small to reduce likelihood of overflow
|
// - Keeping range small to reduce likelihood of overflow
|
||||||
// - Sticking with floating points values that are perfectly representable
|
// - Sticking with floating points values that are perfectly representable
|
||||||
for (int i = 0; i < dataset.numDevices; i++)
|
for (int i = 0; i < dataset.numDevices; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < dataset.NumBytes(ncclInputBuffer)/DataTypeToBytes(dataset.dataType); j++)
|
for (int j = 0; j < dataset.NumBytes(ncclInputBuffer)/DataTypeToBytes(dataset.dataType); j++)
|
||||||
{
|
{
|
||||||
int valueI = (i + j) % 6;
|
int valueI = (i + j) % 256;
|
||||||
float valueF = (float)valueI;
|
double valueF = 1.0L/((double)valueI+1.0L);
|
||||||
|
|
||||||
switch (dataset.dataType)
|
switch (dataset.dataType)
|
||||||
{
|
{
|
||||||
@@ -812,7 +812,7 @@ dropback:
|
|||||||
case ncclUint64: isMatch &= (outputU8[j] == expectedU8[j]); break;
|
case ncclUint64: isMatch &= (outputU8[j] == expectedU8[j]); break;
|
||||||
case ncclFloat32: isMatch &= (fabs(outputF4[j] - expectedF4[j]) < 1e-5); break;
|
case ncclFloat32: isMatch &= (fabs(outputF4[j] - expectedF4[j]) < 1e-5); break;
|
||||||
case ncclFloat64: isMatch &= (fabs(outputF8[j] - expectedF8[j]) < 1e-12); break;
|
case ncclFloat64: isMatch &= (fabs(outputF8[j] - expectedF8[j]) < 1e-12); break;
|
||||||
case ncclBfloat16: isMatch &= (fabs((float)outputB2[j] - (float)expectedB2[j]) < 1e-2); break;
|
case ncclBfloat16: isMatch &= (fabs((float)outputB2[j] - (float)expectedB2[j]) < 5e-2); break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "[ERROR] Unsupported datatype\n");
|
fprintf(stderr, "[ERROR] Unsupported datatype\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user