| 1469 | } |
| 1470 | |
| 1471 | bool DecompressTextureSet(ntc::IContext* context, ntc::ITextureSet* textureSet, bool useInt8Weights) |
| 1472 | { |
| 1473 | ntc::DecompressionStats stats; |
| 1474 | ntc::Status ntcStatus = textureSet->Decompress(&stats, useInt8Weights); |
| 1475 | CHECK_NTC_RESULT(Decompress); |
| 1476 | |
| 1477 | printf("CUDA decompression time: %.3f ms\n", stats.gpuTimeMilliseconds); |
| 1478 | |
| 1479 | if (g_options.inputType == ToolInputType::Directory || |
| 1480 | g_options.inputType == ToolInputType::ManifestFile || |
| 1481 | g_options.inputType == ToolInputType::ManifestStdin || |
| 1482 | g_options.inputType == ToolInputType::Images) |
| 1483 | { |
| 1484 | printf("Overall PSNR (%s weights): %.2f dB\n", useInt8Weights ? "INT8" : "FP8", ntc::LossToPSNR(stats.overallLoss)); |
| 1485 | |
| 1486 | if (!useInt8Weights) |
| 1487 | { |
| 1488 | size_t maxNameLength = 0; |
| 1489 | for (int i = 0; i < textureSet->GetTextureCount(); ++i) |
| 1490 | { |
| 1491 | maxNameLength = std::max(maxNameLength, strlen(textureSet->GetTexture(i)->GetName())); |
| 1492 | } |
| 1493 | |
| 1494 | printf("Per-texture PSNR:\n"); |
| 1495 | for (int i = 0; i < textureSet->GetTextureCount(); ++i) |
| 1496 | { |
| 1497 | ntc::ITextureMetadata* texture = textureSet->GetTexture(i); |
| 1498 | int firstChannel, numChannels; |
| 1499 | texture->GetChannels(firstChannel, numChannels); |
| 1500 | |
| 1501 | float textureMSE = 0.f; |
| 1502 | for (int ch = firstChannel; ch < firstChannel + numChannels; ++ch) |
| 1503 | { |
| 1504 | textureMSE += stats.perChannelLoss[ch]; |
| 1505 | } |
| 1506 | textureMSE /= float(numChannels); |
| 1507 | |
| 1508 | printf(" %-*s : %.2f dB [ ", int(maxNameLength), texture->GetName(), ntc::LossToPSNR(textureMSE)); |
| 1509 | for (int ch = firstChannel; ch < firstChannel + numChannels; ++ch) |
| 1510 | { |
| 1511 | printf("%.2f ", ntc::LossToPSNR(stats.perChannelLoss[ch])); |
| 1512 | } |
| 1513 | printf("]\n"); |
| 1514 | } |
| 1515 | } |
| 1516 | |
| 1517 | if (textureSet->GetDesc().mips > 1) |
| 1518 | { |
| 1519 | for (int mip = 0; mip < textureSet->GetDesc().mips; ++mip) |
| 1520 | { |
| 1521 | printf("MIP %2d PSNR: %.2f dB\n", mip, ntc::LossToPSNR(stats.perMipLoss[mip])); |
| 1522 | } |
| 1523 | } |
| 1524 | } |
| 1525 | |
| 1526 | return true; |
| 1527 | } |
| 1528 | |