Skip to content

Commit

Permalink
updated test suite support for to_decibels
Browse files Browse the repository at this point in the history
  • Loading branch information
sampath1117 committed Sep 22, 2023
1 parent 337ccc1 commit d1b5b41
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 19 deletions.
24 changes: 23 additions & 1 deletion utilities/test_suite/HOST/Tensor_host_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int main(int argc, char **argv)
if (argc < MIN_ARG_COUNT)
{
printf("\nImproper Usage! Needs all arguments!\n");
printf("\nUsage: ./Tensor_host_audio <src folder> <u8 = 0 / f16 = 1 / f32 = 2 / u8->f16 = 3 / u8->f32 = 4 / i8 = 5 / u8->i8 = 6> <case number = 0:0> <test type 0/1> <numRuns> <batchSize> <dst folder>\n");
printf("\nUsage: ./Tensor_host_audio <src folder> <u8 = 0 / f16 = 1 / f32 = 2 / u8->f16 = 3 / u8->f32 = 4 / i8 = 5 / u8->i8 = 6> <case number = 0:1> <test type 0/1> <numRuns> <batchSize> <dst folder>\n");
return -1;
}

Expand Down Expand Up @@ -236,6 +236,28 @@ int main(int argc, char **argv)

break;
}
case 1:
{
testCaseName = "to_decibels";
Rpp32f cutOffDB = std::log(1e-20);
Rpp32f multiplier = std::log(10);
Rpp32f referenceMagnitude = 1.0f;

for (i = 0; i < noOfAudioFiles; i++)
{
srcDims[i].height = srcLengthTensor[i];
srcDims[i].width = 1;
}

startWallTime = omp_get_wtime();
startCpuTime = clock();
if (inputBitDepth == 2)
rppt_to_decibels_host(inputf32, srcDescPtr, outputf32, dstDescPtr, srcDims, cutOffDB, multiplier, referenceMagnitude, handle);
else
missingFuncFlag = 1;

break;
}
default:
{
missingFuncFlag = 1;
Expand Down
26 changes: 13 additions & 13 deletions utilities/test_suite/HOST/runAudioTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,29 +119,29 @@ def run_performance_test(loggingFolder, srcPath, case, numRuns, testType, bitDep
def rpp_test_suite_parser_and_validator():
parser = argparse.ArgumentParser()
parser.add_argument("--input_path", type = str, default = inFilePath, help = "Path to the input folder")
parser.add_argument("--case_start", type = int, default = 0, help = "Testing range starting case # - (0:0)")
parser.add_argument("--case_end", type = int, default = 0, help = "Testing range ending case # - (0:0)")
parser.add_argument("--case_start", type = int, default = 0, help = "Testing range starting case # - (0:1)")
parser.add_argument("--case_end", type = int, default = 1, help = "Testing range ending case # - (0:1)")
parser.add_argument('--test_type', type = int, default = 0, help = "Type of Test - (0 = QA tests / 1 = Performance tests)")
parser.add_argument('--case_list', nargs = "+", help = "List of case numbers to test", required = False)
parser.add_argument('--num_runs', type = int, default = 1, help = "Specifies the number of runs for running the performance tests")
parser.add_argument('--preserve_output', type = int, default = 1, help = "preserves the output of the program - (0 = override output / 1 = preserve output )" )
parser.add_argument('--preserve_output', type = int, default = 1, help = "preserves the output of the program - (0 = override output / 1 = preserve output )")
parser.add_argument('--batch_size', type = int, default = 1, help = "Specifies the batch size to use for running tests. Default is 1.")
args = parser.parse_args()

# check if the folder exists
validate_path(args.input_path)

# validate the parameters passed by user
if ((args.case_start < 0 or args.case_start > 0) or (args.case_end < 0 or args.case_end > 0)):
print("Starting case# and Ending case# must be in the 0:0 range. Aborting!")
if ((args.case_start < 0 or args.case_start > 1) or (args.case_end < 0 or args.case_end > 1)):
print("Starting case# and Ending case# must be in the 0:1 range. Aborting!")
exit(0)
elif args.case_end < args.case_start:
print("Ending case# must be greater than starting case#. Aborting!")
exit(0)
elif args.test_type < 0 or args.test_type > 1:
print("Test Type# must be in the 0 / 1. Aborting!")
exit(0)
elif args.case_list is not None and args.case_start > 0 and args.case_end < 0:
elif args.case_list is not None and args.case_start > 1 and args.case_end < 0:
print("Invalid input! Please provide only 1 option between case_list, case_start and case_end")
exit(0)
elif args.num_runs <= 0:
Expand All @@ -162,8 +162,8 @@ def rpp_test_suite_parser_and_validator():
args.case_list = [str(x) for x in args.case_list]
else:
for case in args.case_list:
if int(case) != 0:
print("The case# must be 0!")
if int(case) < 0 or int(case) > 1:
print("The case# must be 0-1 range!")
exit(0)
return args

Expand Down Expand Up @@ -216,21 +216,21 @@ def rpp_test_suite_parser_and_validator():
if batchSize != 8:
print("QA tests can only run with a batch size of 8.")
exit(0)
if int(case) != 0:
print(f"Invalid case number {case}. Case number must be 0!")
if int(case) < 0 or int(case) > 1:
print(f"Invalid case number {case}. Case number must be 0-1 range!")
continue

run_unit_test(srcPath, case, numRuns, testType, bitDepth, batchSize, outFilePath)
else:
for case in caseList:
if int(case) != 0:
print(f"Invalid case number {case}. Case number must be 0!")
if int(case) < 0 or int(case) > 1:
print(f"Invalid case number {case}. Case number must be 0-1 range!")
continue

run_performance_test(loggingFolder, srcPath, case, numRuns, testType, bitDepth, batchSize, outFilePath)

# print the results of qa tests
supportedCaseList = ['0']
supportedCaseList = ['0', '1']
supportedCases = 0
for num in caseList:
if num in supportedCaseList:
Expand Down
6 changes: 6 additions & 0 deletions utilities/test_suite/rpp_test_suite_audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ typedef half Rpp16f;
// Include this header file to use functions from libsndfile
#include <sndfile.h>

std::map<int, string> audioAugmentationMap =
{
{0, "non_silent_region_detection"},
{1, "to_decibels"},
};

void verify_output(Rpp32f *dstPtr, RpptDescPtr dstDescPtr, RpptImagePatchPtr dstDims, string testCase, vector<string> audioNames, string dst)
{
fstream refFile;
Expand Down
5 changes: 0 additions & 5 deletions utilities/test_suite/rpp_test_suite_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ std::map<int, string> augmentationMap =
{87, "tensor_sum"}
};

std::map<int, string> audioAugmentationMap =
{
{0, "non_silent_region_detection"},
};

template <typename T>
inline T validate_pixel_range(T pixel)
{
Expand Down

0 comments on commit d1b5b41

Please sign in to comment.