From a09de0c8b2ed0f1481502d3b023375609362d9e3 Mon Sep 17 00:00:00 2001 From: Moritz Pflanzer Date: Fri, 1 Sep 2017 20:41:12 +0100 Subject: COMPMID-415: Rename and move tests The boost validation is now "standalone" in validation_old and builds as arm_compute_validation_old. The new validation builds now as arm_compute_validation. Change-Id: Ib93ba848a25680ac60afb92b461d574a0757150d Reviewed-on: http://mpd-gerrit.cambridge.arm.com/86187 Tested-by: Kaizen Reviewed-by: Anthony Barbier --- SConstruct | 1 - docs/02_tests.dox | 31 +- docs/Doxyfile | 1 - framework/Asserts.h | 132 --- framework/DatasetModes.cpp | 56 - framework/DatasetModes.h | 106 -- framework/Exceptions.cpp | 128 --- framework/Exceptions.h | 97 -- framework/Fixture.h | 63 -- framework/Framework.cpp | 494 -------- framework/Framework.h | 330 ------ framework/Macros.h | 260 ----- framework/Profiler.cpp | 67 -- framework/Profiler.h | 75 -- framework/Registrars.h | 113 -- framework/SConscript | 71 -- framework/TestCase.h | 70 -- framework/TestCaseFactory.h | 202 ---- framework/TestFilter.cpp | 143 --- framework/TestFilter.h | 84 -- framework/TestResult.h | 80 -- framework/Utils.h | 158 --- framework/command_line/CommandLineOptions.h | 33 - framework/command_line/CommandLineParser.cpp | 149 --- framework/command_line/CommandLineParser.h | 117 -- framework/command_line/EnumListOption.h | 148 --- framework/command_line/EnumOption.h | 134 --- framework/command_line/ListOption.h | 116 -- framework/command_line/Option.cpp | 68 -- framework/command_line/Option.h | 109 -- framework/command_line/SimpleOption.h | 105 -- framework/command_line/ToggleOption.cpp | 64 -- framework/command_line/ToggleOption.h | 56 - framework/datasets/CartesianProductDataset.h | 165 --- framework/datasets/ContainerDataset.h | 148 --- framework/datasets/Dataset.h | 86 -- framework/datasets/Datasets.h | 35 - framework/datasets/InitializerListDataset.h | 135 --- framework/datasets/JoinDataset.h | 148 --- framework/datasets/RangeDataset.h | 141 --- framework/datasets/SingletonDataset.h | 138 --- framework/datasets/ZipDataset.h | 139 --- framework/instruments/Instrument.h | 98 -- framework/instruments/Instruments.cpp | 59 - framework/instruments/Instruments.h | 105 -- framework/instruments/PMUCounter.cpp | 140 --- framework/instruments/PMUCounter.h | 71 -- framework/instruments/WallClockTimer.cpp | 57 - framework/instruments/WallClockTimer.h | 53 - framework/printers/JSONPrinter.cpp | 168 --- framework/printers/JSONPrinter.h | 64 -- framework/printers/PrettyPrinter.cpp | 140 --- framework/printers/PrettyPrinter.h | 69 -- framework/printers/Printer.cpp | 48 - framework/printers/Printer.h | 129 --- framework/printers/Printers.cpp | 57 - framework/printers/Printers.h | 75 -- scripts/check_bad_style.sh | 4 +- scripts/fix_code_formatting.sh | 2 +- tests/AssetsLibrary.cpp | 3 +- tests/AssetsLibrary.h | 2 +- tests/CMakeLists.txt | 85 -- tests/Globals.h | 2 +- tests/ProgramOptions.cpp | 88 -- tests/ProgramOptions.h | 101 -- tests/RawTensor.h | 2 +- tests/SConscript | 124 +-- tests/UserConfiguration.cpp | 55 - tests/UserConfiguration.h | 136 --- tests/Utils.h | 2 +- tests/benchmark/CL/ActivationLayer.cpp | 128 +++ tests/benchmark/CL/BatchNormalizationLayer.cpp | 73 ++ tests/benchmark/CL/ConvolutionLayer.cpp | 118 ++ tests/benchmark/CL/DepthwiseConvolution.cpp | 51 + .../CL/DepthwiseSeparableConvolutionLayer.cpp | 51 + tests/benchmark/CL/DirectConvolutionLayer.cpp | 107 ++ tests/benchmark/CL/Floor.cpp | 54 + tests/benchmark/CL/FullyConnectedLayer.cpp | 106 ++ tests/benchmark/CL/GEMM.cpp | 54 + tests/benchmark/CL/NormalizationLayer.cpp | 73 ++ tests/benchmark/CL/PoolingLayer.cpp | 128 +++ tests/benchmark/CL/ROIPoolingLayer.cpp | 53 + tests/benchmark/CL/SYSTEM/AlexNet.cpp | 68 ++ tests/benchmark/CL/SYSTEM/LeNet5.cpp | 60 + tests/benchmark/NEON/ActivationLayer.cpp | 118 ++ tests/benchmark/NEON/BatchNormalizationLayer.cpp | 74 ++ tests/benchmark/NEON/ConvolutionLayer.cpp | 111 ++ tests/benchmark/NEON/DirectConvolutionLayer.cpp | 103 ++ tests/benchmark/NEON/Floor.cpp | 54 + tests/benchmark/NEON/FullyConnectedLayer.cpp | 110 ++ tests/benchmark/NEON/GEMM.cpp | 62 ++ tests/benchmark/NEON/NormalizationLayer.cpp | 76 ++ tests/benchmark/NEON/PoolingLayer.cpp | 104 ++ tests/benchmark/NEON/ROIPoolingLayer.cpp | 53 + tests/benchmark/NEON/SYSTEM/AlexNet.cpp | 77 ++ tests/benchmark/NEON/SYSTEM/LeNet5.cpp | 60 + tests/benchmark/fixtures/ActivationLayerFixture.h | 82 ++ tests/benchmark/fixtures/AlexNetFixture.h | 89 ++ .../fixtures/BatchNormalizationLayerFixture.h | 102 ++ tests/benchmark/fixtures/ConvolutionLayerFixture.h | 93 ++ .../fixtures/DepthwiseConvolutionFixture.h | 88 ++ .../DepthwiseSeparableConvolutionLayerFixture.h | 103 ++ tests/benchmark/fixtures/FloorFixture.h | 78 ++ .../fixtures/FullyConnectedLayerFixture.h | 93 ++ tests/benchmark/fixtures/GEMMFixture.h | 89 ++ tests/benchmark/fixtures/LeNet5Fixture.h | 77 ++ .../benchmark/fixtures/NormalizationLayerFixture.h | 82 ++ tests/benchmark/fixtures/PoolingLayerFixture.h | 83 ++ tests/benchmark/fixtures/ROIPoolingLayerFixture.h | 95 ++ tests/benchmark_new/CL/ActivationLayer.cpp | 128 --- tests/benchmark_new/CL/BatchNormalizationLayer.cpp | 73 -- tests/benchmark_new/CL/ConvolutionLayer.cpp | 118 -- tests/benchmark_new/CL/DepthwiseConvolution.cpp | 51 - .../CL/DepthwiseSeparableConvolutionLayer.cpp | 51 - tests/benchmark_new/CL/DirectConvolutionLayer.cpp | 107 -- tests/benchmark_new/CL/Floor.cpp | 54 - tests/benchmark_new/CL/FullyConnectedLayer.cpp | 106 -- tests/benchmark_new/CL/GEMM.cpp | 54 - tests/benchmark_new/CL/NormalizationLayer.cpp | 73 -- tests/benchmark_new/CL/PoolingLayer.cpp | 128 --- tests/benchmark_new/CL/ROIPoolingLayer.cpp | 53 - tests/benchmark_new/CL/SYSTEM/AlexNet.cpp | 68 -- tests/benchmark_new/CL/SYSTEM/LeNet5.cpp | 60 - tests/benchmark_new/NEON/ActivationLayer.cpp | 118 -- .../benchmark_new/NEON/BatchNormalizationLayer.cpp | 74 -- tests/benchmark_new/NEON/ConvolutionLayer.cpp | 111 -- .../benchmark_new/NEON/DirectConvolutionLayer.cpp | 103 -- tests/benchmark_new/NEON/Floor.cpp | 54 - tests/benchmark_new/NEON/FullyConnectedLayer.cpp | 110 -- tests/benchmark_new/NEON/GEMM.cpp | 62 -- tests/benchmark_new/NEON/NormalizationLayer.cpp | 76 -- tests/benchmark_new/NEON/PoolingLayer.cpp | 104 -- tests/benchmark_new/NEON/ROIPoolingLayer.cpp | 53 - tests/benchmark_new/NEON/SYSTEM/AlexNet.cpp | 77 -- tests/benchmark_new/NEON/SYSTEM/LeNet5.cpp | 60 - tests/boost_wrapper.h | 40 - tests/dataset/ActivationFunctionDataset.h | 67 -- tests/dataset/ActivationLayerDataset.h | 177 --- tests/dataset/BatchNormalizationLayerDataset.h | 90 -- tests/dataset/BorderModeDataset.h | 82 -- tests/dataset/ConvertPolicyDataset.h | 82 -- tests/dataset/ConvolutionLayerDataset.h | 273 ----- tests/dataset/DataTypeDatasets.h | 193 ---- tests/dataset/FullyConnectedLayerDataset.h | 155 --- tests/dataset/GEMMDataset.h | 220 ---- tests/dataset/GenericDataset.h | 97 -- tests/dataset/ImageDatasets.h | 120 -- tests/dataset/InterpolationPolicyDataset.h | 80 -- tests/dataset/MatrixPatternDataset.h | 82 -- tests/dataset/NonLinearFilterFunctionDataset.h | 82 -- tests/dataset/NormalizationLayerDataset.h | 99 -- tests/dataset/NormalizationTypeDataset.h | 80 -- tests/dataset/PoolingLayerDataset.h | 138 --- tests/dataset/PoolingTypesDataset.h | 55 - tests/dataset/RoundingPolicyDataset.h | 82 -- tests/dataset/ShapeDatasets.h | 152 --- tests/dataset/ThresholdDataset.h | 95 -- tests/datasets/ActivationFunctionsDataset.h | 61 + tests/datasets/BatchNormalizationLayerDataset.h | 116 ++ tests/datasets/BorderModeDataset.h | 54 + tests/datasets/ConvolutionLayerDataset.h | 126 +++ tests/datasets/DepthwiseConvolutionDataset.h | 119 ++ .../DepthwiseSeparableConvolutionLayerDataset.h | 149 +++ tests/datasets/DirectConvolutionLayerDataset.h | 60 + tests/datasets/FullyConnectedLayerDataset.h | 151 +++ tests/datasets/GEMMDataset.h | 132 +++ tests/datasets/InterpolationPolicyDataset.h | 51 + tests/datasets/LargeConvolutionLayerDataset.h | 76 ++ tests/datasets/LargeDepthwiseConvolutionDataset.h | 56 + tests/datasets/LargeGEMMDataset.h | 54 + tests/datasets/MatrixMultiplyGEMMDataset.h | 52 + .../MobileNetDepthwiseConvolutionDataset.h | 58 + ...eNetDepthwiseSeparableConvolutionLayerDataset.h | 70 ++ tests/datasets/NormalizationTypesDataset.h | 52 + tests/datasets/PoolingLayerDataset.h | 111 ++ tests/datasets/PoolingTypesDataset.h | 52 + tests/datasets/ROIPoolingLayerDataset.h | 127 +++ tests/datasets/ReductionOperationDataset.h | 53 + tests/datasets/ShapeDatasets.h | 148 +++ tests/datasets/SmallConvolutionLayerDataset.h | 66 ++ tests/datasets/SmallDepthwiseConvolutionDataset.h | 56 + tests/datasets/SmallGEMMDataset.h | 54 + .../alexnet/AlexNetActivationLayerDataset.h | 58 + .../alexnet/AlexNetConvolutionLayerDataset.h | 66 ++ .../alexnet/AlexNetFullyConnectedLayerDataset.h | 53 + .../alexnet/AlexNetNormalizationLayerDataset.h | 58 + .../alexnet/AlexNetPoolingLayerDataset.h | 53 + .../GoogLeNetInceptionV1ActivationLayerDataset.h | 123 ++ .../GoogLeNetInceptionV1ConvolutionLayerDataset.h | 237 ++++ ...oogLeNetInceptionV1FullyConnectedLayerDataset.h | 51 + .../inceptionv1/GoogLeNetInceptionV1GEMMDataset.h | 113 ++ ...GoogLeNetInceptionV1NormalizationLayerDataset.h | 61 + .../GoogLeNetInceptionV1PoolingLayerDataset.h | 71 ++ .../GoogLeNetInceptionV4ActivationLayerDataset.h | 101 ++ ...eNetInceptionV4BatchNormalizationLayerDataset.h | 94 ++ .../GoogLeNetInceptionV4ConvolutionLayerDataset.h | 184 +++ ...oogLeNetInceptionV4FullyConnectedLayerDataset.h | 51 + .../GoogLeNetInceptionV4PoolingLayerDataset.h | 65 ++ .../lenet5/LeNet5ActivationLayerDataset.h | 58 + .../lenet5/LeNet5ConvolutionLayerDataset.h | 52 + .../lenet5/LeNet5FullyConnectedLayerDataset.h | 54 + .../lenet5/LeNet5PoolingLayerDataset.h | 52 + .../squeezenet/SqueezeNetActivationLayerDataset.h | 77 ++ .../squeezenet/SqueezeNetConvolutionLayerDataset.h | 86 ++ .../squeezenet/SqueezeNetPoolingLayerDataset.h | 57 + .../vgg/vgg16/VGG16ActivationLayerDataset.h | 69 ++ .../vgg/vgg16/VGG16ConvolutionLayerDataset.h | 94 ++ .../vgg/vgg16/VGG16FullyConnectedLayerDataset.h | 56 + .../vgg/vgg16/VGG16PoolingLayerDataset.h | 60 + .../yolo/v2/YOLOV2ActivationLayerDataset.h | 109 ++ .../yolo/v2/YOLOV2BatchNormalizationLayerDataset.h | 70 ++ .../yolo/v2/YOLOV2ConvolutionLayerDataset.h | 76 ++ .../yolo/v2/YOLOV2PoolingLayerDataset.h | 60 + tests/datasets_new/ActivationFunctionsDataset.h | 58 - .../datasets_new/BatchNormalizationLayerDataset.h | 116 -- tests/datasets_new/BorderModeDataset.h | 51 - tests/datasets_new/ConvolutionLayerDataset.h | 126 --- tests/datasets_new/DepthwiseConvolutionDataset.h | 119 -- .../DepthwiseSeparableConvolutionLayerDataset.h | 149 --- tests/datasets_new/DirectConvolutionLayerDataset.h | 60 - tests/datasets_new/FullyConnectedLayerDataset.h | 151 --- tests/datasets_new/GEMMDataset.h | 132 --- tests/datasets_new/InterpolationPolicyDataset.h | 51 - tests/datasets_new/LargeConvolutionLayerDataset.h | 76 -- .../LargeDepthwiseConvolutionDataset.h | 56 - tests/datasets_new/LargeGEMMDataset.h | 54 - tests/datasets_new/MatrixMultiplyGEMMDataset.h | 52 - .../MobileNetDepthwiseConvolutionDataset.h | 58 - ...eNetDepthwiseSeparableConvolutionLayerDataset.h | 70 -- tests/datasets_new/NormalizationTypesDataset.h | 49 - tests/datasets_new/PoolingLayerDataset.h | 112 -- tests/datasets_new/PoolingTypesDataset.h | 49 - tests/datasets_new/ROIPoolingLayerDataset.h | 127 --- tests/datasets_new/ReductionOperationDataset.h | 50 - tests/datasets_new/ShapeDatasets.h | 148 --- tests/datasets_new/SmallConvolutionLayerDataset.h | 66 -- .../SmallDepthwiseConvolutionDataset.h | 56 - tests/datasets_new/SmallGEMMDataset.h | 54 - .../alexnet/AlexNetActivationLayerDataset.h | 58 - .../alexnet/AlexNetConvolutionLayerDataset.h | 66 -- .../alexnet/AlexNetFullyConnectedLayerDataset.h | 53 - .../alexnet/AlexNetNormalizationLayerDataset.h | 58 - .../alexnet/AlexNetPoolingLayerDataset.h | 53 - .../GoogLeNetInceptionV1ActivationLayerDataset.h | 123 -- .../GoogLeNetInceptionV1ConvolutionLayerDataset.h | 237 ---- ...oogLeNetInceptionV1FullyConnectedLayerDataset.h | 51 - .../inceptionv1/GoogLeNetInceptionV1GEMMDataset.h | 113 -- ...GoogLeNetInceptionV1NormalizationLayerDataset.h | 61 - .../GoogLeNetInceptionV1PoolingLayerDataset.h | 71 -- .../GoogLeNetInceptionV4ActivationLayerDataset.h | 101 -- ...eNetInceptionV4BatchNormalizationLayerDataset.h | 94 -- .../GoogLeNetInceptionV4ConvolutionLayerDataset.h | 184 --- ...oogLeNetInceptionV4FullyConnectedLayerDataset.h | 51 - .../GoogLeNetInceptionV4PoolingLayerDataset.h | 65 -- .../lenet5/LeNet5ActivationLayerDataset.h | 58 - .../lenet5/LeNet5ConvolutionLayerDataset.h | 52 - .../lenet5/LeNet5FullyConnectedLayerDataset.h | 54 - .../lenet5/LeNet5PoolingLayerDataset.h | 52 - .../squeezenet/SqueezeNetActivationLayerDataset.h | 77 -- .../squeezenet/SqueezeNetConvolutionLayerDataset.h | 86 -- .../squeezenet/SqueezeNetPoolingLayerDataset.h | 57 - .../vgg/vgg16/VGG16ActivationLayerDataset.h | 69 -- .../vgg/vgg16/VGG16ConvolutionLayerDataset.h | 94 -- .../vgg/vgg16/VGG16FullyConnectedLayerDataset.h | 56 - .../vgg/vgg16/VGG16PoolingLayerDataset.h | 60 - .../yolo/v2/YOLOV2ActivationLayerDataset.h | 109 -- .../yolo/v2/YOLOV2BatchNormalizationLayerDataset.h | 70 -- .../yolo/v2/YOLOV2ConvolutionLayerDataset.h | 76 -- .../yolo/v2/YOLOV2PoolingLayerDataset.h | 60 - tests/fixtures_new/ActivationLayerFixture.h | 82 -- tests/fixtures_new/AlexNetFixture.h | 89 -- .../fixtures_new/BatchNormalizationLayerFixture.h | 102 -- tests/fixtures_new/ConvolutionLayerFixture.h | 93 -- tests/fixtures_new/DepthwiseConvolutionFixture.h | 88 -- .../DepthwiseSeparableConvolutionLayerFixture.h | 103 -- tests/fixtures_new/FloorFixture.h | 78 -- tests/fixtures_new/FullyConnectedLayerFixture.h | 93 -- tests/fixtures_new/GEMMFixture.h | 89 -- tests/fixtures_new/LeNet5Fixture.h | 77 -- tests/fixtures_new/NormalizationLayerFixture.h | 82 -- tests/fixtures_new/PoolingLayerFixture.h | 83 -- tests/fixtures_new/ROIPoolingLayerFixture.h | 95 -- tests/framework/Asserts.h | 132 +++ tests/framework/DatasetModes.cpp | 56 + tests/framework/DatasetModes.h | 106 ++ tests/framework/Exceptions.cpp | 128 +++ tests/framework/Exceptions.h | 97 ++ tests/framework/Fixture.h | 63 ++ tests/framework/Framework.cpp | 494 ++++++++ tests/framework/Framework.h | 330 ++++++ tests/framework/Macros.h | 260 +++++ tests/framework/Profiler.cpp | 67 ++ tests/framework/Profiler.h | 75 ++ tests/framework/Registrars.h | 113 ++ tests/framework/SConscript | 71 ++ tests/framework/TestCase.h | 70 ++ tests/framework/TestCaseFactory.h | 202 ++++ tests/framework/TestFilter.cpp | 143 +++ tests/framework/TestFilter.h | 84 ++ tests/framework/TestResult.h | 80 ++ tests/framework/Utils.h | 158 +++ tests/framework/command_line/CommandLineOptions.h | 33 + tests/framework/command_line/CommandLineParser.cpp | 149 +++ tests/framework/command_line/CommandLineParser.h | 117 ++ tests/framework/command_line/EnumListOption.h | 148 +++ tests/framework/command_line/EnumOption.h | 134 +++ tests/framework/command_line/ListOption.h | 116 ++ tests/framework/command_line/Option.cpp | 68 ++ tests/framework/command_line/Option.h | 109 ++ tests/framework/command_line/SimpleOption.h | 105 ++ tests/framework/command_line/ToggleOption.cpp | 64 ++ tests/framework/command_line/ToggleOption.h | 56 + tests/framework/datasets/CartesianProductDataset.h | 165 +++ tests/framework/datasets/ContainerDataset.h | 148 +++ tests/framework/datasets/Dataset.h | 86 ++ tests/framework/datasets/Datasets.h | 35 + tests/framework/datasets/InitializerListDataset.h | 135 +++ tests/framework/datasets/JoinDataset.h | 148 +++ tests/framework/datasets/RangeDataset.h | 141 +++ tests/framework/datasets/SingletonDataset.h | 138 +++ tests/framework/datasets/ZipDataset.h | 139 +++ tests/framework/instruments/Instrument.h | 98 ++ tests/framework/instruments/Instruments.cpp | 59 + tests/framework/instruments/Instruments.h | 105 ++ tests/framework/instruments/PMUCounter.cpp | 140 +++ tests/framework/instruments/PMUCounter.h | 71 ++ tests/framework/instruments/WallClockTimer.cpp | 57 + tests/framework/instruments/WallClockTimer.h | 53 + tests/framework/printers/JSONPrinter.cpp | 168 +++ tests/framework/printers/JSONPrinter.h | 64 ++ tests/framework/printers/PrettyPrinter.cpp | 140 +++ tests/framework/printers/PrettyPrinter.h | 69 ++ tests/framework/printers/Printer.cpp | 48 + tests/framework/printers/Printer.h | 129 +++ tests/framework/printers/Printers.cpp | 57 + tests/framework/printers/Printers.h | 75 ++ tests/main.cpp | 16 +- tests/model_objects/AlexNet.h | 585 ---------- tests/model_objects/LeNet5.h | 278 ----- tests/networks/AlexNetNetwork.h | 622 +++++++++++ tests/networks/LeNet5Network.h | 255 +++++ tests/networks_new/AlexNetNetwork.h | 622 ----------- tests/networks_new/LeNet5Network.h | 255 ----- tests/validation/CL/ActivationLayer.cpp | 247 ++++ tests/validation/CL/ArithmeticAddition.cpp | 302 ----- tests/validation/CL/ArithmeticSubtraction.cpp | 288 ----- tests/validation/CL/BatchNormalizationLayer.cpp | 227 ---- tests/validation/CL/BitwiseAnd.cpp | 94 ++ tests/validation/CL/BitwiseNot.cpp | 90 ++ tests/validation/CL/BitwiseOr.cpp | 94 ++ tests/validation/CL/BitwiseXor.cpp | 94 ++ tests/validation/CL/Box3x3.cpp | 166 --- tests/validation/CL/CLFixture.cpp | 32 - tests/validation/CL/CLFixture.h | 45 - tests/validation/CL/CMakeLists.txt | 68 -- tests/validation/CL/ConvolutionLayer.cpp | 186 ++++ tests/validation/CL/DepthConcatenateLayer.cpp | 123 ++ tests/validation/CL/DepthConvert.cpp | 495 -------- tests/validation/CL/DepthwiseConvolution.cpp | 69 ++ .../CL/DepthwiseSeparableConvolutionLayer.cpp | 64 ++ tests/validation/CL/DirectConvolutionLayer.cpp | 129 +++ tests/validation/CL/FillBorder.cpp | 89 -- tests/validation/CL/FixedPoint/FixedPoint_QS8.cpp | 224 ---- tests/validation/CL/Floor.cpp | 66 ++ tests/validation/CL/FullyConnectedLayer.cpp | 195 ++++ tests/validation/CL/GEMM.cpp | 167 +++ tests/validation/CL/Gaussian3x3.cpp | 166 --- tests/validation/CL/Gaussian5x5.cpp | 166 --- tests/validation/CL/HarrisCorners.cpp | 224 ---- tests/validation/CL/IntegralImage.cpp | 142 --- tests/validation/CL/L2Normalize.cpp | 78 ++ tests/validation/CL/MeanStdDev.cpp | 97 ++ tests/validation/CL/MinMaxLocation.cpp | 397 ------- tests/validation/CL/NonLinearFilter.cpp | 203 ---- tests/validation/CL/NormalizationLayer.cpp | 141 +++ tests/validation/CL/PixelWiseMultiplication.cpp | 164 --- tests/validation/CL/PoolingLayer.cpp | 142 +++ tests/validation/CL/ROIPoolingLayer.cpp | 112 -- tests/validation/CL/ReductionOperation.cpp | 78 ++ tests/validation/CL/Scale.cpp | 129 +++ tests/validation/CL/Sobel3x3.cpp | 205 ---- tests/validation/CL/Sobel5x5.cpp | 204 ---- tests/validation/CL/SoftmaxLayer.cpp | 168 +++ tests/validation/CL/TableLookup.cpp | 229 ---- tests/validation/CL/Threshold.cpp | 153 --- tests/validation/CL/WarpPerspective.cpp | 208 ---- tests/validation/CMakeLists.txt | 96 -- tests/validation/CPP/ActivationLayer.cpp | 158 +++ tests/validation/CPP/ActivationLayer.h | 47 + tests/validation/CPP/BitwiseAnd.cpp | 51 + tests/validation/CPP/BitwiseAnd.h | 43 + tests/validation/CPP/BitwiseNot.cpp | 51 + tests/validation/CPP/BitwiseNot.h | 43 + tests/validation/CPP/BitwiseOr.cpp | 51 + tests/validation/CPP/BitwiseOr.h | 43 + tests/validation/CPP/BitwiseXor.cpp | 51 + tests/validation/CPP/BitwiseXor.h | 43 + tests/validation/CPP/ConvolutionLayer.cpp | 205 ++++ tests/validation/CPP/ConvolutionLayer.h | 44 + tests/validation/CPP/DepthConcatenateLayer.cpp | 104 ++ tests/validation/CPP/DepthConcatenateLayer.h | 45 + tests/validation/CPP/DepthwiseConvolution.cpp | 103 ++ tests/validation/CPP/DepthwiseConvolution.h | 44 + .../CPP/DepthwiseSeparableConvolutionLayer.cpp | 60 + .../CPP/DepthwiseSeparableConvolutionLayer.h | 46 + tests/validation/CPP/DequantizationLayer.cpp | 55 + tests/validation/CPP/DequantizationLayer.h | 44 + tests/validation/CPP/Floor.cpp | 57 + tests/validation/CPP/Floor.h | 44 + tests/validation/CPP/FullyConnectedLayer.cpp | 133 +++ tests/validation/CPP/FullyConnectedLayer.h | 44 + tests/validation/CPP/GEMM.cpp | 122 ++ tests/validation/CPP/GEMM.h | 47 + tests/validation/CPP/L2Normalize.cpp | 88 ++ tests/validation/CPP/L2Normalize.h | 44 + tests/validation/CPP/MeanStdDev.cpp | 57 + tests/validation/CPP/MeanStdDev.h | 43 + tests/validation/CPP/NormalizationLayer.cpp | 275 +++++ tests/validation/CPP/NormalizationLayer.h | 47 + tests/validation/CPP/PoolingLayer.cpp | 243 ++++ tests/validation/CPP/PoolingLayer.h | 47 + tests/validation/CPP/QuantizationLayer.cpp | 85 ++ tests/validation/CPP/QuantizationLayer.h | 44 + tests/validation/CPP/ReductionOperation.cpp | 93 ++ tests/validation/CPP/ReductionOperation.h | 44 + tests/validation/CPP/Scale.cpp | 166 +++ tests/validation/CPP/Scale.h | 43 + tests/validation/CPP/SoftmaxLayer.cpp | 122 ++ tests/validation/CPP/SoftmaxLayer.h | 47 + tests/validation/CPP/Utils.cpp | 93 ++ tests/validation/CPP/Utils.h | 52 + tests/validation/Datasets.h | 264 ----- tests/validation/FixedPoint.h | 86 +- tests/validation/Helpers.cpp | 57 + tests/validation/Helpers.h | 259 ++--- tests/validation/NEON/AbsoluteDifference.cpp | 200 ---- tests/validation/NEON/Accumulate.cpp | 145 --- tests/validation/NEON/AccumulateSquared.cpp | 146 --- tests/validation/NEON/AccumulateWeighted.cpp | 145 --- tests/validation/NEON/ActivationLayer.cpp | 230 ++++ tests/validation/NEON/ArithmeticAddition.cpp | 304 ----- tests/validation/NEON/ArithmeticSubtraction.cpp | 306 ----- tests/validation/NEON/BatchNormalizationLayer.cpp | 258 ----- tests/validation/NEON/BitwiseAnd.cpp | 94 ++ tests/validation/NEON/BitwiseNot.cpp | 90 ++ tests/validation/NEON/BitwiseOr.cpp | 94 ++ tests/validation/NEON/BitwiseXor.cpp | 94 ++ tests/validation/NEON/Box3x3.cpp | 167 --- tests/validation/NEON/CMakeLists.txt | 71 -- tests/validation/NEON/ConvolutionLayer.cpp | 192 ++++ tests/validation/NEON/DepthConcatenateLayer.cpp | 125 +++ tests/validation/NEON/DepthConvert.cpp | 637 ----------- tests/validation/NEON/DequantizationLayer.cpp | 100 ++ tests/validation/NEON/DirectConvolutionLayer.cpp | 149 +++ tests/validation/NEON/FillBorder.cpp | 88 -- tests/validation/NEON/Fixedpoint/Exp_QS16.cpp | 122 -- tests/validation/NEON/Fixedpoint/Exp_QS8.cpp | 122 -- tests/validation/NEON/Fixedpoint/Invsqrt_QS16.cpp | 122 -- tests/validation/NEON/Fixedpoint/Invsqrt_QS8.cpp | 120 -- tests/validation/NEON/Fixedpoint/Log_QS16.cpp | 121 -- tests/validation/NEON/Fixedpoint/Log_QS8.cpp | 121 -- .../validation/NEON/Fixedpoint/Reciprocal_QS16.cpp | 121 -- .../validation/NEON/Fixedpoint/Reciprocal_QS8.cpp | 121 -- tests/validation/NEON/Floor.cpp | 66 ++ tests/validation/NEON/FullyConnectedLayer.cpp | 211 ++++ tests/validation/NEON/GEMM.cpp | 170 +++ tests/validation/NEON/Gaussian3x3.cpp | 167 --- tests/validation/NEON/Gaussian5x5.cpp | 167 --- tests/validation/NEON/HarrisCorners.cpp | 229 ---- tests/validation/NEON/IntegralImage.cpp | 144 --- tests/validation/NEON/L2Normalize.cpp | 75 ++ tests/validation/NEON/MeanStdDev.cpp | 93 ++ tests/validation/NEON/MinMaxLocation.cpp | 224 ---- tests/validation/NEON/NonLinearFilter.cpp | 203 ---- tests/validation/NEON/NormalizationLayer.cpp | 144 +++ tests/validation/NEON/PixelWiseMultiplication.cpp | 583 ---------- tests/validation/NEON/PoolingLayer.cpp | 148 +++ tests/validation/NEON/QuantizationLayer.cpp | 98 ++ tests/validation/NEON/ROIPoolingLayer.cpp | 110 -- tests/validation/NEON/ReductionOperation.cpp | 75 ++ tests/validation/NEON/Scale.cpp | 127 +++ tests/validation/NEON/Sobel3x3.cpp | 203 ---- tests/validation/NEON/Sobel5x5.cpp | 204 ---- tests/validation/NEON/SoftmaxLayer.cpp | 175 +++ tests/validation/NEON/TableLookup.cpp | 229 ---- tests/validation/NEON/Threshold.cpp | 153 --- tests/validation/NEON/WarpPerspective.cpp | 209 ---- tests/validation/Reference.cpp | 510 --------- tests/validation/Reference.h | 316 ------ tests/validation/ReferenceCPP.cpp | 294 ----- tests/validation/ReferenceCPP.h | 278 ----- tests/validation/Tensor.h | 118 -- tests/validation/TensorFactory.h | 111 -- tests/validation/TensorOperations.h | 1178 -------------------- tests/validation/TensorVisitors.h | 306 ----- tests/validation/UNIT/CMakeLists.txt | 37 - tests/validation/UNIT/FixedPoint.cpp | 164 --- tests/validation/UNIT/TensorInfo.cpp | 91 -- tests/validation/UNIT/TensorShape.cpp | 70 -- tests/validation/UNIT/Utils.cpp | 94 -- tests/validation/Validation.cpp | 284 +---- tests/validation/Validation.h | 282 +++-- tests/validation/ValidationProgramOptions.cpp | 50 - tests/validation/ValidationProgramOptions.h | 45 - tests/validation/ValidationUserConfiguration.h | 42 - tests/validation/fixtures/ActivationLayerFixture.h | 157 +++ tests/validation/fixtures/BitwiseAndFixture.h | 113 ++ tests/validation/fixtures/BitwiseNotFixture.h | 106 ++ tests/validation/fixtures/BitwiseOrFixture.h | 113 ++ tests/validation/fixtures/BitwiseXorFixture.h | 113 ++ .../validation/fixtures/ConvolutionLayerFixture.h | 152 +++ .../fixtures/DepthConcatenateLayerFixture.h | 177 +++ .../fixtures/DepthwiseConvolutionFixture.h | 120 ++ .../DepthwiseSeparableConvolutionLayerFixture.h | 139 +++ .../fixtures/DequantizationLayerFixture.h | 147 +++ .../fixtures/DirectConvolutionLayerFixture.h | 86 ++ tests/validation/fixtures/FloorFixture.h | 107 ++ .../fixtures/FullyConnectedLayerFixture.h | 250 +++++ tests/validation/fixtures/GEMMFixture.h | 152 +++ tests/validation/fixtures/L2NormalizeFixture.h | 107 ++ tests/validation/fixtures/MeanStdDevFixture.h | 102 ++ .../fixtures/NormalizationLayerFixture.h | 133 +++ tests/validation/fixtures/PoolingLayerFixture.h | 134 +++ .../validation/fixtures/QuantizationLayerFixture.h | 120 ++ .../fixtures/ReductionOperationFixture.h | 116 ++ tests/validation/fixtures/ScaleFixture.h | 127 +++ tests/validation/fixtures/SoftmaxLayerFixture.h | 133 +++ tests/validation/half.h | 1 + tests/validation/main.cpp | 97 -- tests/validation/system_tests/CL/AlexNet.cpp | 132 --- tests/validation/system_tests/CL/LeNet5.cpp | 115 -- tests/validation/system_tests/NEON/AlexNet.cpp | 133 --- tests/validation/system_tests/NEON/LeNet5.cpp | 115 -- tests/validation_new/CL/ActivationLayer.cpp | 247 ---- tests/validation_new/CL/BitwiseAnd.cpp | 94 -- tests/validation_new/CL/BitwiseNot.cpp | 90 -- tests/validation_new/CL/BitwiseOr.cpp | 94 -- tests/validation_new/CL/BitwiseXor.cpp | 94 -- tests/validation_new/CL/ConvolutionLayer.cpp | 186 ---- tests/validation_new/CL/DepthConcatenateLayer.cpp | 123 -- tests/validation_new/CL/DepthwiseConvolution.cpp | 69 -- .../CL/DepthwiseSeparableConvolutionLayer.cpp | 64 -- tests/validation_new/CL/DirectConvolutionLayer.cpp | 129 --- tests/validation_new/CL/Floor.cpp | 66 -- tests/validation_new/CL/FullyConnectedLayer.cpp | 195 ---- tests/validation_new/CL/GEMM.cpp | 167 --- tests/validation_new/CL/L2Normalize.cpp | 78 -- tests/validation_new/CL/MeanStdDev.cpp | 97 -- tests/validation_new/CL/NormalizationLayer.cpp | 141 --- tests/validation_new/CL/PoolingLayer.cpp | 142 --- tests/validation_new/CL/ReductionOperation.cpp | 78 -- tests/validation_new/CL/Scale.cpp | 129 --- tests/validation_new/CL/SoftmaxLayer.cpp | 168 --- tests/validation_new/CPP/ActivationLayer.cpp | 158 --- tests/validation_new/CPP/ActivationLayer.h | 47 - tests/validation_new/CPP/BitwiseAnd.cpp | 51 - tests/validation_new/CPP/BitwiseAnd.h | 43 - tests/validation_new/CPP/BitwiseNot.cpp | 51 - tests/validation_new/CPP/BitwiseNot.h | 43 - tests/validation_new/CPP/BitwiseOr.cpp | 51 - tests/validation_new/CPP/BitwiseOr.h | 43 - tests/validation_new/CPP/BitwiseXor.cpp | 51 - tests/validation_new/CPP/BitwiseXor.h | 43 - tests/validation_new/CPP/ConvolutionLayer.cpp | 205 ---- tests/validation_new/CPP/ConvolutionLayer.h | 44 - tests/validation_new/CPP/DepthConcatenateLayer.cpp | 104 -- tests/validation_new/CPP/DepthConcatenateLayer.h | 45 - tests/validation_new/CPP/DepthwiseConvolution.cpp | 103 -- tests/validation_new/CPP/DepthwiseConvolution.h | 44 - .../CPP/DepthwiseSeparableConvolutionLayer.cpp | 60 - .../CPP/DepthwiseSeparableConvolutionLayer.h | 46 - tests/validation_new/CPP/DequantizationLayer.cpp | 55 - tests/validation_new/CPP/DequantizationLayer.h | 44 - tests/validation_new/CPP/Floor.cpp | 57 - tests/validation_new/CPP/Floor.h | 44 - tests/validation_new/CPP/FullyConnectedLayer.cpp | 133 --- tests/validation_new/CPP/FullyConnectedLayer.h | 44 - tests/validation_new/CPP/GEMM.cpp | 122 -- tests/validation_new/CPP/GEMM.h | 47 - tests/validation_new/CPP/L2Normalize.cpp | 88 -- tests/validation_new/CPP/L2Normalize.h | 44 - tests/validation_new/CPP/MeanStdDev.cpp | 57 - tests/validation_new/CPP/MeanStdDev.h | 43 - tests/validation_new/CPP/NormalizationLayer.cpp | 275 ----- tests/validation_new/CPP/NormalizationLayer.h | 47 - tests/validation_new/CPP/PoolingLayer.cpp | 243 ---- tests/validation_new/CPP/PoolingLayer.h | 47 - tests/validation_new/CPP/QuantizationLayer.cpp | 85 -- tests/validation_new/CPP/QuantizationLayer.h | 44 - tests/validation_new/CPP/ReductionOperation.cpp | 93 -- tests/validation_new/CPP/ReductionOperation.h | 44 - tests/validation_new/CPP/Scale.cpp | 166 --- tests/validation_new/CPP/Scale.h | 43 - tests/validation_new/CPP/SoftmaxLayer.cpp | 122 -- tests/validation_new/CPP/SoftmaxLayer.h | 47 - tests/validation_new/CPP/Utils.cpp | 93 -- tests/validation_new/CPP/Utils.h | 54 - tests/validation_new/FixedPoint.h | 984 ---------------- tests/validation_new/Helpers.cpp | 57 - tests/validation_new/Helpers.h | 142 --- tests/validation_new/NEON/ActivationLayer.cpp | 230 ---- tests/validation_new/NEON/BitwiseAnd.cpp | 94 -- tests/validation_new/NEON/BitwiseNot.cpp | 90 -- tests/validation_new/NEON/BitwiseOr.cpp | 94 -- tests/validation_new/NEON/BitwiseXor.cpp | 94 -- tests/validation_new/NEON/ConvolutionLayer.cpp | 192 ---- .../validation_new/NEON/DepthConcatenateLayer.cpp | 125 --- tests/validation_new/NEON/DequantizationLayer.cpp | 100 -- .../validation_new/NEON/DirectConvolutionLayer.cpp | 149 --- tests/validation_new/NEON/Floor.cpp | 66 -- tests/validation_new/NEON/FullyConnectedLayer.cpp | 211 ---- tests/validation_new/NEON/GEMM.cpp | 170 --- tests/validation_new/NEON/L2Normalize.cpp | 75 -- tests/validation_new/NEON/MeanStdDev.cpp | 93 -- tests/validation_new/NEON/NormalizationLayer.cpp | 144 --- tests/validation_new/NEON/PoolingLayer.cpp | 148 --- tests/validation_new/NEON/QuantizationLayer.cpp | 98 -- tests/validation_new/NEON/ReductionOperation.cpp | 75 -- tests/validation_new/NEON/Scale.cpp | 127 --- tests/validation_new/NEON/SoftmaxLayer.cpp | 175 --- tests/validation_new/Validation.cpp | 307 ----- tests/validation_new/Validation.h | 351 ------ .../fixtures/ActivationLayerFixture.h | 157 --- tests/validation_new/fixtures/BitwiseAndFixture.h | 113 -- tests/validation_new/fixtures/BitwiseNotFixture.h | 106 -- tests/validation_new/fixtures/BitwiseOrFixture.h | 113 -- tests/validation_new/fixtures/BitwiseXorFixture.h | 113 -- .../fixtures/ConvolutionLayerFixture.h | 152 --- .../fixtures/DepthConcatenateLayerFixture.h | 177 --- .../fixtures/DepthwiseConvolutionFixture.h | 120 -- .../DepthwiseSeparableConvolutionLayerFixture.h | 139 --- .../fixtures/DequantizationLayerFixture.h | 147 --- .../fixtures/DirectConvolutionLayerFixture.h | 86 -- tests/validation_new/fixtures/FloorFixture.h | 107 -- .../fixtures/FullyConnectedLayerFixture.h | 250 ----- tests/validation_new/fixtures/GEMMFixture.h | 152 --- tests/validation_new/fixtures/L2NormalizeFixture.h | 107 -- tests/validation_new/fixtures/MeanStdDevFixture.h | 102 -- .../fixtures/NormalizationLayerFixture.h | 133 --- .../validation_new/fixtures/PoolingLayerFixture.h | 134 --- .../fixtures/QuantizationLayerFixture.h | 120 -- .../fixtures/ReductionOperationFixture.h | 116 -- tests/validation_new/fixtures/ScaleFixture.h | 127 --- .../validation_new/fixtures/SoftmaxLayerFixture.h | 133 --- tests/validation_new/half.h | 38 - tests/validation_old/AssetsLibrary.cpp | 447 ++++++++ tests/validation_old/AssetsLibrary.h | 674 +++++++++++ tests/validation_old/CL/ArithmeticAddition.cpp | 302 +++++ tests/validation_old/CL/ArithmeticSubtraction.cpp | 288 +++++ .../validation_old/CL/BatchNormalizationLayer.cpp | 227 ++++ tests/validation_old/CL/Box3x3.cpp | 166 +++ tests/validation_old/CL/CLFixture.cpp | 32 + tests/validation_old/CL/CLFixture.h | 45 + tests/validation_old/CL/DepthConvert.cpp | 495 ++++++++ tests/validation_old/CL/FillBorder.cpp | 89 ++ .../CL/FixedPoint/FixedPoint_QS8.cpp | 224 ++++ tests/validation_old/CL/Gaussian3x3.cpp | 166 +++ tests/validation_old/CL/Gaussian5x5.cpp | 166 +++ tests/validation_old/CL/HarrisCorners.cpp | 224 ++++ tests/validation_old/CL/IntegralImage.cpp | 142 +++ tests/validation_old/CL/MinMaxLocation.cpp | 397 +++++++ tests/validation_old/CL/NonLinearFilter.cpp | 203 ++++ .../validation_old/CL/PixelWiseMultiplication.cpp | 164 +++ tests/validation_old/CL/ROIPoolingLayer.cpp | 112 ++ tests/validation_old/CL/Sobel3x3.cpp | 205 ++++ tests/validation_old/CL/Sobel5x5.cpp | 204 ++++ tests/validation_old/CL/TableLookup.cpp | 229 ++++ tests/validation_old/CL/Threshold.cpp | 153 +++ tests/validation_old/CL/WarpPerspective.cpp | 208 ++++ tests/validation_old/Datasets.h | 264 +++++ tests/validation_old/FixedPoint.h | 986 ++++++++++++++++ tests/validation_old/Helpers.h | 273 +++++ tests/validation_old/NEON/AbsoluteDifference.cpp | 200 ++++ tests/validation_old/NEON/Accumulate.cpp | 145 +++ tests/validation_old/NEON/AccumulateSquared.cpp | 146 +++ tests/validation_old/NEON/AccumulateWeighted.cpp | 145 +++ tests/validation_old/NEON/ArithmeticAddition.cpp | 304 +++++ .../validation_old/NEON/ArithmeticSubtraction.cpp | 306 +++++ .../NEON/BatchNormalizationLayer.cpp | 258 +++++ tests/validation_old/NEON/Box3x3.cpp | 167 +++ tests/validation_old/NEON/DepthConvert.cpp | 637 +++++++++++ tests/validation_old/NEON/FillBorder.cpp | 88 ++ tests/validation_old/NEON/Fixedpoint/Exp_QS16.cpp | 122 ++ tests/validation_old/NEON/Fixedpoint/Exp_QS8.cpp | 122 ++ .../NEON/Fixedpoint/Invsqrt_QS16.cpp | 122 ++ .../validation_old/NEON/Fixedpoint/Invsqrt_QS8.cpp | 120 ++ tests/validation_old/NEON/Fixedpoint/Log_QS16.cpp | 121 ++ tests/validation_old/NEON/Fixedpoint/Log_QS8.cpp | 121 ++ .../NEON/Fixedpoint/Reciprocal_QS16.cpp | 121 ++ .../NEON/Fixedpoint/Reciprocal_QS8.cpp | 121 ++ tests/validation_old/NEON/Gaussian3x3.cpp | 167 +++ tests/validation_old/NEON/Gaussian5x5.cpp | 167 +++ tests/validation_old/NEON/HarrisCorners.cpp | 229 ++++ tests/validation_old/NEON/IntegralImage.cpp | 144 +++ tests/validation_old/NEON/MinMaxLocation.cpp | 224 ++++ tests/validation_old/NEON/NonLinearFilter.cpp | 203 ++++ .../NEON/PixelWiseMultiplication.cpp | 583 ++++++++++ tests/validation_old/NEON/ROIPoolingLayer.cpp | 110 ++ tests/validation_old/NEON/Sobel3x3.cpp | 203 ++++ tests/validation_old/NEON/Sobel5x5.cpp | 204 ++++ tests/validation_old/NEON/TableLookup.cpp | 229 ++++ tests/validation_old/NEON/Threshold.cpp | 153 +++ tests/validation_old/NEON/WarpPerspective.cpp | 209 ++++ tests/validation_old/ProgramOptions.cpp | 88 ++ tests/validation_old/ProgramOptions.h | 101 ++ tests/validation_old/RawTensor.cpp | 67 ++ tests/validation_old/RawTensor.h | 86 ++ tests/validation_old/Reference.cpp | 510 +++++++++ tests/validation_old/Reference.h | 316 ++++++ tests/validation_old/ReferenceCPP.cpp | 294 +++++ tests/validation_old/ReferenceCPP.h | 278 +++++ tests/validation_old/SConscript | 119 ++ tests/validation_old/Tensor.h | 118 ++ tests/validation_old/TensorFactory.h | 111 ++ tests/validation_old/TensorOperations.h | 1178 ++++++++++++++++++++ tests/validation_old/TensorVisitors.h | 306 +++++ tests/validation_old/UNIT/FixedPoint.cpp | 164 +++ tests/validation_old/UNIT/TensorInfo.cpp | 91 ++ tests/validation_old/UNIT/TensorShape.cpp | 70 ++ tests/validation_old/UNIT/Utils.cpp | 94 ++ tests/validation_old/UserConfiguration.cpp | 55 + tests/validation_old/UserConfiguration.h | 136 +++ tests/validation_old/Validation.cpp | 477 ++++++++ tests/validation_old/Validation.h | 193 ++++ tests/validation_old/ValidationProgramOptions.cpp | 50 + tests/validation_old/ValidationProgramOptions.h | 45 + tests/validation_old/ValidationUserConfiguration.h | 42 + tests/validation_old/boost_wrapper.h | 40 + .../dataset/ActivationFunctionDataset.h | 67 ++ .../dataset/ActivationLayerDataset.h | 177 +++ .../dataset/BatchNormalizationLayerDataset.h | 90 ++ tests/validation_old/dataset/BorderModeDataset.h | 82 ++ .../validation_old/dataset/ConvertPolicyDataset.h | 82 ++ .../dataset/ConvolutionLayerDataset.h | 273 +++++ tests/validation_old/dataset/DataTypeDatasets.h | 193 ++++ .../dataset/FullyConnectedLayerDataset.h | 155 +++ tests/validation_old/dataset/GEMMDataset.h | 220 ++++ tests/validation_old/dataset/GenericDataset.h | 97 ++ tests/validation_old/dataset/ImageDatasets.h | 120 ++ .../dataset/InterpolationPolicyDataset.h | 80 ++ .../validation_old/dataset/MatrixPatternDataset.h | 82 ++ .../dataset/NonLinearFilterFunctionDataset.h | 82 ++ .../dataset/NormalizationLayerDataset.h | 99 ++ .../dataset/NormalizationTypeDataset.h | 80 ++ tests/validation_old/dataset/PoolingLayerDataset.h | 138 +++ tests/validation_old/dataset/PoolingTypesDataset.h | 55 + .../validation_old/dataset/RoundingPolicyDataset.h | 82 ++ tests/validation_old/dataset/ShapeDatasets.h | 152 +++ tests/validation_old/dataset/ThresholdDataset.h | 95 ++ tests/validation_old/half.h | 37 + tests/validation_old/main.cpp | 97 ++ tests/validation_old/model_objects/AlexNet.h | 585 ++++++++++ tests/validation_old/model_objects/LeNet5.h | 278 +++++ tests/validation_old/system_tests/CL/AlexNet.cpp | 132 +++ tests/validation_old/system_tests/CL/LeNet5.cpp | 115 ++ tests/validation_old/system_tests/NEON/AlexNet.cpp | 133 +++ tests/validation_old/system_tests/NEON/LeNet5.cpp | 115 ++ 757 files changed, 49144 insertions(+), 48160 deletions(-) delete mode 100644 framework/Asserts.h delete mode 100644 framework/DatasetModes.cpp delete mode 100644 framework/DatasetModes.h delete mode 100644 framework/Exceptions.cpp delete mode 100644 framework/Exceptions.h delete mode 100644 framework/Fixture.h delete mode 100644 framework/Framework.cpp delete mode 100644 framework/Framework.h delete mode 100644 framework/Macros.h delete mode 100644 framework/Profiler.cpp delete mode 100644 framework/Profiler.h delete mode 100644 framework/Registrars.h delete mode 100644 framework/SConscript delete mode 100644 framework/TestCase.h delete mode 100644 framework/TestCaseFactory.h delete mode 100644 framework/TestFilter.cpp delete mode 100644 framework/TestFilter.h delete mode 100644 framework/TestResult.h delete mode 100644 framework/Utils.h delete mode 100644 framework/command_line/CommandLineOptions.h delete mode 100644 framework/command_line/CommandLineParser.cpp delete mode 100644 framework/command_line/CommandLineParser.h delete mode 100644 framework/command_line/EnumListOption.h delete mode 100644 framework/command_line/EnumOption.h delete mode 100644 framework/command_line/ListOption.h delete mode 100644 framework/command_line/Option.cpp delete mode 100644 framework/command_line/Option.h delete mode 100644 framework/command_line/SimpleOption.h delete mode 100644 framework/command_line/ToggleOption.cpp delete mode 100644 framework/command_line/ToggleOption.h delete mode 100644 framework/datasets/CartesianProductDataset.h delete mode 100644 framework/datasets/ContainerDataset.h delete mode 100644 framework/datasets/Dataset.h delete mode 100644 framework/datasets/Datasets.h delete mode 100644 framework/datasets/InitializerListDataset.h delete mode 100644 framework/datasets/JoinDataset.h delete mode 100644 framework/datasets/RangeDataset.h delete mode 100644 framework/datasets/SingletonDataset.h delete mode 100644 framework/datasets/ZipDataset.h delete mode 100644 framework/instruments/Instrument.h delete mode 100644 framework/instruments/Instruments.cpp delete mode 100644 framework/instruments/Instruments.h delete mode 100644 framework/instruments/PMUCounter.cpp delete mode 100644 framework/instruments/PMUCounter.h delete mode 100644 framework/instruments/WallClockTimer.cpp delete mode 100644 framework/instruments/WallClockTimer.h delete mode 100644 framework/printers/JSONPrinter.cpp delete mode 100644 framework/printers/JSONPrinter.h delete mode 100644 framework/printers/PrettyPrinter.cpp delete mode 100644 framework/printers/PrettyPrinter.h delete mode 100644 framework/printers/Printer.cpp delete mode 100644 framework/printers/Printer.h delete mode 100644 framework/printers/Printers.cpp delete mode 100644 framework/printers/Printers.h delete mode 100644 tests/CMakeLists.txt delete mode 100644 tests/ProgramOptions.cpp delete mode 100644 tests/ProgramOptions.h delete mode 100644 tests/UserConfiguration.cpp delete mode 100644 tests/UserConfiguration.h create mode 100644 tests/benchmark/CL/ActivationLayer.cpp create mode 100644 tests/benchmark/CL/BatchNormalizationLayer.cpp create mode 100644 tests/benchmark/CL/ConvolutionLayer.cpp create mode 100644 tests/benchmark/CL/DepthwiseConvolution.cpp create mode 100644 tests/benchmark/CL/DepthwiseSeparableConvolutionLayer.cpp create mode 100644 tests/benchmark/CL/DirectConvolutionLayer.cpp create mode 100644 tests/benchmark/CL/Floor.cpp create mode 100644 tests/benchmark/CL/FullyConnectedLayer.cpp create mode 100644 tests/benchmark/CL/GEMM.cpp create mode 100644 tests/benchmark/CL/NormalizationLayer.cpp create mode 100644 tests/benchmark/CL/PoolingLayer.cpp create mode 100644 tests/benchmark/CL/ROIPoolingLayer.cpp create mode 100644 tests/benchmark/CL/SYSTEM/AlexNet.cpp create mode 100644 tests/benchmark/CL/SYSTEM/LeNet5.cpp create mode 100644 tests/benchmark/NEON/ActivationLayer.cpp create mode 100644 tests/benchmark/NEON/BatchNormalizationLayer.cpp create mode 100644 tests/benchmark/NEON/ConvolutionLayer.cpp create mode 100644 tests/benchmark/NEON/DirectConvolutionLayer.cpp create mode 100644 tests/benchmark/NEON/Floor.cpp create mode 100644 tests/benchmark/NEON/FullyConnectedLayer.cpp create mode 100644 tests/benchmark/NEON/GEMM.cpp create mode 100644 tests/benchmark/NEON/NormalizationLayer.cpp create mode 100644 tests/benchmark/NEON/PoolingLayer.cpp create mode 100644 tests/benchmark/NEON/ROIPoolingLayer.cpp create mode 100644 tests/benchmark/NEON/SYSTEM/AlexNet.cpp create mode 100644 tests/benchmark/NEON/SYSTEM/LeNet5.cpp create mode 100644 tests/benchmark/fixtures/ActivationLayerFixture.h create mode 100644 tests/benchmark/fixtures/AlexNetFixture.h create mode 100644 tests/benchmark/fixtures/BatchNormalizationLayerFixture.h create mode 100644 tests/benchmark/fixtures/ConvolutionLayerFixture.h create mode 100644 tests/benchmark/fixtures/DepthwiseConvolutionFixture.h create mode 100644 tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h create mode 100644 tests/benchmark/fixtures/FloorFixture.h create mode 100644 tests/benchmark/fixtures/FullyConnectedLayerFixture.h create mode 100644 tests/benchmark/fixtures/GEMMFixture.h create mode 100644 tests/benchmark/fixtures/LeNet5Fixture.h create mode 100644 tests/benchmark/fixtures/NormalizationLayerFixture.h create mode 100644 tests/benchmark/fixtures/PoolingLayerFixture.h create mode 100644 tests/benchmark/fixtures/ROIPoolingLayerFixture.h delete mode 100644 tests/benchmark_new/CL/ActivationLayer.cpp delete mode 100644 tests/benchmark_new/CL/BatchNormalizationLayer.cpp delete mode 100644 tests/benchmark_new/CL/ConvolutionLayer.cpp delete mode 100644 tests/benchmark_new/CL/DepthwiseConvolution.cpp delete mode 100644 tests/benchmark_new/CL/DepthwiseSeparableConvolutionLayer.cpp delete mode 100644 tests/benchmark_new/CL/DirectConvolutionLayer.cpp delete mode 100644 tests/benchmark_new/CL/Floor.cpp delete mode 100644 tests/benchmark_new/CL/FullyConnectedLayer.cpp delete mode 100644 tests/benchmark_new/CL/GEMM.cpp delete mode 100644 tests/benchmark_new/CL/NormalizationLayer.cpp delete mode 100644 tests/benchmark_new/CL/PoolingLayer.cpp delete mode 100644 tests/benchmark_new/CL/ROIPoolingLayer.cpp delete mode 100644 tests/benchmark_new/CL/SYSTEM/AlexNet.cpp delete mode 100644 tests/benchmark_new/CL/SYSTEM/LeNet5.cpp delete mode 100644 tests/benchmark_new/NEON/ActivationLayer.cpp delete mode 100644 tests/benchmark_new/NEON/BatchNormalizationLayer.cpp delete mode 100644 tests/benchmark_new/NEON/ConvolutionLayer.cpp delete mode 100644 tests/benchmark_new/NEON/DirectConvolutionLayer.cpp delete mode 100644 tests/benchmark_new/NEON/Floor.cpp delete mode 100644 tests/benchmark_new/NEON/FullyConnectedLayer.cpp delete mode 100644 tests/benchmark_new/NEON/GEMM.cpp delete mode 100644 tests/benchmark_new/NEON/NormalizationLayer.cpp delete mode 100644 tests/benchmark_new/NEON/PoolingLayer.cpp delete mode 100644 tests/benchmark_new/NEON/ROIPoolingLayer.cpp delete mode 100644 tests/benchmark_new/NEON/SYSTEM/AlexNet.cpp delete mode 100644 tests/benchmark_new/NEON/SYSTEM/LeNet5.cpp delete mode 100644 tests/boost_wrapper.h delete mode 100644 tests/dataset/ActivationFunctionDataset.h delete mode 100644 tests/dataset/ActivationLayerDataset.h delete mode 100644 tests/dataset/BatchNormalizationLayerDataset.h delete mode 100644 tests/dataset/BorderModeDataset.h delete mode 100644 tests/dataset/ConvertPolicyDataset.h delete mode 100644 tests/dataset/ConvolutionLayerDataset.h delete mode 100644 tests/dataset/DataTypeDatasets.h delete mode 100644 tests/dataset/FullyConnectedLayerDataset.h delete mode 100644 tests/dataset/GEMMDataset.h delete mode 100644 tests/dataset/GenericDataset.h delete mode 100644 tests/dataset/ImageDatasets.h delete mode 100644 tests/dataset/InterpolationPolicyDataset.h delete mode 100644 tests/dataset/MatrixPatternDataset.h delete mode 100644 tests/dataset/NonLinearFilterFunctionDataset.h delete mode 100644 tests/dataset/NormalizationLayerDataset.h delete mode 100644 tests/dataset/NormalizationTypeDataset.h delete mode 100644 tests/dataset/PoolingLayerDataset.h delete mode 100644 tests/dataset/PoolingTypesDataset.h delete mode 100644 tests/dataset/RoundingPolicyDataset.h delete mode 100644 tests/dataset/ShapeDatasets.h delete mode 100644 tests/dataset/ThresholdDataset.h create mode 100644 tests/datasets/ActivationFunctionsDataset.h create mode 100644 tests/datasets/BatchNormalizationLayerDataset.h create mode 100644 tests/datasets/BorderModeDataset.h create mode 100644 tests/datasets/ConvolutionLayerDataset.h create mode 100644 tests/datasets/DepthwiseConvolutionDataset.h create mode 100644 tests/datasets/DepthwiseSeparableConvolutionLayerDataset.h create mode 100644 tests/datasets/DirectConvolutionLayerDataset.h create mode 100644 tests/datasets/FullyConnectedLayerDataset.h create mode 100644 tests/datasets/GEMMDataset.h create mode 100644 tests/datasets/InterpolationPolicyDataset.h create mode 100644 tests/datasets/LargeConvolutionLayerDataset.h create mode 100644 tests/datasets/LargeDepthwiseConvolutionDataset.h create mode 100644 tests/datasets/LargeGEMMDataset.h create mode 100644 tests/datasets/MatrixMultiplyGEMMDataset.h create mode 100644 tests/datasets/MobileNetDepthwiseConvolutionDataset.h create mode 100644 tests/datasets/MobileNetDepthwiseSeparableConvolutionLayerDataset.h create mode 100644 tests/datasets/NormalizationTypesDataset.h create mode 100644 tests/datasets/PoolingLayerDataset.h create mode 100644 tests/datasets/PoolingTypesDataset.h create mode 100644 tests/datasets/ROIPoolingLayerDataset.h create mode 100644 tests/datasets/ReductionOperationDataset.h create mode 100644 tests/datasets/ShapeDatasets.h create mode 100644 tests/datasets/SmallConvolutionLayerDataset.h create mode 100644 tests/datasets/SmallDepthwiseConvolutionDataset.h create mode 100644 tests/datasets/SmallGEMMDataset.h create mode 100644 tests/datasets/system_tests/alexnet/AlexNetActivationLayerDataset.h create mode 100644 tests/datasets/system_tests/alexnet/AlexNetConvolutionLayerDataset.h create mode 100644 tests/datasets/system_tests/alexnet/AlexNetFullyConnectedLayerDataset.h create mode 100644 tests/datasets/system_tests/alexnet/AlexNetNormalizationLayerDataset.h create mode 100644 tests/datasets/system_tests/alexnet/AlexNetPoolingLayerDataset.h create mode 100644 tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ActivationLayerDataset.h create mode 100644 tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ConvolutionLayerDataset.h create mode 100644 tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1FullyConnectedLayerDataset.h create mode 100644 tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1GEMMDataset.h create mode 100644 tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1NormalizationLayerDataset.h create mode 100644 tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1PoolingLayerDataset.h create mode 100644 tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ActivationLayerDataset.h create mode 100644 tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4BatchNormalizationLayerDataset.h create mode 100644 tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ConvolutionLayerDataset.h create mode 100644 tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4FullyConnectedLayerDataset.h create mode 100644 tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4PoolingLayerDataset.h create mode 100644 tests/datasets/system_tests/lenet5/LeNet5ActivationLayerDataset.h create mode 100644 tests/datasets/system_tests/lenet5/LeNet5ConvolutionLayerDataset.h create mode 100644 tests/datasets/system_tests/lenet5/LeNet5FullyConnectedLayerDataset.h create mode 100644 tests/datasets/system_tests/lenet5/LeNet5PoolingLayerDataset.h create mode 100644 tests/datasets/system_tests/squeezenet/SqueezeNetActivationLayerDataset.h create mode 100644 tests/datasets/system_tests/squeezenet/SqueezeNetConvolutionLayerDataset.h create mode 100644 tests/datasets/system_tests/squeezenet/SqueezeNetPoolingLayerDataset.h create mode 100644 tests/datasets/system_tests/vgg/vgg16/VGG16ActivationLayerDataset.h create mode 100644 tests/datasets/system_tests/vgg/vgg16/VGG16ConvolutionLayerDataset.h create mode 100644 tests/datasets/system_tests/vgg/vgg16/VGG16FullyConnectedLayerDataset.h create mode 100644 tests/datasets/system_tests/vgg/vgg16/VGG16PoolingLayerDataset.h create mode 100644 tests/datasets/system_tests/yolo/v2/YOLOV2ActivationLayerDataset.h create mode 100644 tests/datasets/system_tests/yolo/v2/YOLOV2BatchNormalizationLayerDataset.h create mode 100644 tests/datasets/system_tests/yolo/v2/YOLOV2ConvolutionLayerDataset.h create mode 100644 tests/datasets/system_tests/yolo/v2/YOLOV2PoolingLayerDataset.h delete mode 100644 tests/datasets_new/ActivationFunctionsDataset.h delete mode 100644 tests/datasets_new/BatchNormalizationLayerDataset.h delete mode 100644 tests/datasets_new/BorderModeDataset.h delete mode 100644 tests/datasets_new/ConvolutionLayerDataset.h delete mode 100644 tests/datasets_new/DepthwiseConvolutionDataset.h delete mode 100644 tests/datasets_new/DepthwiseSeparableConvolutionLayerDataset.h delete mode 100644 tests/datasets_new/DirectConvolutionLayerDataset.h delete mode 100644 tests/datasets_new/FullyConnectedLayerDataset.h delete mode 100644 tests/datasets_new/GEMMDataset.h delete mode 100644 tests/datasets_new/InterpolationPolicyDataset.h delete mode 100644 tests/datasets_new/LargeConvolutionLayerDataset.h delete mode 100644 tests/datasets_new/LargeDepthwiseConvolutionDataset.h delete mode 100644 tests/datasets_new/LargeGEMMDataset.h delete mode 100644 tests/datasets_new/MatrixMultiplyGEMMDataset.h delete mode 100644 tests/datasets_new/MobileNetDepthwiseConvolutionDataset.h delete mode 100644 tests/datasets_new/MobileNetDepthwiseSeparableConvolutionLayerDataset.h delete mode 100644 tests/datasets_new/NormalizationTypesDataset.h delete mode 100644 tests/datasets_new/PoolingLayerDataset.h delete mode 100644 tests/datasets_new/PoolingTypesDataset.h delete mode 100644 tests/datasets_new/ROIPoolingLayerDataset.h delete mode 100644 tests/datasets_new/ReductionOperationDataset.h delete mode 100644 tests/datasets_new/ShapeDatasets.h delete mode 100644 tests/datasets_new/SmallConvolutionLayerDataset.h delete mode 100644 tests/datasets_new/SmallDepthwiseConvolutionDataset.h delete mode 100644 tests/datasets_new/SmallGEMMDataset.h delete mode 100644 tests/datasets_new/system_tests/alexnet/AlexNetActivationLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/alexnet/AlexNetConvolutionLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/alexnet/AlexNetFullyConnectedLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/alexnet/AlexNetNormalizationLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/alexnet/AlexNetPoolingLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ActivationLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ConvolutionLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1FullyConnectedLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1GEMMDataset.h delete mode 100644 tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1NormalizationLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1PoolingLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ActivationLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4BatchNormalizationLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ConvolutionLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4FullyConnectedLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4PoolingLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/lenet5/LeNet5ActivationLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/lenet5/LeNet5ConvolutionLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/lenet5/LeNet5FullyConnectedLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/lenet5/LeNet5PoolingLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/squeezenet/SqueezeNetActivationLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/squeezenet/SqueezeNetConvolutionLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/squeezenet/SqueezeNetPoolingLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/vgg/vgg16/VGG16ActivationLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/vgg/vgg16/VGG16ConvolutionLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/vgg/vgg16/VGG16FullyConnectedLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/vgg/vgg16/VGG16PoolingLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/yolo/v2/YOLOV2ActivationLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/yolo/v2/YOLOV2BatchNormalizationLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/yolo/v2/YOLOV2ConvolutionLayerDataset.h delete mode 100644 tests/datasets_new/system_tests/yolo/v2/YOLOV2PoolingLayerDataset.h delete mode 100644 tests/fixtures_new/ActivationLayerFixture.h delete mode 100644 tests/fixtures_new/AlexNetFixture.h delete mode 100644 tests/fixtures_new/BatchNormalizationLayerFixture.h delete mode 100644 tests/fixtures_new/ConvolutionLayerFixture.h delete mode 100644 tests/fixtures_new/DepthwiseConvolutionFixture.h delete mode 100644 tests/fixtures_new/DepthwiseSeparableConvolutionLayerFixture.h delete mode 100644 tests/fixtures_new/FloorFixture.h delete mode 100644 tests/fixtures_new/FullyConnectedLayerFixture.h delete mode 100644 tests/fixtures_new/GEMMFixture.h delete mode 100644 tests/fixtures_new/LeNet5Fixture.h delete mode 100644 tests/fixtures_new/NormalizationLayerFixture.h delete mode 100644 tests/fixtures_new/PoolingLayerFixture.h delete mode 100644 tests/fixtures_new/ROIPoolingLayerFixture.h create mode 100644 tests/framework/Asserts.h create mode 100644 tests/framework/DatasetModes.cpp create mode 100644 tests/framework/DatasetModes.h create mode 100644 tests/framework/Exceptions.cpp create mode 100644 tests/framework/Exceptions.h create mode 100644 tests/framework/Fixture.h create mode 100644 tests/framework/Framework.cpp create mode 100644 tests/framework/Framework.h create mode 100644 tests/framework/Macros.h create mode 100644 tests/framework/Profiler.cpp create mode 100644 tests/framework/Profiler.h create mode 100644 tests/framework/Registrars.h create mode 100644 tests/framework/SConscript create mode 100644 tests/framework/TestCase.h create mode 100644 tests/framework/TestCaseFactory.h create mode 100644 tests/framework/TestFilter.cpp create mode 100644 tests/framework/TestFilter.h create mode 100644 tests/framework/TestResult.h create mode 100644 tests/framework/Utils.h create mode 100644 tests/framework/command_line/CommandLineOptions.h create mode 100644 tests/framework/command_line/CommandLineParser.cpp create mode 100644 tests/framework/command_line/CommandLineParser.h create mode 100644 tests/framework/command_line/EnumListOption.h create mode 100644 tests/framework/command_line/EnumOption.h create mode 100644 tests/framework/command_line/ListOption.h create mode 100644 tests/framework/command_line/Option.cpp create mode 100644 tests/framework/command_line/Option.h create mode 100644 tests/framework/command_line/SimpleOption.h create mode 100644 tests/framework/command_line/ToggleOption.cpp create mode 100644 tests/framework/command_line/ToggleOption.h create mode 100644 tests/framework/datasets/CartesianProductDataset.h create mode 100644 tests/framework/datasets/ContainerDataset.h create mode 100644 tests/framework/datasets/Dataset.h create mode 100644 tests/framework/datasets/Datasets.h create mode 100644 tests/framework/datasets/InitializerListDataset.h create mode 100644 tests/framework/datasets/JoinDataset.h create mode 100644 tests/framework/datasets/RangeDataset.h create mode 100644 tests/framework/datasets/SingletonDataset.h create mode 100644 tests/framework/datasets/ZipDataset.h create mode 100644 tests/framework/instruments/Instrument.h create mode 100644 tests/framework/instruments/Instruments.cpp create mode 100644 tests/framework/instruments/Instruments.h create mode 100644 tests/framework/instruments/PMUCounter.cpp create mode 100644 tests/framework/instruments/PMUCounter.h create mode 100644 tests/framework/instruments/WallClockTimer.cpp create mode 100644 tests/framework/instruments/WallClockTimer.h create mode 100644 tests/framework/printers/JSONPrinter.cpp create mode 100644 tests/framework/printers/JSONPrinter.h create mode 100644 tests/framework/printers/PrettyPrinter.cpp create mode 100644 tests/framework/printers/PrettyPrinter.h create mode 100644 tests/framework/printers/Printer.cpp create mode 100644 tests/framework/printers/Printer.h create mode 100644 tests/framework/printers/Printers.cpp create mode 100644 tests/framework/printers/Printers.h delete mode 100644 tests/model_objects/AlexNet.h delete mode 100644 tests/model_objects/LeNet5.h create mode 100644 tests/networks/AlexNetNetwork.h create mode 100644 tests/networks/LeNet5Network.h delete mode 100644 tests/networks_new/AlexNetNetwork.h delete mode 100644 tests/networks_new/LeNet5Network.h create mode 100644 tests/validation/CL/ActivationLayer.cpp delete mode 100644 tests/validation/CL/ArithmeticAddition.cpp delete mode 100644 tests/validation/CL/ArithmeticSubtraction.cpp delete mode 100644 tests/validation/CL/BatchNormalizationLayer.cpp create mode 100644 tests/validation/CL/BitwiseAnd.cpp create mode 100644 tests/validation/CL/BitwiseNot.cpp create mode 100644 tests/validation/CL/BitwiseOr.cpp create mode 100644 tests/validation/CL/BitwiseXor.cpp delete mode 100644 tests/validation/CL/Box3x3.cpp delete mode 100644 tests/validation/CL/CLFixture.cpp delete mode 100644 tests/validation/CL/CLFixture.h delete mode 100644 tests/validation/CL/CMakeLists.txt create mode 100644 tests/validation/CL/ConvolutionLayer.cpp create mode 100644 tests/validation/CL/DepthConcatenateLayer.cpp delete mode 100644 tests/validation/CL/DepthConvert.cpp create mode 100644 tests/validation/CL/DepthwiseConvolution.cpp create mode 100644 tests/validation/CL/DepthwiseSeparableConvolutionLayer.cpp create mode 100644 tests/validation/CL/DirectConvolutionLayer.cpp delete mode 100644 tests/validation/CL/FillBorder.cpp delete mode 100644 tests/validation/CL/FixedPoint/FixedPoint_QS8.cpp create mode 100644 tests/validation/CL/Floor.cpp create mode 100644 tests/validation/CL/FullyConnectedLayer.cpp create mode 100644 tests/validation/CL/GEMM.cpp delete mode 100644 tests/validation/CL/Gaussian3x3.cpp delete mode 100644 tests/validation/CL/Gaussian5x5.cpp delete mode 100644 tests/validation/CL/HarrisCorners.cpp delete mode 100644 tests/validation/CL/IntegralImage.cpp create mode 100644 tests/validation/CL/L2Normalize.cpp create mode 100644 tests/validation/CL/MeanStdDev.cpp delete mode 100644 tests/validation/CL/MinMaxLocation.cpp delete mode 100644 tests/validation/CL/NonLinearFilter.cpp create mode 100644 tests/validation/CL/NormalizationLayer.cpp delete mode 100644 tests/validation/CL/PixelWiseMultiplication.cpp create mode 100644 tests/validation/CL/PoolingLayer.cpp delete mode 100644 tests/validation/CL/ROIPoolingLayer.cpp create mode 100644 tests/validation/CL/ReductionOperation.cpp create mode 100644 tests/validation/CL/Scale.cpp delete mode 100644 tests/validation/CL/Sobel3x3.cpp delete mode 100644 tests/validation/CL/Sobel5x5.cpp create mode 100644 tests/validation/CL/SoftmaxLayer.cpp delete mode 100644 tests/validation/CL/TableLookup.cpp delete mode 100644 tests/validation/CL/Threshold.cpp delete mode 100644 tests/validation/CL/WarpPerspective.cpp delete mode 100644 tests/validation/CMakeLists.txt create mode 100644 tests/validation/CPP/ActivationLayer.cpp create mode 100644 tests/validation/CPP/ActivationLayer.h create mode 100644 tests/validation/CPP/BitwiseAnd.cpp create mode 100644 tests/validation/CPP/BitwiseAnd.h create mode 100644 tests/validation/CPP/BitwiseNot.cpp create mode 100644 tests/validation/CPP/BitwiseNot.h create mode 100644 tests/validation/CPP/BitwiseOr.cpp create mode 100644 tests/validation/CPP/BitwiseOr.h create mode 100644 tests/validation/CPP/BitwiseXor.cpp create mode 100644 tests/validation/CPP/BitwiseXor.h create mode 100644 tests/validation/CPP/ConvolutionLayer.cpp create mode 100644 tests/validation/CPP/ConvolutionLayer.h create mode 100644 tests/validation/CPP/DepthConcatenateLayer.cpp create mode 100644 tests/validation/CPP/DepthConcatenateLayer.h create mode 100644 tests/validation/CPP/DepthwiseConvolution.cpp create mode 100644 tests/validation/CPP/DepthwiseConvolution.h create mode 100644 tests/validation/CPP/DepthwiseSeparableConvolutionLayer.cpp create mode 100644 tests/validation/CPP/DepthwiseSeparableConvolutionLayer.h create mode 100644 tests/validation/CPP/DequantizationLayer.cpp create mode 100644 tests/validation/CPP/DequantizationLayer.h create mode 100644 tests/validation/CPP/Floor.cpp create mode 100644 tests/validation/CPP/Floor.h create mode 100644 tests/validation/CPP/FullyConnectedLayer.cpp create mode 100644 tests/validation/CPP/FullyConnectedLayer.h create mode 100644 tests/validation/CPP/GEMM.cpp create mode 100644 tests/validation/CPP/GEMM.h create mode 100644 tests/validation/CPP/L2Normalize.cpp create mode 100644 tests/validation/CPP/L2Normalize.h create mode 100644 tests/validation/CPP/MeanStdDev.cpp create mode 100644 tests/validation/CPP/MeanStdDev.h create mode 100644 tests/validation/CPP/NormalizationLayer.cpp create mode 100644 tests/validation/CPP/NormalizationLayer.h create mode 100644 tests/validation/CPP/PoolingLayer.cpp create mode 100644 tests/validation/CPP/PoolingLayer.h create mode 100644 tests/validation/CPP/QuantizationLayer.cpp create mode 100644 tests/validation/CPP/QuantizationLayer.h create mode 100644 tests/validation/CPP/ReductionOperation.cpp create mode 100644 tests/validation/CPP/ReductionOperation.h create mode 100644 tests/validation/CPP/Scale.cpp create mode 100644 tests/validation/CPP/Scale.h create mode 100644 tests/validation/CPP/SoftmaxLayer.cpp create mode 100644 tests/validation/CPP/SoftmaxLayer.h create mode 100644 tests/validation/CPP/Utils.cpp create mode 100644 tests/validation/CPP/Utils.h delete mode 100644 tests/validation/Datasets.h create mode 100644 tests/validation/Helpers.cpp delete mode 100644 tests/validation/NEON/AbsoluteDifference.cpp delete mode 100644 tests/validation/NEON/Accumulate.cpp delete mode 100644 tests/validation/NEON/AccumulateSquared.cpp delete mode 100644 tests/validation/NEON/AccumulateWeighted.cpp create mode 100644 tests/validation/NEON/ActivationLayer.cpp delete mode 100644 tests/validation/NEON/ArithmeticAddition.cpp delete mode 100644 tests/validation/NEON/ArithmeticSubtraction.cpp delete mode 100644 tests/validation/NEON/BatchNormalizationLayer.cpp create mode 100644 tests/validation/NEON/BitwiseAnd.cpp create mode 100644 tests/validation/NEON/BitwiseNot.cpp create mode 100644 tests/validation/NEON/BitwiseOr.cpp create mode 100644 tests/validation/NEON/BitwiseXor.cpp delete mode 100644 tests/validation/NEON/Box3x3.cpp delete mode 100644 tests/validation/NEON/CMakeLists.txt create mode 100644 tests/validation/NEON/ConvolutionLayer.cpp create mode 100644 tests/validation/NEON/DepthConcatenateLayer.cpp delete mode 100644 tests/validation/NEON/DepthConvert.cpp create mode 100644 tests/validation/NEON/DequantizationLayer.cpp create mode 100644 tests/validation/NEON/DirectConvolutionLayer.cpp delete mode 100644 tests/validation/NEON/FillBorder.cpp delete mode 100644 tests/validation/NEON/Fixedpoint/Exp_QS16.cpp delete mode 100644 tests/validation/NEON/Fixedpoint/Exp_QS8.cpp delete mode 100644 tests/validation/NEON/Fixedpoint/Invsqrt_QS16.cpp delete mode 100644 tests/validation/NEON/Fixedpoint/Invsqrt_QS8.cpp delete mode 100644 tests/validation/NEON/Fixedpoint/Log_QS16.cpp delete mode 100644 tests/validation/NEON/Fixedpoint/Log_QS8.cpp delete mode 100644 tests/validation/NEON/Fixedpoint/Reciprocal_QS16.cpp delete mode 100644 tests/validation/NEON/Fixedpoint/Reciprocal_QS8.cpp create mode 100644 tests/validation/NEON/Floor.cpp create mode 100644 tests/validation/NEON/FullyConnectedLayer.cpp create mode 100644 tests/validation/NEON/GEMM.cpp delete mode 100644 tests/validation/NEON/Gaussian3x3.cpp delete mode 100644 tests/validation/NEON/Gaussian5x5.cpp delete mode 100644 tests/validation/NEON/HarrisCorners.cpp delete mode 100644 tests/validation/NEON/IntegralImage.cpp create mode 100644 tests/validation/NEON/L2Normalize.cpp create mode 100644 tests/validation/NEON/MeanStdDev.cpp delete mode 100644 tests/validation/NEON/MinMaxLocation.cpp delete mode 100644 tests/validation/NEON/NonLinearFilter.cpp create mode 100644 tests/validation/NEON/NormalizationLayer.cpp delete mode 100644 tests/validation/NEON/PixelWiseMultiplication.cpp create mode 100644 tests/validation/NEON/PoolingLayer.cpp create mode 100644 tests/validation/NEON/QuantizationLayer.cpp delete mode 100644 tests/validation/NEON/ROIPoolingLayer.cpp create mode 100644 tests/validation/NEON/ReductionOperation.cpp create mode 100644 tests/validation/NEON/Scale.cpp delete mode 100644 tests/validation/NEON/Sobel3x3.cpp delete mode 100644 tests/validation/NEON/Sobel5x5.cpp create mode 100644 tests/validation/NEON/SoftmaxLayer.cpp delete mode 100644 tests/validation/NEON/TableLookup.cpp delete mode 100644 tests/validation/NEON/Threshold.cpp delete mode 100644 tests/validation/NEON/WarpPerspective.cpp delete mode 100644 tests/validation/Reference.cpp delete mode 100644 tests/validation/Reference.h delete mode 100644 tests/validation/ReferenceCPP.cpp delete mode 100644 tests/validation/ReferenceCPP.h delete mode 100644 tests/validation/Tensor.h delete mode 100644 tests/validation/TensorFactory.h delete mode 100644 tests/validation/TensorOperations.h delete mode 100644 tests/validation/TensorVisitors.h delete mode 100644 tests/validation/UNIT/CMakeLists.txt delete mode 100644 tests/validation/UNIT/FixedPoint.cpp delete mode 100644 tests/validation/UNIT/TensorInfo.cpp delete mode 100644 tests/validation/UNIT/TensorShape.cpp delete mode 100644 tests/validation/UNIT/Utils.cpp delete mode 100644 tests/validation/ValidationProgramOptions.cpp delete mode 100644 tests/validation/ValidationProgramOptions.h delete mode 100644 tests/validation/ValidationUserConfiguration.h create mode 100644 tests/validation/fixtures/ActivationLayerFixture.h create mode 100644 tests/validation/fixtures/BitwiseAndFixture.h create mode 100644 tests/validation/fixtures/BitwiseNotFixture.h create mode 100644 tests/validation/fixtures/BitwiseOrFixture.h create mode 100644 tests/validation/fixtures/BitwiseXorFixture.h create mode 100644 tests/validation/fixtures/ConvolutionLayerFixture.h create mode 100644 tests/validation/fixtures/DepthConcatenateLayerFixture.h create mode 100644 tests/validation/fixtures/DepthwiseConvolutionFixture.h create mode 100644 tests/validation/fixtures/DepthwiseSeparableConvolutionLayerFixture.h create mode 100644 tests/validation/fixtures/DequantizationLayerFixture.h create mode 100644 tests/validation/fixtures/DirectConvolutionLayerFixture.h create mode 100644 tests/validation/fixtures/FloorFixture.h create mode 100644 tests/validation/fixtures/FullyConnectedLayerFixture.h create mode 100644 tests/validation/fixtures/GEMMFixture.h create mode 100644 tests/validation/fixtures/L2NormalizeFixture.h create mode 100644 tests/validation/fixtures/MeanStdDevFixture.h create mode 100644 tests/validation/fixtures/NormalizationLayerFixture.h create mode 100644 tests/validation/fixtures/PoolingLayerFixture.h create mode 100644 tests/validation/fixtures/QuantizationLayerFixture.h create mode 100644 tests/validation/fixtures/ReductionOperationFixture.h create mode 100644 tests/validation/fixtures/ScaleFixture.h create mode 100644 tests/validation/fixtures/SoftmaxLayerFixture.h delete mode 100644 tests/validation/main.cpp delete mode 100644 tests/validation/system_tests/CL/AlexNet.cpp delete mode 100644 tests/validation/system_tests/CL/LeNet5.cpp delete mode 100644 tests/validation/system_tests/NEON/AlexNet.cpp delete mode 100644 tests/validation/system_tests/NEON/LeNet5.cpp delete mode 100644 tests/validation_new/CL/ActivationLayer.cpp delete mode 100644 tests/validation_new/CL/BitwiseAnd.cpp delete mode 100644 tests/validation_new/CL/BitwiseNot.cpp delete mode 100644 tests/validation_new/CL/BitwiseOr.cpp delete mode 100644 tests/validation_new/CL/BitwiseXor.cpp delete mode 100644 tests/validation_new/CL/ConvolutionLayer.cpp delete mode 100644 tests/validation_new/CL/DepthConcatenateLayer.cpp delete mode 100644 tests/validation_new/CL/DepthwiseConvolution.cpp delete mode 100644 tests/validation_new/CL/DepthwiseSeparableConvolutionLayer.cpp delete mode 100644 tests/validation_new/CL/DirectConvolutionLayer.cpp delete mode 100644 tests/validation_new/CL/Floor.cpp delete mode 100644 tests/validation_new/CL/FullyConnectedLayer.cpp delete mode 100644 tests/validation_new/CL/GEMM.cpp delete mode 100644 tests/validation_new/CL/L2Normalize.cpp delete mode 100644 tests/validation_new/CL/MeanStdDev.cpp delete mode 100644 tests/validation_new/CL/NormalizationLayer.cpp delete mode 100644 tests/validation_new/CL/PoolingLayer.cpp delete mode 100644 tests/validation_new/CL/ReductionOperation.cpp delete mode 100644 tests/validation_new/CL/Scale.cpp delete mode 100644 tests/validation_new/CL/SoftmaxLayer.cpp delete mode 100644 tests/validation_new/CPP/ActivationLayer.cpp delete mode 100644 tests/validation_new/CPP/ActivationLayer.h delete mode 100644 tests/validation_new/CPP/BitwiseAnd.cpp delete mode 100644 tests/validation_new/CPP/BitwiseAnd.h delete mode 100644 tests/validation_new/CPP/BitwiseNot.cpp delete mode 100644 tests/validation_new/CPP/BitwiseNot.h delete mode 100644 tests/validation_new/CPP/BitwiseOr.cpp delete mode 100644 tests/validation_new/CPP/BitwiseOr.h delete mode 100644 tests/validation_new/CPP/BitwiseXor.cpp delete mode 100644 tests/validation_new/CPP/BitwiseXor.h delete mode 100644 tests/validation_new/CPP/ConvolutionLayer.cpp delete mode 100644 tests/validation_new/CPP/ConvolutionLayer.h delete mode 100644 tests/validation_new/CPP/DepthConcatenateLayer.cpp delete mode 100644 tests/validation_new/CPP/DepthConcatenateLayer.h delete mode 100644 tests/validation_new/CPP/DepthwiseConvolution.cpp delete mode 100644 tests/validation_new/CPP/DepthwiseConvolution.h delete mode 100644 tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.cpp delete mode 100644 tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.h delete mode 100644 tests/validation_new/CPP/DequantizationLayer.cpp delete mode 100644 tests/validation_new/CPP/DequantizationLayer.h delete mode 100644 tests/validation_new/CPP/Floor.cpp delete mode 100644 tests/validation_new/CPP/Floor.h delete mode 100644 tests/validation_new/CPP/FullyConnectedLayer.cpp delete mode 100644 tests/validation_new/CPP/FullyConnectedLayer.h delete mode 100644 tests/validation_new/CPP/GEMM.cpp delete mode 100644 tests/validation_new/CPP/GEMM.h delete mode 100644 tests/validation_new/CPP/L2Normalize.cpp delete mode 100644 tests/validation_new/CPP/L2Normalize.h delete mode 100644 tests/validation_new/CPP/MeanStdDev.cpp delete mode 100644 tests/validation_new/CPP/MeanStdDev.h delete mode 100644 tests/validation_new/CPP/NormalizationLayer.cpp delete mode 100644 tests/validation_new/CPP/NormalizationLayer.h delete mode 100644 tests/validation_new/CPP/PoolingLayer.cpp delete mode 100644 tests/validation_new/CPP/PoolingLayer.h delete mode 100644 tests/validation_new/CPP/QuantizationLayer.cpp delete mode 100644 tests/validation_new/CPP/QuantizationLayer.h delete mode 100644 tests/validation_new/CPP/ReductionOperation.cpp delete mode 100644 tests/validation_new/CPP/ReductionOperation.h delete mode 100644 tests/validation_new/CPP/Scale.cpp delete mode 100644 tests/validation_new/CPP/Scale.h delete mode 100644 tests/validation_new/CPP/SoftmaxLayer.cpp delete mode 100644 tests/validation_new/CPP/SoftmaxLayer.h delete mode 100644 tests/validation_new/CPP/Utils.cpp delete mode 100644 tests/validation_new/CPP/Utils.h delete mode 100644 tests/validation_new/FixedPoint.h delete mode 100644 tests/validation_new/Helpers.cpp delete mode 100644 tests/validation_new/Helpers.h delete mode 100644 tests/validation_new/NEON/ActivationLayer.cpp delete mode 100644 tests/validation_new/NEON/BitwiseAnd.cpp delete mode 100644 tests/validation_new/NEON/BitwiseNot.cpp delete mode 100644 tests/validation_new/NEON/BitwiseOr.cpp delete mode 100644 tests/validation_new/NEON/BitwiseXor.cpp delete mode 100644 tests/validation_new/NEON/ConvolutionLayer.cpp delete mode 100644 tests/validation_new/NEON/DepthConcatenateLayer.cpp delete mode 100644 tests/validation_new/NEON/DequantizationLayer.cpp delete mode 100644 tests/validation_new/NEON/DirectConvolutionLayer.cpp delete mode 100644 tests/validation_new/NEON/Floor.cpp delete mode 100644 tests/validation_new/NEON/FullyConnectedLayer.cpp delete mode 100644 tests/validation_new/NEON/GEMM.cpp delete mode 100644 tests/validation_new/NEON/L2Normalize.cpp delete mode 100644 tests/validation_new/NEON/MeanStdDev.cpp delete mode 100644 tests/validation_new/NEON/NormalizationLayer.cpp delete mode 100644 tests/validation_new/NEON/PoolingLayer.cpp delete mode 100644 tests/validation_new/NEON/QuantizationLayer.cpp delete mode 100644 tests/validation_new/NEON/ReductionOperation.cpp delete mode 100644 tests/validation_new/NEON/Scale.cpp delete mode 100644 tests/validation_new/NEON/SoftmaxLayer.cpp delete mode 100644 tests/validation_new/Validation.cpp delete mode 100644 tests/validation_new/Validation.h delete mode 100644 tests/validation_new/fixtures/ActivationLayerFixture.h delete mode 100644 tests/validation_new/fixtures/BitwiseAndFixture.h delete mode 100644 tests/validation_new/fixtures/BitwiseNotFixture.h delete mode 100644 tests/validation_new/fixtures/BitwiseOrFixture.h delete mode 100644 tests/validation_new/fixtures/BitwiseXorFixture.h delete mode 100644 tests/validation_new/fixtures/ConvolutionLayerFixture.h delete mode 100644 tests/validation_new/fixtures/DepthConcatenateLayerFixture.h delete mode 100644 tests/validation_new/fixtures/DepthwiseConvolutionFixture.h delete mode 100644 tests/validation_new/fixtures/DepthwiseSeparableConvolutionLayerFixture.h delete mode 100644 tests/validation_new/fixtures/DequantizationLayerFixture.h delete mode 100644 tests/validation_new/fixtures/DirectConvolutionLayerFixture.h delete mode 100644 tests/validation_new/fixtures/FloorFixture.h delete mode 100644 tests/validation_new/fixtures/FullyConnectedLayerFixture.h delete mode 100644 tests/validation_new/fixtures/GEMMFixture.h delete mode 100644 tests/validation_new/fixtures/L2NormalizeFixture.h delete mode 100644 tests/validation_new/fixtures/MeanStdDevFixture.h delete mode 100644 tests/validation_new/fixtures/NormalizationLayerFixture.h delete mode 100644 tests/validation_new/fixtures/PoolingLayerFixture.h delete mode 100644 tests/validation_new/fixtures/QuantizationLayerFixture.h delete mode 100644 tests/validation_new/fixtures/ReductionOperationFixture.h delete mode 100644 tests/validation_new/fixtures/ScaleFixture.h delete mode 100644 tests/validation_new/fixtures/SoftmaxLayerFixture.h delete mode 100644 tests/validation_new/half.h create mode 100644 tests/validation_old/AssetsLibrary.cpp create mode 100644 tests/validation_old/AssetsLibrary.h create mode 100644 tests/validation_old/CL/ArithmeticAddition.cpp create mode 100644 tests/validation_old/CL/ArithmeticSubtraction.cpp create mode 100644 tests/validation_old/CL/BatchNormalizationLayer.cpp create mode 100644 tests/validation_old/CL/Box3x3.cpp create mode 100644 tests/validation_old/CL/CLFixture.cpp create mode 100644 tests/validation_old/CL/CLFixture.h create mode 100644 tests/validation_old/CL/DepthConvert.cpp create mode 100644 tests/validation_old/CL/FillBorder.cpp create mode 100644 tests/validation_old/CL/FixedPoint/FixedPoint_QS8.cpp create mode 100644 tests/validation_old/CL/Gaussian3x3.cpp create mode 100644 tests/validation_old/CL/Gaussian5x5.cpp create mode 100644 tests/validation_old/CL/HarrisCorners.cpp create mode 100644 tests/validation_old/CL/IntegralImage.cpp create mode 100644 tests/validation_old/CL/MinMaxLocation.cpp create mode 100644 tests/validation_old/CL/NonLinearFilter.cpp create mode 100644 tests/validation_old/CL/PixelWiseMultiplication.cpp create mode 100644 tests/validation_old/CL/ROIPoolingLayer.cpp create mode 100644 tests/validation_old/CL/Sobel3x3.cpp create mode 100644 tests/validation_old/CL/Sobel5x5.cpp create mode 100644 tests/validation_old/CL/TableLookup.cpp create mode 100644 tests/validation_old/CL/Threshold.cpp create mode 100644 tests/validation_old/CL/WarpPerspective.cpp create mode 100644 tests/validation_old/Datasets.h create mode 100644 tests/validation_old/FixedPoint.h create mode 100644 tests/validation_old/Helpers.h create mode 100644 tests/validation_old/NEON/AbsoluteDifference.cpp create mode 100644 tests/validation_old/NEON/Accumulate.cpp create mode 100644 tests/validation_old/NEON/AccumulateSquared.cpp create mode 100644 tests/validation_old/NEON/AccumulateWeighted.cpp create mode 100644 tests/validation_old/NEON/ArithmeticAddition.cpp create mode 100644 tests/validation_old/NEON/ArithmeticSubtraction.cpp create mode 100644 tests/validation_old/NEON/BatchNormalizationLayer.cpp create mode 100644 tests/validation_old/NEON/Box3x3.cpp create mode 100644 tests/validation_old/NEON/DepthConvert.cpp create mode 100644 tests/validation_old/NEON/FillBorder.cpp create mode 100644 tests/validation_old/NEON/Fixedpoint/Exp_QS16.cpp create mode 100644 tests/validation_old/NEON/Fixedpoint/Exp_QS8.cpp create mode 100644 tests/validation_old/NEON/Fixedpoint/Invsqrt_QS16.cpp create mode 100644 tests/validation_old/NEON/Fixedpoint/Invsqrt_QS8.cpp create mode 100644 tests/validation_old/NEON/Fixedpoint/Log_QS16.cpp create mode 100644 tests/validation_old/NEON/Fixedpoint/Log_QS8.cpp create mode 100644 tests/validation_old/NEON/Fixedpoint/Reciprocal_QS16.cpp create mode 100644 tests/validation_old/NEON/Fixedpoint/Reciprocal_QS8.cpp create mode 100644 tests/validation_old/NEON/Gaussian3x3.cpp create mode 100644 tests/validation_old/NEON/Gaussian5x5.cpp create mode 100644 tests/validation_old/NEON/HarrisCorners.cpp create mode 100644 tests/validation_old/NEON/IntegralImage.cpp create mode 100644 tests/validation_old/NEON/MinMaxLocation.cpp create mode 100644 tests/validation_old/NEON/NonLinearFilter.cpp create mode 100644 tests/validation_old/NEON/PixelWiseMultiplication.cpp create mode 100644 tests/validation_old/NEON/ROIPoolingLayer.cpp create mode 100644 tests/validation_old/NEON/Sobel3x3.cpp create mode 100644 tests/validation_old/NEON/Sobel5x5.cpp create mode 100644 tests/validation_old/NEON/TableLookup.cpp create mode 100644 tests/validation_old/NEON/Threshold.cpp create mode 100644 tests/validation_old/NEON/WarpPerspective.cpp create mode 100644 tests/validation_old/ProgramOptions.cpp create mode 100644 tests/validation_old/ProgramOptions.h create mode 100644 tests/validation_old/RawTensor.cpp create mode 100644 tests/validation_old/RawTensor.h create mode 100644 tests/validation_old/Reference.cpp create mode 100644 tests/validation_old/Reference.h create mode 100644 tests/validation_old/ReferenceCPP.cpp create mode 100644 tests/validation_old/ReferenceCPP.h create mode 100644 tests/validation_old/SConscript create mode 100644 tests/validation_old/Tensor.h create mode 100644 tests/validation_old/TensorFactory.h create mode 100644 tests/validation_old/TensorOperations.h create mode 100644 tests/validation_old/TensorVisitors.h create mode 100644 tests/validation_old/UNIT/FixedPoint.cpp create mode 100644 tests/validation_old/UNIT/TensorInfo.cpp create mode 100644 tests/validation_old/UNIT/TensorShape.cpp create mode 100644 tests/validation_old/UNIT/Utils.cpp create mode 100644 tests/validation_old/UserConfiguration.cpp create mode 100644 tests/validation_old/UserConfiguration.h create mode 100644 tests/validation_old/Validation.cpp create mode 100644 tests/validation_old/Validation.h create mode 100644 tests/validation_old/ValidationProgramOptions.cpp create mode 100644 tests/validation_old/ValidationProgramOptions.h create mode 100644 tests/validation_old/ValidationUserConfiguration.h create mode 100644 tests/validation_old/boost_wrapper.h create mode 100644 tests/validation_old/dataset/ActivationFunctionDataset.h create mode 100644 tests/validation_old/dataset/ActivationLayerDataset.h create mode 100644 tests/validation_old/dataset/BatchNormalizationLayerDataset.h create mode 100644 tests/validation_old/dataset/BorderModeDataset.h create mode 100644 tests/validation_old/dataset/ConvertPolicyDataset.h create mode 100644 tests/validation_old/dataset/ConvolutionLayerDataset.h create mode 100644 tests/validation_old/dataset/DataTypeDatasets.h create mode 100644 tests/validation_old/dataset/FullyConnectedLayerDataset.h create mode 100644 tests/validation_old/dataset/GEMMDataset.h create mode 100644 tests/validation_old/dataset/GenericDataset.h create mode 100644 tests/validation_old/dataset/ImageDatasets.h create mode 100644 tests/validation_old/dataset/InterpolationPolicyDataset.h create mode 100644 tests/validation_old/dataset/MatrixPatternDataset.h create mode 100644 tests/validation_old/dataset/NonLinearFilterFunctionDataset.h create mode 100644 tests/validation_old/dataset/NormalizationLayerDataset.h create mode 100644 tests/validation_old/dataset/NormalizationTypeDataset.h create mode 100644 tests/validation_old/dataset/PoolingLayerDataset.h create mode 100644 tests/validation_old/dataset/PoolingTypesDataset.h create mode 100644 tests/validation_old/dataset/RoundingPolicyDataset.h create mode 100644 tests/validation_old/dataset/ShapeDatasets.h create mode 100644 tests/validation_old/dataset/ThresholdDataset.h create mode 100644 tests/validation_old/half.h create mode 100644 tests/validation_old/main.cpp create mode 100644 tests/validation_old/model_objects/AlexNet.h create mode 100644 tests/validation_old/model_objects/LeNet5.h create mode 100644 tests/validation_old/system_tests/CL/AlexNet.cpp create mode 100644 tests/validation_old/system_tests/CL/LeNet5.cpp create mode 100644 tests/validation_old/system_tests/NEON/AlexNet.cpp create mode 100644 tests/validation_old/system_tests/NEON/LeNet5.cpp diff --git a/SConstruct b/SConstruct index 34b717b186..cb08c89fcc 100644 --- a/SConstruct +++ b/SConstruct @@ -217,5 +217,4 @@ if env['opencl']: if env['examples']: SConscript('./examples/SConscript', variant_dir='#build/%s/examples' % env['build_dir'], duplicate=0) -SConscript('./framework/SConscript', variant_dir='#build/%s/framework' % env['build_dir'], duplicate=0) SConscript('./tests/SConscript', variant_dir='#build/%s/tests' % env['build_dir'], duplicate=0) diff --git a/docs/02_tests.dox b/docs/02_tests.dox index a3e4f8b05b..212f8f0fae 100644 --- a/docs/02_tests.dox +++ b/docs/02_tests.dox @@ -22,36 +22,36 @@ information is needed within the test (e.g. to validate the results). . |-- computer_vision <- Legacy tests. No new test must be added. - |-- framework <- Underlying test framework. Will later be moved into tests. - `-- tests <- Top level test directory. All files in here are shared among validation and benchmark + `-- tests <- Top level test directory. All files in here are shared among validation and benchmark. + |-- framework <- Underlying test framework. |-- CL \ |-- NEON -> Backend specific files with helper functions etc. - |-- VX / - |-- benchmark_new <- Top level directory for the benchmarking files - | |-- CL <- OpenCL backend test cases on a function level + |-- VX / + |-- benchmark <- Top level directory for the benchmarking files. + | |-- fixtures <- Fixtures for benchmark tests. + | |-- CL <- OpenCL backend test cases on a function level. | | `-- SYSTEM <- OpenCL system tests, e.g. whole networks | `-- NEON <- Same for NEON | `-- SYSTEM - |-- dataset <- Old datasets for boost. Not to be used for new tests! - |-- datasets_new <- New datasets for benchmark and validation tests. - |-- fixtures_new <- Fixtures for benchmarking only! Will later be moved into benchmark_new. + |-- datasets <- Datasets for benchmark and validation tests. |-- main.cpp <- Main entry point for the tests. Currently shared between validation and benchmarking. - |-- model_objects <- Old helper files for system level validation. Not to be used for new tests! - |-- networks_new <- Network classes for system level tests - |-- validation <- Old validation framework. No new tests must be added! + |-- networks <- Network classes for system level tests. + |-- validation_old <- Old validation framework. No new tests must be added! + | |-- dataset <- Old datasets for boost. Not to be used for new tests! + | |-- model_objects <- Old helper files for system level validation. Not to be used for new tests! | |-- CL \ | |-- DEMO \ | |-- NEON --> Backend specific test cases | |-- UNIT / - | |-- VX / + | |-- VX / | `-- system_tests -> System level tests | |-- CL | `-- NEON - `-- validation_new -> New validation tests + `-- validation -> Top level directory for validation files. |-- CPP -> C++ reference code |-- CL \ |-- NEON -> Backend specific test cases - |-- VX / + |-- VX / `-- fixtures -> Fixtures shared among all backends. Used to setup target function and tensors. @subsection tests_overview_fixtures Fixtures @@ -313,6 +313,7 @@ provide a good overview how test cases are structured. Typically the will be multiple tests for different data types and for different execution modes, e.g. precommit and nightly. + @section building_test_dependencies Building dependencies @note Only required when tests from the old validation framework need to be run. @@ -341,6 +342,7 @@ the ```toolset=``` option to choose the right compiler. Moreover, After executing the build command the libraries ```libboost_program_options.a``` and ```libboost_unit_test_framework.a``` can be found in ```./stage/lib```. + @section tests_running_tests Running tests @subsection tests_running_tests_benchmarking Benchmarking @@ -380,6 +382,7 @@ As an alternative output format JSON is supported and can be selected via `--log-format=json`. To write the output to a file instead of stdout the `--log-file` option can be used. + @subsection tests_running_tests_validation Validation @note The new validation tests have the same interface as the benchmarking tests. diff --git a/docs/Doxyfile b/docs/Doxyfile index f9b6e1403c..44f9e92b58 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -776,7 +776,6 @@ INPUT = ./docs/00_introduction.dox \ ./scripts/ \ ./src/core/CL/cl_kernels/ \ ./examples/ \ - ./framework/ \ ./tests/ \ ./utils/ \ ./support/ diff --git a/framework/Asserts.h b/framework/Asserts.h deleted file mode 100644 index b545a9ebba..0000000000 --- a/framework/Asserts.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_FRAMEWORK_ASSERTS -#define ARM_COMPUTE_TEST_FRAMEWORK_ASSERTS - -#include "Exceptions.h" -#include "Framework.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -// Cast char values to int so that their numeric value are printed. -inline int make_printable(int8_t value) -{ - return value; -} - -inline unsigned int make_printable(uint8_t value) -{ - return value; -} - -// Everything else can be printed as its own type. -template -inline T make_printable(T &&value) -{ - return value; -} - -#define ARM_COMPUTE_TEST_INFO(INFO) \ - { \ - std::stringstream info; \ - info << INFO; \ - arm_compute::test::framework::Framework::get().add_test_info(info.str()); \ - } - -namespace detail -{ -#define ARM_COMPUTE_TEST_COMP_FACTORY(SEVERITY, SEVERITY_NAME, COMP, COMP_NAME, ERROR_CALL) \ - template \ - void ARM_COMPUTE_##SEVERITY##_##COMP_NAME##_IMPL(T &&x, U &&y, const std::string &x_str, const std::string &y_str, LogLevel level) \ - { \ - if(!(x COMP y)) \ - { \ - std::stringstream msg; \ - msg << #SEVERITY_NAME " '" << x_str << " " #COMP " " << y_str << "' failed. [" \ - << std::boolalpha << arm_compute::test::framework::make_printable(x) \ - << " " #COMP " " \ - << std::boolalpha << arm_compute::test::framework::make_printable(y) \ - << "]\n"; \ - arm_compute::test::framework::Framework::get().print_test_info(msg); \ - ERROR_CALL \ - } \ - arm_compute::test::framework::Framework::get().clear_test_info(); \ - } - -ARM_COMPUTE_TEST_COMP_FACTORY(EXPECT, Expectation, ==, EQUAL, arm_compute::test::framework::Framework::get().log_failed_expectation(arm_compute::test::framework::TestError(msg.str(), level));) -ARM_COMPUTE_TEST_COMP_FACTORY(EXPECT, Expectation, !=, NOT_EQUAL, arm_compute::test::framework::Framework::get().log_failed_expectation(arm_compute::test::framework::TestError(msg.str(), level));) -ARM_COMPUTE_TEST_COMP_FACTORY(ASSERT, Assertion, ==, EQUAL, throw arm_compute::test::framework::TestError(msg.str(), level);) -ARM_COMPUTE_TEST_COMP_FACTORY(ASSERT, Assertion, !=, NOT_EQUAL, throw arm_compute::test::framework::TestError(msg.str(), level);) -} // namespace detail - -#define ARM_COMPUTE_ASSERT_NOT_EQUAL(X, Y) \ - arm_compute::test::framework::detail::ARM_COMPUTE_ASSERT_NOT_EQUAL_IMPL(X, Y, #X, #Y, LogLevel::ERRORS) - -#define ARM_COMPUTE_ASSERT_EQUAL(X, Y) \ - arm_compute::test::framework::detail::ARM_COMPUTE_ASSERT_EQUAL_IMPL(X, Y, #X, #Y, LogLevel::ERRORS) - -#define ARM_COMPUTE_EXPECT_EQUAL(X, Y, LEVEL) \ - arm_compute::test::framework::detail::ARM_COMPUTE_EXPECT_EQUAL_IMPL(X, Y, #X, #Y, LEVEL) - -#define ARM_COMPUTE_EXPECT_NOT_EQUAL(X, Y, LEVEL) \ - arm_compute::test::framework::detail::ARM_COMPUTE_EXPECT_NOT_EQUAL_IMPL(X, Y, #X, #Y, LEVEL) - -#define ARM_COMPUTE_ASSERT(X) \ - do \ - { \ - const auto &x = X; \ - if(!x) \ - { \ - std::stringstream msg; \ - msg << "Assertion '" #X "' failed.\n"; \ - arm_compute::test::framework::Framework::get().print_test_info(msg); \ - throw arm_compute::test::framework::TestError(msg.str(), arm_compute::test::framework::LogLevel::ERRORS); \ - } \ - arm_compute::test::framework::Framework::get().clear_test_info(); \ - } while(false) - -#define ARM_COMPUTE_EXPECT(X, LEVEL) \ - do \ - { \ - const auto &x = X; \ - if(!x) \ - { \ - std::stringstream msg; \ - msg << "Expectation '" #X "' failed.\n"; \ - arm_compute::test::framework::Framework::get().print_test_info(msg); \ - arm_compute::test::framework::Framework::get().log_failed_expectation(arm_compute::test::framework::TestError(msg.str(), LEVEL)); \ - } \ - arm_compute::test::framework::Framework::get().clear_test_info(); \ - } while(false) -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_FRAMEWORK_ASSERTS */ diff --git a/framework/DatasetModes.cpp b/framework/DatasetModes.cpp deleted file mode 100644 index 3f747df747..0000000000 --- a/framework/DatasetModes.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "DatasetModes.h" - -#include "Utils.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -DatasetMode dataset_mode_from_name(const std::string &name) -{ - static const std::map modes = - { - { "all", DatasetMode::ALL }, - { "precommit", DatasetMode::PRECOMMIT }, - { "nightly", DatasetMode::NIGHTLY }, - }; - - try - { - return modes.at(tolower(name)); - } - catch(const std::out_of_range &) - { - throw std::invalid_argument(name); - } -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/DatasetModes.h b/framework/DatasetModes.h deleted file mode 100644 index 27638b0504..0000000000 --- a/framework/DatasetModes.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DATASET_MODES -#define ARM_COMPUTE_TEST_DATASET_MODES - -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Possible dataset modes. */ -enum class DatasetMode : unsigned int -{ - ALL = ~0U, - DISABLED = 0, - PRECOMMIT = 1, - NIGHTLY = 2 -}; - -inline DatasetMode operator&(DatasetMode t1, DatasetMode t2) -{ - using type = std::underlying_type::type; - return static_cast(static_cast(t1) & static_cast(t2)); -} - -inline DatasetMode operator|(DatasetMode t1, DatasetMode t2) -{ - using type = std::underlying_type::type; - return static_cast(static_cast(t1) | static_cast(t2)); -} - -inline DatasetMode &operator|=(DatasetMode &t1, DatasetMode t2) -{ - using type = std::underlying_type::type; - t1 = static_cast(static_cast(t1) | static_cast(t2)); - return t1; -} - -DatasetMode dataset_mode_from_name(const std::string &name); - -inline ::std::istream &operator>>(::std::istream &stream, DatasetMode &mode) -{ - std::string value; - stream >> value; - mode = dataset_mode_from_name(value); - return stream; -} - -inline ::std::ostream &operator<<(::std::ostream &stream, DatasetMode mode) -{ - switch(mode) - { - case DatasetMode::PRECOMMIT: - stream << "PRECOMMIT"; - break; - case DatasetMode::NIGHTLY: - stream << "NIGHTLY"; - break; - case DatasetMode::ALL: - stream << "ALL"; - break; - default: - throw std::invalid_argument("Unsupported dataset mode"); - } - - return stream; -} - -inline std::string to_string(DatasetMode mode) -{ - std::stringstream stream; - stream << mode; - return stream.str(); -} -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DATASET_MODES */ diff --git a/framework/Exceptions.cpp b/framework/Exceptions.cpp deleted file mode 100644 index 3d6c65c181..0000000000 --- a/framework/Exceptions.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Exceptions.h" - -#include "Utils.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -LogLevel log_level_from_name(const std::string &name) -{ - static const std::map levels = - { - { "none", LogLevel::NONE }, - { "config", LogLevel::CONFIG }, - { "tests", LogLevel::TESTS }, - { "errors", LogLevel::ERRORS }, - { "debug", LogLevel::DEBUG }, - { "measurements", LogLevel::MEASUREMENTS }, - { "all", LogLevel::ALL }, - }; - - try - { - return levels.at(tolower(name)); - } - catch(const std::out_of_range &) - { - throw std::invalid_argument(name); - } -} - -::std::istream &operator>>(::std::istream &stream, LogLevel &level) -{ - std::string value; - stream >> value; - level = log_level_from_name(value); - return stream; -} - -::std::ostream &operator<<(::std::ostream &stream, LogLevel level) -{ - switch(level) - { - case LogLevel::NONE: - stream << "NONE"; - break; - case LogLevel::CONFIG: - stream << "CONFIG"; - break; - case LogLevel::TESTS: - stream << "TESTS"; - break; - case LogLevel::ERRORS: - stream << "ERRORS"; - break; - case LogLevel::DEBUG: - stream << "DEBUG"; - break; - case LogLevel::MEASUREMENTS: - stream << "MEASUREMENTS"; - break; - case LogLevel::ALL: - stream << "ALL"; - break; - default: - throw std::invalid_argument("Unsupported log level"); - } - - return stream; -} - -std::string to_string(LogLevel level) -{ - std::stringstream stream; - stream << level; - return stream.str(); -} - -TestError::TestError(const std::string &msg, LogLevel level, std::string context) - : std::runtime_error{ msg }, _level{ level }, _msg{ msg }, _context{ std::move(context) }, _combined{ "ERROR: " + msg } -{ - if(!_context.empty()) - { - _combined += "\nCONTEXT:\n" + _context; - } -} - -LogLevel TestError::level() const -{ - return _level; -} - -const char *TestError::what() const noexcept -{ - return _combined.c_str(); -} - -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/Exceptions.h b/framework/Exceptions.h deleted file mode 100644 index edb0ed92c9..0000000000 --- a/framework/Exceptions.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_EXCEPTIONS -#define ARM_COMPUTE_TEST_EXCEPTIONS - -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Severity of the information. - * - * Each category includes the ones above it. - * - * NONE == Only for filtering. Not used to tag information. - * CONFIG == Configuration info. - * TESTS == Information about the tests. - * ERRORS == Violated assertions/expectations. - * DEBUG == More violated assertions/expectations. - * MEASUREMENTS == Information about measurements. - * ALL == Only for filtering. Not used to tag information. - */ -enum class LogLevel -{ - NONE, - CONFIG, - TESTS, - ERRORS, - DEBUG, - MEASUREMENTS, - ALL, -}; - -LogLevel log_level_from_name(const std::string &name); -::std::istream &operator>>(::std::istream &stream, LogLevel &level); -::std::ostream &operator<<(::std::ostream &stream, LogLevel level); -std::string to_string(LogLevel level); - -/** Error class for failures during test execution. */ -class TestError : public std::runtime_error -{ -public: - using std::runtime_error::runtime_error; - - /** Construct error with severity. - * - * @param[in] msg Error message. - * @param[in] level Severity level. - * @param[in] context Context. - */ - TestError(const std::string &msg, LogLevel level, std::string context = ""); - - /** Severity of the error. - * - * @return Severity. - */ - LogLevel level() const; - - const char *what() const noexcept override; - -private: - LogLevel _level{ LogLevel::ERRORS }; - std::string _msg{}; - std::string _context{}; - std::string _combined{}; -}; -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_EXCEPTIONS */ diff --git a/framework/Fixture.h b/framework/Fixture.h deleted file mode 100644 index 916dcc7fef..0000000000 --- a/framework/Fixture.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_FIXTURE -#define ARM_COMPUTE_TEST_FIXTURE - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Abstract fixture class. - * - * All custom fixtures have to inherit from this class. - */ -class Fixture -{ -public: - /** Setup function. - * - * This function is only invoked by non-data fixture test cases. Fixture - * data test cases implement a setup function with arguments matching the - * dataset. - * - * The function is called before the test case is executed. - */ - void setup() {}; - - /** Teardown function. - * - * The function is called after the test case finished. - */ - void teardown() {}; - -protected: - Fixture() = default; - virtual ~Fixture() = default; -}; -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_FIXTURE */ diff --git a/framework/Framework.cpp b/framework/Framework.cpp deleted file mode 100644 index 315f8ebea7..0000000000 --- a/framework/Framework.cpp +++ /dev/null @@ -1,494 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Framework.h" - -#include "support/ToolchainSupport.h" - -#ifdef ARM_COMPUTE_CL -#include "arm_compute/core/CL/OpenCL.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#endif /* ARM_COMPUTE_CL */ - -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -Framework::Framework() -{ - _available_instruments.emplace(InstrumentType::WALL_CLOCK_TIMER, Instrument::make_instrument); -#ifdef PMU_ENABLED - _available_instruments.emplace(InstrumentType::PMU_CYCLE_COUNTER, Instrument::make_instrument); - _available_instruments.emplace(InstrumentType::PMU_INSTRUCTION_COUNTER, Instrument::make_instrument); -#endif /* PMU_ENABLED */ -} - -std::set Framework::available_instruments() const -{ - std::set types; - - for(const auto &instrument : _available_instruments) - { - types.emplace(instrument.first); - } - - return types; -} - -std::map Framework::count_test_results() const -{ - std::map counts; - - for(const auto &test : _test_results) - { - ++counts[test.second.status]; - } - - return counts; -} - -Framework &Framework::get() -{ - static Framework instance; - return instance; -} - -void Framework::init(const std::vector &instruments, int num_iterations, DatasetMode mode, const std::string &name_filter, const std::string &id_filter, LogLevel log_level) -{ - _test_filter = TestFilter(mode, name_filter, id_filter); - _num_iterations = num_iterations; - _log_level = log_level; - - _instruments = InstrumentType::NONE; - - for(const auto &instrument : instruments) - { - _instruments |= instrument; - } -} - -std::string Framework::current_suite_name() const -{ - return join(_test_suite_name.cbegin(), _test_suite_name.cend(), "/"); -} - -void Framework::push_suite(std::string name) -{ - _test_suite_name.emplace_back(std::move(name)); -} - -void Framework::pop_suite() -{ - _test_suite_name.pop_back(); -} - -void Framework::add_test_info(std::string info) -{ - _test_info.emplace_back(std::move(info)); -} - -void Framework::clear_test_info() -{ - _test_info.clear(); -} - -bool Framework::has_test_info() const -{ - return !_test_info.empty(); -} - -void Framework::print_test_info(std::ostream &os) const -{ - if(!_test_info.empty()) - { - os << "CONTEXT:\n"; - - for(const auto &str : _test_info) - { - os << " " << str << "\n"; - } - } -} - -void Framework::log_test_start(const TestInfo &info) -{ - if(_printer != nullptr && _log_level >= LogLevel::TESTS) - { - _printer->print_test_header(info); - } -} - -void Framework::log_test_skipped(const TestInfo &info) -{ - static_cast(info); -} - -void Framework::log_test_end(const TestInfo &info) -{ - if(_printer != nullptr) - { - if(_log_level >= LogLevel::MEASUREMENTS) - { - _printer->print_measurements(_test_results.at(info).measurements); - } - - if(_log_level >= LogLevel::TESTS) - { - _printer->print_test_footer(); - } - } -} - -void Framework::log_failed_expectation(const TestError &error) -{ - if(_log_level >= error.level() && _printer != nullptr) - { - _printer->print_error(error); - } - - if(_current_test_result != nullptr) - { - _current_test_result->status = TestResult::Status::FAILED; - } -} - -int Framework::num_iterations() const -{ - return _num_iterations; -} - -void Framework::set_num_iterations(int num_iterations) -{ - _num_iterations = num_iterations; -} - -void Framework::set_throw_errors(bool throw_errors) -{ - _throw_errors = throw_errors; -} - -bool Framework::throw_errors() const -{ - return _throw_errors; -} - -void Framework::set_stop_on_error(bool stop_on_error) -{ - _stop_on_error = stop_on_error; -} - -bool Framework::stop_on_error() const -{ - return _stop_on_error; -} - -void Framework::run_test(const TestInfo &info, TestCaseFactory &test_factory) -{ - if(test_factory.status() == TestCaseFactory::Status::DISABLED) - { - log_test_skipped(info); - set_test_result(info, TestResult(TestResult::Status::DISABLED)); - return; - } - - log_test_start(info); - - Profiler profiler = get_profiler(); - TestResult result(TestResult::Status::NOT_RUN); - - _current_test_result = &result; - - if(_log_level >= LogLevel::ERRORS && _printer != nullptr) - { - _printer->print_errors_header(); - } - - try - { - std::unique_ptr test_case = test_factory.make(); - - try - { - test_case->do_setup(); - - for(int i = 0; i < _num_iterations; ++i) - { - profiler.start(); - test_case->do_run(); -#ifdef ARM_COMPUTE_CL - if(opencl_is_available()) - { - CLScheduler::get().sync(); - } -#endif /* ARM_COMPUTE_CL */ - profiler.stop(); - } - - test_case->do_teardown(); - - // Change status to success if no error has happend - if(result.status == TestResult::Status::NOT_RUN) - { - result.status = TestResult::Status::SUCCESS; - } - } - catch(const TestError &error) - { - if(_log_level >= error.level() && _printer != nullptr) - { - _printer->print_error(error); - } - - result.status = TestResult::Status::FAILED; - - if(_throw_errors) - { - throw; - } - } -#ifdef ARM_COMPUTE_CL - catch(const ::cl::Error &error) - { - if(_log_level >= LogLevel::ERRORS && _printer != nullptr) - { - std::stringstream stream; - stream << "Error code: " << error.err(); - _printer->print_error(TestError(error.what(), LogLevel::ERRORS, stream.str())); - } - - result.status = TestResult::Status::FAILED; - - if(_throw_errors) - { - throw; - } - } -#endif /* ARM_COMPUTE_CL */ - catch(const std::exception &error) - { - if(_log_level >= LogLevel::ERRORS && _printer != nullptr) - { - _printer->print_error(error); - } - - result.status = TestResult::Status::CRASHED; - - if(_throw_errors) - { - throw; - } - } - catch(...) - { - if(_log_level >= LogLevel::ERRORS && _printer != nullptr) - { - _printer->print_error(TestError("Received unknown exception")); - } - - result.status = TestResult::Status::CRASHED; - - if(_throw_errors) - { - throw; - } - } - } - catch(const std::exception &error) - { - if(_log_level >= LogLevel::ERRORS && _printer != nullptr) - { - _printer->print_error(error); - } - - result.status = TestResult::Status::CRASHED; - - if(_throw_errors) - { - throw; - } - } - catch(...) - { - if(_log_level >= LogLevel::ERRORS && _printer != nullptr) - { - _printer->print_error(TestError("Received unknown exception")); - } - - result.status = TestResult::Status::CRASHED; - - if(_throw_errors) - { - throw; - } - } - - if(_log_level >= LogLevel::ERRORS && _printer != nullptr) - { - _printer->print_errors_footer(); - } - - _current_test_result = nullptr; - - if(result.status == TestResult::Status::FAILED) - { - if(info.status == TestCaseFactory::Status::EXPECTED_FAILURE) - { - result.status = TestResult::Status::EXPECTED_FAILURE; - } - } - - if(result.status == TestResult::Status::FAILED || result.status == TestResult::Status::CRASHED) - { - if(_stop_on_error) - { - throw std::runtime_error("Abort on first error."); - } - } - - result.measurements = profiler.measurements(); - - set_test_result(info, result); - log_test_end(info); -} - -bool Framework::run() -{ - // Clear old test results - _test_results.clear(); - - if(_printer != nullptr && _log_level >= LogLevel::TESTS) - { - _printer->print_run_header(); - } - - const std::chrono::time_point start = std::chrono::high_resolution_clock::now(); - - int id = 0; - - for(auto &test_factory : _test_factories) - { - const std::string test_case_name = test_factory->name(); - const TestInfo test_info{ id, test_case_name, test_factory->mode(), test_factory->status() }; - - if(_test_filter.is_selected(test_info)) - { - run_test(test_info, *test_factory); - } - - ++id; - } - - const std::chrono::time_point end = std::chrono::high_resolution_clock::now(); - - if(_printer != nullptr && _log_level >= LogLevel::TESTS) - { - _printer->print_run_footer(); - } - - auto runtime = std::chrono::duration_cast(end - start); - std::map results = count_test_results(); - - if(_log_level > LogLevel::NONE) - { - std::cout << "Executed " << _test_results.size() << " test(s) (" - << results[TestResult::Status::SUCCESS] << " passed, " - << results[TestResult::Status::EXPECTED_FAILURE] << " expected failures, " - << results[TestResult::Status::FAILED] << " failed, " - << results[TestResult::Status::CRASHED] << " crashed, " - << results[TestResult::Status::DISABLED] << " disabled) in " << runtime.count() << " second(s)\n"; - } - - int num_successful_tests = results[TestResult::Status::SUCCESS] + results[TestResult::Status::EXPECTED_FAILURE]; - - return (static_cast(num_successful_tests) == _test_results.size()); -} - -void Framework::set_test_result(TestInfo info, TestResult result) -{ - _test_results.emplace(std::move(info), std::move(result)); -} - -void Framework::print_test_results(Printer &printer) const -{ - printer.print_run_header(); - - for(const auto &test : _test_results) - { - printer.print_test_header(test.first); - printer.print_measurements(test.second.measurements); - printer.print_test_footer(); - } - - printer.print_run_footer(); -} - -Profiler Framework::get_profiler() const -{ - Profiler profiler; - - for(const auto &instrument : _available_instruments) - { - if((instrument.first & _instruments) != InstrumentType::NONE) - { - profiler.add(instrument.second()); - } - } - - return profiler; -} - -void Framework::set_printer(Printer *printer) -{ - _printer = printer; -} - -std::vector Framework::test_infos() const -{ - std::vector ids; - - int id = 0; - - for(const auto &factory : _test_factories) - { - TestInfo test_info{ id, factory->name(), factory->mode(), factory->status() }; - - if(_test_filter.is_selected(test_info)) - { - ids.emplace_back(std::move(test_info)); - } - - ++id; - } - - return ids; -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/Framework.h b/framework/Framework.h deleted file mode 100644 index 055392cdae..0000000000 --- a/framework/Framework.h +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_FRAMEWORK -#define ARM_COMPUTE_TEST_FRAMEWORK - -#include "DatasetModes.h" -#include "Exceptions.h" -#include "Profiler.h" -#include "TestCase.h" -#include "TestCaseFactory.h" -#include "TestFilter.h" -#include "TestResult.h" -#include "Utils.h" -#include "instruments/Instruments.h" -#include "printers/Printer.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Information about a test case. - * - * A test can be identified either via its id or via its name. Additionally - * each test is tagged with the data set mode in which it will be used and - * its status. - * - * @note The mapping between test id and test name is not guaranteed to be - * stable. It is subject to change as new test are added. - */ -struct TestInfo -{ - int id; - std::string name; - DatasetMode mode; - TestCaseFactory::Status status; -}; - -inline bool operator<(const TestInfo &lhs, const TestInfo &rhs) -{ - return lhs.id < rhs.id; -} - -/** Main framework class. - * - * Keeps track of the global state, owns all test cases and collects results. - */ -class Framework final -{ -public: - /** Access to the singleton. - * - * @return Unique instance of the framework class. - */ - static Framework &get(); - - /** Supported instrument types for benchmarking. - * - * @return Set of all available instrument types. - */ - std::set available_instruments() const; - - /** Init the framework. - * - * @see TestFilter::TestFilter for the format of the string to filter ids. - * - * @param[in] instruments Instrument types that will be used for benchmarking. - * @param[in] num_iterations Number of iterations per test. - * @param[in] mode Dataset mode. - * @param[in] name_filter Regular expression to filter tests by name. Only matching tests will be executed. - * @param[in] id_filter String to match selected test ids. Only matching tests will be executed. - * @param[in] log_level Verbosity of the output. - */ - void init(const std::vector &instruments, int num_iterations, DatasetMode mode, const std::string &name_filter, const std::string &id_filter, LogLevel log_level); - - /** Add a new test suite. - * - * @warning Cannot be used at execution time. It can only be used for - * registering test cases. - * - * @param[in] name Name of the added test suite. - * - * @return Name of the current test suite. - */ - void push_suite(std::string name); - - /** Remove innermost test suite. - * - * @warning Cannot be used at execution time. It can only be used for - * registering test cases. - */ - void pop_suite(); - - /** Add a test case to the framework. - * - * @param[in] test_name Name of the new test case. - * @param[in] mode Mode in which to include the test. - * @param[in] status Status of the test case. - */ - template - void add_test_case(std::string test_name, DatasetMode mode, TestCaseFactory::Status status); - - /** Add a data test case to the framework. - * - * @param[in] test_name Name of the new test case. - * @param[in] mode Mode in which to include the test. - * @param[in] status Status of the test case. - * @param[in] description Description of @p data. - * @param[in] data Data that will be used as input to the test. - */ - template - void add_data_test_case(std::string test_name, DatasetMode mode, TestCaseFactory::Status status, std::string description, D &&data); - - /** Add info string for the next expectation/assertion. - * - * @param[in] info Info string. - */ - void add_test_info(std::string info); - - /** Clear the collected test info. */ - void clear_test_info(); - - /** Check if any info has been registered. - * - * @return True if there is test info. - */ - bool has_test_info() const; - - /** Print test info. - * - * @param[out] os Output stream. - */ - void print_test_info(std::ostream &os) const; - - /** Tell the framework that execution of a test starts. - * - * @param[in] info Test info. - */ - void log_test_start(const TestInfo &info); - - /** Tell the framework that a test case is skipped. - * - * @param[in] info Test info. - */ - void log_test_skipped(const TestInfo &info); - - /** Tell the framework that a test case finished. - * - * @param[in] info Test info. - */ - void log_test_end(const TestInfo &info); - - /** Tell the framework that the currently running test case failed a non-fatal expectation. - * - * @param[in] error Description of the error. - */ - void log_failed_expectation(const TestError &error); - - /** Number of iterations per test case. - * - * @return Number of iterations per test case. - */ - int num_iterations() const; - - /** Set number of iterations per test case. - * - * @param[in] num_iterations Number of iterations per test case. - */ - void set_num_iterations(int num_iterations); - - /** Should errors be caught or thrown by the framework. - * - * @return True if errors are thrown. - */ - bool throw_errors() const; - - /** Set whether errors are caught or thrown by the framework. - * - * @param[in] throw_errors True if errors should be thrown. - */ - void set_throw_errors(bool throw_errors); - - /** Indicates if test execution is stopped after the first failed test. - * - * @return True if the execution is going to be aborted after the first failed test. - */ - bool stop_on_error() const; - - /** Set whether to abort execution after the first failed test. - * - * @param[in] stop_on_error True if execution is going to be aborted after first failed test. - */ - void set_stop_on_error(bool stop_on_error); - - /** Run all enabled test cases. - * - * @return True if all test cases executed successful. - */ - bool run(); - - /** Set the result for an executed test case. - * - * @param[in] info Test info. - * @param[in] result Execution result. - */ - void set_test_result(TestInfo info, TestResult result); - - /** Use the specified printer to output test results from the last run. - * - * This method can be used if the test results need to be obtained using a - * different printer than the one managed by the framework. - * - * @param[in] printer Printer used to output results. - */ - void print_test_results(Printer &printer) const; - - /** Factory method to obtain a configured profiler. - * - * The profiler enables all instruments that have been passed to the @ref - * init method. - * - * @return Configured profiler to collect benchmark results. - */ - Profiler get_profiler() const; - - /** Set the printer used for the output of test results. - * - * @param[in] printer Pointer to a printer. - */ - void set_printer(Printer *printer); - - /** List of @ref TestInfo's. - * - * @return Vector with all test ids. - */ - std::vector test_infos() const; - -private: - Framework(); - ~Framework() = default; - - Framework(const Framework &) = delete; - Framework &operator=(const Framework &) = delete; - - void run_test(const TestInfo &info, TestCaseFactory &test_factory); - std::map count_test_results() const; - - /** Returns the current test suite name. - * - * @warning Cannot be used at execution time to get the test suite of the - * currently executed test case. It can only be used for registering test - * cases. - * - * @return Name of the current test suite. - */ - std::string current_suite_name() const; - - std::vector _test_suite_name{}; - std::vector> _test_factories{}; - std::map _test_results{}; - int _num_iterations{ 1 }; - bool _throw_errors{ false }; - bool _stop_on_error{ false }; - Printer *_printer{ nullptr }; - - using create_function = std::unique_ptr(); - std::map _available_instruments{}; - - InstrumentType _instruments{ InstrumentType::NONE }; - TestFilter _test_filter{}; - LogLevel _log_level{ LogLevel::ALL }; - TestResult *_current_test_result{ nullptr }; - std::vector _test_info{}; -}; - -template -inline void Framework::add_test_case(std::string test_name, DatasetMode mode, TestCaseFactory::Status status) -{ - _test_factories.emplace_back(support::cpp14::make_unique>(current_suite_name(), std::move(test_name), mode, status)); -} - -template -inline void Framework::add_data_test_case(std::string test_name, DatasetMode mode, TestCaseFactory::Status status, std::string description, D &&data) -{ - // WORKAROUND for GCC 4.9 - // The function should get *it which is tuple but that seems to trigger a - // bug in the compiler. - auto tmp = std::unique_ptr())>>(new DataTestCaseFactory())>(current_suite_name(), std::move(test_name), mode, status, - std::move(description), *data)); - _test_factories.emplace_back(std::move(tmp)); -} -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_FRAMEWORK */ diff --git a/framework/Macros.h b/framework/Macros.h deleted file mode 100644 index 7aabb75cfc..0000000000 --- a/framework/Macros.h +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_FRAMEWORK_MACROS -#define ARM_COMPUTE_TEST_FRAMEWORK_MACROS - -#include "Framework.h" -#include "Registrars.h" -#include "TestCase.h" - -// -// TEST SUITE MACROS -// -#define TEST_SUITE(SUITE_NAME) \ - namespace SUITE_NAME##Suite \ - { \ - static arm_compute::test::framework::detail::TestSuiteRegistrar SUITE_NAME##Suite_reg{ #SUITE_NAME }; - -#define TEST_SUITE_END() \ - static arm_compute::test::framework::detail::TestSuiteRegistrar Suite_end; \ - } -// -// TEST SUITE MACROS END -// - -// -// HELPER MACROS -// - -#define CONCAT(ARG0, ARG1) ARG0##ARG1 - -#define VARIADIC_SIZE_IMPL(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, size, ...) size -#define VARIADIC_SIZE(...) VARIADIC_SIZE_IMPL(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) - -#define JOIN_PARAM1(OP, param) OP(0, param) -#define JOIN_PARAM2(OP, param, ...) \ - OP(1, param) \ - , JOIN_PARAM1(OP, __VA_ARGS__) -#define JOIN_PARAM3(OP, param, ...) \ - OP(2, param) \ - , JOIN_PARAM2(OP, __VA_ARGS__) -#define JOIN_PARAM4(OP, param, ...) \ - OP(3, param) \ - , JOIN_PARAM3(OP, __VA_ARGS__) -#define JOIN_PARAM5(OP, param, ...) \ - OP(4, param) \ - , JOIN_PARAM4(OP, __VA_ARGS__) -#define JOIN_PARAM6(OP, param, ...) \ - OP(5, param) \ - , JOIN_PARAM5(OP, __VA_ARGS__) -#define JOIN_PARAM7(OP, param, ...) \ - OP(6, param) \ - , JOIN_PARAM6(OP, __VA_ARGS__) -#define JOIN_PARAM8(OP, param, ...) \ - OP(7, param) \ - , JOIN_PARAM7(OP, __VA_ARGS__) -#define JOIN_PARAM9(OP, param, ...) \ - OP(8, param) \ - , JOIN_PARAM8(OP, __VA_ARGS__) -#define JOIN_PARAM10(OP, param, ...) \ - OP(9, param) \ - , JOIN_PARAM9(OP, __VA_ARGS__) -#define JOIN_PARAM(OP, NUM, ...) \ - CONCAT(JOIN_PARAM, NUM) \ - (OP, __VA_ARGS__) - -#define MAKE_TYPE_PARAM(i, name) typename T##i -#define MAKE_ARG_PARAM(i, name) const T##i &name -#define MAKE_TYPE_PARAMS(...) JOIN_PARAM(MAKE_TYPE_PARAM, VARIADIC_SIZE(__VA_ARGS__), __VA_ARGS__) -#define MAKE_ARG_PARAMS(...) JOIN_PARAM(MAKE_ARG_PARAM, VARIADIC_SIZE(__VA_ARGS__), __VA_ARGS__) - -// -// TEST CASE MACROS -// -#define TEST_CASE_CONSTRUCTOR(TEST_NAME) \ - TEST_NAME() = default; -#define DATA_TEST_CASE_CONSTRUCTOR(TEST_NAME, DATASET) \ - template \ - explicit TEST_NAME(D &&data) : DataTestCase{ std::forward(data) } \ - { \ - } -#define FIXTURE_SETUP(FIXTURE) \ - void do_setup() override \ - { \ - FIXTURE::setup(); \ - } -#define FIXTURE_DATA_SETUP(FIXTURE) \ - void do_setup() override \ - { \ - apply(this, &FIXTURE::setup, _data); \ - } -#define FIXTURE_RUN(FIXTURE) \ - void do_run() override \ - { \ - FIXTURE::run(); \ - } -#define FIXTURE_TEARDOWN(FIXTURE) \ - void do_teardown() override \ - { \ - FIXTURE::teardown(); \ - } -#define TEST_REGISTRAR(TEST_NAME, MODE, STATUS) \ - static arm_compute::test::framework::detail::TestCaseRegistrar TEST_NAME##_reg \ - { \ - #TEST_NAME, MODE, STATUS \ - } -#define DATA_TEST_REGISTRAR(TEST_NAME, MODE, STATUS, DATASET) \ - static arm_compute::test::framework::detail::TestCaseRegistrar> TEST_NAME##_reg \ - { \ - #TEST_NAME, MODE, STATUS, DATASET \ - } - -#define TEST_CASE_IMPL(TEST_NAME, MODE, STATUS) \ - class TEST_NAME : public arm_compute::test::framework::TestCase \ - { \ - public: \ - TEST_CASE_CONSTRUCTOR(TEST_NAME) \ - void do_run() override; \ - }; \ - TEST_REGISTRAR(TEST_NAME, MODE, STATUS); \ - void TEST_NAME::do_run() - -#define TEST_CASE(TEST_NAME, MODE) \ - TEST_CASE_IMPL(TEST_NAME, MODE, arm_compute::test::framework::TestCaseFactory::Status::ACTIVE) -#define EXPECTED_FAILURE_TEST_CASE(TEST_NAME, MODE) \ - TEST_CASE_IMPL(TEST_NAME, MODE, arm_compute::test::framework::TestCaseFactory::Status::EXPECTED_FAILURE) -#define DISABLED_TEST_CASE(TEST_NAME, MODE) \ - TEST_CASE_IMPL(TEST_NAME, MODE, arm_compute::test::framework::TestCaseFactory::Status::DISABLED) - -#define DATA_TEST_CASE_IMPL(TEST_NAME, MODE, STATUS, DATASET, ...) \ - template \ - class TEST_NAME; \ - template \ - class TEST_NAME> : public arm_compute::test::framework::DataTestCase \ - { \ - public: \ - DATA_TEST_CASE_CONSTRUCTOR(TEST_NAME, DATASET) \ - void do_run() override \ - { \ - arm_compute::test::framework::apply(this, &TEST_NAME::run, _data); \ - } \ - template \ - void run(MAKE_ARG_PARAMS(__VA_ARGS__)); \ - }; \ - DATA_TEST_REGISTRAR(TEST_NAME, MODE, STATUS, DATASET); \ - template \ - template \ - void TEST_NAME>::run(MAKE_ARG_PARAMS(__VA_ARGS__)) - -#define DATA_TEST_CASE(TEST_NAME, MODE, DATASET, ...) \ - DATA_TEST_CASE_IMPL(TEST_NAME, MODE, arm_compute::test::framework::TestCaseFactory::Status::ACTIVE, DATASET, __VA_ARGS__) -#define EXPECTED_FAILURE_DATA_TEST_CASE(TEST_NAME, MODE, DATASET, ...) \ - DATA_TEST_CASE_IMPL(TEST_NAME, MODE, arm_compute::test::framework::TestCaseFactory::Status::EXPECTED_FAILURE, DATASET, __VA_ARGS__) -#define DISABLED_DATA_TEST_CASE(TEST_NAME, MODE, DATASET, ...) \ - DATA_TEST_CASE_IMPL(TEST_NAME, MODE, arm_compute::test::framework::TestCaseFactory::Status::DISABLED, DATASET, __VA_ARGS__) - -#define FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, STATUS) \ - class TEST_NAME : public arm_compute::test::framework::TestCase, public FIXTURE \ - { \ - public: \ - TEST_CASE_CONSTRUCTOR(TEST_NAME) \ - FIXTURE_SETUP(FIXTURE) \ - void do_run() override; \ - FIXTURE_TEARDOWN(FIXTURE) \ - }; \ - TEST_REGISTRAR(TEST_NAME, MODE, STATUS); \ - void TEST_NAME::do_run() - -#define FIXTURE_TEST_CASE(TEST_NAME, FIXTURE, MODE) \ - FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::ACTIVE) -#define EXPECTED_FAILURE_FIXTURE_TEST_CASE(TEST_NAME, FIXTURE, MODE) \ - FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::EXPECTED_FAILURE) -#define DISABLED_FIXTURE_TEST_CASE(TEST_NAME, FIXTURE, MODE) \ - FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::DISABLED) - -#define FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, STATUS, DATASET) \ - template \ - class TEST_NAME; \ - template \ - class TEST_NAME> : public arm_compute::test::framework::DataTestCase, public FIXTURE \ - { \ - public: \ - DATA_TEST_CASE_CONSTRUCTOR(TEST_NAME, DATASET) \ - FIXTURE_DATA_SETUP(FIXTURE) \ - void do_run() override; \ - FIXTURE_TEARDOWN(FIXTURE) \ - }; \ - DATA_TEST_REGISTRAR(TEST_NAME, MODE, STATUS, DATASET); \ - template \ - void TEST_NAME>::do_run() - -#define FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, DATASET) \ - FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::ACTIVE, DATASET) -#define EXPECTED_FAILURE_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, DATASET) \ - FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::EXPECTED_FAILURE, DATASET) -#define DISABLED_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, DATASET) \ - FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::DISABLED, DATASET) - -#define REGISTER_FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, STATUS) \ - class TEST_NAME : public arm_compute::test::framework::TestCase, public FIXTURE \ - { \ - public: \ - TEST_CASE_CONSTRUCTOR(TEST_NAME) \ - FIXTURE_SETUP(FIXTURE) \ - FIXTURE_RUN(FIXTURE) \ - FIXTURE_TEARDOWN(FIXTURE) \ - }; \ - TEST_REGISTRAR(TEST_NAME, MODE, STATUS) - -#define REGISTER_FIXTURE_TEST_CASE(TEST_NAME, FIXTURE, MODE) \ - REGISTER_FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::ACTIVE) -#define EXPECTED_FAILURE_REGISTER_FIXTURE_TEST_CASE(TEST_NAME, FIXTURE, MODE) \ - REGISTER_FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::EXPECTED_FAILURE) -#define DISABLED_REGISTER_FIXTURE_TEST_CASE(TEST_NAME, FIXTURE, MODE) \ - REGISTER_FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::DISABLED) - -#define REGISTER_FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, STATUS, DATASET) \ - template \ - class TEST_NAME; \ - template \ - class TEST_NAME> : public arm_compute::test::framework::DataTestCase, public FIXTURE \ - { \ - public: \ - DATA_TEST_CASE_CONSTRUCTOR(TEST_NAME, DATASET) \ - FIXTURE_DATA_SETUP(FIXTURE) \ - FIXTURE_RUN(FIXTURE) \ - FIXTURE_TEARDOWN(FIXTURE) \ - }; \ - DATA_TEST_REGISTRAR(TEST_NAME, MODE, STATUS, DATASET) - -#define REGISTER_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, DATASET) \ - REGISTER_FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::ACTIVE, DATASET) -#define EXPECTED_FAILURE_REGISTER_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, DATASET) \ - REGISTER_FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::EXPECTED_FAILURE, DATASET) -#define DISABLED_REGISTER_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, DATASET) \ - REGISTER_FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::DISABLED, DATASET) -// -// TEST CASE MACROS END -// -#endif /* ARM_COMPUTE_TEST_FRAMEWORK_MACROS */ diff --git a/framework/Profiler.cpp b/framework/Profiler.cpp deleted file mode 100644 index 76de9a818f..0000000000 --- a/framework/Profiler.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Profiler.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -void Profiler::add(std::unique_ptr instrument) -{ - _instruments.emplace_back(std::move(instrument)); -} - -void Profiler::start() -{ - for(auto &instrument : _instruments) - { - instrument->start(); - } -} - -void Profiler::stop() -{ - for(auto &instrument : _instruments) - { - instrument->stop(); - } - - for(const auto &instrument : _instruments) - { - _measurements[instrument->id()].push_back(instrument->measurement()); - } -} - -const Profiler::MeasurementsMap &Profiler::measurements() const -{ - return _measurements; -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/Profiler.h b/framework/Profiler.h deleted file mode 100644 index 1454c0f875..0000000000 --- a/framework/Profiler.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_PROFILER -#define ARM_COMPUTE_TEST_PROFILER - -#include "instruments/Instrument.h" - -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Profiler class to collect benchmark numbers. - * - * A profiler manages multiple instruments that can collect different types of benchmarking numbers. - */ -class Profiler -{ -public: - /** Mapping from instrument ids to their measurements. */ - using MeasurementsMap = std::map>; - - /** Add @p instrument to the performance monitor. - * - * All added instruments will be used when @ref start or @ref stop are - * called to make measurements. - * - * @param[in] instrument Instrument to be used to measure performance. - */ - void add(std::unique_ptr instrument); - - /** Start all added instruments to measure performance. */ - void start(); - - /** Stop all added instruments. */ - void stop(); - - /** Return measurements for all instruments. */ - const MeasurementsMap &measurements() const; - -private: - std::vector> _instruments{}; - MeasurementsMap _measurements{}; -}; -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_PROFILER */ diff --git a/framework/Registrars.h b/framework/Registrars.h deleted file mode 100644 index ca23edf0de..0000000000 --- a/framework/Registrars.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_FRAMEWORK_REGISTRARS -#define ARM_COMPUTE_TEST_FRAMEWORK_REGISTRARS - -#include "DatasetModes.h" -#include "Framework.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -namespace detail -{ -/** Helper class to statically register a test case. */ -template -class TestCaseRegistrar final -{ -public: - /** Add a new test case with the given name to the framework. - * - * @param[in] test_name Name of the test case. - * @param[in] mode Mode in which the test should be activated. - * @param[in] status Status of the test case. - */ - TestCaseRegistrar(std::string test_name, DatasetMode mode, TestCaseFactory::Status status); - - /** Add a new data test case with the given name to the framework. - * - * @param[in] test_name Name of the test case. - * @param[in] mode Mode in which the test should be activated. - * @param[in] status Status of the test case. - * @param[in] dataset Dataset used as input for the test case. - */ - template - TestCaseRegistrar(std::string test_name, DatasetMode mode, TestCaseFactory::Status status, D &&dataset); -}; - -/** Helper class to statically begin and end a test suite. */ -class TestSuiteRegistrar final -{ -public: - /** Remove the last added test suite from the framework. */ - TestSuiteRegistrar(); - - /** Add a new test suite with the given name to the framework. - * - * @param[in] name Name of the test suite. - */ - TestSuiteRegistrar(std::string name); -}; - -template -inline TestCaseRegistrar::TestCaseRegistrar(std::string test_name, DatasetMode mode, TestCaseFactory::Status status) -{ - Framework::get().add_test_case(std::move(test_name), mode, status); -} - -template -template -inline TestCaseRegistrar::TestCaseRegistrar(std::string test_name, DatasetMode mode, TestCaseFactory::Status status, D &&dataset) -{ - auto it = dataset.begin(); - - for(int i = 0; i < dataset.size(); ++i, ++it) - { - // WORKAROUND for GCC 4.9 - // The last argument should be *it to pass just the data and not the - // iterator. - Framework::get().add_data_test_case(test_name, mode, status, it.description(), it); - } -} - -inline TestSuiteRegistrar::TestSuiteRegistrar() -{ - Framework::get().pop_suite(); -} - -inline TestSuiteRegistrar::TestSuiteRegistrar(std::string name) -{ - Framework::get().push_suite(std::move(name)); -} -} // namespace detail -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_FRAMEWORK_REGISTRARS */ diff --git a/framework/SConscript b/framework/SConscript deleted file mode 100644 index 36632515a3..0000000000 --- a/framework/SConscript +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright (c) 2017 ARM Limited. -# -# SPDX-License-Identifier: MIT -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -import SCons -import os.path - -Import('env') -Import('vars') - -# vars is imported from arm_compute: -variables = [ - BoolVariable("pmu", "Enable PMU counters", False) -] - -# We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice) -new_options = Variables('scons') - -for v in variables: - new_options.Add(v) - vars.Add(v) - -# Clone the environment to make sure we're not polluting the arm_compute one: -framework_env = env.Clone() -vars.Update(framework_env) - -Help(new_options.GenerateHelpText(framework_env)) - -if env['os'] == 'android' and framework_env['pmu']: - print("pmu=1 is not supported for os=android") - Exit(1) - -if(env['opencl']): - framework_env.Append(CPPDEFINES=['ARM_COMPUTE_CL']) - -framework_env.Append(CPPPATH = ["."]) -framework_env.Append(CPPFLAGS=['-Wno-overloaded-virtual']) - -files = Glob('*.cpp') -files += Glob('command_line/*.cpp') -files += Glob('printers/*.cpp') -files += Glob('datasets/*.cpp') -files += Glob('instruments/*.cpp') - -if not framework_env['pmu']: - # Remove PMU files - files = [f for f in files if "PMU" not in os.path.basename(str(f))] -else: - framework_env.Append(CPPDEFINES = ['PMU_ENABLED']) - -arm_compute_test_framework = framework_env.StaticLibrary('arm_compute_test_framework', files) - -Default(arm_compute_test_framework) -Export('arm_compute_test_framework') diff --git a/framework/TestCase.h b/framework/TestCase.h deleted file mode 100644 index dbb9312dee..0000000000 --- a/framework/TestCase.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_TESTCASE -#define ARM_COMPUTE_TEST_TESTCASE - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Abstract test case class. - * - * All test cases have to inherit from this class. - */ -class TestCase -{ -public: - virtual void do_setup() {}; - virtual void do_run() {}; - virtual void do_teardown() {}; - - /** Default destructor. */ - virtual ~TestCase() = default; - -protected: - TestCase() = default; - - friend class TestCaseFactory; -}; - -template -class DataTestCase : public TestCase -{ -protected: - explicit DataTestCase(T data) - : _data{ std::move(data) } - { - } - - T _data; -}; -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_TESTCASE */ diff --git a/framework/TestCaseFactory.h b/framework/TestCaseFactory.h deleted file mode 100644 index b8c8cdbeb0..0000000000 --- a/framework/TestCaseFactory.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_TEST_CASE_FACTORY -#define ARM_COMPUTE_TEST_TEST_CASE_FACTORY - -#include "DatasetModes.h" -#include "TestCase.h" -#include "support/ToolchainSupport.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Abstract factory class to create test cases. */ -class TestCaseFactory -{ -public: - /** Test case status. - * - * ACTIVE == Test is run and result is validated. Failure on failed validation. - * EXPECTED_FAILURE == Test is run and result is validated. Failure on successful validation. - * DISABLED == Test is not run. - */ - enum class Status - { - ACTIVE, - EXPECTED_FAILURE, - DISABLED - }; - - /** Constructor. - * - * @param[in] suite_name Name of the test suite to which the test case has been added. - * @param[in] name Name of the test case. - * @param[in] mode Datset mode of the test case. - * @param[in] status Status of the test case. - * @param[in] description Description of data arguments. - */ - TestCaseFactory(std::string suite_name, std::string name, DatasetMode mode, Status status, std::string description = ""); - - /** Default destructor. */ - virtual ~TestCaseFactory() = default; - - /** Name of the test case. - * - * @return Name of the test case. - */ - std::string name() const; - - /** Get the mode for which test case will be enabled. - * - * @return Dataset mode of the test case. - */ - DatasetMode mode() const; - - /** Get the status of the test case. - * - * @return Status of the test case. - */ - Status status() const; - - /** Factory function to create the test case - * - * @return Unique pointer to a newly created test case. - */ - virtual std::unique_ptr make() const = 0; - -private: - const std::string _suite_name; - const std::string _test_name; - const std::string _data_description; - const DatasetMode _mode{ DatasetMode::ALL }; - const Status _status{ Status::ACTIVE }; -}; - -/** Implementation of a test case factory to create non-data test cases. */ -template -class SimpleTestCaseFactory final : public TestCaseFactory -{ -public: - /** Default constructor. */ - using TestCaseFactory::TestCaseFactory; - - std::unique_ptr make() const override; -}; - -template -class DataTestCaseFactory final : public TestCaseFactory -{ -public: - /** Constructor. - * - * @param[in] suite_name Name of the test suite to which the test case has been added. - * @param[in] test_name Name of the test case. - * @param[in] mode Mode in which the test case is enabled. - * @param[in] status Status of the test case. - * @param[in] description Description of data arguments. - * @param[in] data Input data for the test case. - */ - DataTestCaseFactory(std::string suite_name, std::string test_name, DatasetMode mode, Status status, std::string description, const D &data); - - std::unique_ptr make() const override; - -private: - D _data; -}; - -inline TestCaseFactory::TestCaseFactory(std::string suite_name, std::string test_name, DatasetMode mode, Status status, std::string description) - : _suite_name{ std::move(suite_name) }, _test_name{ std::move(test_name) }, _data_description{ std::move(description) }, _mode{ mode }, _status{ status } - -{ -} - -inline std::string TestCaseFactory::name() const -{ - std::string name = _suite_name + "/" + _test_name; - - if(!_data_description.empty()) - { - name += "@" + _data_description; - } - - return name; -} - -inline DatasetMode TestCaseFactory::mode() const -{ - return _mode; -} - -inline TestCaseFactory::Status TestCaseFactory::status() const -{ - return _status; -} - -inline ::std::ostream &operator<<(::std::ostream &stream, TestCaseFactory::Status status) -{ - switch(status) - { - case TestCaseFactory::Status::ACTIVE: - stream << "ACTIVE"; - break; - case TestCaseFactory::Status::EXPECTED_FAILURE: - stream << "EXPECTED_FAILURE"; - break; - case TestCaseFactory::Status::DISABLED: - stream << "DISABLED"; - break; - default: - throw std::invalid_argument("Unsupported test case factory status"); - } - - return stream; -} - -template -inline std::unique_ptr SimpleTestCaseFactory::make() const -{ - return support::cpp14::make_unique(); -} - -template -inline DataTestCaseFactory::DataTestCaseFactory(std::string suite_name, std::string test_name, DatasetMode mode, Status status, std::string description, const D &data) - : TestCaseFactory{ std::move(suite_name), std::move(test_name), mode, status, std::move(description) }, _data{ data } -{ -} - -template -inline std::unique_ptr DataTestCaseFactory::make() const -{ - return support::cpp14::make_unique(_data); -} -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_TEST_CASE_FACTORY */ diff --git a/framework/TestFilter.cpp b/framework/TestFilter.cpp deleted file mode 100644 index 0af40c1717..0000000000 --- a/framework/TestFilter.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "TestFilter.h" - -#include "Framework.h" -#include "support/ToolchainSupport.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -TestFilter::TestFilter(DatasetMode mode, const std::string &name_filter, const std::string &id_filter) - : _dataset_mode{ mode }, _name_filter{ name_filter }, _id_filter{ parse_id_filter(id_filter) } -{ -} - -bool TestFilter::is_selected(const TestInfo &info) const -{ - if((info.mode & _dataset_mode) == DatasetMode::DISABLED) - { - return false; - } - - if(!std::regex_search(info.name, _name_filter)) - { - return false; - } - - if(!_id_filter.empty()) - { - bool found = false; - - for(const auto range : _id_filter) - { - if(range.first <= info.id && info.id <= range.second) - { - found = true; - break; - } - } - - if(!found) - { - return false; - } - } - - return true; -} - -TestFilter::Ranges TestFilter::parse_id_filter(const std::string &id_filter) const -{ - Ranges ranges; - std::string str; - bool in_range = false; - int value = 0; - int start = 0; - int end = std::numeric_limits::max(); - - std::stringstream stream(id_filter); - - // Get first value - std::getline(stream, str, ','); - - if(stream.fail()) - { - return ranges; - } - - if(str.find("...") != std::string::npos) - { - in_range = true; - } - else - { - start = support::cpp11::stoi(str); - end = start; - } - - while(!stream.eof()) - { - std::getline(stream, str, ','); - - if(stream.fail()) - { - break; - } - - if(str.find("...") != std::string::npos) - { - end = std::numeric_limits::max(); - in_range = true; - } - else - { - value = support::cpp11::stoi(str); - - if(in_range || end == value - 1) - { - end = value; - in_range = false; - } - else - { - ranges.emplace_back(start, end); - start = value; - end = start; - } - } - } - - ranges.emplace_back(start, end); - return ranges; -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/TestFilter.h b/framework/TestFilter.h deleted file mode 100644 index f64e73a2ba..0000000000 --- a/framework/TestFilter.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_TESTFILTER -#define ARM_COMPUTE_TEST_TESTFILTER - -#include "DatasetModes.h" - -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -struct TestInfo; - -/** Test filter class. - * - * Stores information about which test cases are selected for execution. Based - * on test name and test id. - */ -class TestFilter final -{ -public: - /** Default constructor. All tests selected. */ - TestFilter() = default; - - /** Constructor. - * - * The id_filter string has be a comma separated list of test ids. ... can - * be used to include a range of tests. For instance, "..., 15" means all - * test up to and including 15, "3, 6, ..., 10" means tests 3 and 6 to 10, - * and "15, ..." means test 15 and all following. - * - * @param[in] mode Dataset mode. - * @param[in] name_filter Regular expression to filter tests by name. Only matching tests will be executed. - * @param[in] id_filter String to match selected test ids. Only matching tests will be executed. - */ - TestFilter(DatasetMode mode, const std::string &name_filter, const std::string &id_filter); - - /** Check if a test case is selected to be executed. - * - * @param[in] info Test case info. - * - * @return True if the test case is selected to be executed. - */ - bool is_selected(const TestInfo &info) const; - -private: - using Ranges = std::vector>; - Ranges parse_id_filter(const std::string &id_filter) const; - - DatasetMode _dataset_mode{ DatasetMode::ALL }; - std::regex _name_filter{ ".*" }; - Ranges _id_filter{}; -}; -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_TESTFILTER */ diff --git a/framework/TestResult.h b/framework/TestResult.h deleted file mode 100644 index e71ef95112..0000000000 --- a/framework/TestResult.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_TESTRESULT -#define ARM_COMPUTE_TEST_TESTRESULT - -#include "Profiler.h" - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Class to store results of a test. - * - * Currently the execution status and profiling information are stored. - */ -struct TestResult -{ - /** Execution status of a test. */ - enum class Status - { - NOT_RUN, - SUCCESS, - EXPECTED_FAILURE, - FAILED, - CRASHED, - DISABLED - }; - - /** Default constructor. */ - TestResult() = default; - - /** Initialise the result with a status. - * - * @param[in] status Execution status. - */ - TestResult(Status status) - : status{ status } - { - } - - /** Initialise the result with a status and profiling information. - * - * @param[in] status Execution status. - * @param[in] measurements Profiling information. - */ - TestResult(Status status, const Profiler::MeasurementsMap &measurements) - : status{ status }, measurements{ measurements } - { - } - - Status status{ Status::NOT_RUN }; //< Execution status - Profiler::MeasurementsMap measurements{}; //< Profiling information -}; -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_TESTRESULT */ diff --git a/framework/Utils.h b/framework/Utils.h deleted file mode 100644 index a9fe0dcaa3..0000000000 --- a/framework/Utils.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_UTILS -#define ARM_COMPUTE_TEST_UTILS - -#include "support/ToolchainSupport.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** @cond */ -namespace detail -{ -template -struct sequence -{ -}; - -template -struct sequence_generator; - -template -struct sequence_generator<0, Ns...> -{ - using type = sequence; -}; - -template -struct sequence_generator : sequence_generator < N - 1, N - 1, Ns... > -{ -}; - -template -using sequence_t = typename sequence_generator::type; -/** @endcond */ - -template -void apply_impl(O *obj, F &&func, const std::tuple &args, detail::sequence) -{ - (obj->*func)(std::get(args)...); -} -} // namespace - -template -void apply(O *obj, F &&func, const std::tuple &args) -{ - detail::apply_impl(obj, std::forward(func), args, detail::sequence_t()); -} - -/** Helper function to concatenate multiple strings. - * - * @param[in] first Iterator pointing to the first element to be concatenated. - * @param[in] last Iterator pointing behind the last element to be concatenated. - * @param[in] separator String used to join the elements. - * - * @return String containing all elements joined by @p separator. - */ -template ::value, int>::type = 0> -std::string join(T first, T last, const std::string &separator) -{ - return std::accumulate(std::next(first), last, *first, [&separator](const std::string & base, const std::string & suffix) - { - return base + separator + suffix; - }); -} - -/** Helper function to concatenate multiple values. - * - * All values are converted to std::string using the provided operation before - * being joined. - * - * The signature of op has to be equivalent to - * std::string op(const T::value_type &val). - * - * @param[in] first Iterator pointing to the first element to be concatenated. - * @param[in] last Iterator pointing behind the last element to be concatenated. - * @param[in] separator String used to join the elements. - * @param[in] op Conversion function. - * - * @return String containing all elements joined by @p separator. - */ -template -std::string join(T &&first, T &&last, const std::string &separator, UnaryOp &&op) -{ - return std::accumulate(std::next(first), last, op(*first), [&separator, &op](const std::string & base, const typename T::value_type & suffix) - { - return base + separator + op(suffix); - }); -} - -/** Helper function to concatenate multiple values. - * - * All values are converted to std::string using std::to_string before being joined. - * - * @param[in] first Iterator pointing to the first element to be concatenated. - * @param[in] last Iterator pointing behind the last element to be concatenated. - * @param[in] separator String used to join the elements. - * - * @return String containing all elements joined by @p separator. - */ -template ::value, int>::type = 0> -std::string join(T && first, T && last, const std::string &separator) -{ - return join(std::forward(first), std::forward(last), separator, support::cpp11::to_string); -} - -/** Convert string to lower case. - * - * @param[in] string To be converted string. - * - * @return Lower case string. - */ -inline std::string tolower(std::string string) -{ - std::transform(string.begin(), string.end(), string.begin(), [](unsigned char c) - { - return std::tolower(c); - }); - return string; -} -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_UTILS */ diff --git a/framework/command_line/CommandLineOptions.h b/framework/command_line/CommandLineOptions.h deleted file mode 100644 index cb4b794a3e..0000000000 --- a/framework/command_line/CommandLineOptions.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_COMMANDLINEOPTIONS -#define ARM_COMPUTE_TEST_COMMANDLINEOPTIONS - -#include "EnumListOption.h" -#include "EnumOption.h" -#include "ListOption.h" -#include "Option.h" -#include "ToggleOption.h" - -#endif /* ARM_COMPUTE_TEST_COMMANDLINEOPTIONS */ diff --git a/framework/command_line/CommandLineParser.cpp b/framework/command_line/CommandLineParser.cpp deleted file mode 100644 index 228b18d842..0000000000 --- a/framework/command_line/CommandLineParser.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "CommandLineParser.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -void CommandLineParser::parse(int argc, char **argv) -{ - const std::regex option_regex{ "--((?:no-)?)([^=]+)(?:=(.*))?" }; - - const auto set_option = [&](const std::string & option, const std::string & name, const std::string & value) - { - if(_options.find(name) == _options.end()) - { - _unknown_options.push_back(option); - return; - } - - const bool success = _options[name]->parse(value); - - if(!success) - { - _invalid_options.push_back(option); - } - }; - - unsigned int positional_index = 0; - - for(int i = 1; i < argc; ++i) - { - const std::string option{ argv[i] }; - std::smatch option_matches; - - if(std::regex_match(option, option_matches, option_regex)) - { - // Boolean option - if(option_matches.str(3).empty()) - { - set_option(option, option_matches.str(2), option_matches.str(1).empty() ? "true" : "false"); - } - else - { - // Can't have "no-" and a value - if(!option_matches.str(1).empty()) - { - _invalid_options.emplace_back(option); - } - else - { - set_option(option, option_matches.str(2), option_matches.str(3)); - } - } - } - else - { - if(positional_index >= _positional_options.size()) - { - _invalid_options.push_back(option); - } - else - { - _positional_options[positional_index]->parse(option); - ++positional_index; - } - } - } -} - -bool CommandLineParser::validate() const -{ - bool is_valid = true; - - for(const auto &option : _options) - { - if(option.second->is_required() && !option.second->is_set()) - { - is_valid = false; - std::cerr << "ERROR: Option '" << option.second->name() << "' is required but not given!\n"; - } - } - - for(const auto &option : _positional_options) - { - if(option->is_required() && !option->is_set()) - { - is_valid = false; - std::cerr << "ERROR: Option '" << option->name() << "' is required but not given!\n"; - } - } - - for(const auto &option : _unknown_options) - { - std::cerr << "WARNING: Skipping unknown option '" << option << "'!\n"; - } - - for(const auto &option : _invalid_options) - { - std::cerr << "WARNING: Skipping invalid option '" << option << "'!\n"; - } - - return is_valid; -} - -void CommandLineParser::print_help(const std::string &program_name) const -{ - std::cout << "usage: " << program_name << " \n"; - - for(const auto &option : _options) - { - std::cout << option.second->help() << "\n"; - } - - for(const auto &option : _positional_options) - { - //FIXME: Print help string as well - std::cout << option->name() << "\n"; - } -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/command_line/CommandLineParser.h b/framework/command_line/CommandLineParser.h deleted file mode 100644 index adb5214e2f..0000000000 --- a/framework/command_line/CommandLineParser.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_COMMANDLINEPARSER -#define ARM_COMPUTE_TEST_COMMANDLINEPARSER - -#include "../Utils.h" -#include "Option.h" - -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Class to parse command line arguments. */ -class CommandLineParser final -{ -public: - /** Default constructor. */ - CommandLineParser() = default; - - /** Function to add a new option to the parser. - * - * @param[in] name Name of the option. Will be available under --name=VALUE. - * @param[in] args Option specific configuration arguments. - * - * @return Pointer to the option. The option is owned by the parser. - */ - template - T *add_option(const std::string &name, As &&... args); - - /** Function to add a new positional argument to the parser. - * - * @param[in] args Option specific configuration arguments. - * - * @return Pointer to the option. The option is owned by the parser. - */ - template - T *add_positional_option(As &&... args); - - /** Parses the command line arguments and updates the options accordingly. - * - * @param[in] argc Number of arguments. - * @param[in] argv Arguments. - */ - void parse(int argc, char **argv); - - /** Validates the previously parsed command line arguments. - * - * Validation fails if not all required options are provided. Additionally - * warnings are generated for options that have illegal values or unknown - * options. - * - * @return True if all required options have been provided. - */ - bool validate() const; - - /** Prints a help message for all configured options. - * - * @param[in] program_name Name of the program to be used in the help message. - */ - void print_help(const std::string &program_name) const; - -private: - using OptionsMap = std::map>; - using PositionalOptionsVector = std::vector>; - - OptionsMap _options{}; - PositionalOptionsVector _positional_options{}; - std::vector _unknown_options{}; - std::vector _invalid_options{}; -}; - -template -inline T *CommandLineParser::add_option(const std::string &name, As &&... args) -{ - auto result = _options.emplace(name, support::cpp14::make_unique(name, std::forward(args)...)); - return static_cast(result.first->second.get()); -} - -template -inline T *CommandLineParser::add_positional_option(As &&... args) -{ - _positional_options.emplace_back(support::cpp14::make_unique(std::forward(args)...)); - return static_cast(_positional_options.back().get()); -} -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_COMMANDLINEPARSER */ diff --git a/framework/command_line/EnumListOption.h b/framework/command_line/EnumListOption.h deleted file mode 100644 index d19bfbdc0f..0000000000 --- a/framework/command_line/EnumListOption.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_ENUMLISTOPTION -#define ARM_COMPUTE_TEST_ENUMLISTOPTION - -#include "Option.h" - -#include -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Implementation of an option that accepts any number of values from a fixed set. */ -template -class EnumListOption : public Option -{ -public: - /** Construct option with allowed values. - * - * @param[in] name Name of the option. - * @param[in] allowed_values Set of allowed values for the option. - */ - EnumListOption(std::string name, std::set allowed_values); - - /** Construct option with allowed values, a fixed number of accepted values and default values for the option. - * - * @param[in] name Name of the option. - * @param[in] allowed_values Set of allowed values for the option. - * @param[in] default_values Default values. - */ - EnumListOption(std::string name, std::set allowed_values, std::initializer_list &&default_values); - - bool parse(std::string value) override; - std::string help() const override; - const std::vector &value() const; - -private: - std::vector _values{}; - std::set _allowed_values{}; -}; - -template -inline EnumListOption::EnumListOption(std::string name, std::set allowed_values) - : Option{ std::move(name) }, _allowed_values{ std::move(allowed_values) } -{ -} - -template -inline EnumListOption::EnumListOption(std::string name, std::set allowed_values, std::initializer_list &&default_values) - : Option{ std::move(name), false, true }, _values{ std::forward>(default_values) }, _allowed_values{ std::move(allowed_values) } -{ -} - -template -bool EnumListOption::parse(std::string value) -{ - // Remove default values - _values.clear(); - _is_set = true; - - try - { - std::stringstream stream{ value }; - std::string item; - - while(!std::getline(stream, item, ',').fail()) - { - std::stringstream item_stream(item); - T typed_value{}; - - item_stream >> typed_value; - - if(!item_stream.fail()) - { - if(_allowed_values.count(typed_value) == 0) - { - _values.clear(); - return false; - } - - _values.emplace_back(typed_value); - } - - _is_set = _is_set && !item_stream.fail(); - } - - return _is_set; - } - catch(const std::invalid_argument &) - { - return false; - } -} - -template -std::string EnumListOption::help() const -{ - std::stringstream msg; - msg << "--" + name() + "={"; - - for(const auto &value : _allowed_values) - { - msg << value << ","; - } - - msg << "}[,{...}[,...]] - " << _help; - - return msg.str(); -} - -template -inline const std::vector &EnumListOption::value() const -{ - return _values; -} -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ENUMLISTOPTION */ diff --git a/framework/command_line/EnumOption.h b/framework/command_line/EnumOption.h deleted file mode 100644 index 1abba77b4b..0000000000 --- a/framework/command_line/EnumOption.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_ENUMOPTION -#define ARM_COMPUTE_TEST_ENUMOPTION - -#include "SimpleOption.h" - -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Implementation of a simple option that accepts a value from a fixed set. */ -template -class EnumOption : public SimpleOption -{ -public: - /** Construct option with allowed values. - * - * @param[in] name Name of the option. - * @param[in] allowed_values Set of allowed values for the option. - */ - EnumOption(std::string name, std::set allowed_values); - - /** Construct option with allowed values, a fixed number of accepted values and default values for the option. - * - * @param[in] name Name of the option. - * @param[in] allowed_values Set of allowed values for the option. - * @param[in] default_value Default value. - */ - EnumOption(std::string name, std::set allowed_values, T default_value); - - bool parse(std::string value) override; - std::string help() const override; - const T &value() const; - -private: - std::set _allowed_values{}; -}; - -template -inline EnumOption::EnumOption(std::string name, std::set allowed_values) - : SimpleOption{ std::move(name) }, _allowed_values{ std::move(allowed_values) } -{ -} - -template -inline EnumOption::EnumOption(std::string name, std::set allowed_values, T default_value) - : SimpleOption{ std::move(name), std::move(default_value) }, _allowed_values{ std::move(allowed_values) } -{ -} - -template -bool EnumOption::parse(std::string value) -{ - try - { - std::stringstream stream{ value }; - T typed_value{}; - - stream >> typed_value; - - if(!stream.fail()) - { - if(_allowed_values.count(typed_value) == 0) - { - return false; - } - - this->_value = std::move(typed_value); - this->_is_set = true; - return true; - } - - return false; - } - catch(const std::invalid_argument &) - { - return false; - } -} - -template -std::string EnumOption::help() const -{ - std::stringstream msg; - msg << "--" + this->name() + "={"; - - for(const auto &value : _allowed_values) - { - msg << value << ","; - } - - msg << "} - " << this->_help; - - return msg.str(); -} - -template -inline const T &EnumOption::value() const -{ - return this->_value; -} -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ENUMOPTION */ diff --git a/framework/command_line/ListOption.h b/framework/command_line/ListOption.h deleted file mode 100644 index 8b1bb3d05a..0000000000 --- a/framework/command_line/ListOption.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_LISTOPTION -#define ARM_COMPUTE_TEST_LISTOPTION - -#include "Option.h" - -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Implementation of an option that accepts any number of values. */ -template -class ListOption : public Option -{ -public: - using Option::Option; - - /** Construct the option with the given default values. - * - * @param[in] name Name of the option. - * @param[in] default_values Default values. - */ - ListOption(std::string name, std::initializer_list &&default_values); - - bool parse(std::string value) override; - std::string help() const override; - const std::vector &value() const; - -private: - std::vector _values{}; -}; - -template -inline ListOption::ListOption(std::string name, std::initializer_list &&default_values) - : Option{ std::move(name), false, true }, _values{ std::forward>(default_values) } -{ -} - -template -bool ListOption::parse(std::string value) -{ - _is_set = true; - - try - { - std::stringstream stream{ value }; - std::string item; - - while(!std::getline(stream, item, ',').fail()) - { - std::stringstream item_stream(item); - T typed_value{}; - - item_stream >> typed_value; - - if(!item_stream.fail()) - { - _values.emplace_back(typed_value); - } - - _is_set = _is_set && !item_stream.fail(); - } - - return _is_set; - } - catch(const std::invalid_argument &) - { - return false; - } -} - -template -inline std::string ListOption::help() const -{ - return "--" + name() + "=VALUE[,VALUE[,...]] - " + _help; -} - -template -inline const std::vector &ListOption::value() const -{ - return _values; -} -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_LISTOPTION */ diff --git a/framework/command_line/Option.cpp b/framework/command_line/Option.cpp deleted file mode 100644 index d60c35a698..0000000000 --- a/framework/command_line/Option.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Option.h" - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -Option::Option(std::string name) - : _name{ std::move(name) } -{ -} - -Option::Option(std::string name, bool is_required, bool is_set) - : _name{ std::move(name) }, _is_required{ is_required }, _is_set{ is_set } -{ -} - -std::string Option::name() const -{ - return _name; -} - -void Option::set_required(bool is_required) -{ - _is_required = is_required; -} - -void Option::set_help(std::string help) -{ - _help = std::move(help); -} - -bool Option::is_required() const -{ - return _is_required; -} - -bool Option::is_set() const -{ - return _is_set; -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/command_line/Option.h b/framework/command_line/Option.h deleted file mode 100644 index 25cf492b86..0000000000 --- a/framework/command_line/Option.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_OPTIONBASE -#define ARM_COMPUTE_TEST_OPTIONBASE - -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Abstract base class for a command line option. */ -class Option -{ -public: - /** Constructor. - * - * @param[in] name Name of the option. - */ - Option(std::string name); - - /** Constructor. - * - * @param[in] name Name of the option. - * @param[in] is_required Is the option required? - * @param[in] is_set Has a value been assigned to the option? - */ - Option(std::string name, bool is_required, bool is_set); - - /** Default destructor. */ - virtual ~Option() = default; - - /** Parses the given string. - * - * @param[in] value String representation as passed on the command line. - * - * @return True if the value could be parsed by the specific subclass. - */ - virtual bool parse(std::string value) = 0; - - /** Help message for the option. - * - * @return String representing the help message for the specific subclass. - */ - virtual std::string help() const = 0; - - /** Name of the option. - * - * @return Name of the option. - */ - std::string name() const; - - /** Set whether the option is required. - * - * @param[in] is_required Pass true if the option is required. - */ - void set_required(bool is_required); - - /** Set the help message for the option. - * - * @param[in] help Option specific help message. - */ - void set_help(std::string help); - - /** Is the option required? - * - * @return True if the option is required. - */ - bool is_required() const; - - /** Has a value been assigned to the option? - * - * @return True if a value has been set. - */ - bool is_set() const; - -protected: - std::string _name; - bool _is_required{ false }; - bool _is_set{ false }; - std::string _help{}; -}; -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_OPTIONBASE */ diff --git a/framework/command_line/SimpleOption.h b/framework/command_line/SimpleOption.h deleted file mode 100644 index e6e8045840..0000000000 --- a/framework/command_line/SimpleOption.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_SIMPLEOPTION -#define ARM_COMPUTE_TEST_SIMPLEOPTION - -#include "Option.h" - -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Implementation of an option that accepts a single value. */ -template -class SimpleOption : public Option -{ -public: - using Option::Option; - - /** Construct the option with the given default value. - * - * @param[in] name Name of the option. - * @param[in] default_value Default value. - */ - SimpleOption(std::string name, T default_value); - - bool parse(std::string value) override; - std::string help() const override; - const T &value() const; - -protected: - T _value{}; -}; - -template -inline SimpleOption::SimpleOption(std::string name, T default_value) - : Option{ std::move(name), false, true }, _value{ std::move(default_value) } -{ -} - -template -bool SimpleOption::parse(std::string value) -{ - try - { - std::stringstream stream{ std::move(value) }; - stream >> _value; - _is_set = !stream.fail(); - return _is_set; - } - catch(const std::invalid_argument &) - { - return false; - } -} - -template <> -inline bool SimpleOption::parse(std::string value) -{ - _value = std::move(value); - _is_set = true; - return true; -} - -template -inline std::string SimpleOption::help() const -{ - return "--" + name() + "=VALUE - " + _help; -} - -template -inline const T &SimpleOption::value() const -{ - return _value; -} -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_SIMPLEOPTION */ diff --git a/framework/command_line/ToggleOption.cpp b/framework/command_line/ToggleOption.cpp deleted file mode 100644 index df5b1f813b..0000000000 --- a/framework/command_line/ToggleOption.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "ToggleOption.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -ToggleOption::ToggleOption(std::string name, bool default_value) - : SimpleOption -{ - std::move(name), default_value -} -{ -} - -bool ToggleOption::parse(std::string value) -{ - if(value == "true") - { - _value = true; - _is_set = true; - } - else if(value == "false") - { - _value = false; - _is_set = true; - } - - return _is_set; -} - -std::string ToggleOption::help() const -{ - return "--" + name() + ", --no-" + name() + " - " + _help; -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/command_line/ToggleOption.h b/framework/command_line/ToggleOption.h deleted file mode 100644 index c440c0ee87..0000000000 --- a/framework/command_line/ToggleOption.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_TOGGLEOPTION -#define ARM_COMPUTE_TEST_TOGGLEOPTION - -#include "SimpleOption.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Implementation of an option that can be either true or false. */ -class ToggleOption : public SimpleOption -{ -public: - using SimpleOption::SimpleOption; - - /** Construct the option with the given default value. - * - * @param[in] name Name of the option. - * @param[in] default_value Default value. - */ - ToggleOption(std::string name, bool default_value); - - bool parse(std::string value) override; - std::string help() const override; -}; -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_TOGGLEOPTION */ diff --git a/framework/datasets/CartesianProductDataset.h b/framework/datasets/CartesianProductDataset.h deleted file mode 100644 index f6e45ddc12..0000000000 --- a/framework/datasets/CartesianProductDataset.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DATASET_CARTESIAN_PRODUCT -#define ARM_COMPUTE_TEST_DATASET_CARTESIAN_PRODUCT - -#include "Dataset.h" - -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -namespace dataset -{ -/** Implementation of a dataset representing all combinations of values of the input datasets. - * - * For example, for the inputs {1, 2} and {3, 4} this dataset virtually - * represents the values {(1, 3), (1, 4), (2, 3), (2, 4)}. - */ -template -class CartesianProductDataset : public Dataset -{ -private: - using T_noref = typename std::remove_reference::type; - using U_noref = typename std::remove_reference::type; - using iter1_type = typename T_noref::iterator; - using iter2_type = typename U_noref::iterator; - -public: - /** Construct dataset from the given datasets. - * - * @param[in] dataset1 First dataset. - * @param[in] dataset2 Second dataset. - */ - CartesianProductDataset(T &&dataset1, U &&dataset2) - : _dataset1{ std::forward(dataset1) }, - _dataset2{ std::forward(dataset2) } - { - } - - CartesianProductDataset(CartesianProductDataset &&) = default; - - /** Type of the dataset. */ - using type = decltype(std::tuple_cat(*std::declval(), *std::declval())); - - /** Iterator for the dataset. */ - struct iterator - { - iterator(const T_noref *dataset1, const U_noref *dataset2) - : _iter1{ dataset1->begin() }, - _dataset2{ dataset2 }, - _iter2{ dataset2->begin() } - { - } - - iterator(const iterator &) = default; - iterator &operator=(const iterator &) = default; - iterator(iterator &&) = default; - iterator &operator=(iterator &&) = default; - - ~iterator() = default; - - std::string description() const - { - return _iter1.description() + ":" + _iter2.description(); - } - - CartesianProductDataset::type operator*() const - { - return std::tuple_cat(*_iter1, *_iter2); - } - - iterator &operator++() - { - ++_second_pos; - - if(_second_pos < _dataset2->size()) - { - ++_iter2; - } - else - { - _second_pos = 0; - _iter2 = _dataset2->begin(); - - ++_iter1; - } - - return *this; - } - - private: - iter1_type _iter1; - const U_noref *_dataset2; - iter2_type _iter2; - int _first_pos{ 0 }; - int _second_pos{ 0 }; - }; - - /** Iterator pointing at the begin of the dataset. - * - * @return Iterator for the dataset. - */ - iterator begin() const - { - return iterator(&_dataset1, &_dataset2); - } - - /** Size of the dataset. - * - * @return Number of values in the dataset. - */ - int size() const - { - return _dataset1.size() * _dataset2.size(); - } - -private: - T _dataset1; - U _dataset2; -}; - -/** Helper function to create a @ref CartesianProductDataset. - * - * @param[in] dataset1 First dataset. - * @param[in] dataset2 Second dataset. - * - * @return A grid dataset. - */ -template -CartesianProductDataset combine(T &&dataset1, U &&dataset2) -{ - return CartesianProductDataset(std::forward(dataset1), std::forward(dataset2)); -} -} // namespace dataset -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DATASET_CARTESIAN_PRODUCT */ diff --git a/framework/datasets/ContainerDataset.h b/framework/datasets/ContainerDataset.h deleted file mode 100644 index bdca97cbac..0000000000 --- a/framework/datasets/ContainerDataset.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DATASET_CONTAINER -#define ARM_COMPUTE_TEST_DATASET_CONTAINER - -#include "Dataset.h" -#include "support/ToolchainSupport.h" - -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -namespace dataset -{ -/** Base case. Nothing is a container. */ -template -struct is_container : public std::false_type -{ -}; - -/** Vector is considered a container. */ -template -struct is_container> : public std::true_type -{ -}; - -/** Implementation of a dataset created from a container. */ -template -class ContainerDataset : public NamedDataset -{ -private: - using container_value_type = typename T::value_type; - using container_const_iterator = typename T::const_iterator; - -public: - /** Construct dataset with given name and values from the container. - * - * @param[in] name Description of the values. - * @param[in] container Values for the dataset. - */ - ContainerDataset(std::string name, T &&container) - : NamedDataset{ std::move(name) }, _container(std::forward(container)) - { - } - - ContainerDataset(ContainerDataset &&) = default; - - /** Type of the dataset. */ - using type = std::tuple; - - /** Iterator for the dataset. */ - struct iterator - { - iterator(std::string name, container_const_iterator iterator) - : _name{ name }, _iterator{ iterator } - { - } - - std::string description() const - { - using support::cpp11::to_string; - return _name + "=" + to_string(*_iterator); - } - - ContainerDataset::type operator*() const - { - return std::make_tuple(*_iterator); - } - - iterator &operator++() - { - ++_iterator; - return *this; - } - - private: - std::string _name; - container_const_iterator _iterator; - }; - - /** Iterator pointing at the begin of the dataset. - * - * @return Iterator for the dataset. - */ - iterator begin() const - { - return iterator(name(), _container.cbegin()); - } - - /** Size of the dataset. - * - * @return Number of values in the dataset. - */ - int size() const - { - return _container.size(); - } - -private: - T _container; -}; - -/** Helper function to create a @ref ContainerDataset. - * - * @param[in] name Name of the dataset. - * @param[in] values Container. - * - * @return A container dataset. - */ -template -typename std::enable_if::value, ContainerDataset>::type make(std::string name, T &&values) -{ - return ContainerDataset(std::move(name), std::forward(values)); -} -} // namespace dataset -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DATASET_CONTAINER */ diff --git a/framework/datasets/Dataset.h b/framework/datasets/Dataset.h deleted file mode 100644 index d91673073a..0000000000 --- a/framework/datasets/Dataset.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DATASET -#define ARM_COMPUTE_TEST_DATASET - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -namespace dataset -{ -/** Abstract dataset base class. */ -class Dataset -{ -protected: - Dataset() = default; - ~Dataset() = default; - -public: - Dataset(Dataset &&) = default; -}; - -/** Abstract implementation of a named dataset. - * - * The name should describe the values of the dataset. - */ -class NamedDataset : public Dataset -{ -protected: - /** Construct the dataset with the given name. - * - * @param[in] name Description of the values. - */ - explicit NamedDataset(std::string name) - : _name{ std::move(name) } - { - } - - ~NamedDataset() = default; - -public: - NamedDataset(NamedDataset &&) = default; - - /** Return name of the dataset. - * - * @return Description of the values. - */ - std::string name() const - { - return _name; - } - -protected: - const std::string _name; -}; -} // namespace dataset -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DATASET */ diff --git a/framework/datasets/Datasets.h b/framework/datasets/Datasets.h deleted file mode 100644 index c0e5822e17..0000000000 --- a/framework/datasets/Datasets.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DATASETS -#define ARM_COMPUTE_TEST_DATASETS - -#include "CartesianProductDataset.h" -#include "ContainerDataset.h" -#include "InitializerListDataset.h" -#include "JoinDataset.h" -#include "RangeDataset.h" -#include "SingletonDataset.h" -#include "ZipDataset.h" - -#endif /* ARM_COMPUTE_TEST_DATASETS */ diff --git a/framework/datasets/InitializerListDataset.h b/framework/datasets/InitializerListDataset.h deleted file mode 100644 index 7d32234fab..0000000000 --- a/framework/datasets/InitializerListDataset.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DATASET_LIST -#define ARM_COMPUTE_TEST_DATASET_LIST - -#include "Dataset.h" -#include "support/ToolchainSupport.h" - -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -namespace dataset -{ -/** Implementation of a dataset created from an initializer list. */ -template -class InitializerListDataset final : public NamedDataset -{ -private: - using data_const_iterator = typename std::vector::const_iterator; - -public: - /** Construct dataset with given name and values from the container. - * - * @param[in] name Description of the values. - * @param[in] list Values for the dataset. - */ - InitializerListDataset(std::string name, std::initializer_list &&list) - : NamedDataset{ std::move(name) }, _data(std::forward>(list)) - { - } - - InitializerListDataset(InitializerListDataset &&) = default; - - /** Type of the dataset. */ - using type = std::tuple; - - /** Iterator for the dataset. */ - struct iterator - { - iterator(std::string name, data_const_iterator iterator) - : _name{ name }, _iterator{ iterator } - { - } - - std::string description() const - { - using support::cpp11::to_string; - return _name + "=" + to_string(*_iterator); - } - - InitializerListDataset::type operator*() const - { - return std::make_tuple(*_iterator); - } - - iterator &operator++() - { - ++_iterator; - return *this; - } - - private: - std::string _name; - data_const_iterator _iterator; - }; - - /** Iterator pointing at the begin of the dataset. - * - * @return Iterator for the dataset. - */ - iterator begin() const - { - return iterator(name(), _data.cbegin()); - } - - /** Size of the dataset. - * - * @return Number of values in the dataset. - */ - int size() const - { - return _data.size(); - } - -private: - std::vector _data; -}; - -/** Helper function to create an @ref InitializerListDataset. - * - * @param[in] name Name of the dataset. - * @param[in] list Initializer list. - * - * @return An initializer list dataset. - */ -template -InitializerListDataset make(std::string name, std::initializer_list &&list) -{ - return InitializerListDataset(std::move(name), std::forward>(list)); -} -} // namespace dataset -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DATASET_LIST */ diff --git a/framework/datasets/JoinDataset.h b/framework/datasets/JoinDataset.h deleted file mode 100644 index eded6e0259..0000000000 --- a/framework/datasets/JoinDataset.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DATASET_JOIN -#define ARM_COMPUTE_TEST_DATASET_JOIN - -#include "Dataset.h" - -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -namespace dataset -{ -/** Implementation of a dataset representing the concatenation of the input datasets. - * - * For example, for the inputs {1, 2} and {3, 4} this dataset virtually - * represents the values {1, 2, 3, 4}. - */ -template -class JoinDataset : public Dataset -{ -private: - using iter1_type = typename T::iterator; - using iter2_type = typename U::iterator; - -public: - /** Construct dataset from the given datasets. - * - * @param[in] dataset1 First dataset. - * @param[in] dataset2 Second dataset. - */ - JoinDataset(T &&dataset1, U &&dataset2) - : _dataset1{ std::forward(dataset1) }, - _dataset2{ std::forward(dataset2) } - { - } - - JoinDataset(JoinDataset &&) = default; - - /** Type of the dataset. */ - using type = typename T::type; - - /** Iterator for the dataset. */ - struct iterator - { - iterator(const T *dataset1, const U *dataset2) - : _iter1{ dataset1->begin() }, _iter2{ dataset2->begin() }, _first_size{ dataset1->size() } - { - } - - std::string description() const - { - return _first_size > 0 ? _iter1.description() : _iter2.description(); - } - - JoinDataset::type operator*() const - { - return _first_size > 0 ? *_iter1 : *_iter2; - } - - iterator &operator++() - { - if(_first_size > 0) - { - --_first_size; - ++_iter1; - } - else - { - ++_iter2; - } - - return *this; - } - - private: - iter1_type _iter1; - iter2_type _iter2; - int _first_size; - }; - - /** Iterator pointing at the begin of the dataset. - * - * @return Iterator for the dataset. - */ - iterator begin() const - { - return iterator(&_dataset1, &_dataset2); - } - - /** Size of the dataset. - * - * @return Number of values in the dataset. - */ - int size() const - { - return _dataset1.size() + _dataset2.size(); - } - -private: - T _dataset1; - U _dataset2; -}; - -/** Helper function to create a @ref JoinDataset. - * - * @param[in] dataset1 First dataset. - * @param[in] dataset2 Second dataset. - * - * @return A join dataset. - */ -template -JoinDataset concat(T &&dataset1, U &&dataset2) -{ - return JoinDataset(std::forward(dataset1), std::forward(dataset2)); -} -} // namespace dataset -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DATASET_JOIN */ diff --git a/framework/datasets/RangeDataset.h b/framework/datasets/RangeDataset.h deleted file mode 100644 index 637abe0a83..0000000000 --- a/framework/datasets/RangeDataset.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DATASET_RANGE -#define ARM_COMPUTE_TEST_DATASET_RANGE - -#include "Dataset.h" -#include "support/ToolchainSupport.h" - -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -namespace dataset -{ -/** Implementation of a dataset created from a range of values. - * - * The range is inclusive of the first value but exclusive of the last, i.e. [start, end). - */ -template -class RangeDataset final : public NamedDataset -{ -public: - /** Construct dataset with given name and values in the specified range. - * - * @param[in] name Description of the values. - * @param[in] start Begin of the range. - * @param[in] end End of the range. - * @param[in] step Step size. - */ - RangeDataset(std::string name, T start, T end, T step = 1) - : NamedDataset{ std::move(name) }, _start{ start }, _end{ end }, _step{ step } - { - } - - RangeDataset(RangeDataset &&) = default; - - /** Type of the dataset. */ - using type = std::tuple; - - /** Iterator for the dataset. */ - struct iterator - { - iterator(std::string name, T start, T step) - : _name{ name }, _value{ start }, _step{ step } - { - } - - std::string description() const - { - using support::cpp11::to_string; - return _name + "=" + to_string(_value); - } - - RangeDataset::type operator*() const - { - return std::make_tuple(_value); - } - - iterator &operator++() - { - _value += _step; - return *this; - } - - private: - std::string _name; - T _value; - T _step; - }; - - /** Iterator pointing at the begin of the dataset. - * - * @return Iterator for the dataset. - */ - iterator begin() const - { - return iterator(name(), _start, _step); - } - - /** Size of the dataset. - * - * @return Number of values in the dataset. - */ - int size() const - { - return (_end - _start) / std::abs(_step); - } - -private: - T _start; - T _end; - T _step; -}; - -/** Helper function to create a @ref RangeDataset. - * - * @param[in] name Name of the dataset. - * @param[in] start Begin of the range. - * @param[in] end End of the range. - * @param[in] step Step size. - * - * @return A range dataset. - */ -template -RangeDataset make(std::string name, T start, T end, T step = 1) -{ - return RangeDataset(std::move(name), start, end, step); -} -} // namespace dataset -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DATASET_RANGE */ diff --git a/framework/datasets/SingletonDataset.h b/framework/datasets/SingletonDataset.h deleted file mode 100644 index 1acb5765e5..0000000000 --- a/framework/datasets/SingletonDataset.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DATASET_SINGLETON -#define ARM_COMPUTE_TEST_DATASET_SINGLETON - -#include "ContainerDataset.h" -#include "Dataset.h" -#include "support/ToolchainSupport.h" - -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -namespace dataset -{ -/** Implementation of a dataset holding a single value. */ -template -class SingletonDataset : public NamedDataset -{ -public: - /** Construct dataset with given name and value. - * - * @param[in] name Description of the value. - * @param[in] value Value for the dataset. - */ - SingletonDataset(std::string name, T &&value) - : NamedDataset{ std::move(name) }, _value{ std::forward(value) } - { - } - - SingletonDataset(SingletonDataset &&) = default; - - /** Type of the dataset. */ - using type = std::tuple; - - /** Iterator for the dataset. */ - struct iterator - { - iterator(std::string name, const T *value) - : _name{ name }, _value{ value } - { - } - - ~iterator() = default; - - iterator(const iterator &) = default; - iterator &operator=(const iterator &) = default; - iterator(iterator &&) = default; - iterator &operator=(iterator &&) = default; - - std::string description() const - { - using support::cpp11::to_string; - return _name + "=" + to_string(*_value); - } - - SingletonDataset::type operator*() const - { - return std::make_tuple(*_value); - } - - iterator &operator++() - { - return *this; - } - - private: - std::string _name; - const T *_value; - }; - - /** Iterator pointing at the begin of the dataset. - * - * @return Iterator for the dataset. - */ - iterator begin() const - { - return iterator(name(), &_value); - } - - /** Size of the dataset. - * - * @return Number of values in the dataset. - */ - int size() const - { - return 1; - } - -private: - T _value; -}; - -/** Helper function to create a @ref SingletonDataset. - * - * @param[in] name Name of the dataset. - * @param[in] value Value. - * - * @return A singleton dataset. - */ -template -typename std::enable_if < !is_container::value, SingletonDataset>::type make(std::string name, T &&value) -{ - return SingletonDataset(std::move(name), std::forward(value)); -} -} // namespace dataset -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DATASET_SINGLETON */ diff --git a/framework/datasets/ZipDataset.h b/framework/datasets/ZipDataset.h deleted file mode 100644 index b95b7209a7..0000000000 --- a/framework/datasets/ZipDataset.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DATASET_ZIP -#define ARM_COMPUTE_TEST_DATASET_ZIP - -#include "Dataset.h" - -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -namespace dataset -{ -/** Implementation of a dataset representing pairs of values of the input datasets. - * - * For example, for the inputs {1, 2} and {3, 4} this dataset virtually - * represents the values {(1, 3), (1, 4)}. - */ -template -class ZipDataset : public Dataset -{ -private: - using iter1_type = typename T::iterator; - using iter2_type = typename U::iterator; - -public: - /** Construct dataset from the given datasets. - * - * @param[in] dataset1 First dataset. - * @param[in] dataset2 Second dataset. - */ - ZipDataset(T &&dataset1, U &&dataset2) - : _dataset1{ std::forward(dataset1) }, - _dataset2{ std::forward(dataset2) } - { - } - - ZipDataset(ZipDataset &&) = default; - - /** Type of the dataset. */ - using type = decltype(std::tuple_cat(*std::declval(), *std::declval())); - - /** Iterator for the dataset. */ - struct iterator - { - iterator(iter1_type iter1, iter2_type iter2) - : _iter1{ std::move(iter1) }, _iter2{ std::move(iter2) } - { - } - - std::string description() const - { - return _iter1.description() + ":" + _iter2.description(); - } - - ZipDataset::type operator*() const - { - return std::tuple_cat(*_iter1, *_iter2); - } - - iterator &operator++() - { - ++_iter1; - ++_iter2; - return *this; - } - - private: - iter1_type _iter1; - iter2_type _iter2; - }; - - /** Iterator pointing at the begin of the dataset. - * - * @return Iterator for the dataset. - */ - iterator begin() const - { - return iterator(_dataset1.begin(), _dataset2.begin()); - } - - /** Size of the dataset. - * - * @return Number of values in the dataset. - */ - int size() const - { - return std::min(_dataset1.size(), _dataset2.size()); - } - -private: - T _dataset1; - U _dataset2; -}; - -/** Helper function to create a @ref ZipDataset. - * - * @param[in] dataset1 First dataset. - * @param[in] dataset2 Second dataset. - * - * @return A zip dataset. - */ -template -ZipDataset zip(T &&dataset1, U &&dataset2) -{ - return ZipDataset(std::forward(dataset1), std::forward(dataset2)); -} -} // namespace dataset -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DATASET_ZIP */ diff --git a/framework/instruments/Instrument.h b/framework/instruments/Instrument.h deleted file mode 100644 index 895a64738c..0000000000 --- a/framework/instruments/Instrument.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_INSTRUMENT -#define ARM_COMPUTE_TEST_INSTRUMENT - -#include "../Utils.h" - -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Interface for classes that can be used to measure performance. */ -class Instrument -{ -public: - /** Helper function to create an instrument of the given type. - * - * @return Instance of an instrument of the given type. - */ - template - static std::unique_ptr make_instrument(); - - /** Struct representing measurement consisting of value and unit. */ - struct Measurement final - { - Measurement(double value, std::string unit) - : value{ value }, unit{ std::move(unit) } - { - } - - friend std::ostream &operator<<(std::ostream &os, const Measurement &measurement); - - double value; - std::string unit; - }; - - Instrument() = default; - Instrument(const Instrument &) = default; - Instrument(Instrument &&) = default; - Instrument &operator=(const Instrument &) = default; - Instrument &operator=(Instrument &&) = default; - virtual ~Instrument() = default; - - /** Identifier for the instrument */ - virtual std::string id() const = 0; - - /** Start measuring. */ - virtual void start() = 0; - - /** Stop measuring. */ - virtual void stop() = 0; - - /** Return the latest measurement. */ - virtual Measurement measurement() const = 0; -}; - -inline std::ostream &operator<<(std::ostream &os, const Instrument::Measurement &measurement) -{ - os << measurement.value << measurement.unit; - return os; -} - -template -inline std::unique_ptr Instrument::make_instrument() -{ - return support::cpp14::make_unique(); -} -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_INSTRUMENT */ diff --git a/framework/instruments/Instruments.cpp b/framework/instruments/Instruments.cpp deleted file mode 100644 index 12ad86c70a..0000000000 --- a/framework/instruments/Instruments.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Instruments.h" - -#include "framework/Utils.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -InstrumentType instrument_type_from_name(const std::string &name) -{ - static const std::map types = - { - { "all", InstrumentType::ALL }, - { "none", InstrumentType::NONE }, - { "wall_clock", InstrumentType::WALL_CLOCK_TIMER }, - { "cycles", InstrumentType::PMU_CYCLE_COUNTER }, - { "instructions", InstrumentType::PMU_INSTRUCTION_COUNTER }, - }; - - try - { - return types.at(tolower(name)); - } - catch(const std::out_of_range &) - { - throw std::invalid_argument(name); - } -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/instruments/Instruments.h b/framework/instruments/Instruments.h deleted file mode 100644 index 034fa168f5..0000000000 --- a/framework/instruments/Instruments.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_INSTRUMENTS -#define ARM_COMPUTE_TEST_INSTRUMENTS - -#include "PMUCounter.h" -#include "WallClockTimer.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -enum class InstrumentType : unsigned int -{ - ALL = ~0U, - NONE = 0, - WALL_CLOCK_TIMER = 1, - PMU_CYCLE_COUNTER = 2, - PMU_INSTRUCTION_COUNTER = 4 -}; - -InstrumentType instrument_type_from_name(const std::string &name); - -inline InstrumentType operator&(InstrumentType t1, InstrumentType t2) -{ - using type = std::underlying_type::type; - return static_cast(static_cast(t1) & static_cast(t2)); -} - -inline InstrumentType operator|(InstrumentType t1, InstrumentType t2) -{ - using type = std::underlying_type::type; - return static_cast(static_cast(t1) | static_cast(t2)); -} - -inline InstrumentType &operator|=(InstrumentType &t1, InstrumentType t2) -{ - using type = std::underlying_type::type; - t1 = static_cast(static_cast(t1) | static_cast(t2)); - return t1; -} - -inline ::std::stringstream &operator>>(::std::stringstream &stream, InstrumentType &instrument) -{ - std::string value; - stream >> value; - instrument = instrument_type_from_name(value); - return stream; -} - -inline ::std::stringstream &operator<<(::std::stringstream &stream, InstrumentType instrument) -{ - switch(instrument) - { - case InstrumentType::WALL_CLOCK_TIMER: - stream << "WALL_CLOCK_TIMER"; - break; - case InstrumentType::PMU_CYCLE_COUNTER: - stream << "PMU_CYCLE_COUNTER"; - break; - case InstrumentType::PMU_INSTRUCTION_COUNTER: - stream << "PMU_INSTRUCTION_COUNTER"; - break; - case InstrumentType::ALL: - stream << "ALL"; - break; - case InstrumentType::NONE: - stream << "NONE"; - break; - default: - throw std::invalid_argument("Unsupported instrument type"); - } - - return stream; -} -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_INSTRUMENTS */ diff --git a/framework/instruments/PMUCounter.cpp b/framework/instruments/PMUCounter.cpp deleted file mode 100644 index 7994a15862..0000000000 --- a/framework/instruments/PMUCounter.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "PMUCounter.h" - -#define _GNU_SOURCE 1 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#undef _GNU_SOURCE - -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -CycleCounter::CycleCounter() -{ - const pid_t pid = getpid(); - - struct perf_event_attr perf_config; //NOLINT - memset(&perf_config, 0, sizeof(struct perf_event_attr)); - - perf_config.config = PERF_COUNT_HW_CPU_CYCLES; - perf_config.size = sizeof(struct perf_event_attr); - perf_config.type = PERF_TYPE_HARDWARE; - // The inherit bit specifies that this counter should count events of child - // tasks as well as the task specified - perf_config.inherit = 1; - // Enables saving of event counts on context switch for inherited tasks - perf_config.inherit_stat = 1; - - _fd = syscall(__NR_perf_event_open, &perf_config, pid, -1, -1, 0); - - if(_fd < 0) - { - throw std::runtime_error("perf_event_open for cycles failed"); - } -} - -std::string CycleCounter::id() const -{ - return "Cycle Counter"; -} - -void CycleCounter::start() -{ - ioctl(_fd, PERF_EVENT_IOC_RESET, 0); - ioctl(_fd, PERF_EVENT_IOC_ENABLE, 0); -} - -void CycleCounter::stop() -{ - ioctl(_fd, PERF_EVENT_IOC_DISABLE, 0); - read(_fd, &_cycles, sizeof(_cycles)); -} - -Instrument::Measurement CycleCounter::measurement() const -{ - return Measurement(_cycles, "cycles"); -} - -InstructionCounter::InstructionCounter() -{ - const pid_t pid = getpid(); - - struct perf_event_attr perf_config; //NOLINT - memset(&perf_config, 0, sizeof(struct perf_event_attr)); - - perf_config.config = PERF_COUNT_HW_INSTRUCTIONS; - perf_config.size = sizeof(struct perf_event_attr); - perf_config.type = PERF_TYPE_HARDWARE; - // The inherit bit specifies that this counter should count events of child - // tasks as well as the task specified - perf_config.inherit = 1; - // Enables saving of event counts on context switch for inherited tasks - perf_config.inherit_stat = 1; - - _fd = syscall(__NR_perf_event_open, &perf_config, pid, -1, -1, 0); - - if(_fd < 0) - { - throw std::runtime_error("perf_event_open for instructions failed"); - } -} - -std::string InstructionCounter::id() const -{ - return "Instruction Counter"; -} - -void InstructionCounter::start() -{ - ioctl(_fd, PERF_EVENT_IOC_RESET, 0); - ioctl(_fd, PERF_EVENT_IOC_ENABLE, 0); -} - -void InstructionCounter::stop() -{ - ioctl(_fd, PERF_EVENT_IOC_DISABLE, 0); - read(_fd, &_instructions, sizeof(_instructions)); -} - -Instrument::Measurement InstructionCounter::measurement() const -{ - return Measurement(_instructions, "instructions"); -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/instruments/PMUCounter.h b/framework/instruments/PMUCounter.h deleted file mode 100644 index f407be602f..0000000000 --- a/framework/instruments/PMUCounter.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_PMU_COUNTER -#define ARM_COMPUTE_TEST_PMU_COUNTER - -#include "Instrument.h" - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Implementation of an instrument to count CPU cycles. */ -class CycleCounter : public Instrument -{ -public: - /** Initialise the cycle counter. */ - CycleCounter(); - - std::string id() const override; - void start() override; - void stop() override; - Measurement measurement() const override; - -private: - long _fd{ -1 }; - long long _cycles{ 0 }; -}; - -/** Implementation of an instrument to count executed CPU instructions. */ -class InstructionCounter : public Instrument -{ -public: - /** Initialise the instruction counter. */ - InstructionCounter(); - - std::string id() const override; - void start() override; - void stop() override; - Measurement measurement() const override; - -private: - long _fd{ -1 }; - long long _instructions{ 0 }; -}; -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_PMU_COUNTER */ diff --git a/framework/instruments/WallClockTimer.cpp b/framework/instruments/WallClockTimer.cpp deleted file mode 100644 index 37db0c7f05..0000000000 --- a/framework/instruments/WallClockTimer.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "WallClockTimer.h" - -#include "../Framework.h" -#include "../Utils.h" - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -std::string WallClockTimer::id() const -{ - return "Wall clock"; -} - -void WallClockTimer::start() -{ - _start = std::chrono::high_resolution_clock::now(); -} - -void WallClockTimer::stop() -{ - _stop = std::chrono::high_resolution_clock::now(); -} - -Instrument::Measurement WallClockTimer::measurement() const -{ - const auto delta = std::chrono::duration_cast(_stop - _start); - return Instrument::Measurement(delta.count(), "us"); -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/instruments/WallClockTimer.h b/framework/instruments/WallClockTimer.h deleted file mode 100644 index b7c390f691..0000000000 --- a/framework/instruments/WallClockTimer.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_WALL_CLOCK_TIMER -#define ARM_COMPUTE_TEST_WALL_CLOCK_TIMER - -#include "Instrument.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Implementation of an instrument to measure elapsed wall-clock time in milliseconds. */ -class WallClockTimer : public Instrument -{ -public: - std::string id() const override; - void start() override; - void stop() override; - Measurement measurement() const override; - -private: - std::chrono::high_resolution_clock::time_point _start{}; - std::chrono::high_resolution_clock::time_point _stop{}; -}; -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_WALL_CLOCK_TIMER */ diff --git a/framework/printers/JSONPrinter.cpp b/framework/printers/JSONPrinter.cpp deleted file mode 100644 index 099734e72f..0000000000 --- a/framework/printers/JSONPrinter.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "JSONPrinter.h" - -#include "framework/Framework.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -void JSONPrinter::print_separator(bool &flag) -{ - if(flag) - { - flag = false; - } - else - { - *_stream << ","; - } -} - -void JSONPrinter::print_entry(const std::string &name, const std::string &value) -{ - print_separator(_first_entry); - - *_stream << R"(")" << name << R"(" : ")" << value << R"(")"; -} - -void JSONPrinter::print_global_header() -{ - *_stream << "{"; -} - -void JSONPrinter::print_global_footer() -{ - *_stream << "}\n"; -} - -void JSONPrinter::print_run_header() -{ - print_separator(_first_entry); - - *_stream << R"("tests" : {)"; -} - -void JSONPrinter::print_run_footer() -{ - *_stream << "}"; -} - -void JSONPrinter::print_test_header(const TestInfo &info) -{ - print_separator(_first_test); - - _first_test_entry = true; - *_stream << R"(")" << info.name << R"(" : {)"; -} - -void JSONPrinter::print_test_footer() -{ - *_stream << "}"; -} - -void JSONPrinter::print_errors_header() -{ - print_separator(_first_test_entry); - - _first_error = true; - *_stream << R"("errors" : [)"; -} - -void JSONPrinter::print_errors_footer() -{ - *_stream << "]"; -} - -void JSONPrinter::print_error(const std::exception &error) -{ - std::stringstream error_log; - error_log.str(error.what()); - - for(std::string line; !std::getline(error_log, line).fail();) - { - print_separator(_first_error); - - *_stream << R"(")" << line << R"(")"; - } -} - -void JSONPrinter::print_measurements(const Profiler::MeasurementsMap &measurements) -{ - print_separator(_first_test_entry); - - *_stream << R"("measurements" : {)"; - - for(auto i_it = measurements.cbegin(), i_end = measurements.cend(); i_it != i_end;) - { - *_stream << R"(")" << i_it->first << R"(" : {)"; - - auto add_measurements = [](double a, const Instrument::Measurement & b) - { - return a + b.value; - }; - - auto cmp_measurements = [](const Instrument::Measurement & a, const Instrument::Measurement & b) - { - return a.value < b.value; - }; - - double sum_values = std::accumulate(i_it->second.cbegin(), i_it->second.cend(), 0., add_measurements); - int num_values = i_it->second.size(); - const auto minmax_values = std::minmax_element(i_it->second.begin(), i_it->second.end(), cmp_measurements); - - if(num_values > 2) - { - sum_values -= minmax_values.first->value + minmax_values.second->value; - num_values -= 2; - } - - auto measurement_to_string = [](const Instrument::Measurement & measurement) - { - return support::cpp11::to_string(measurement.value); - }; - - *_stream << R"("avg" : )" << (sum_values / num_values) << ","; - *_stream << R"("min" : )" << minmax_values.first->value << ","; - *_stream << R"("max" : )" << minmax_values.second->value << ","; - *_stream << R"("raw" : [)" << join(i_it->second.begin(), i_it->second.end(), ",", measurement_to_string) << "],"; - *_stream << R"("unit" : ")" << minmax_values.first->unit << R"(")"; - *_stream << "}"; - - if(++i_it != i_end) - { - *_stream << ","; - } - } - - *_stream << "}"; -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/printers/JSONPrinter.h b/framework/printers/JSONPrinter.h deleted file mode 100644 index 14c8b35cb9..0000000000 --- a/framework/printers/JSONPrinter.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_JSONPRINTER -#define ARM_COMPUTE_TEST_JSONPRINTER - -#include "Printer.h" - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Implementation of a @ref Printer that produces JSON output. */ -class JSONPrinter : public Printer -{ -public: - using Printer::Printer; - - void print_entry(const std::string &name, const std::string &value) override; - void print_global_header() override; - void print_global_footer() override; - void print_run_header() override; - void print_run_footer() override; - void print_test_header(const TestInfo &info) override; - void print_test_footer() override; - void print_errors_header() override; - void print_errors_footer() override; - void print_error(const std::exception &error) override; - void print_measurements(const Profiler::MeasurementsMap &measurements) override; - -private: - void print_separator(bool &flag); - - bool _first_entry{ true }; - bool _first_test{ true }; - bool _first_test_entry{ true }; - bool _first_error{ true }; -}; -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_JSONPRINTER */ diff --git a/framework/printers/PrettyPrinter.cpp b/framework/printers/PrettyPrinter.cpp deleted file mode 100644 index 6f7174371a..0000000000 --- a/framework/printers/PrettyPrinter.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "PrettyPrinter.h" - -#include "framework/Framework.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -std::string PrettyPrinter::begin_color(const std::string &color) const -{ - if(!_color_output) - { - return ""; - } - - return "\033[0;3" + color + "m"; -} - -std::string PrettyPrinter::end_color() const -{ - if(!_color_output) - { - return ""; - } - - return "\033[m"; -} - -void PrettyPrinter::set_color_output(bool color_output) -{ - _color_output = color_output; -} - -void PrettyPrinter::print_entry(const std::string &name, const std::string &value) -{ - *_stream << begin_color("4") << name << " = " << value << end_color() << "\n"; -} - -void PrettyPrinter::print_global_header() -{ -} - -void PrettyPrinter::print_global_footer() -{ -} - -void PrettyPrinter::print_run_header() -{ -} - -void PrettyPrinter::print_run_footer() -{ -} - -void PrettyPrinter::print_test_header(const TestInfo &info) -{ - *_stream << begin_color("2") << "Running [" << info.id << "] '" << info.name << "'" << end_color() << "\n"; -} - -void PrettyPrinter::print_test_footer() -{ -} - -void PrettyPrinter::print_errors_header() -{ -} - -void PrettyPrinter::print_errors_footer() -{ -} - -void PrettyPrinter::print_error(const std::exception &error) -{ - *_stream << begin_color("1") << "ERROR: " << error.what() << end_color() << "\n"; -} - -void PrettyPrinter::print_measurements(const Profiler::MeasurementsMap &measurements) -{ - for(const auto &instrument : measurements) - { - *_stream << begin_color("3") << " " << instrument.first << ":"; - - auto add_measurements = [](double a, const Instrument::Measurement & b) - { - return a + b.value; - }; - - auto cmp_measurements = [](const Instrument::Measurement & a, const Instrument::Measurement & b) - { - return a.value < b.value; - }; - - double sum_values = std::accumulate(instrument.second.begin(), instrument.second.end(), 0., add_measurements); - int num_values = instrument.second.size(); - const auto minmax_values = std::minmax_element(instrument.second.begin(), instrument.second.end(), cmp_measurements); - - if(num_values > 2) - { - sum_values -= minmax_values.first->value + minmax_values.second->value; - num_values -= 2; - } - - Instrument::Measurement avg{ sum_values / num_values, minmax_values.first->unit }; - - *_stream << " "; - *_stream << "AVG=" << avg << ", "; - *_stream << "MIN=" << *minmax_values.first << ", "; - *_stream << "MAX=" << *minmax_values.second << end_color() << "\n"; - } -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/printers/PrettyPrinter.h b/framework/printers/PrettyPrinter.h deleted file mode 100644 index fa7b7b2c59..0000000000 --- a/framework/printers/PrettyPrinter.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_PRETTYPRINTER -#define ARM_COMPUTE_TEST_PRETTYPRINTER - -#include "Printer.h" - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -/** Implementation of a @ref Printer that produces human readable output. */ -class PrettyPrinter : public Printer -{ -public: - using Printer::Printer; - - /** Set if the output is colored. - * - * @param[in] color_output True if the output is colored. - */ - void set_color_output(bool color_output); - - void print_entry(const std::string &name, const std::string &value) override; - void print_global_header() override; - void print_global_footer() override; - void print_run_header() override; - void print_run_footer() override; - void print_test_header(const TestInfo &info) override; - void print_test_footer() override; - void print_errors_header() override; - void print_errors_footer() override; - void print_error(const std::exception &error) override; - void print_measurements(const Profiler::MeasurementsMap &measurements) override; - -private: - std::string begin_color(const std::string &color) const; - std::string end_color() const; - - bool _color_output{ true }; -}; -} // namespace framework -} // namespace test -} // namespace arm_compute - -#endif /* ARM_COMPUTE_TEST_PRETTYPRINTER */ diff --git a/framework/printers/Printer.cpp b/framework/printers/Printer.cpp deleted file mode 100644 index e034c2ed43..0000000000 --- a/framework/printers/Printer.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Printer.h" - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -Printer::Printer(std::ostream &stream) - : _stream{ &stream } -{ -} - -void Printer::print(const std::string &str) -{ - *_stream << str; -} - -void Printer::set_stream(std::ostream &stream) -{ - _stream = &stream; -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/printers/Printer.h b/framework/printers/Printer.h deleted file mode 100644 index 85b7a570c8..0000000000 --- a/framework/printers/Printer.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_PRINTER -#define ARM_COMPUTE_TEST_PRINTER - -#include "framework/Profiler.h" - -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -struct TestInfo; - -/** Abstract printer class used by the @ref Framework to present output. */ -class Printer -{ -public: - /** Default constructor. - * - * Prints values to std::cout. - * */ - Printer() = default; - - /** Construct printer with given output stream. - * - * @param[out] stream Output stream. - */ - Printer(std::ostream &stream); - - Printer(const Printer &) = delete; - Printer &operator=(const Printer &) = delete; - Printer(Printer &&) = default; - Printer &operator=(Printer &&) = default; - - virtual ~Printer() = default; - - /** Print given string. - * - * @param[in] str String. - */ - void print(const std::string &str); - - /** Print an entry consisting of a (name, value) pair. - * - * @param[in] name Description of the value. - * @param[in] value Value. - */ - virtual void print_entry(const std::string &name, const std::string &value) = 0; - - /** Print global header. */ - virtual void print_global_header() = 0; - - /** Print global footer. */ - virtual void print_global_footer() = 0; - - /** Print header before running all tests. */ - virtual void print_run_header() = 0; - - /** Print footer after running all tests. */ - virtual void print_run_footer() = 0; - - /** Print header before a test. - * - * @param[in] info Test info. - */ - virtual void print_test_header(const TestInfo &info) = 0; - - /** Print footer after a test. */ - virtual void print_test_footer() = 0; - - /** Print header before errors. */ - virtual void print_errors_header() = 0; - - /** Print footer after errors. */ - virtual void print_errors_footer() = 0; - - /** Print test error. - * - * @param[in] error Description of the error. - */ - virtual void print_error(const std::exception &error) = 0; - - /** Print measurements for a test. - * - * @param[in] measurements Measurements as collected by a @ref Profiler. - */ - virtual void print_measurements(const Profiler::MeasurementsMap &measurements) = 0; - - /** Set the output stream. - * - * @param[out] stream Output stream. - */ - void set_stream(std::ostream &stream); - -protected: - std::ostream *_stream{ &std::cout }; -}; -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_PRINTER */ diff --git a/framework/printers/Printers.cpp b/framework/printers/Printers.cpp deleted file mode 100644 index 9ca5e317b3..0000000000 --- a/framework/printers/Printers.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Printers.h" - -#include "framework/Utils.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -LogFormat log_format_from_name(const std::string &name) -{ - static const std::map formats = - { - { "pretty", LogFormat::PRETTY }, - { "none", LogFormat::NONE }, - { "json", LogFormat::JSON }, - }; - - try - { - return formats.at(tolower(name)); - } - catch(const std::out_of_range &) - { - throw std::invalid_argument(name); - } -} -} // namespace framework -} // namespace test -} // namespace arm_compute diff --git a/framework/printers/Printers.h b/framework/printers/Printers.h deleted file mode 100644 index 53867e2dff..0000000000 --- a/framework/printers/Printers.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_PRINTERS -#define ARM_COMPUTE_TEST_PRINTERS - -#include "JSONPrinter.h" -#include "PrettyPrinter.h" - -namespace arm_compute -{ -namespace test -{ -namespace framework -{ -enum class LogFormat -{ - NONE, - JSON, - PRETTY -}; - -LogFormat log_format_from_name(const std::string &name); - -inline ::std::stringstream &operator>>(::std::stringstream &stream, LogFormat &format) -{ - std::string value; - stream >> value; - format = log_format_from_name(value); - return stream; -} - -inline ::std::stringstream &operator<<(::std::stringstream &stream, LogFormat format) -{ - switch(format) - { - case LogFormat::PRETTY: - stream << "PRETTY"; - break; - case LogFormat::NONE: - stream << "NONE"; - break; - case LogFormat::JSON: - stream << "JSON"; - break; - default: - throw std::invalid_argument("Unsupported log format"); - } - - return stream; -} -} // namespace framework -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_PRINTERS */ diff --git a/scripts/check_bad_style.sh b/scripts/check_bad_style.sh index 0f0b657521..d713122f2d 100755 --- a/scripts/check_bad_style.sh +++ b/scripts/check_bad_style.sh @@ -2,7 +2,7 @@ set -e -DIRECTORIES="./arm_compute ./src ./examples ./tests ./utils ./framework ./support" +DIRECTORIES="./arm_compute ./src ./examples ./tests ./utils ./support" grep -HrnP "/\*\*$" $DIRECTORIES | tee bad_style.log if (( `cat bad_style.log | wc -l` > 0 )) @@ -60,7 +60,7 @@ then exit -1 fi -grep -Hnir "ARM_COMPUTE_ENABLE_FP16" ./tests/validation_new/CL | tee bad_style.log +grep -Hnir "ARM_COMPUTE_ENABLE_FP16" ./tests/validation/CL | tee bad_style.log if [[ $(cat bad_style.log | wc -l) > 0 ]] then echo "" diff --git a/scripts/fix_code_formatting.sh b/scripts/fix_code_formatting.sh index 5ceeb06794..f64bdfb62a 100755 --- a/scripts/fix_code_formatting.sh +++ b/scripts/fix_code_formatting.sh @@ -17,7 +17,7 @@ ASTYLE_PARAMETERS=" --style=ansi \ --indent-preprocessor \ " -DIRECTORIES="./arm_compute ./src ./examples ./tests ./utils ./framework ./support" +DIRECTORIES="./arm_compute ./src ./examples ./tests ./utils ./support" if [ $# -eq 0 ] then diff --git a/tests/AssetsLibrary.cpp b/tests/AssetsLibrary.cpp index be565d9aaf..d7c881d9a8 100644 --- a/tests/AssetsLibrary.cpp +++ b/tests/AssetsLibrary.cpp @@ -21,10 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "AssetsLibrary.h" +#include "tests/AssetsLibrary.h" #include "TypePrinter.h" -#include "UserConfiguration.h" #include "Utils.h" #include "arm_compute/core/ITensor.h" diff --git a/tests/AssetsLibrary.h b/tests/AssetsLibrary.h index 2993662dc7..6945aa6fe1 100644 --- a/tests/AssetsLibrary.h +++ b/tests/AssetsLibrary.h @@ -34,7 +34,7 @@ #include "tests/RawTensor.h" #include "tests/TensorCache.h" #include "tests/Utils.h" -#include "tests/validation/half.h" +#include "tests/validation_old/half.h" #include #include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt deleted file mode 100644 index 70dfd67728..0000000000 --- a/tests/CMakeLists.txt +++ /dev/null @@ -1,85 +0,0 @@ -# Copyright (c) 2017 ARM Limited. -# -# SPDX-License-Identifier: MIT -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -cmake_minimum_required (VERSION 3.1) -project (arm_compute_test) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -add_library(boost_unit_test_framework STATIC IMPORTED) -set_target_properties(boost_unit_test_framework PROPERTIES - IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/../3rdparty/linux/armv7a/libboost_unit_test_framework.a" -) - -add_library(boost_program_options STATIC IMPORTED) -set_target_properties(boost_program_options PROPERTIES - IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/../3rdparty/linux/armv7a/libboost_program_options.a" -) - -add_library(arm_compute SHARED IMPORTED) -set_target_properties(arm_compute PROPERTIES - IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/../build/libarm_compute.so" -) - -include_directories("${CMAKE_SOURCE_DIR}") -include_directories("${CMAKE_SOURCE_DIR}/..") -include_directories("${CMAKE_SOURCE_DIR}/../3rdparty/include/") - -# AssetsLibrary -set(tensor_library_SOURCE_FILES - ${CMAKE_SOURCE_DIR}/RawTensor.h - ${CMAKE_SOURCE_DIR}/RawTensor.cpp - ${CMAKE_SOURCE_DIR}/TensorCache.h - ${CMAKE_SOURCE_DIR}/AssetsLibrary.h - ${CMAKE_SOURCE_DIR}/AssetsLibrary.cpp -) - -add_library(tensor_library OBJECT - ${tensor_library_SOURCE_FILES} -) - -set(arm_compute_test_SOURCE_FILES - ${CMAKE_SOURCE_DIR}/BorderModeDataset.h - ${CMAKE_SOURCE_DIR}/ConvertPolicyDataset.h - ${CMAKE_SOURCE_DIR}/Globals.h - ${CMAKE_SOURCE_DIR}/IAccessor.h - ${CMAKE_SOURCE_DIR}/ImageDatasets.h - ${CMAKE_SOURCE_DIR}/InterpolationPolicyDataset.h - ${CMAKE_SOURCE_DIR}/NormalizationTypeDataset.h - ${CMAKE_SOURCE_DIR}/ProgramOptions.h - ${CMAKE_SOURCE_DIR}/ProgramOptions.cpp - ${CMAKE_SOURCE_DIR}/RoundingPolicyDataset.h - ${CMAKE_SOURCE_DIR}/ShapeDatasets.h - ${CMAKE_SOURCE_DIR}/TypePrinter.h - ${CMAKE_SOURCE_DIR}/TypeReader.h - ${CMAKE_SOURCE_DIR}/UserConfiguration.h - ${CMAKE_SOURCE_DIR}/UserConfiguration.cpp - ${CMAKE_SOURCE_DIR}/Utils.h - ${CMAKE_SOURCE_DIR}/boost_wrapper.h -) - -add_library(arm_compute_test OBJECT - ${arm_compute_test_SOURCE_FILES} -) - -add_subdirectory(validation) -add_subdirectory(benchmark) diff --git a/tests/Globals.h b/tests/Globals.h index d94250bb82..c4c450c5fe 100644 --- a/tests/Globals.h +++ b/tests/Globals.h @@ -24,7 +24,7 @@ #ifndef __ARM_COMPUTE_TEST_GLOBALS_H__ #define __ARM_COMPUTE_TEST_GLOBALS_H__ -#include "AssetsLibrary.h" +#include "tests/AssetsLibrary.h" #include diff --git a/tests/ProgramOptions.cpp b/tests/ProgramOptions.cpp deleted file mode 100644 index b5a7bb14ad..0000000000 --- a/tests/ProgramOptions.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "ProgramOptions.h" - -#include "TypePrinter.h" -#include "TypeReader.h" - -#include "arm_compute/core/Types.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -ProgramOptions::ProgramOptions() -{ - boost::program_options::options_description generic("Generic options"); - generic.add_options()("help", "Print help message")("seed", boost::program_options::value()->default_value(std::random_device()()), "Seed for the tensor library"); - - _visible.add(generic); - - _hidden.add_options()("path", boost::program_options::value(), "Path from where to load the asset/s"); - - _positional.add("path", 1); -} - -void ProgramOptions::add_options(const boost::program_options::options_description &options) -{ - _visible.add(options); -} - -bool ProgramOptions::wants_help() const -{ - return (_vm.count("help") != 0); -} - -std::string ProgramOptions::get_help() const -{ - std::stringstream help; - help << _visible; - - return help.str(); -} - -void ProgramOptions::parse_commandline(int argc, char **argv) -{ - boost::program_options::options_description all; - all.add(_visible).add(_hidden); - - boost::program_options::store(boost::program_options::command_line_parser(argc, argv) - .options(all) - .positional(_positional) - .allow_unregistered() - .run(), - _vm); - - if(_vm.count("help") == 0 && _vm.count("path") == 0) - { - throw boost::program_options::required_option("PATH"); - } - - boost::program_options::notify(_vm); -} -} // namespace test -} // namespace arm_compute diff --git a/tests/ProgramOptions.h b/tests/ProgramOptions.h deleted file mode 100644 index 0b28355aa6..0000000000 --- a/tests/ProgramOptions.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_PROGRAM_OPTIONS_H__ -#define __ARM_COMPUTE_TEST_PROGRAM_OPTIONS_H__ - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Weffc++" -#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" -#include "boost/program_options.hpp" -#pragma GCC diagnostic pop - -#include -#include - -namespace arm_compute -{ -namespace test -{ -/** Defines available commandline arguments and allows to parse them. */ -class ProgramOptions -{ -public: - /** Defines available options. */ - ProgramOptions(); - - /** Signals if the --help flag has been passed on the commandline. */ - bool wants_help() const; - - /** Returns a string describing all available options. */ - std::string get_help() const; - - /** Parses the given arguments and makes them available via @ref get. - * - * @param[in] argc Number of command line arguments. - * @param[in] argv Pointer to the command line arguments. - */ - void parse_commandline(int argc, char **argv); - - /** Sets @p value if it has been specified on the command line. - * - * @note The type T has to match the type that has been specified for the - * command line option. - * - * @param[in] name Name of the option to query. - * @param[out] value Variable to which the value will be assigned. - * - * @return True if the value is assigned, false otherwise. - */ - template - bool get(const std::string &name, T &value) const; - -protected: - /** Allows subclasses to add more specific options - * - * @param[in] options Boost object containing options and their descriptions - */ - void add_options(const boost::program_options::options_description &options); - -private: - boost::program_options::options_description _hidden{}; - boost::program_options::options_description _visible{ "Configuration options" }; - boost::program_options::positional_options_description _positional{}; - boost::program_options::variables_map _vm{}; -}; - -template -bool ProgramOptions::get(const std::string &name, T &value) const -{ - if(_vm.count(name) != 0) - { - value = _vm[name].as(); - return true; - } - - return false; -} -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_PROGRAM_OPTIONS_H__ */ diff --git a/tests/RawTensor.h b/tests/RawTensor.h index f1a9af37c9..fd0ab2b9fd 100644 --- a/tests/RawTensor.h +++ b/tests/RawTensor.h @@ -24,7 +24,7 @@ #ifndef __ARM_COMPUTE_TEST_RAW_TENSOR_H__ #define __ARM_COMPUTE_TEST_RAW_TENSOR_H__ -#include "SimpleTensor.h" +#include "tests/SimpleTensor.h" namespace arm_compute { diff --git a/tests/SConscript b/tests/SConscript index 92a8b59d29..9be03adeb7 100644 --- a/tests/SConscript +++ b/tests/SConscript @@ -25,6 +25,11 @@ import os.path Import('env') Import('vars') +SConscript('./framework/SConscript', duplicate=0) + +#FIXME: Remove before release +SConscript('./validation_old/SConscript', duplicate=0) + # vars is imported from arm_compute: variables = [ #FIXME Remove before release (And remove all references to INTERNAL_ONLY) @@ -41,76 +46,11 @@ for v in variables: new_options.Add(v) vars.Add(v) -# Clone the environment to make sure we're not polluting the arm_compute one: -old_validation_env = env.Clone() -vars.Update(old_validation_env) - -Help(new_options.GenerateHelpText(old_validation_env)) - -if env['os'] in ['android', 'bare_metal'] or env['standalone']: - Import('arm_compute_a') - old_validation_env.Append(LIBS = [arm_compute_a]) - arm_compute_lib = arm_compute_a -else: - Import('arm_compute_so') - old_validation_env.Append(LIBS = ["arm_compute"]) - arm_compute_lib = arm_compute_so - -#FIXME Delete before release -if old_validation_env['internal_only']: - old_validation_env.Append(CPPDEFINES=['INTERNAL_ONLY']) - -old_validation_env.Append(CPPPATH = [".", "#3rdparty/include"]) -old_validation_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])]) -old_validation_env.Append(LIBPATH = ["#build/%s" % env['build_dir']]) -old_validation_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']]) -old_validation_env.Append(LIBS = ['boost_program_options']) -old_validation_env.Append(CXXFLAGS = ['-Wno-missing-field-initializers']) -old_validation_env.Append(CPPDEFINES=['BOOST']) -old_validation_env.Append(LIBS = ['boost_unit_test_framework']) - -old_files_validation = Glob('*.cpp') -old_files_validation = [f for f in old_files_validation if "main.cpp" not in os.path.basename(str(f))] -old_files_validation += Glob('validation/*.cpp') - -# Add unit tests -old_files_validation += Glob('validation/UNIT/*.cpp') -old_files_validation += Glob('validation/UNIT/*/*.cpp') - -if env['opencl']: - Import('opencl') - - old_files_validation += Glob('validation/CL/*.cpp') - old_files_validation += Glob('validation/CL/*/*.cpp') - old_files_validation += Glob('validation/system_tests/CL/*.cpp') - - old_validation_env.Append(LIBS = "OpenCL") - old_validation_env.Append(CPPDEFINES=['ARM_COMPUTE_CL']) - -if env['neon']: - old_files_validation += Glob('validation/NEON/*.cpp') - old_files_validation += Glob('validation/NEON/*/*.cpp') - old_files_validation += Glob('validation/system_tests/NEON/*.cpp') - -if env['os'] == 'android': - old_validation_env.Append(LIBS = ["log"]) - -if old_validation_env['validation_tests']: - arm_compute_validation = old_validation_env.Program('arm_compute_validation', old_files_validation) - Depends(arm_compute_validation, arm_compute_lib) - if env['opencl']: - Depends(arm_compute_validation, opencl) - Default(arm_compute_validation) - Export('arm_compute_validation') - -####################################################################### -# Using new framework -####################################################################### - # Clone the environment to make sure we're not polluting the arm_compute one: test_env = env.Clone() -# Workaround to build both test systems in parallel -test_env.VariantDir("new", ".", duplicate=0) +vars.Update(test_env) + +Help(new_options.GenerateHelpText(test_env)) if env['os'] in ['android', 'bare_metal'] or env['standalone']: Import("arm_compute_a") @@ -122,29 +62,25 @@ else: arm_compute_lib = arm_compute_so #FIXME Delete before release -if old_validation_env['internal_only']: +if test_env['internal_only']: test_env.Append(CPPDEFINES=['INTERNAL_ONLY']) -test_env.Append(CPPPATH = [".", "#3rdparty/include"]) +test_env.Append(CPPPATH = ["#3rdparty/include"]) test_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])]) test_env.Append(LIBPATH = ["#build/%s" % env['build_dir']]) -test_env.Append(LIBPATH = ["#build/%s/framework" % env['build_dir']]) test_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']]) Import("arm_compute_test_framework") test_env.Append(LIBS = arm_compute_test_framework) -common_files = Glob('new/AssetsLibrary.cpp') -common_files += Glob('new/RawTensor.cpp') -common_files += Glob('new/main.cpp') - +common_files = Glob('*.cpp') common_objects = [test_env.StaticObject(f) for f in common_files] -files_benchmark = Glob('new/benchmark_new/*.cpp') -files_validation = Glob('new/validation_new/*.cpp') +files_benchmark = Glob('benchmark/*.cpp') +files_validation = Glob('validation/*.cpp') # Always compile reference for validation -files_validation += Glob('new/validation_new/CPP/*.cpp') +files_validation += Glob('validation/CPP/*.cpp') if env['opencl']: Import('opencl') @@ -152,25 +88,25 @@ if env['opencl']: test_env.Append(CPPDEFINES=['ARM_COMPUTE_CL']) test_env.Append(LIBS = ["OpenCL"]) - files_benchmark += Glob('new/benchmark_new/CL/*/*.cpp') - files_benchmark += Glob('new/benchmark_new/CL/*.cpp') + files_benchmark += Glob('benchmark/CL/*/*.cpp') + files_benchmark += Glob('benchmark/CL/*.cpp') - files_validation += Glob('new/validation_new/CL/*/*.cpp') - files_validation += Glob('new/validation_new/CL/*.cpp') + files_validation += Glob('validation/CL/*/*.cpp') + files_validation += Glob('validation/CL/*.cpp') if env['neon']: - files_benchmark += Glob('new/benchmark_new/NEON/*/*.cpp') - files_benchmark += Glob('new/benchmark_new/NEON/*.cpp') + files_benchmark += Glob('benchmark/NEON/*/*.cpp') + files_benchmark += Glob('benchmark/NEON/*.cpp') - files_validation += Glob('new/validation_new/NEON/*/*.cpp') - files_validation += Glob('new/validation_new/NEON/*.cpp') + files_validation += Glob('validation/NEON/*/*.cpp') + files_validation += Glob('validation/NEON/*.cpp') if env['os'] == 'android': test_env.Append(LIBS = ["log"]) else: test_env.Append(LIBS = ["rt"]) -if old_validation_env['benchmark_tests']: +if test_env['benchmark_tests']: arm_compute_benchmark = test_env.Program('arm_compute_benchmark', files_benchmark + common_objects) Depends(arm_compute_benchmark, arm_compute_test_framework) Depends(arm_compute_benchmark, arm_compute_lib) @@ -181,13 +117,13 @@ if old_validation_env['benchmark_tests']: Default(arm_compute_benchmark) Export('arm_compute_benchmark') -if old_validation_env['validation_tests']: - arm_compute_validation_new = test_env.Program('arm_compute_validation_new', files_validation + common_objects) - Depends(arm_compute_validation_new, arm_compute_test_framework) - Depends(arm_compute_validation_new, arm_compute_lib) +if test_env['validation_tests']: + arm_compute_validation = test_env.Program('arm_compute_validation', files_validation + common_objects) + Depends(arm_compute_validation, arm_compute_test_framework) + Depends(arm_compute_validation, arm_compute_lib) if env['opencl']: - Depends(arm_compute_validation_new, opencl) + Depends(arm_compute_validation, opencl) - Default(arm_compute_validation_new) - Export('arm_compute_validation_new') + Default(arm_compute_validation) + Export('arm_compute_validation') diff --git a/tests/UserConfiguration.cpp b/tests/UserConfiguration.cpp deleted file mode 100644 index a24de90468..0000000000 --- a/tests/UserConfiguration.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "UserConfiguration.h" - -#include "ProgramOptions.h" - -#include - -namespace arm_compute -{ -namespace test -{ -UserConfiguration::UserConfiguration(const ProgramOptions &options) -{ - std::random_device::result_type tmp_seed = 0; - if(options.get("seed", tmp_seed)) - { - seed = tmp_seed; - } - - std::string tmp_path; - if(options.get("path", tmp_path)) - { - path = tmp_path; - } - - unsigned int tmp_threads = 0; - if(options.get("threads", tmp_threads)) - { - threads = tmp_threads; - } -} -} // namespace test -} // namespace arm_compute diff --git a/tests/UserConfiguration.h b/tests/UserConfiguration.h deleted file mode 100644 index 815da04810..0000000000 --- a/tests/UserConfiguration.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_USER_CONFIGURATION_H__ -#define __ARM_COMPUTE_TEST_USER_CONFIGURATION_H__ - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/Types.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -class ProgramOptions; - -/** Container providing easy access to runtime options provided by the user. */ -struct UserConfiguration -{ -protected: - /** Wrapper around options to store if an option has been set. */ - template - class Option - { - public: - /** Initialise the option to its default (C++) value and mark it as 'not set'. */ - Option(); - - /** Initialise the option to the given @p value and mark it as 'set'. */ - Option(const T &value); - - /** Assign the given @p value and mark it as 'set'. */ - Option &operator=(const T &value); - - /** Query if the option has been set. */ - constexpr bool is_set() const; - - /** Return the underlying value as constant. */ - T get() const; - - /** Return the underlying value. */ - T &get(); - - /** Implicitly return the underlying value. */ - operator T() const; - - private: - T _value; - bool _is_set; - }; - -public: - UserConfiguration() = default; - - /** Initialise the configuration according to the program options. - * - * @param[in] options Parsed command line options. - */ - UserConfiguration(const ProgramOptions &options); - - Option path{}; - Option seed{}; - Option threads{}; -}; - -template -UserConfiguration::Option::Option() - : _value{}, _is_set{ false } -{ -} - -template -UserConfiguration::Option::Option(const T &value) - : _value{ value }, _is_set{ true } -{ -} - -template -UserConfiguration::Option &UserConfiguration::Option::operator=(const T &value) -{ - _value = value; - _is_set = true; - - return *this; -} - -template -constexpr bool UserConfiguration::Option::is_set() const -{ - return _is_set; -} - -template -T UserConfiguration::Option::get() const -{ - ARM_COMPUTE_ERROR_ON(!is_set()); - return _value; -} - -template -T &UserConfiguration::Option::get() -{ - return _value; -} - -template -UserConfiguration::Option::operator T() const -{ - ARM_COMPUTE_ERROR_ON(!is_set()); - return _value; -} -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_USER_CONFIGURATION_H__ */ diff --git a/tests/Utils.h b/tests/Utils.h index f1725d7d74..7af38e5c93 100644 --- a/tests/Utils.h +++ b/tests/Utils.h @@ -31,7 +31,7 @@ #include "arm_compute/core/TensorShape.h" #include "arm_compute/core/Types.h" #include "support/ToolchainSupport.h" -#include "tests/validation_new/half.h" +#include "tests/validation/half.h" #include #include diff --git a/tests/benchmark/CL/ActivationLayer.cpp b/tests/benchmark/CL/ActivationLayer.cpp new file mode 100644 index 0000000000..50a2004b07 --- /dev/null +++ b/tests/benchmark/CL/ActivationLayer.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLActivationLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/ActivationLayerFixture.h" +#include "tests/datasets/system_tests/alexnet/AlexNetActivationLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ActivationLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ActivationLayerDataset.h" +#include "tests/datasets/system_tests/lenet5/LeNet5ActivationLayerDataset.h" +#include "tests/datasets/system_tests/squeezenet/SqueezeNetActivationLayerDataset.h" +#include "tests/datasets/system_tests/vgg/vgg16/VGG16ActivationLayerDataset.h" +#include "tests/datasets/system_tests/yolo/v2/YOLOV2ActivationLayerDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8, DataType::QS16 }); +} // namespace + +using CLActivationLayerFixture = ActivationLayerFixture; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetActivationLayer, CLActivationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetActivationLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ActivationLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1ActivationLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4ActivationLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetActivationLayer, CLActivationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetActivationLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(VGG16ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::VGG16ActivationLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2ActivationLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +TEST_SUITE(NIGHTLY) +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetActivationLayer, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetActivationLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ActivationLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1ActivationLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4ActivationLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetActivationLayer, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetActivationLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(VGG16ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::VGG16ActivationLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2ActivationLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/CL/BatchNormalizationLayer.cpp b/tests/benchmark/CL/BatchNormalizationLayer.cpp new file mode 100644 index 0000000000..b0e36d31af --- /dev/null +++ b/tests/benchmark/CL/BatchNormalizationLayer.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITCLSS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLBatchNormalizationLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/BatchNormalizationLayerFixture.h" +#include "tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4BatchNormalizationLayerDataset.h" +#include "tests/datasets/system_tests/yolo/v2/YOLOV2BatchNormalizationLayerDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +const auto data_types = framework::dataset::make("DataType", { DataType::F32, DataType::QS8, DataType::QS16 }); +} // namespace + +using CLBatchNormalizationLayerFixture = BatchNormalizationLayerFixture; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2BatchNormalizationLayer, CLBatchNormalizationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2BatchNormalizationLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4BatchNormalizationLayer, CLBatchNormalizationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4BatchNormalizationLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +TEST_SUITE(NIGHTLY) +REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2BatchNormalizationLayer, CLBatchNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2BatchNormalizationLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4BatchNormalizationLayer, CLBatchNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4BatchNormalizationLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/CL/ConvolutionLayer.cpp b/tests/benchmark/CL/ConvolutionLayer.cpp new file mode 100644 index 0000000000..122e19bbe5 --- /dev/null +++ b/tests/benchmark/CL/ConvolutionLayer.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/ConvolutionLayerFixture.h" +#include "tests/datasets/system_tests/alexnet/AlexNetConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/lenet5/LeNet5ConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/squeezenet/SqueezeNetConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/vgg/vgg16/VGG16ConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/yolo/v2/YOLOV2ConvolutionLayerDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8, DataType::QS16 }); +} // namespace + +using CLConvolutionLayerFixture = ConvolutionLayerFixture; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1ConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1ConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4ConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4ConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +TEST_SUITE(NIGHTLY) +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1ConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1ConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4ConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4ConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(VGG16ConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::VGG16ConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2ConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2ConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", { 1, 4, 8 }))); +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/CL/DepthwiseConvolution.cpp b/tests/benchmark/CL/DepthwiseConvolution.cpp new file mode 100644 index 0000000000..acdc4019b4 --- /dev/null +++ b/tests/benchmark/CL/DepthwiseConvolution.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLDepthwiseConvolution.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/DepthwiseConvolutionFixture.h" +#include "tests/datasets/MobileNetDepthwiseConvolutionDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +const auto data_types = framework::dataset::make("DataType", { DataType::F32 }); +using CLDepthwiseConvolutionFixture = DepthwiseConvolutionFixture; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(MobileNetDepthwiseConvolution, CLDepthwiseConvolutionFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::MobileNetDepthwiseConvolutionDataset(), data_types), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/CL/DepthwiseSeparableConvolutionLayer.cpp b/tests/benchmark/CL/DepthwiseSeparableConvolutionLayer.cpp new file mode 100644 index 0000000000..1ab8628435 --- /dev/null +++ b/tests/benchmark/CL/DepthwiseSeparableConvolutionLayer.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLDepthwiseSeparableConvolutionLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h" +#include "tests/datasets/MobileNetDepthwiseSeparableConvolutionLayerDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +const auto data_types = framework::dataset::make("DataType", { DataType::F32 }); +using CLDepthwiseSeparableConvolutionLayerFixture = DepthwiseSeparableConvolutionLayerFixture; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(MobileNetDepthwiseSeparableConvolutionLayer, CLDepthwiseSeparableConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::MobileNetDepthwiseSeparableConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/CL/DirectConvolutionLayer.cpp b/tests/benchmark/CL/DirectConvolutionLayer.cpp new file mode 100644 index 0000000000..15bf8084ea --- /dev/null +++ b/tests/benchmark/CL/DirectConvolutionLayer.cpp @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLDirectConvolutionLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/ConvolutionLayerFixture.h" +#include "tests/datasets/system_tests/alexnet/AlexNetConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/squeezenet/SqueezeNetConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/vgg/vgg16/VGG16ConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/yolo/v2/YOLOV2ConvolutionLayerDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32 }); +} // namespace + +using CLConvolutionLayerFixture = ConvolutionLayerFixture; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetDirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetDirectConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1DirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1DirectConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4DirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4DirectConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetDirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +TEST_SUITE(NIGHTLY) +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetDirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetDirectConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1DirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1DirectConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4DirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4DirectConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetDirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(VGG16DirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::VGG16ConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2DirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2ConvolutionLayerDataset(), + data_types), + framework::dataset::make("Batches", { 1, 4, 8 }))); +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/CL/Floor.cpp b/tests/benchmark/CL/Floor.cpp new file mode 100644 index 0000000000..ce8fa487c1 --- /dev/null +++ b/tests/benchmark/CL/Floor.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLFloor.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/FloorFixture.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +const auto data_types = framework::dataset::make("DataType", { DataType::F32 }); +} // namespace + +using CLFloorFixture = FloorFixture; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(Floor, CLFloorFixture, framework::DatasetMode::ALL, + framework::dataset::combine(datasets::SmallShapes(), data_types)); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/CL/FullyConnectedLayer.cpp b/tests/benchmark/CL/FullyConnectedLayer.cpp new file mode 100644 index 0000000000..d41424acce --- /dev/null +++ b/tests/benchmark/CL/FullyConnectedLayer.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITCLSS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/FullyConnectedLayerFixture.h" +#include "tests/datasets/system_tests/alexnet/AlexNetFullyConnectedLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1FullyConnectedLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4FullyConnectedLayerDataset.h" +#include "tests/datasets/system_tests/lenet5/LeNet5FullyConnectedLayerDataset.h" +#include "tests/datasets/system_tests/vgg/vgg16/VGG16FullyConnectedLayerDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8, DataType::QS16 }); +} // namespace + +using CLFullyConnectedLayerFixture = FullyConnectedLayerFixture; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetFullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetFullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5FullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5FullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(VGG16FullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::VGG16FullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1FullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1FullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4FullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4FullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +TEST_SUITE(NIGHTLY) +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetFullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetFullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5FullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5FullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(VGG16FullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::VGG16FullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1FullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1FullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4FullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4FullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/CL/GEMM.cpp b/tests/benchmark/CL/GEMM.cpp new file mode 100644 index 0000000000..3febef5613 --- /dev/null +++ b/tests/benchmark/CL/GEMM.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLGEMM.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/GEMMFixture.h" +#include "tests/datasets/MatrixMultiplyGEMMDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1GEMMDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32 }); +} // namespace + +using CLGEMMFixture = GEMMFixture; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1GEMM, CLGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(datasets::GoogLeNetInceptionV1GEMMDataset(), data_types)); +REGISTER_FIXTURE_DATA_TEST_CASE(MatrixMultiplyGEMM, CLGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(datasets::MatrixMultiplyGEMMDataset(), data_types)); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/CL/NormalizationLayer.cpp b/tests/benchmark/CL/NormalizationLayer.cpp new file mode 100644 index 0000000000..2035ae301a --- /dev/null +++ b/tests/benchmark/CL/NormalizationLayer.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITCLSS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLNormalizationLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/NormalizationLayerFixture.h" +#include "tests/datasets/system_tests/alexnet/AlexNetNormalizationLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1NormalizationLayerDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +const auto data_types = framework::dataset::make("DataType", { DataType::QS8, DataType::QS16, DataType::F16, DataType::F32 }); +} // namespace + +using CLNormalizationLayerFixture = NormalizationLayerFixture; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetNormalizationLayer, CLNormalizationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetNormalizationLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1NormalizationLayer, CLNormalizationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1NormalizationLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +TEST_SUITE(NIGHTLY) +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetNormalizationLayer, CLNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetNormalizationLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1NormalizationLayer, CLNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1NormalizationLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/CL/PoolingLayer.cpp b/tests/benchmark/CL/PoolingLayer.cpp new file mode 100644 index 0000000000..fcc37e9571 --- /dev/null +++ b/tests/benchmark/CL/PoolingLayer.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLPoolingLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/PoolingLayerFixture.h" +#include "tests/datasets/system_tests/alexnet/AlexNetPoolingLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1PoolingLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4PoolingLayerDataset.h" +#include "tests/datasets/system_tests/lenet5/LeNet5PoolingLayerDataset.h" +#include "tests/datasets/system_tests/squeezenet/SqueezeNetPoolingLayerDataset.h" +#include "tests/datasets/system_tests/vgg/vgg16/VGG16PoolingLayerDataset.h" +#include "tests/datasets/system_tests/yolo/v2/YOLOV2PoolingLayerDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32 }); +} // namespace + +using CLPoolingLayerFixture = PoolingLayerFixture; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetPoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetPoolingLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5PoolingLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1PoolingLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4PoolingLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetPoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetPoolingLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(VGG16PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::VGG16PoolingLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2PoolingLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +TEST_SUITE(NIGHTLY) +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetPoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetPoolingLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5PoolingLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1PoolingLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4PoolingLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetPoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetPoolingLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(VGG16PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::VGG16PoolingLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2PoolingLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/CL/ROIPoolingLayer.cpp b/tests/benchmark/CL/ROIPoolingLayer.cpp new file mode 100644 index 0000000000..a10134fb04 --- /dev/null +++ b/tests/benchmark/CL/ROIPoolingLayer.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLArray.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLROIPoolingLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/CL/CLArrayAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/ROIPoolingLayerFixture.h" +#include "tests/datasets/ROIPoolingLayerDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +using CLROIPoolingLayerFixture = ROIPoolingLayerFixture, CLArrayAccessor>; + +TEST_SUITE(CL) + +REGISTER_FIXTURE_DATA_TEST_CASE(SmallROIPoolingLayer, CLROIPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::SmallROIPoolingLayerDataset(), + framework::dataset::make("DataType", { DataType::F16, DataType::F32 })), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/CL/SYSTEM/AlexNet.cpp b/tests/benchmark/CL/SYSTEM/AlexNet.cpp new file mode 100644 index 0000000000..fcf8a52f9e --- /dev/null +++ b/tests/benchmark/CL/SYSTEM/AlexNet.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLSubTensor.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLActivationLayer.h" +#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h" +#include "arm_compute/runtime/CL/functions/CLDirectConvolutionLayer.h" +#include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h" +#include "arm_compute/runtime/CL/functions/CLNormalizationLayer.h" +#include "arm_compute/runtime/CL/functions/CLPoolingLayer.h" +#include "arm_compute/runtime/CL/functions/CLSoftmaxLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/AlexNetFixture.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +using CLAlexNetFixture = AlexNetFixture; + +TEST_SUITE(CL) +TEST_SUITE(SYSTEM_TEST) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNet, CLAlexNetFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::make("DataType", { DataType::F16, DataType::F32 }), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/CL/SYSTEM/LeNet5.cpp b/tests/benchmark/CL/SYSTEM/LeNet5.cpp new file mode 100644 index 0000000000..35ebc7d8fb --- /dev/null +++ b/tests/benchmark/CL/SYSTEM/LeNet5.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLActivationLayer.h" +#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h" +#include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h" +#include "arm_compute/runtime/CL/functions/CLPoolingLayer.h" +#include "arm_compute/runtime/CL/functions/CLSoftmaxLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/LeNet5Fixture.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +using CLLeNet5Fixture = LeNet5Fixture; + +TEST_SUITE(CL) +TEST_SUITE(SYSTEM_TEST) + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5, CLLeNet5Fixture, framework::DatasetMode::ALL, + framework::dataset::make("Batches", { 1, 4, 8 })); + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/NEON/ActivationLayer.cpp b/tests/benchmark/NEON/ActivationLayer.cpp new file mode 100644 index 0000000000..0b699f2501 --- /dev/null +++ b/tests/benchmark/NEON/ActivationLayer.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/ActivationLayerFixture.h" +#include "tests/datasets/system_tests/alexnet/AlexNetActivationLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ActivationLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ActivationLayerDataset.h" +#include "tests/datasets/system_tests/lenet5/LeNet5ActivationLayerDataset.h" +#include "tests/datasets/system_tests/squeezenet/SqueezeNetActivationLayerDataset.h" +#include "tests/datasets/system_tests/vgg/vgg16/VGG16ActivationLayerDataset.h" +#include "tests/datasets/system_tests/yolo/v2/YOLOV2ActivationLayerDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +#ifdef ARM_COMPUTE_ENABLE_FP16 +const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8, DataType::QS16 }); +#else /* ARM_COMPUTE_ENABLE_FP16 */ +const auto data_types = framework::dataset::make("DataType", { DataType::F32, DataType::QS8, DataType::QS16 }); +#endif /* ARM_COMPUTE_ENABLE_FP16 */ +} // namespace + +using NEActivationLayerFixture = ActivationLayerFixture; + +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetActivationLayer, NEActivationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetActivationLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ActivationLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1ActivationLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4ActivationLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetActivationLayer, NEActivationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetActivationLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(VGG16ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::VGG16ActivationLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2ActivationLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +TEST_SUITE(NIGHTLY) +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetActivationLayer, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetActivationLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ActivationLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1ActivationLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4ActivationLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetActivationLayer, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetActivationLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(VGG16ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::VGG16ActivationLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2ActivationLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/NEON/BatchNormalizationLayer.cpp b/tests/benchmark/NEON/BatchNormalizationLayer.cpp new file mode 100644 index 0000000000..1b0d484404 --- /dev/null +++ b/tests/benchmark/NEON/BatchNormalizationLayer.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEBatchNormalizationLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/TypePrinter.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +#include "tests/benchmark/fixtures/BatchNormalizationLayerFixture.h" +#include "tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4BatchNormalizationLayerDataset.h" +#include "tests/datasets/system_tests/yolo/v2/YOLOV2BatchNormalizationLayerDataset.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +#ifdef ARM_COMPUTE_ENABLE_FP16 +const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8 }); +#else /* ARM_COMPUTE_ENABLE_FP16 */ +const auto data_types = framework::dataset::make("DataType", { DataType::F32, DataType::QS8 }); +#endif /* ARM_COMPUTE_ENABLE_FP16 */ +} // namespace + +using NEBatchNormalizationLayerFixture = BatchNormalizationLayerFixture; + +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2BatchNormalizationLayer, NEBatchNormalizationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2BatchNormalizationLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4BatchNormalizationLayer, NEBatchNormalizationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4BatchNormalizationLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +TEST_SUITE(NIGHTLY) +REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2BatchNormalizationLayer, NEBatchNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2BatchNormalizationLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4BatchNormalizationLayer, NEBatchNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4BatchNormalizationLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/NEON/ConvolutionLayer.cpp b/tests/benchmark/NEON/ConvolutionLayer.cpp new file mode 100644 index 0000000000..ba682825f1 --- /dev/null +++ b/tests/benchmark/NEON/ConvolutionLayer.cpp @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/ConvolutionLayerFixture.h" +#include "tests/datasets/system_tests/alexnet/AlexNetConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/lenet5/LeNet5ConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/squeezenet/SqueezeNetConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/vgg/vgg16/VGG16ConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/yolo/v2/YOLOV2ConvolutionLayerDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +#ifdef ARM_COMPUTE_ENABLE_FP16 +const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8, DataType::QS16 }); +#else /* ARM_COMPUTE_ENABLE_FP16 */ +const auto data_types = framework::dataset::make("DataType", { DataType::F32, DataType::QS8, DataType::QS16 }); +#endif /* ARM_COMPUTE_ENABLE_FP16 */ +} // namespace + +using NEConvolutionLayerFixture = ConvolutionLayerFixture; + +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1ConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1ConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4ConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4ConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +TEST_SUITE(NIGHTLY) +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1ConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1ConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4ConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4ConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(VGG16ConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::VGG16ConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2ConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2ConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/NEON/DirectConvolutionLayer.cpp b/tests/benchmark/NEON/DirectConvolutionLayer.cpp new file mode 100644 index 0000000000..a9dd4b94ea --- /dev/null +++ b/tests/benchmark/NEON/DirectConvolutionLayer.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEDirectConvolutionLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/ConvolutionLayerFixture.h" +#include "tests/datasets/DirectConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/alexnet/AlexNetConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/squeezenet/SqueezeNetConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/vgg/vgg16/VGG16ConvolutionLayerDataset.h" +#include "tests/datasets/system_tests/yolo/v2/YOLOV2ConvolutionLayerDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +#ifdef ARM_COMPUTE_ENABLE_F16 +const auto data_types = framework::dataset::make("DataType", { DataType::QS8, DataType::F16, DataType::F32 }); +#else /* ARM_COMPUTE_ENABLE_F16 */ +const auto data_types = framework::dataset::make("DataType", { DataType::QS8, DataType::F32 }); +#endif /* ARM_COMPUTE_ENABLE_F16 */ +} // namespace + +using NEConvolutionLayerFixture = ConvolutionLayerFixture; + +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetDirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetDirectConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1DirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1DirectConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4DirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4DirectConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetDirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", 1))); + +TEST_SUITE(NIGHTLY) +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetDirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetDirectConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1DirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1DirectConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4DirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4DirectConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetDirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(VGG16DirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::VGG16ConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2DirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2ConvolutionLayerDataset(), data_types), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/NEON/Floor.cpp b/tests/benchmark/NEON/Floor.cpp new file mode 100644 index 0000000000..4bc0c05fdc --- /dev/null +++ b/tests/benchmark/NEON/Floor.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEFloor.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/FloorFixture.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +const auto data_types = framework::dataset::make("DataType", { DataType::F32 }); +} // namespace + +using NEFloorFixture = FloorFixture; + +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(Floor, NEFloorFixture, framework::DatasetMode::ALL, + framework::dataset::combine(datasets::SmallShapes(), data_types)); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/NEON/FullyConnectedLayer.cpp b/tests/benchmark/NEON/FullyConnectedLayer.cpp new file mode 100644 index 0000000000..88499b1b6f --- /dev/null +++ b/tests/benchmark/NEON/FullyConnectedLayer.cpp @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/FullyConnectedLayerFixture.h" +#include "tests/datasets/system_tests/alexnet/AlexNetFullyConnectedLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1FullyConnectedLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4FullyConnectedLayerDataset.h" +#include "tests/datasets/system_tests/lenet5/LeNet5FullyConnectedLayerDataset.h" +#include "tests/datasets/system_tests/vgg/vgg16/VGG16FullyConnectedLayerDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +#ifdef ARM_COMPUTE_ENABLE_FP16 +const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8, DataType::QS16 }); +#else /* ARM_COMPUTE_ENABLE_FP16 */ +const auto data_types = framework::dataset::make("DataType", { DataType::F32, DataType::QS8, DataType::QS16 }); +#endif /* ARM_COMPUTE_ENABLE_FP16 */ +} // namespace + +using NEFullyConnectedLayerFixture = FullyConnectedLayerFixture; + +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetFullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetFullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5FullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5FullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(VGG16FullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::VGG16FullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1FullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1FullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4FullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4FullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +TEST_SUITE(NIGHTLY) +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetFullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetFullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5FullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5FullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(VGG16FullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::VGG16FullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1FullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1FullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4FullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4FullyConnectedLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/NEON/GEMM.cpp b/tests/benchmark/NEON/GEMM.cpp new file mode 100644 index 0000000000..2c5a726784 --- /dev/null +++ b/tests/benchmark/NEON/GEMM.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEGEMM.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/GEMMFixture.h" +#include "tests/datasets/MatrixMultiplyGEMMDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1GEMMDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +const auto data_types = framework::dataset::make("DataType", +{ +#if ARM_COMPUTE_ENABLE_FP16 + DataType::F16, +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + DataType::F32, + DataType::QS8 +}); +} // namespace + +using NEGEMMFixture = GEMMFixture; + +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1GEMM, NEGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(datasets::GoogLeNetInceptionV1GEMMDataset(), data_types)); +REGISTER_FIXTURE_DATA_TEST_CASE(MatrixMultiplyGEMM, NEGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(datasets::MatrixMultiplyGEMMDataset(), data_types)); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/NEON/NormalizationLayer.cpp b/tests/benchmark/NEON/NormalizationLayer.cpp new file mode 100644 index 0000000000..04887951bd --- /dev/null +++ b/tests/benchmark/NEON/NormalizationLayer.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NENormalizationLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/NormalizationLayerFixture.h" +#include "tests/datasets/system_tests/alexnet/AlexNetNormalizationLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1NormalizationLayerDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +#ifdef ARM_COMPUTE_ENABLE_FP16 +const auto data_types = framework::dataset::make("DataType", { DataType::QS8, DataType::QS16, DataType::F16, DataType::F32 }); +#else /* ARM_COMPUTE_ENABLE_FP16 */ +const auto data_types = framework::dataset::make("DataType", { DataType::QS8, DataType::QS16, DataType::F32 }); +#endif /* ARM_COMPUTE_ENABLE_FP16 */ +} // namespace +using NENormalizationLayerFixture = NormalizationLayerFixture; + +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetNormalizationLayer, NENormalizationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetNormalizationLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1NormalizationLayer, NENormalizationLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1NormalizationLayerDataset(), + data_types), + framework::dataset::make("Batches", 1))); + +TEST_SUITE(NIGHTLY) +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetNormalizationLayer, NENormalizationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetNormalizationLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1NormalizationLayer, NENormalizationLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1NormalizationLayerDataset(), + data_types), + framework::dataset::make("Batches", { 4, 8 }))); +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/NEON/PoolingLayer.cpp b/tests/benchmark/NEON/PoolingLayer.cpp new file mode 100644 index 0000000000..05a173b283 --- /dev/null +++ b/tests/benchmark/NEON/PoolingLayer.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/PoolingLayerFixture.h" +#include "tests/datasets/system_tests/alexnet/AlexNetPoolingLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1PoolingLayerDataset.h" +#include "tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4PoolingLayerDataset.h" +#include "tests/datasets/system_tests/lenet5/LeNet5PoolingLayerDataset.h" +#include "tests/datasets/system_tests/squeezenet/SqueezeNetPoolingLayerDataset.h" +#include "tests/datasets/system_tests/vgg/vgg16/VGG16PoolingLayerDataset.h" +#include "tests/datasets/system_tests/yolo/v2/YOLOV2PoolingLayerDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +#ifdef ARM_COMPUTE_ENABLE_FP16 +const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8 }); +#else /* ARM_COMPUTE_ENABLE_FP16 */ +const auto data_types = framework::dataset::make("DataType", { DataType::F32, DataType::QS8 }); +#endif /* ARM_COMPUTE_ENABLE_FP16 */ +} // namespace + +using NEPoolingLayerFixture = PoolingLayerFixture; + +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetPoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetPoolingLayerDataset(), data_types), framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5PoolingLayerDataset(), data_types), framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1PoolingLayerDataset(), data_types), framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4PoolingLayerDataset(), data_types), framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetPoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetPoolingLayerDataset(), data_types), framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(VGG16PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::VGG16PoolingLayerDataset(), data_types), framework::dataset::make("Batches", 1))); + +REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2PoolingLayerDataset(), data_types), framework::dataset::make("Batches", 1))); + +TEST_SUITE(NIGHTLY) +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetPoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::AlexNetPoolingLayerDataset(), data_types), framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::LeNet5PoolingLayerDataset(), data_types), framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1PoolingLayerDataset(), data_types), framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4PoolingLayerDataset(), data_types), framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetPoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetPoolingLayerDataset(), data_types), framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(VGG16PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::VGG16PoolingLayerDataset(), data_types), framework::dataset::make("Batches", { 4, 8 }))); + +REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, + framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2PoolingLayerDataset(), data_types), framework::dataset::make("Batches", { 4, 8 }))); +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/NEON/ROIPoolingLayer.cpp b/tests/benchmark/NEON/ROIPoolingLayer.cpp new file mode 100644 index 0000000000..d3a7e4b3af --- /dev/null +++ b/tests/benchmark/NEON/ROIPoolingLayer.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Array.h" +#include "arm_compute/runtime/NEON/functions/NEROIPoolingLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/NEON/ArrayAccessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/ROIPoolingLayerFixture.h" +#include "tests/datasets/ROIPoolingLayerDataset.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +using NEROIPoolingLayerFixture = ROIPoolingLayerFixture, ArrayAccessor>; + +TEST_SUITE(NEON) + +REGISTER_FIXTURE_DATA_TEST_CASE(SmallROIPoolingLayer, NEROIPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::SmallROIPoolingLayerDataset(), + framework::dataset::make("DataType", { DataType::F32 })), + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/NEON/SYSTEM/AlexNet.cpp b/tests/benchmark/NEON/SYSTEM/AlexNet.cpp new file mode 100644 index 0000000000..cd48e5db25 --- /dev/null +++ b/tests/benchmark/NEON/SYSTEM/AlexNet.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" +#include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" +#include "arm_compute/runtime/NEON/functions/NEDirectConvolutionLayer.h" +#include "arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h" +#include "arm_compute/runtime/NEON/functions/NENormalizationLayer.h" +#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" +#include "arm_compute/runtime/NEON/functions/NESoftmaxLayer.h" +#include "arm_compute/runtime/SubTensor.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/AlexNetFixture.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +namespace +{ +#ifdef ARM_COMPUTE_ENABLE_FP16 +const auto alex_net_data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8 }); +#else /* ARM_COMPUTE_ENABLE_FP16 */ +const auto alex_net_data_types = framework::dataset::make("DataType", { DataType::F32, DataType::QS8 }); +#endif /* ARM_COMPUTE_ENABLE_FP16 */ +} // namespace + +using NEAlexNetFixture = AlexNetFixture; + +TEST_SUITE(NEON) +TEST_SUITE(SYSTEM_TEST) + +REGISTER_FIXTURE_DATA_TEST_CASE(AlexNet, NEAlexNetFixture, framework::DatasetMode::ALL, + framework::dataset::combine(alex_net_data_types, + framework::dataset::make("Batches", { 1, 4, 8 }))); + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/NEON/SYSTEM/LeNet5.cpp b/tests/benchmark/NEON/SYSTEM/LeNet5.cpp new file mode 100644 index 0000000000..46ccfc01d5 --- /dev/null +++ b/tests/benchmark/NEON/SYSTEM/LeNet5.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" +#include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" +#include "arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h" +#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" +#include "arm_compute/runtime/NEON/functions/NESoftmaxLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/TypePrinter.h" +#include "tests/benchmark/fixtures/LeNet5Fixture.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" + +namespace arm_compute +{ +namespace test +{ +using NELeNet5Fixture = LeNet5Fixture; + +TEST_SUITE(NEON) +TEST_SUITE(SYSTEM_TEST) + +REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5, NELeNet5Fixture, framework::DatasetMode::ALL, + framework::dataset::make("Batches", { 1, 4, 8 })); + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace test +} // namespace arm_compute diff --git a/tests/benchmark/fixtures/ActivationLayerFixture.h b/tests/benchmark/fixtures/ActivationLayerFixture.h new file mode 100644 index 0000000000..9ded063a37 --- /dev/null +++ b/tests/benchmark/fixtures/ActivationLayerFixture.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_ACTIVATIONLAYERFIXTURE +#define ARM_COMPUTE_TEST_ACTIVATIONLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class ActivationLayerFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, ActivationLayerInfo info, DataType data_type, int batches) + { + // Set batched in source and destination shapes + shape.set(shape.num_dimensions(), batches); + + // Create tensors + const int fixed_point_position = 4; + src = create_tensor(shape, data_type, 1, fixed_point_position); + dst = create_tensor(shape, data_type, 1, fixed_point_position); + + // Create and configure function + act_layer.configure(&src, &dst, info); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + } + + void run() + { + act_layer.run(); + } + + void teardown() + { + src.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType dst{}; + Function act_layer{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ACTIVATIONLAYERFIXTURE */ diff --git a/tests/benchmark/fixtures/AlexNetFixture.h b/tests/benchmark/fixtures/AlexNetFixture.h new file mode 100644 index 0000000000..961f4e889f --- /dev/null +++ b/tests/benchmark/fixtures/AlexNetFixture.h @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_ALEXNETFIXTURE +#define ARM_COMPUTE_TEST_ALEXNETFIXTURE + +#include "tests/AssetsLibrary.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" +#include "tests/networks/AlexNetNetwork.h" + +namespace arm_compute +{ +namespace test +{ +template + +class AlexNetFixture : public framework::Fixture +{ +public: + template + void setup(DataType data_type, int batches) + { + constexpr bool weights_reshaped = true; + constexpr int fixed_point_position = 4; + + network.init(data_type, fixed_point_position, batches, weights_reshaped); + network.build(); + network.allocate(); + network.fill_random(); + } + + void run() + { + network.run(); + } + + void teardown() + { + network.clear(); + } + +private: + networks::AlexNetNetwork + network{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ALEXNETFIXTURE */ diff --git a/tests/benchmark/fixtures/BatchNormalizationLayerFixture.h b/tests/benchmark/fixtures/BatchNormalizationLayerFixture.h new file mode 100644 index 0000000000..79dbc76300 --- /dev/null +++ b/tests/benchmark/fixtures/BatchNormalizationLayerFixture.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_BATCHNORMALIZATIONLAYERFIXTURE +#define ARM_COMPUTE_TEST_BATCHNORMALIZATIONLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class BatchNormalizationLayerFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape tensor_shape, TensorShape param_shape, float epsilon, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + tensor_shape.set(tensor_shape.num_dimensions(), batches); + + // Create tensors + src = create_tensor(tensor_shape, data_type, 1, fixed_point_position); + dst = create_tensor(tensor_shape, data_type, 1, fixed_point_position); + mean = create_tensor(param_shape, data_type, 1, fixed_point_position); + variance = create_tensor(param_shape, data_type, 1, fixed_point_position); + beta = create_tensor(param_shape, data_type, 1, fixed_point_position); + gamma = create_tensor(param_shape, data_type, 1, fixed_point_position); + + // Create and configure function + batch_norm_layer.configure(&src, &dst, &mean, &variance, &beta, &gamma, epsilon); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + mean.allocator()->allocate(); + variance.allocator()->allocate(); + beta.allocator()->allocate(); + gamma.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + library->fill_tensor_uniform(Accessor(mean), 1); + library->fill_tensor_uniform(Accessor(variance), 2); + library->fill_tensor_uniform(Accessor(beta), 3); + library->fill_tensor_uniform(Accessor(gamma), 4); + } + + void run() + { + batch_norm_layer.run(); + } + + void teardown() + { + src.allocator()->free(); + dst.allocator()->free(); + mean.allocator()->free(); + variance.allocator()->free(); + beta.allocator()->free(); + gamma.allocator()->free(); + } + +private: + TensorType src{}; + TensorType dst{}; + TensorType mean{}; + TensorType variance{}; + TensorType beta{}; + TensorType gamma{}; + Function batch_norm_layer{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_BATCHNORMALIZATIONLAYERFIXTURE */ diff --git a/tests/benchmark/fixtures/ConvolutionLayerFixture.h b/tests/benchmark/fixtures/ConvolutionLayerFixture.h new file mode 100644 index 0000000000..fd508d4500 --- /dev/null +++ b/tests/benchmark/fixtures/ConvolutionLayerFixture.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_CONVOLUTIONLAYERFIXTURE +#define ARM_COMPUTE_TEST_CONVOLUTIONLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class ConvolutionLayerFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape src_shape, TensorShape weights_shape, TensorShape biases_shape, TensorShape dst_shape, PadStrideInfo info, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + src_shape.set(3 /* batch */, batches); + dst_shape.set(3 /* batch */, batches); + + // Create tensors + src = create_tensor(src_shape, data_type, 1, fixed_point_position); + weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); + biases = create_tensor(biases_shape, data_type, 1, fixed_point_position); + dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); + + // Create and configure function + conv_layer.configure(&src, &weights, &biases, &dst, info); + + // Allocate tensors + src.allocator()->allocate(); + weights.allocator()->allocate(); + biases.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + library->fill_tensor_uniform(Accessor(weights), 1); + library->fill_tensor_uniform(Accessor(biases), 2); + } + + void run() + { + conv_layer.run(); + } + + void teardown() + { + src.allocator()->free(); + weights.allocator()->free(); + biases.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType weights{}; + TensorType biases{}; + TensorType dst{}; + Function conv_layer{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_CONVOLUTIONLAYERFIXTURE */ diff --git a/tests/benchmark/fixtures/DepthwiseConvolutionFixture.h b/tests/benchmark/fixtures/DepthwiseConvolutionFixture.h new file mode 100644 index 0000000000..e080fe253b --- /dev/null +++ b/tests/benchmark/fixtures/DepthwiseConvolutionFixture.h @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DEPTHWISECONVOLUTIONFIXTURE +#define ARM_COMPUTE_TEST_DEPTHWISECONVOLUTIONFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class DepthwiseConvolutionFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape src_shape, TensorShape weights_shape, TensorShape dst_shape, PadStrideInfo info, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + src_shape.set(3 /* batch */, batches); + dst_shape.set(3 /* batch */, batches); + + // Create tensors + src = create_tensor(src_shape, data_type, 1, fixed_point_position); + weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); + dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); + + // Create and configure function + depth_conv.configure(&src, &dst, &weights, info); + + // Allocate tensors + src.allocator()->allocate(); + weights.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + library->fill_tensor_uniform(Accessor(weights), 1); + } + + void run() + { + depth_conv.run(); + } + + void teardown() + { + src.allocator()->free(); + weights.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType weights{}; + TensorType dst{}; + Function depth_conv{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DEPTHWISECONVOLUTIONFIXTURE */ diff --git a/tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h b/tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h new file mode 100644 index 0000000000..928b0c7328 --- /dev/null +++ b/tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DEPTHWISESEPARABLECONVOLUTIONLAYERFIXTURE +#define ARM_COMPUTE_TEST_DEPTHWISESEPARABLECONVOLUTIONLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class DepthwiseSeparableConvolutionLayerFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape src_shape, TensorShape depthwise_weights_shape, TensorShape depthwise_out_shape, TensorShape pointwise_weights_shape, TensorShape biases_shape, TensorShape dst_shape, + PadStrideInfo pad_stride_depthwise_info, PadStrideInfo pad_stride_pointwise_info, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + src_shape.set(3 /* batch */, batches); + depthwise_out_shape.set(3 /* batch */, batches); + dst_shape.set(3 /* batch */, batches); + + src = create_tensor(src_shape, data_type, 1, fixed_point_position); + depthwise_weights = create_tensor(depthwise_weights_shape, data_type, 1, fixed_point_position); + depthwise_out = create_tensor(depthwise_out_shape, data_type, 1, fixed_point_position); + pointwise_weights = create_tensor(pointwise_weights_shape, data_type, 1, fixed_point_position); + biases = create_tensor(biases_shape, data_type, 1, fixed_point_position); + dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); + + // Create and configure function + depth_sep_conv_layer.configure(&src, &depthwise_weights, &depthwise_out, &pointwise_weights, &biases, &dst, pad_stride_depthwise_info, pad_stride_pointwise_info); + + // Allocate tensors + src.allocator()->allocate(); + depthwise_weights.allocator()->allocate(); + depthwise_out.allocator()->allocate(); + pointwise_weights.allocator()->allocate(); + biases.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + library->fill_tensor_uniform(Accessor(depthwise_weights), 1); + library->fill_tensor_uniform(Accessor(pointwise_weights), 2); + library->fill_tensor_uniform(Accessor(biases), 3); + } + + void run() + { + depth_sep_conv_layer.run(); + } + + void teardown() + { + src.allocator()->free(); + depthwise_weights.allocator()->free(); + depthwise_out.allocator()->free(); + pointwise_weights.allocator()->free(); + biases.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType depthwise_weights{}; + TensorType depthwise_out{}; + TensorType pointwise_weights{}; + TensorType biases{}; + TensorType dst{}; + Function depth_sep_conv_layer{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DEPTHWISESEPARABLECONVOLUTIONLAYERFIXTURE */ diff --git a/tests/benchmark/fixtures/FloorFixture.h b/tests/benchmark/fixtures/FloorFixture.h new file mode 100644 index 0000000000..8de87b886b --- /dev/null +++ b/tests/benchmark/fixtures/FloorFixture.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_FLOORFIXTURE +#define ARM_COMPUTE_TEST_FLOORFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class FloorFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type) + { + // Create tensors + src = create_tensor(shape, data_type); + dst = create_tensor(shape, data_type); + + // Create and configure function + floor_func.configure(&src, &dst); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + } + + void run() + { + floor_func.run(); + } + + void teardown() + { + src.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType dst{}; + Function floor_func{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_FLOORFIXTURE */ diff --git a/tests/benchmark/fixtures/FullyConnectedLayerFixture.h b/tests/benchmark/fixtures/FullyConnectedLayerFixture.h new file mode 100644 index 0000000000..2d1f2334b6 --- /dev/null +++ b/tests/benchmark/fixtures/FullyConnectedLayerFixture.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_FULLYCONNECTEDLAYERFIXTURE +#define ARM_COMPUTE_TEST_FULLYCONNECTEDLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class FullyConnectedLayerFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape src_shape, TensorShape weights_shape, TensorShape biases_shape, TensorShape dst_shape, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + src_shape.set(src_shape.num_dimensions() /* batch */, batches); + dst_shape.set(dst_shape.num_dimensions() /* batch */, batches); + + // Create tensors + src = create_tensor(src_shape, data_type, 1, fixed_point_position); + weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); + biases = create_tensor(biases_shape, data_type, 1, fixed_point_position); + dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); + + // Create and configure function + fc_layer.configure(&src, &weights, &biases, &dst); + + // Allocate tensors + src.allocator()->allocate(); + weights.allocator()->allocate(); + biases.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + library->fill_tensor_uniform(Accessor(weights), 1); + library->fill_tensor_uniform(Accessor(biases), 2); + } + + void run() + { + fc_layer.run(); + } + + void teardown() + { + src.allocator()->free(); + weights.allocator()->free(); + biases.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType weights{}; + TensorType biases{}; + TensorType dst{}; + Function fc_layer{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_FULLYCONNECTEDLAYERFIXTURE */ diff --git a/tests/benchmark/fixtures/GEMMFixture.h b/tests/benchmark/fixtures/GEMMFixture.h new file mode 100644 index 0000000000..0c41c67af1 --- /dev/null +++ b/tests/benchmark/fixtures/GEMMFixture.h @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_GEMMFIXTURE +#define ARM_COMPUTE_TEST_GEMMFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class GEMMFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape_a, TensorShape shape_b, TensorShape shape_c, TensorShape shape_dst, float alpha, float beta, DataType data_type) + { + constexpr int fixed_point_position = 4; + + // Create tensors + a = create_tensor(shape_a, data_type, 1, fixed_point_position); + b = create_tensor(shape_b, data_type, 1, fixed_point_position); + c = create_tensor(shape_c, data_type, 1, fixed_point_position); + dst = create_tensor(shape_dst, data_type, 1, fixed_point_position); + + // Create and configure function + gemm.configure(&a, &b, &c, &dst, alpha, beta); + + // Allocate tensors + a.allocator()->allocate(); + b.allocator()->allocate(); + c.allocator()->allocate(); + dst.allocator()->allocate(); + + library->fill_tensor_uniform(Accessor(a), 0); + library->fill_tensor_uniform(Accessor(b), 1); + library->fill_tensor_uniform(Accessor(c), 2); + } + + void run() + { + gemm.run(); + } + + void teardown() + { + a.allocator()->free(); + b.allocator()->free(); + c.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType a{}; + TensorType b{}; + TensorType c{}; + TensorType dst{}; + Function gemm{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GEMMFIXTURE */ diff --git a/tests/benchmark/fixtures/LeNet5Fixture.h b/tests/benchmark/fixtures/LeNet5Fixture.h new file mode 100644 index 0000000000..77a09d3025 --- /dev/null +++ b/tests/benchmark/fixtures/LeNet5Fixture.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_LENET5FIXTURE +#define ARM_COMPUTE_TEST_LENET5FIXTURE + +#include "tests/AssetsLibrary.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" +#include "tests/networks/LeNet5Network.h" + +namespace arm_compute +{ +namespace test +{ +template +class LeNet5Fixture : public framework::Fixture +{ +public: + template + void setup(int batches) + { + network.init(batches); + network.build(); + network.allocate(); + network.fill_random(); + } + + void run() + { + network.run(); + } + + void teardown() + { + network.clear(); + } + +private: + networks::LeNet5Network + network{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_LENET5FIXTURE */ diff --git a/tests/benchmark/fixtures/NormalizationLayerFixture.h b/tests/benchmark/fixtures/NormalizationLayerFixture.h new file mode 100644 index 0000000000..41dd8a7b27 --- /dev/null +++ b/tests/benchmark/fixtures/NormalizationLayerFixture.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_NORMALIZATIONLAYERFIXTURE +#define ARM_COMPUTE_TEST_NORMALIZATIONLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class NormalizationLayerFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, NormalizationLayerInfo info, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + shape.set(shape.num_dimensions(), batches); + + // Create tensors + src = create_tensor(shape, data_type, 1, fixed_point_position); + dst = create_tensor(shape, data_type, 1, fixed_point_position); + + // Create and configure function + norm_layer.configure(&src, &dst, info); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + } + + void run() + { + norm_layer.run(); + } + + void teardown() + { + src.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType dst{}; + Function norm_layer{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_NORMALIZATIONLAYERFIXTURE */ diff --git a/tests/benchmark/fixtures/PoolingLayerFixture.h b/tests/benchmark/fixtures/PoolingLayerFixture.h new file mode 100644 index 0000000000..2060301531 --- /dev/null +++ b/tests/benchmark/fixtures/PoolingLayerFixture.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_POOLINGLAYERFIXTURE +#define ARM_COMPUTE_TEST_POOLINGLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class PoolingLayerFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape src_shape, TensorShape dst_shape, PoolingLayerInfo info, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + src_shape.set(src_shape.num_dimensions(), batches); + dst_shape.set(dst_shape.num_dimensions(), batches); + + // Create tensors + src = create_tensor(src_shape, data_type, 1, fixed_point_position); + dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); + + // Create and configure function + pool_layer.configure(&src, &dst, info); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + } + + void run() + { + pool_layer.run(); + } + + void teardown() + { + src.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType dst{}; + Function pool_layer{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_POOLINGLAYERFIXTURE */ diff --git a/tests/benchmark/fixtures/ROIPoolingLayerFixture.h b/tests/benchmark/fixtures/ROIPoolingLayerFixture.h new file mode 100644 index 0000000000..76c2280b74 --- /dev/null +++ b/tests/benchmark/fixtures/ROIPoolingLayerFixture.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_ROIPOOLINGLAYERFIXTURE +#define ARM_COMPUTE_TEST_ROIPOOLINGLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +#include + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class ROIPoolingLayerFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, const ROIPoolingLayerInfo pool_info, unsigned int num_rois, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + TensorShape shape_dst; + shape.set(shape.num_dimensions(), batches); + shape_dst.set(0, pool_info.pooled_width()); + shape_dst.set(1, pool_info.pooled_height()); + shape_dst.set(2, shape.z()); + shape_dst.set(3, num_rois); + + // Create tensors + src = create_tensor(shape, data_type, 1, fixed_point_position); + dst = create_tensor(shape_dst, data_type, 1, fixed_point_position); + + // Create random ROIs + std::vector rois = generate_random_rois(shape, pool_info, num_rois, 0U); + rois_array = arm_compute::support::cpp14::make_unique(num_rois); + fill_array(ArrayAccessor(*rois_array), rois); + + // Create and configure function + roi_pool.configure(&src, rois_array.get(), &dst, pool_info); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + } + + void run() + { + roi_pool.run(); + } + + void teardown() + { + src.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType dst{}; + std::unique_ptr rois_array{}; + Function roi_pool{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ROIPOOLINGLAYERFIXTURE */ diff --git a/tests/benchmark_new/CL/ActivationLayer.cpp b/tests/benchmark_new/CL/ActivationLayer.cpp deleted file mode 100644 index 4edbc55065..0000000000 --- a/tests/benchmark_new/CL/ActivationLayer.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLActivationLayer.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/system_tests/alexnet/AlexNetActivationLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ActivationLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ActivationLayerDataset.h" -#include "tests/datasets_new/system_tests/lenet5/LeNet5ActivationLayerDataset.h" -#include "tests/datasets_new/system_tests/squeezenet/SqueezeNetActivationLayerDataset.h" -#include "tests/datasets_new/system_tests/vgg/vgg16/VGG16ActivationLayerDataset.h" -#include "tests/datasets_new/system_tests/yolo/v2/YOLOV2ActivationLayerDataset.h" -#include "tests/fixtures_new/ActivationLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8, DataType::QS16 }); -} // namespace - -using CLActivationLayerFixture = ActivationLayerFixture; - -TEST_SUITE(CL) - -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetActivationLayer, CLActivationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetActivationLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ActivationLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1ActivationLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4ActivationLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetActivationLayer, CLActivationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetActivationLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(VGG16ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::VGG16ActivationLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2ActivationLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -TEST_SUITE(NIGHTLY) -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetActivationLayer, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetActivationLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ActivationLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1ActivationLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4ActivationLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetActivationLayer, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetActivationLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(VGG16ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::VGG16ActivationLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2ActivationLayer, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2ActivationLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/CL/BatchNormalizationLayer.cpp b/tests/benchmark_new/CL/BatchNormalizationLayer.cpp deleted file mode 100644 index fb081341c9..0000000000 --- a/tests/benchmark_new/CL/BatchNormalizationLayer.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITCLSS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLBatchNormalizationLayer.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4BatchNormalizationLayerDataset.h" -#include "tests/datasets_new/system_tests/yolo/v2/YOLOV2BatchNormalizationLayerDataset.h" -#include "tests/fixtures_new/BatchNormalizationLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -const auto data_types = framework::dataset::make("DataType", { DataType::F32, DataType::QS8, DataType::QS16 }); -} // namespace - -using CLBatchNormalizationLayerFixture = BatchNormalizationLayerFixture; - -TEST_SUITE(CL) - -REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2BatchNormalizationLayer, CLBatchNormalizationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2BatchNormalizationLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4BatchNormalizationLayer, CLBatchNormalizationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4BatchNormalizationLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -TEST_SUITE(NIGHTLY) -REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2BatchNormalizationLayer, CLBatchNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2BatchNormalizationLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4BatchNormalizationLayer, CLBatchNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4BatchNormalizationLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/CL/ConvolutionLayer.cpp b/tests/benchmark_new/CL/ConvolutionLayer.cpp deleted file mode 100644 index 6447004f06..0000000000 --- a/tests/benchmark_new/CL/ConvolutionLayer.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/system_tests/alexnet/AlexNetConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/lenet5/LeNet5ConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/squeezenet/SqueezeNetConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/vgg/vgg16/VGG16ConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/yolo/v2/YOLOV2ConvolutionLayerDataset.h" -#include "tests/fixtures_new/ConvolutionLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8, DataType::QS16 }); -} // namespace - -using CLConvolutionLayerFixture = ConvolutionLayerFixture; - -TEST_SUITE(CL) - -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1ConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1ConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4ConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4ConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -TEST_SUITE(NIGHTLY) -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1ConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1ConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4ConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4ConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(VGG16ConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::VGG16ConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", { 1, 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2ConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2ConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", { 1, 4, 8 }))); -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/CL/DepthwiseConvolution.cpp b/tests/benchmark_new/CL/DepthwiseConvolution.cpp deleted file mode 100644 index 15c474fd12..0000000000 --- a/tests/benchmark_new/CL/DepthwiseConvolution.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLDepthwiseConvolution.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/MobileNetDepthwiseConvolutionDataset.h" -#include "tests/fixtures_new/DepthwiseConvolutionFixture.h" - -namespace arm_compute -{ -namespace test -{ -const auto data_types = framework::dataset::make("DataType", { DataType::F32 }); -using CLDepthwiseConvolutionFixture = DepthwiseConvolutionFixture; - -TEST_SUITE(CL) - -REGISTER_FIXTURE_DATA_TEST_CASE(MobileNetDepthwiseConvolution, CLDepthwiseConvolutionFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::MobileNetDepthwiseConvolutionDataset(), data_types), - framework::dataset::make("Batches", { 1, 4, 8 }))); - -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/CL/DepthwiseSeparableConvolutionLayer.cpp b/tests/benchmark_new/CL/DepthwiseSeparableConvolutionLayer.cpp deleted file mode 100644 index 038a2ab72d..0000000000 --- a/tests/benchmark_new/CL/DepthwiseSeparableConvolutionLayer.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLDepthwiseSeparableConvolutionLayer.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/MobileNetDepthwiseSeparableConvolutionLayerDataset.h" -#include "tests/fixtures_new/DepthwiseSeparableConvolutionLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -const auto data_types = framework::dataset::make("DataType", { DataType::F32 }); -using CLDepthwiseSeparableConvolutionLayerFixture = DepthwiseSeparableConvolutionLayerFixture; - -TEST_SUITE(CL) - -REGISTER_FIXTURE_DATA_TEST_CASE(MobileNetDepthwiseSeparableConvolutionLayer, CLDepthwiseSeparableConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::MobileNetDepthwiseSeparableConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", { 1, 4, 8 }))); - -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/CL/DirectConvolutionLayer.cpp b/tests/benchmark_new/CL/DirectConvolutionLayer.cpp deleted file mode 100644 index 675739bac9..0000000000 --- a/tests/benchmark_new/CL/DirectConvolutionLayer.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLDirectConvolutionLayer.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/system_tests/alexnet/AlexNetConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/squeezenet/SqueezeNetConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/vgg/vgg16/VGG16ConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/yolo/v2/YOLOV2ConvolutionLayerDataset.h" -#include "tests/fixtures_new/ConvolutionLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32 }); -} // namespace - -using CLConvolutionLayerFixture = ConvolutionLayerFixture; - -TEST_SUITE(CL) - -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetDirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetDirectConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1DirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1DirectConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4DirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4DirectConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetDirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -TEST_SUITE(NIGHTLY) -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetDirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetDirectConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1DirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1DirectConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4DirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4DirectConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetDirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(VGG16DirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::VGG16ConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", { 1, 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2DirectConvolutionLayer, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2ConvolutionLayerDataset(), - data_types), - framework::dataset::make("Batches", { 1, 4, 8 }))); -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/CL/Floor.cpp b/tests/benchmark_new/CL/Floor.cpp deleted file mode 100644 index cfa9d173f0..0000000000 --- a/tests/benchmark_new/CL/Floor.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLFloor.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/fixtures_new/FloorFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -const auto data_types = framework::dataset::make("DataType", { DataType::F32 }); -} // namespace - -using CLFloorFixture = FloorFixture; - -TEST_SUITE(CL) - -REGISTER_FIXTURE_DATA_TEST_CASE(Floor, CLFloorFixture, framework::DatasetMode::ALL, - framework::dataset::combine(datasets::SmallShapes(), data_types)); - -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/CL/FullyConnectedLayer.cpp b/tests/benchmark_new/CL/FullyConnectedLayer.cpp deleted file mode 100644 index e8f11b6c37..0000000000 --- a/tests/benchmark_new/CL/FullyConnectedLayer.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITCLSS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/system_tests/alexnet/AlexNetFullyConnectedLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1FullyConnectedLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4FullyConnectedLayerDataset.h" -#include "tests/datasets_new/system_tests/lenet5/LeNet5FullyConnectedLayerDataset.h" -#include "tests/datasets_new/system_tests/vgg/vgg16/VGG16FullyConnectedLayerDataset.h" -#include "tests/fixtures_new/FullyConnectedLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8, DataType::QS16 }); -} // namespace - -using CLFullyConnectedLayerFixture = FullyConnectedLayerFixture; - -TEST_SUITE(CL) - -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetFullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetFullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5FullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::LeNet5FullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(VGG16FullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::VGG16FullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1FullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1FullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4FullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4FullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -TEST_SUITE(NIGHTLY) -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetFullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetFullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5FullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::LeNet5FullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(VGG16FullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::VGG16FullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1FullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1FullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4FullyConnectedLayer, CLFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4FullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/CL/GEMM.cpp b/tests/benchmark_new/CL/GEMM.cpp deleted file mode 100644 index 9b35285e7c..0000000000 --- a/tests/benchmark_new/CL/GEMM.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLGEMM.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/MatrixMultiplyGEMMDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1GEMMDataset.h" -#include "tests/fixtures_new/GEMMFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32 }); -} // namespace - -using CLGEMMFixture = GEMMFixture; - -TEST_SUITE(CL) - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1GEMM, CLGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(datasets::GoogLeNetInceptionV1GEMMDataset(), data_types)); -REGISTER_FIXTURE_DATA_TEST_CASE(MatrixMultiplyGEMM, CLGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(datasets::MatrixMultiplyGEMMDataset(), data_types)); - -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/CL/NormalizationLayer.cpp b/tests/benchmark_new/CL/NormalizationLayer.cpp deleted file mode 100644 index f433172cd1..0000000000 --- a/tests/benchmark_new/CL/NormalizationLayer.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITCLSS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLNormalizationLayer.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/system_tests/alexnet/AlexNetNormalizationLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1NormalizationLayerDataset.h" -#include "tests/fixtures_new/NormalizationLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -const auto data_types = framework::dataset::make("DataType", { DataType::QS8, DataType::QS16, DataType::F16, DataType::F32 }); -} // namespace - -using CLNormalizationLayerFixture = NormalizationLayerFixture; - -TEST_SUITE(CL) - -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetNormalizationLayer, CLNormalizationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetNormalizationLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1NormalizationLayer, CLNormalizationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1NormalizationLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -TEST_SUITE(NIGHTLY) -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetNormalizationLayer, CLNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetNormalizationLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1NormalizationLayer, CLNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1NormalizationLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/CL/PoolingLayer.cpp b/tests/benchmark_new/CL/PoolingLayer.cpp deleted file mode 100644 index 15c98cbe30..0000000000 --- a/tests/benchmark_new/CL/PoolingLayer.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLPoolingLayer.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/system_tests/alexnet/AlexNetPoolingLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1PoolingLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4PoolingLayerDataset.h" -#include "tests/datasets_new/system_tests/lenet5/LeNet5PoolingLayerDataset.h" -#include "tests/datasets_new/system_tests/squeezenet/SqueezeNetPoolingLayerDataset.h" -#include "tests/datasets_new/system_tests/vgg/vgg16/VGG16PoolingLayerDataset.h" -#include "tests/datasets_new/system_tests/yolo/v2/YOLOV2PoolingLayerDataset.h" -#include "tests/fixtures_new/PoolingLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32 }); -} // namespace - -using CLPoolingLayerFixture = PoolingLayerFixture; - -TEST_SUITE(CL) - -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetPoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetPoolingLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::LeNet5PoolingLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1PoolingLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4PoolingLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetPoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetPoolingLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(VGG16PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::VGG16PoolingLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2PoolingLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -TEST_SUITE(NIGHTLY) -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetPoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetPoolingLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::LeNet5PoolingLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1PoolingLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4PoolingLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetPoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetPoolingLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(VGG16PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::VGG16PoolingLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2PoolingLayer, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2PoolingLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/CL/ROIPoolingLayer.cpp b/tests/benchmark_new/CL/ROIPoolingLayer.cpp deleted file mode 100644 index 260f4d7b0d..0000000000 --- a/tests/benchmark_new/CL/ROIPoolingLayer.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLArray.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLROIPoolingLayer.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/CL/CLArrayAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/ROIPoolingLayerDataset.h" -#include "tests/fixtures_new/ROIPoolingLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -using CLROIPoolingLayerFixture = ROIPoolingLayerFixture, CLArrayAccessor>; - -TEST_SUITE(CL) - -REGISTER_FIXTURE_DATA_TEST_CASE(SmallROIPoolingLayer, CLROIPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::SmallROIPoolingLayerDataset(), - framework::dataset::make("DataType", { DataType::F16, DataType::F32 })), - framework::dataset::make("Batches", { 1, 4, 8 }))); - -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/CL/SYSTEM/AlexNet.cpp b/tests/benchmark_new/CL/SYSTEM/AlexNet.cpp deleted file mode 100644 index 4e5e729501..0000000000 --- a/tests/benchmark_new/CL/SYSTEM/AlexNet.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLSubTensor.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLActivationLayer.h" -#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h" -#include "arm_compute/runtime/CL/functions/CLDirectConvolutionLayer.h" -#include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h" -#include "arm_compute/runtime/CL/functions/CLNormalizationLayer.h" -#include "arm_compute/runtime/CL/functions/CLPoolingLayer.h" -#include "arm_compute/runtime/CL/functions/CLSoftmaxLayer.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/fixtures_new/AlexNetFixture.h" - -namespace arm_compute -{ -namespace test -{ -using CLAlexNetFixture = AlexNetFixture; - -TEST_SUITE(CL) -TEST_SUITE(SYSTEM_TEST) - -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNet, CLAlexNetFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::make("DataType", { DataType::F16, DataType::F32 }), - framework::dataset::make("Batches", { 1, 4, 8 }))); - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/CL/SYSTEM/LeNet5.cpp b/tests/benchmark_new/CL/SYSTEM/LeNet5.cpp deleted file mode 100644 index 1b500bfabb..0000000000 --- a/tests/benchmark_new/CL/SYSTEM/LeNet5.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLActivationLayer.h" -#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h" -#include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h" -#include "arm_compute/runtime/CL/functions/CLPoolingLayer.h" -#include "arm_compute/runtime/CL/functions/CLSoftmaxLayer.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/fixtures_new/LeNet5Fixture.h" - -namespace arm_compute -{ -namespace test -{ -using CLLeNet5Fixture = LeNet5Fixture; - -TEST_SUITE(CL) -TEST_SUITE(SYSTEM_TEST) - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5, CLLeNet5Fixture, framework::DatasetMode::ALL, - framework::dataset::make("Batches", { 1, 4, 8 })); - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/ActivationLayer.cpp b/tests/benchmark_new/NEON/ActivationLayer.cpp deleted file mode 100644 index 9083ce9091..0000000000 --- a/tests/benchmark_new/NEON/ActivationLayer.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/system_tests/alexnet/AlexNetActivationLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ActivationLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ActivationLayerDataset.h" -#include "tests/datasets_new/system_tests/lenet5/LeNet5ActivationLayerDataset.h" -#include "tests/datasets_new/system_tests/squeezenet/SqueezeNetActivationLayerDataset.h" -#include "tests/datasets_new/system_tests/vgg/vgg16/VGG16ActivationLayerDataset.h" -#include "tests/datasets_new/system_tests/yolo/v2/YOLOV2ActivationLayerDataset.h" -#include "tests/fixtures_new/ActivationLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 -const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8, DataType::QS16 }); -#else /* ARM_COMPUTE_ENABLE_FP16 */ -const auto data_types = framework::dataset::make("DataType", { DataType::F32, DataType::QS8, DataType::QS16 }); -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -} // namespace - -using NEActivationLayerFixture = ActivationLayerFixture; - -TEST_SUITE(NEON) - -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetActivationLayer, NEActivationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetActivationLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ActivationLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1ActivationLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4ActivationLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetActivationLayer, NEActivationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetActivationLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(VGG16ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::VGG16ActivationLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2ActivationLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -TEST_SUITE(NIGHTLY) -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetActivationLayer, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetActivationLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ActivationLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1ActivationLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4ActivationLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetActivationLayer, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetActivationLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(VGG16ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::VGG16ActivationLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2ActivationLayer, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2ActivationLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/BatchNormalizationLayer.cpp b/tests/benchmark_new/NEON/BatchNormalizationLayer.cpp deleted file mode 100644 index ffc7d4b19e..0000000000 --- a/tests/benchmark_new/NEON/BatchNormalizationLayer.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEBatchNormalizationLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/TypePrinter.h" - -#include "tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4BatchNormalizationLayerDataset.h" -#include "tests/datasets_new/system_tests/yolo/v2/YOLOV2BatchNormalizationLayerDataset.h" -#include "tests/fixtures_new/BatchNormalizationLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 -const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8 }); -#else /* ARM_COMPUTE_ENABLE_FP16 */ -const auto data_types = framework::dataset::make("DataType", { DataType::F32, DataType::QS8 }); -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -} // namespace - -using NEBatchNormalizationLayerFixture = BatchNormalizationLayerFixture; - -TEST_SUITE(NEON) - -REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2BatchNormalizationLayer, NEBatchNormalizationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2BatchNormalizationLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4BatchNormalizationLayer, NEBatchNormalizationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4BatchNormalizationLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -TEST_SUITE(NIGHTLY) -REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2BatchNormalizationLayer, NEBatchNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2BatchNormalizationLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4BatchNormalizationLayer, NEBatchNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4BatchNormalizationLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/ConvolutionLayer.cpp b/tests/benchmark_new/NEON/ConvolutionLayer.cpp deleted file mode 100644 index 548fe8b8c5..0000000000 --- a/tests/benchmark_new/NEON/ConvolutionLayer.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/system_tests/alexnet/AlexNetConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/lenet5/LeNet5ConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/squeezenet/SqueezeNetConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/vgg/vgg16/VGG16ConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/yolo/v2/YOLOV2ConvolutionLayerDataset.h" -#include "tests/fixtures_new/ConvolutionLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 -const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8, DataType::QS16 }); -#else /* ARM_COMPUTE_ENABLE_FP16 */ -const auto data_types = framework::dataset::make("DataType", { DataType::F32, DataType::QS8, DataType::QS16 }); -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -} // namespace - -using NEConvolutionLayerFixture = ConvolutionLayerFixture; - -TEST_SUITE(NEON) - -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1ConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1ConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4ConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4ConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -TEST_SUITE(NIGHTLY) -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5ConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::LeNet5ConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1ConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1ConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4ConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4ConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(VGG16ConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::VGG16ConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", { 1, 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2ConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2ConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", { 1, 4, 8 }))); - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/DirectConvolutionLayer.cpp b/tests/benchmark_new/NEON/DirectConvolutionLayer.cpp deleted file mode 100644 index 1233b0cd1d..0000000000 --- a/tests/benchmark_new/NEON/DirectConvolutionLayer.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEDirectConvolutionLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/DirectConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/alexnet/AlexNetConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/squeezenet/SqueezeNetConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/vgg/vgg16/VGG16ConvolutionLayerDataset.h" -#include "tests/datasets_new/system_tests/yolo/v2/YOLOV2ConvolutionLayerDataset.h" -#include "tests/fixtures_new/ConvolutionLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -#ifdef ARM_COMPUTE_ENABLE_F16 -const auto data_types = framework::dataset::make("DataType", { DataType::QS8, DataType::F16, DataType::F32 }); -#else /* ARM_COMPUTE_ENABLE_F16 */ -const auto data_types = framework::dataset::make("DataType", { DataType::QS8, DataType::F32 }); -#endif /* ARM_COMPUTE_ENABLE_F16 */ -} // namespace - -using NEConvolutionLayerFixture = ConvolutionLayerFixture; - -TEST_SUITE(NEON) - -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetDirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetDirectConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1DirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1DirectConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4DirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4DirectConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetDirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", 1))); - -TEST_SUITE(NIGHTLY) -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetDirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetDirectConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1DirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1DirectConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4DirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4DirectConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetDirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(VGG16DirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::VGG16ConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", { 1, 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2DirectConvolutionLayer, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2ConvolutionLayerDataset(), data_types), - framework::dataset::make("Batches", { 1, 4, 8 }))); - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/Floor.cpp b/tests/benchmark_new/NEON/Floor.cpp deleted file mode 100644 index ea6a52b4b2..0000000000 --- a/tests/benchmark_new/NEON/Floor.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEFloor.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/fixtures_new/FloorFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -const auto data_types = framework::dataset::make("DataType", { DataType::F32 }); -} // namespace - -using NEFloorFixture = FloorFixture; - -TEST_SUITE(NEON) - -REGISTER_FIXTURE_DATA_TEST_CASE(Floor, NEFloorFixture, framework::DatasetMode::ALL, - framework::dataset::combine(datasets::SmallShapes(), data_types)); - -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/FullyConnectedLayer.cpp b/tests/benchmark_new/NEON/FullyConnectedLayer.cpp deleted file mode 100644 index 72a0742c46..0000000000 --- a/tests/benchmark_new/NEON/FullyConnectedLayer.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/system_tests/alexnet/AlexNetFullyConnectedLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1FullyConnectedLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4FullyConnectedLayerDataset.h" -#include "tests/datasets_new/system_tests/lenet5/LeNet5FullyConnectedLayerDataset.h" -#include "tests/datasets_new/system_tests/vgg/vgg16/VGG16FullyConnectedLayerDataset.h" -#include "tests/fixtures_new/FullyConnectedLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 -const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8, DataType::QS16 }); -#else /* ARM_COMPUTE_ENABLE_FP16 */ -const auto data_types = framework::dataset::make("DataType", { DataType::F32, DataType::QS8, DataType::QS16 }); -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -} // namespace - -using NEFullyConnectedLayerFixture = FullyConnectedLayerFixture; - -TEST_SUITE(NEON) - -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetFullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetFullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5FullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::LeNet5FullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(VGG16FullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::VGG16FullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1FullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1FullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4FullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4FullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -TEST_SUITE(NIGHTLY) -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetFullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetFullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5FullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::LeNet5FullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(VGG16FullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::VGG16FullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1FullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1FullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4FullyConnectedLayer, NEFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4FullyConnectedLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/GEMM.cpp b/tests/benchmark_new/NEON/GEMM.cpp deleted file mode 100644 index 59ac4329c0..0000000000 --- a/tests/benchmark_new/NEON/GEMM.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEGEMM.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/MatrixMultiplyGEMMDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1GEMMDataset.h" -#include "tests/fixtures_new/GEMMFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -const auto data_types = framework::dataset::make("DataType", -{ -#if ARM_COMPUTE_ENABLE_FP16 - DataType::F16, -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - DataType::F32, - DataType::QS8 -}); -} // namespace - -using NEGEMMFixture = GEMMFixture; - -TEST_SUITE(NEON) - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1GEMM, NEGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(datasets::GoogLeNetInceptionV1GEMMDataset(), data_types)); -REGISTER_FIXTURE_DATA_TEST_CASE(MatrixMultiplyGEMM, NEGEMMFixture, framework::DatasetMode::ALL, framework::dataset::combine(datasets::MatrixMultiplyGEMMDataset(), data_types)); - -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/NormalizationLayer.cpp b/tests/benchmark_new/NEON/NormalizationLayer.cpp deleted file mode 100644 index fefcb96b21..0000000000 --- a/tests/benchmark_new/NEON/NormalizationLayer.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NENormalizationLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/system_tests/alexnet/AlexNetNormalizationLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1NormalizationLayerDataset.h" -#include "tests/fixtures_new/NormalizationLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 -const auto data_types = framework::dataset::make("DataType", { DataType::QS8, DataType::QS16, DataType::F16, DataType::F32 }); -#else /* ARM_COMPUTE_ENABLE_FP16 */ -const auto data_types = framework::dataset::make("DataType", { DataType::QS8, DataType::QS16, DataType::F32 }); -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -} // namespace -using NENormalizationLayerFixture = NormalizationLayerFixture; - -TEST_SUITE(NEON) - -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetNormalizationLayer, NENormalizationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetNormalizationLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1NormalizationLayer, NENormalizationLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1NormalizationLayerDataset(), - data_types), - framework::dataset::make("Batches", 1))); - -TEST_SUITE(NIGHTLY) -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetNormalizationLayer, NENormalizationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetNormalizationLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1NormalizationLayer, NENormalizationLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1NormalizationLayerDataset(), - data_types), - framework::dataset::make("Batches", { 4, 8 }))); -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/PoolingLayer.cpp b/tests/benchmark_new/NEON/PoolingLayer.cpp deleted file mode 100644 index 59cb127a45..0000000000 --- a/tests/benchmark_new/NEON/PoolingLayer.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/system_tests/alexnet/AlexNetPoolingLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1PoolingLayerDataset.h" -#include "tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4PoolingLayerDataset.h" -#include "tests/datasets_new/system_tests/lenet5/LeNet5PoolingLayerDataset.h" -#include "tests/datasets_new/system_tests/squeezenet/SqueezeNetPoolingLayerDataset.h" -#include "tests/datasets_new/system_tests/vgg/vgg16/VGG16PoolingLayerDataset.h" -#include "tests/datasets_new/system_tests/yolo/v2/YOLOV2PoolingLayerDataset.h" -#include "tests/fixtures_new/PoolingLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 -const auto data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8 }); -#else /* ARM_COMPUTE_ENABLE_FP16 */ -const auto data_types = framework::dataset::make("DataType", { DataType::F32, DataType::QS8 }); -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -} // namespace - -using NEPoolingLayerFixture = PoolingLayerFixture; - -TEST_SUITE(NEON) - -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetPoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetPoolingLayerDataset(), data_types), framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::LeNet5PoolingLayerDataset(), data_types), framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1PoolingLayerDataset(), data_types), framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4PoolingLayerDataset(), data_types), framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetPoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetPoolingLayerDataset(), data_types), framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(VGG16PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::VGG16PoolingLayerDataset(), data_types), framework::dataset::make("Batches", 1))); - -REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2PoolingLayerDataset(), data_types), framework::dataset::make("Batches", 1))); - -TEST_SUITE(NIGHTLY) -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNetPoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::AlexNetPoolingLayerDataset(), data_types), framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::LeNet5PoolingLayerDataset(), data_types), framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV1PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV1PoolingLayerDataset(), data_types), framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(GoogLeNetInceptionV4PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::GoogLeNetInceptionV4PoolingLayerDataset(), data_types), framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(SqueezeNetPoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::SqueezeNetPoolingLayerDataset(), data_types), framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(VGG16PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::VGG16PoolingLayerDataset(), data_types), framework::dataset::make("Batches", { 4, 8 }))); - -REGISTER_FIXTURE_DATA_TEST_CASE(YOLOV2PoolingLayer, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, - framework::dataset::combine(framework::dataset::combine(datasets::YOLOV2PoolingLayerDataset(), data_types), framework::dataset::make("Batches", { 4, 8 }))); -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/ROIPoolingLayer.cpp b/tests/benchmark_new/NEON/ROIPoolingLayer.cpp deleted file mode 100644 index e8c5ba3109..0000000000 --- a/tests/benchmark_new/NEON/ROIPoolingLayer.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Array.h" -#include "arm_compute/runtime/NEON/functions/NEROIPoolingLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/NEON/ArrayAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/datasets_new/ROIPoolingLayerDataset.h" -#include "tests/fixtures_new/ROIPoolingLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -using NEROIPoolingLayerFixture = ROIPoolingLayerFixture, ArrayAccessor>; - -TEST_SUITE(NEON) - -REGISTER_FIXTURE_DATA_TEST_CASE(SmallROIPoolingLayer, NEROIPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::SmallROIPoolingLayerDataset(), - framework::dataset::make("DataType", { DataType::F32 })), - framework::dataset::make("Batches", { 1, 4, 8 }))); - -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/SYSTEM/AlexNet.cpp b/tests/benchmark_new/NEON/SYSTEM/AlexNet.cpp deleted file mode 100644 index 5a0cb3cb5b..0000000000 --- a/tests/benchmark_new/NEON/SYSTEM/AlexNet.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" -#include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" -#include "arm_compute/runtime/NEON/functions/NEDirectConvolutionLayer.h" -#include "arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h" -#include "arm_compute/runtime/NEON/functions/NENormalizationLayer.h" -#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" -#include "arm_compute/runtime/NEON/functions/NESoftmaxLayer.h" -#include "arm_compute/runtime/SubTensor.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/TypePrinter.h" -#include "tests/fixtures_new/AlexNetFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 -const auto alex_net_data_types = framework::dataset::make("DataType", { DataType::F16, DataType::F32, DataType::QS8 }); -#else /* ARM_COMPUTE_ENABLE_FP16 */ -const auto alex_net_data_types = framework::dataset::make("DataType", { DataType::F32, DataType::QS8 }); -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -} // namespace - -using NEAlexNetFixture = AlexNetFixture; - -TEST_SUITE(NEON) -TEST_SUITE(SYSTEM_TEST) - -REGISTER_FIXTURE_DATA_TEST_CASE(AlexNet, NEAlexNetFixture, framework::DatasetMode::ALL, - framework::dataset::combine(alex_net_data_types, - framework::dataset::make("Batches", { 1, 4, 8 }))); - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/benchmark_new/NEON/SYSTEM/LeNet5.cpp b/tests/benchmark_new/NEON/SYSTEM/LeNet5.cpp deleted file mode 100644 index 2375c52a1c..0000000000 --- a/tests/benchmark_new/NEON/SYSTEM/LeNet5.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" -#include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" -#include "arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h" -#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" -#include "arm_compute/runtime/NEON/functions/NESoftmaxLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/TypePrinter.h" -#include "tests/fixtures_new/LeNet5Fixture.h" - -namespace arm_compute -{ -namespace test -{ -using NELeNet5Fixture = LeNet5Fixture; - -TEST_SUITE(NEON) -TEST_SUITE(SYSTEM_TEST) - -REGISTER_FIXTURE_DATA_TEST_CASE(LeNet5, NELeNet5Fixture, framework::DatasetMode::ALL, - framework::dataset::make("Batches", { 1, 4, 8 })); - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace test -} // namespace arm_compute diff --git a/tests/boost_wrapper.h b/tests/boost_wrapper.h deleted file mode 100644 index b584e4cd1f..0000000000 --- a/tests/boost_wrapper.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Woverloaded-virtual" -#pragma GCC diagnostic ignored "-Weffc++" -#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" -#pragma GCC diagnostic ignored "-Wunused-variable" -#pragma GCC diagnostic ignored "-Wsign-compare" -#include "boost/test/unit_test.hpp" -#include "boost/variant.hpp" -#include "boost/variant/multivisitors.hpp" -#pragma GCC diagnostic pop - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Weffc++" -#include "boost/test/data/test_case.hpp" -#pragma GCC diagnostic pop - -#include "boost/test/data/monomorphic.hpp" diff --git a/tests/dataset/ActivationFunctionDataset.h b/tests/dataset/ActivationFunctionDataset.h deleted file mode 100644 index e6c196560b..0000000000 --- a/tests/dataset/ActivationFunctionDataset.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_DATASET_ACTIVATION_FUNCTION_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_ACTIVATION_FUNCTION_DATASET_H__ - -#include "arm_compute/core/Types.h" -#include "dataset/GenericDataset.h" - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible activation functions. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on all activation functions. - */ -class ActivationFunctions final : public GenericDataset -{ -public: - ActivationFunctions() - : GenericDataset - { - ActivationLayerInfo::ActivationFunction::ABS, - ActivationLayerInfo::ActivationFunction::LINEAR, - ActivationLayerInfo::ActivationFunction::LOGISTIC, - ActivationLayerInfo::ActivationFunction::RELU, - ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, - ActivationLayerInfo::ActivationFunction::LEAKY_RELU, - ActivationLayerInfo::ActivationFunction::SOFT_RELU, - ActivationLayerInfo::ActivationFunction::SQRT, - ActivationLayerInfo::ActivationFunction::SQUARE, - ActivationLayerInfo::ActivationFunction::TANH - } - { - } - - ~ActivationFunctions() = default; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DATASET_ACTIVATION_FUNCTION_DATASET_H__ */ diff --git a/tests/dataset/ActivationLayerDataset.h b/tests/dataset/ActivationLayerDataset.h deleted file mode 100644 index ef6f382f97..0000000000 --- a/tests/dataset/ActivationLayerDataset.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_DATASET_ACTIVATION_LAYER_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_ACTIVATION_LAYER_DATASET_H__ - -#include "TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "dataset/GenericDataset.h" - -#include -#include - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -class ActivationLayerDataObject -{ -public: - operator std::string() const - { - std::stringstream ss; - ss << "ActivationLayer"; - ss << "_I" << shape; - ss << "_F_" << info.activation(); - return ss.str(); - } - -public: - TensorShape shape; - ActivationLayerInfo info; -}; - -template -using ActivationLayerDataset = GenericDataset; - -class AlexNetActivationLayerDataset final : public ActivationLayerDataset<5> -{ -public: - AlexNetActivationLayerDataset() - : GenericDataset - { - ActivationLayerDataObject{ TensorShape(55U, 55U, 96U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - ActivationLayerDataObject{ TensorShape(27U, 27U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - ActivationLayerDataObject{ TensorShape(13U, 13U, 384U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - ActivationLayerDataObject{ TensorShape(13U, 13U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - ActivationLayerDataObject{ TensorShape(4096U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - } - { - } - - ~AlexNetActivationLayerDataset() = default; -}; - -class LeNet5ActivationLayerDataset final : public ActivationLayerDataset<1> -{ -public: - LeNet5ActivationLayerDataset() - : GenericDataset - { - ActivationLayerDataObject{ TensorShape(500U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - } - { - } - - ~LeNet5ActivationLayerDataset() = default; -}; - -class GoogLeNetActivationLayerDataset final : public ActivationLayerDataset<33> -{ -public: - GoogLeNetActivationLayerDataset() - : GenericDataset - { - // conv1/relu_7x7 - ActivationLayerDataObject{ TensorShape(112U, 112U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // conv2/relu_3x3_reduce - ActivationLayerDataObject{ TensorShape(56U, 56U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // conv2/relu_3x3 - ActivationLayerDataObject{ TensorShape(56U, 56U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_3a/relu_1x1, inception_3b/relu_pool_proj - ActivationLayerDataObject{ TensorShape(28U, 28U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_3a/relu_3x3_reduce, inception_3b/relu_5x5 - ActivationLayerDataObject{ TensorShape(28U, 28U, 96U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_3a/relu_3x3, inception_3b/relu_1x1, inception_3b/relu_3x3_reduce - ActivationLayerDataObject{ TensorShape(28U, 28U, 128U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_3a/relu_5x5_reduce - ActivationLayerDataObject{ TensorShape(28U, 28U, 16U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_3a/relu_5x5, inception_3a/relu_pool_proj, inception_3b/relu_5x5_reduce - ActivationLayerDataObject{ TensorShape(28U, 28U, 32U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_3b/relu_3x3 - ActivationLayerDataObject{ TensorShape(28U, 28U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4a/relu_1x1 - ActivationLayerDataObject{ TensorShape(14U, 14U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4a/relu_3x3_reduce - ActivationLayerDataObject{ TensorShape(14U, 14U, 96U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4a/relu_3x3 - ActivationLayerDataObject{ TensorShape(14U, 14U, 208U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4a/relu_5x5_reduce - ActivationLayerDataObject{ TensorShape(14U, 14U, 16U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4a/relu_5x5 - ActivationLayerDataObject{ TensorShape(14U, 14U, 48U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4a/relu_pool_proj, inception_4b/relu_5x5, inception_4b/relu_pool_proj, inception_4c/relu_5x5, inception_4c/relu_pool_proj, inception_4d/relu_5x5, inception_4d/relu_pool_proj - ActivationLayerDataObject{ TensorShape(14U, 14U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4b/relu_1x1, inception_4e/relu_3x3_reduce - ActivationLayerDataObject{ TensorShape(14U, 14U, 160U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4b/relu_3x3_reduce, inception_4d/relu_1x1 - ActivationLayerDataObject{ TensorShape(14U, 14U, 112U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4b/relu_3x3 - ActivationLayerDataObject{ TensorShape(14U, 14U, 224U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4b/relu_5x5_reduce, inception_4c/relu_5x5_reduce - ActivationLayerDataObject{ TensorShape(14U, 14U, 24U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4c/relu_1x1, inception_4c/relu_3x3_reduce, inception_4e/relu_5x5, inception_4e/relu_pool_proj - ActivationLayerDataObject{ TensorShape(14U, 14U, 128U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4c/relu_3x3, inception_4e/relu_1x1 - ActivationLayerDataObject{ TensorShape(14U, 14U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4d/relu_3x3_reduce - ActivationLayerDataObject{ TensorShape(14U, 14U, 144U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4d/relu_3x3 - ActivationLayerDataObject{ TensorShape(14U, 14U, 288U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4d/relu_5x5_reduce, inception_4e/relu_5x5_reduce - ActivationLayerDataObject{ TensorShape(14U, 14U, 32U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4e/relu_3x3 - ActivationLayerDataObject{ TensorShape(14U, 14U, 320U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_5a/relu_1x1 - ActivationLayerDataObject{ TensorShape(7U, 7U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_5a/relu_3x3_reduce - ActivationLayerDataObject{ TensorShape(7U, 7U, 160U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_5a/relu_3x3 - ActivationLayerDataObject{ TensorShape(7U, 7U, 320U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_5a/relu_5x5_reduce - ActivationLayerDataObject{ TensorShape(7U, 7U, 32U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_5a/relu_5x5, inception_5a/relu_pool_proj, inception_5b/relu_5x5, inception_5b/relu_pool_proj - ActivationLayerDataObject{ TensorShape(7U, 7U, 128U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_5b/relu_1x1, inception_5b/relu_3x3 - ActivationLayerDataObject{ TensorShape(7U, 7U, 384U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_5b/relu_3x3_reduce - ActivationLayerDataObject{ TensorShape(7U, 7U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_5b/relu_5x5_reduce - ActivationLayerDataObject{ TensorShape(7U, 7U, 48U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) } - } - { - } - - ~GoogLeNetActivationLayerDataset() = default; -}; - -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_DATASET_ACTIVATION_LAYER_DATASET_H__ diff --git a/tests/dataset/BatchNormalizationLayerDataset.h b/tests/dataset/BatchNormalizationLayerDataset.h deleted file mode 100644 index f1ba212b97..0000000000 --- a/tests/dataset/BatchNormalizationLayerDataset.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_DATASET_BATCH_NORMALIZATION_LAYER_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_BATCH_NORMALIZATION_LAYER_DATASET_H__ - -#include "TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "dataset/GenericDataset.h" - -#include -#include - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -class BatchNormalizationLayerDataObject -{ -public: - operator std::string() const - { - std::stringstream ss; - ss << "BatchNormalizationLayer"; - ss << "_I" << shape0; - ss << "_I" << shape1; - ss << "_I" << epsilon; - return ss.str(); - } - - friend std::ostream &operator<<(std::ostream &s, const BatchNormalizationLayerDataObject &obj) - { - s << static_cast(obj); - return s; - } - -public: - TensorShape shape0; - TensorShape shape1; - float epsilon; -}; - -template -using BatchNormalizationLayerDataset = GenericDataset; - -class RandomBatchNormalizationLayerDataset final : public BatchNormalizationLayerDataset<3> -{ -public: - RandomBatchNormalizationLayerDataset() - : GenericDataset - { - BatchNormalizationLayerDataObject{ TensorShape(15U, 16U, 2U, 12U), TensorShape(2U), 0.1f }, - BatchNormalizationLayerDataObject{ TensorShape(21U, 11U, 12U, 7U), TensorShape(12U), 0.1f }, - BatchNormalizationLayerDataObject{ TensorShape(7U, 3U, 6U, 11U), TensorShape(6U), 0.1f }, - } - { - } - - ~RandomBatchNormalizationLayerDataset() = default; -}; - -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_DATASET_BATCH_NORMALIZATION_LAYER_DATASET_H__ diff --git a/tests/dataset/BorderModeDataset.h b/tests/dataset/BorderModeDataset.h deleted file mode 100644 index debf7bdf00..0000000000 --- a/tests/dataset/BorderModeDataset.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_BORDER_MODE_DATASET_H__ -#define __ARM_COMPUTE_TEST_BORDER_MODE_DATASET_H__ - -#include "arm_compute/core/Types.h" - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -#include - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible border modes. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on all border modes. - */ -class BorderModes -{ -public: - /** Type of the samples in the data set. */ - using sample = BorderMode; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _modes.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const BorderMode *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _modes.data(); - } - -private: - std::array _modes{ { BorderMode::UNDEFINED, BorderMode::CONSTANT, BorderMode::REPLICATE } }; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_BORDER_MODE_DATASET_H__ */ diff --git a/tests/dataset/ConvertPolicyDataset.h b/tests/dataset/ConvertPolicyDataset.h deleted file mode 100644 index bca033e515..0000000000 --- a/tests/dataset/ConvertPolicyDataset.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_CONVERT_POLICY_DATASETS_H__ -#define __ARM_COMPUTE_TEST_CONVERT_POLICY_DATASETS_H__ - -#include "arm_compute/core/Types.h" - -#include - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible convert/overflow policies. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on different convert policies. - */ -class ConvertPolicies -{ -public: - /** Type of the samples in the data set. */ - using sample = ConvertPolicy; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _policies.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const ConvertPolicy *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _policies.data(); - } - -private: - std::array _policies{ { ConvertPolicy::WRAP, ConvertPolicy::SATURATE } }; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_CONVERT_POLICY_DATASETS_H__ */ diff --git a/tests/dataset/ConvolutionLayerDataset.h b/tests/dataset/ConvolutionLayerDataset.h deleted file mode 100644 index 3d8ec4a2d9..0000000000 --- a/tests/dataset/ConvolutionLayerDataset.h +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_DATASET_CONVOLUTION_LAYER_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_CONVOLUTION_LAYER_DATASET_H__ - -#include "TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "dataset/GenericDataset.h" -#include "dataset/ShapeDatasets.h" - -#include -#include - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Convolution Layer data object */ -class ConvolutionLayerDataObject -{ -public: - operator std::string() const - { - std::stringstream ss; - ss << "ConvolutionLayer"; - ss << "_I" << src_shape; - ss << "_K" << weights_shape; - ss << "_PS" << info; - return ss.str(); - } - - friend std::ostream &operator<<(std::ostream &os, const ConvolutionLayerDataObject &obj) - { - os << static_cast(obj); - return os; - } - -public: - TensorShape src_shape; - TensorShape weights_shape; - TensorShape bias_shape; - TensorShape dst_shape; - PadStrideInfo info; -}; - -template -using ConvolutionLayerDataset = GenericDataset; - -/** Data set containing small convolution layer shapes */ -class SmallConvolutionLayerDataset final : public ConvolutionLayerDataset<6> -{ -public: - SmallConvolutionLayerDataset() - : GenericDataset - { - ConvolutionLayerDataObject{ TensorShape(23U, 27U, 5U), TensorShape(3U, 3U, 5U, 21U), TensorShape(21U), TensorShape(11U, 25U, 21U), PadStrideInfo(2, 1, 0, 0) }, - ConvolutionLayerDataObject{ TensorShape(33U, 27U, 7U), TensorShape(5U, 5U, 7U, 16U), TensorShape(16U), TensorShape(11U, 12U, 16U), PadStrideInfo(3, 2, 1, 0) }, - ConvolutionLayerDataObject{ TensorShape(17U, 31U, 2U, 7U), TensorShape(5U, 5U, 2U, 19U), TensorShape(19U), TensorShape(15U, 15U, 19U, 7U), PadStrideInfo(1, 2, 1, 1) }, - ConvolutionLayerDataObject{ TensorShape(23U, 27U, 5U), TensorShape(3U, 1U, 5U, 21U), TensorShape(21U), TensorShape(11U, 27U, 21U), PadStrideInfo(2, 1, 0, 0) }, - ConvolutionLayerDataObject{ TensorShape(33U, 27U, 7U), TensorShape(5U, 7U, 7U, 16U), TensorShape(16U), TensorShape(11U, 11U, 16U), PadStrideInfo(3, 2, 1, 0) }, - ConvolutionLayerDataObject{ TensorShape(17U, 31U, 2U, 7U), TensorShape(5U, 3U, 2U, 19U), TensorShape(19U), TensorShape(15U, 16U, 19U, 7U), PadStrideInfo(1, 2, 1, 1) } - } - { - } - - ~SmallConvolutionLayerDataset() = default; -}; - -/** Data set containing direct convolution tensor shapes. */ -class DirectConvolutionShapes final : public ShapeDataset<4> -{ -public: - DirectConvolutionShapes() - : ShapeDataset(TensorShape(3U, 3U, 3U, 2U, 4U, 5U), - TensorShape(32U, 37U, 3U), - TensorShape(64U, 32U, 4U, 2U), - TensorShape(13U, 15U, 8U, 3U)) - { - } -}; - -/** AlexNet's convolution layers tensor shapes. */ -class AlexNetConvolutionLayerDataset final : public ConvolutionLayerDataset<5> -{ -public: - AlexNetConvolutionLayerDataset() - : GenericDataset - { - ConvolutionLayerDataObject{ TensorShape(227U, 227U, 3U), TensorShape(11U, 11U, 3U, 96U), TensorShape(96U), TensorShape(55U, 55U, 96U), PadStrideInfo(4, 4, 0, 0) }, - ConvolutionLayerDataObject{ TensorShape(27U, 27U, 96U), TensorShape(5U, 5U, 96U, 256U), TensorShape(256U), TensorShape(27U, 27U, 256U), PadStrideInfo(1, 1, 2, 2) }, - ConvolutionLayerDataObject{ TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1) }, - ConvolutionLayerDataObject{ TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1) }, - ConvolutionLayerDataObject{ TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U), PadStrideInfo(1, 1, 1, 1) } - } - { - } - - ~AlexNetConvolutionLayerDataset() = default; -}; - -/** LeNet5's convolution layers tensor shapes. */ -class LeNet5ConvolutionLayerDataset final : public ConvolutionLayerDataset<2> -{ -public: - LeNet5ConvolutionLayerDataset() - : GenericDataset - { - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 1U), TensorShape(5U, 5U, 1U, 20U), TensorShape(20U), TensorShape(24U, 24U, 20U), PadStrideInfo(1, 1, 0, 0) }, - ConvolutionLayerDataObject{ TensorShape(12U, 12U, 20U), TensorShape(5U, 5U, 20U, 50U), TensorShape(50U), TensorShape(8U, 8U, 50U), PadStrideInfo(1, 1, 0, 0) }, - } - { - } - - ~LeNet5ConvolutionLayerDataset() = default; -}; - -/** GoogleLeNet v1 convolution layers tensor shapes (Part 1). - * - * @note Dataset is split into two to avoid a register allocation failure produced by clang in Android debug builds. - */ -class GoogLeNetConvolutionLayerDataset1 final : public ConvolutionLayerDataset<32> -{ -public: - GoogLeNetConvolutionLayerDataset1() - : GenericDataset - { - // conv1/7x7_s2 - ConvolutionLayerDataObject{ TensorShape(224U, 224U, 3U), TensorShape(7U, 7U, 3U, 64U), TensorShape(64U), TensorShape(112U, 112U, 64U), PadStrideInfo(2, 2, 3, 3) }, - // conv2/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(56U, 56U, 64U), TensorShape(1U, 1U, 64U, 64U), TensorShape(64U), TensorShape(56U, 56U, 64U), PadStrideInfo(1, 1, 0, 0) }, - // conv2/3x3 - ConvolutionLayerDataObject{ TensorShape(56U, 56U, 64U), TensorShape(3U, 3U, 64U, 192U), TensorShape(192U), TensorShape(56U, 56U, 192U), PadStrideInfo(1, 1, 1, 1) }, - // inception_3a/1x1 - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0) }, - // inception_3a/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 96U), TensorShape(96U), TensorShape(28U, 28U, 96U), PadStrideInfo(1, 1, 0, 0) }, - // inception_3a/3x3 - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 96U), TensorShape(3U, 3U, 96U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 1, 1) }, - // inception_3a/5x5_reduce - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 16U), TensorShape(16U), TensorShape(28U, 28U, 16U), PadStrideInfo(1, 1, 0, 0) }, - // inception_3a/5x5 - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 16U), TensorShape(5U, 5U, 16U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 2, 2) }, - // inception_3a/pool_proj - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0) }, - // inception_3b/1x1, inception_3b/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 0, 0) }, - // inception_3b/3x3 - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 128U), TensorShape(3U, 3U, 128U, 192U), TensorShape(192U), TensorShape(28U, 28U, 192U), PadStrideInfo(1, 1, 1, 1) }, - // inception_3b/5x5_reduce - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0) }, - // inception_3b/5x5 - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 32U), TensorShape(5U, 5U, 32U, 96U), TensorShape(96U), TensorShape(28U, 28U, 96U), PadStrideInfo(1, 1, 2, 2) }, - // inception_3b/pool_proj - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4a/1x1 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 192U), TensorShape(192U), TensorShape(14U, 14U, 192U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4a/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 96U), TensorShape(96U), TensorShape(14U, 14U, 96U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4a/3x3 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 96U), TensorShape(3U, 3U, 96U, 208U), TensorShape(208U), TensorShape(14U, 14U, 208U), PadStrideInfo(1, 1, 1, 1) }, - // inception_4a/5x5_reduce - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 16U), TensorShape(16U), TensorShape(14U, 14U, 16U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4a/5x5 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 16U), TensorShape(5U, 5U, 16U, 48U), TensorShape(48U), TensorShape(14U, 14U, 48U), PadStrideInfo(1, 1, 2, 2) }, - // inception_4a/pool_proj - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4b/1x1 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4b/3x3_reduce, inception_4d/1x1 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 112U), TensorShape(112U), TensorShape(14U, 14U, 112U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4b/3x3 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 112U), TensorShape(3U, 3U, 112U, 224U), TensorShape(224U), TensorShape(14U, 14U, 224U), PadStrideInfo(1, 1, 1, 1) }, - // inception_4b/5x5_reduce, inception_4c/5x5_reduce - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 24U), TensorShape(24U), TensorShape(14U, 14U, 24U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4b/5x5, inception_4c/5x5 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 24U), TensorShape(5U, 5U, 24U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 2, 2) }, - // inception_4b/pool_proj, inception_4c/pool_proj, inception_4d/pool_proj - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4c/1x1, inception_4c/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4c/3x3 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 128U), TensorShape(3U, 3U, 128U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 1, 1) }, - // inception_4d/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 144U), TensorShape(144U), TensorShape(14U, 14U, 144U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4d/3x3 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 144U), TensorShape(3U, 3U, 144U, 288U), TensorShape(288U), TensorShape(14U, 14U, 288U), PadStrideInfo(1, 1, 1, 1) }, - // inception_4d/5x5_reduce - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4d/5x5 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 32U), TensorShape(5U, 5U, 32U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 2, 2) }, - } - { - } - - ~GoogLeNetConvolutionLayerDataset1() = default; -}; - -/** GoogleLeNet v1 convolution layers tensor shapes (Part 2). */ -class GoogLeNetConvolutionLayerDataset2 final : public ConvolutionLayerDataset<17> -{ -public: - GoogLeNetConvolutionLayerDataset2() - : GenericDataset - { - // inception_4e/1x1 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4e/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4e/3x3 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(14U, 14U, 320U), PadStrideInfo(1, 1, 1, 1) }, - // inception_4e/5x5_reduce - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4e/5x5 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 32U), TensorShape(5U, 5U, 32U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 2, 2) }, - // inception_4e/pool_proj - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0) }, - // inception_5a/1x1 - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 256U), TensorShape(256U), TensorShape(7U, 7U, 256U), PadStrideInfo(1, 1, 0, 0) }, - // inception_5a/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 160U), TensorShape(160U), TensorShape(7U, 7U, 160U), PadStrideInfo(1, 1, 0, 0) }, - // inception_5a/3x3 - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(7U, 7U, 320U), PadStrideInfo(1, 1, 1, 1) }, - // inception_5a/5x5_reduce - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 32U), TensorShape(32U), TensorShape(7U, 7U, 32U), PadStrideInfo(1, 1, 0, 0) }, - // inception_5a/5x5 - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 32U), TensorShape(5U, 5U, 32U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 2, 2) }, - // inception_5a/pool_proj, inception_5b/pool_proj - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 0, 0) }, - // inception_5b/1x1 - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 0, 0) }, - // inception_5b/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 192U), TensorShape(192U), TensorShape(7U, 7U, 192U), PadStrideInfo(1, 1, 0, 0) }, - // inception_5b/3x3 - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 192U), TensorShape(3U, 3U, 192U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 1, 1) }, - // inception_5b/5x5_reduce - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 48U), TensorShape(48U), TensorShape(7U, 7U, 48U), PadStrideInfo(1, 1, 0, 0) }, - // inception_5b/5x5 - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 48U), TensorShape(5U, 5U, 48U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 2, 2) } - } - { - } - - ~GoogLeNetConvolutionLayerDataset2() = default; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DATASET_CONVOLUTION_LAYER_DATASET_H__ */ diff --git a/tests/dataset/DataTypeDatasets.h b/tests/dataset/DataTypeDatasets.h deleted file mode 100644 index 5f313711c0..0000000000 --- a/tests/dataset/DataTypeDatasets.h +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_DATA_TYPE_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATA_TYPE_DATASET_H__ - -#include "arm_compute/core/Types.h" - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Abstract data set containing data types. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on different data types. - */ -template -class DataTypes -{ -public: - /** Type of the samples in the data set. */ - using sample = DataType; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _types.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const DataType *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _types.data(); - } - -protected: - /** Protected constructor to make the class abstract. */ - template - DataTypes(Ts &&... types) - : _types{ { types... } } - { - } - - /** Protected destructor to prevent deletion of derived classes through a - * pointer to the base class. - */ - ~DataTypes() = default; - -private: - std::array _types; -}; - -/** Data set containing all data types. */ -class AllDataTypes final : public DataTypes<14> -{ -public: - AllDataTypes() - : DataTypes{ DataType::U8, DataType::S8, DataType::U16, DataType::S16, - DataType::U32, DataType::S32, DataType::U64, DataType::S64, - DataType::F16, DataType::F32, DataType::F64, DataType::SIZET, - DataType::QS8, DataType::QS16 } - { - } - - ~AllDataTypes() = default; -}; - -/** Data set containing all unsigned data types. */ -class UnsignedDataTypes final : public DataTypes<4> -{ -public: - UnsignedDataTypes() - : DataTypes{ DataType::U8, DataType::U16, DataType::U32, DataType::U64 } - { - } - - ~UnsignedDataTypes() = default; -}; - -/** Data set containing all signed data types. */ -class SignedDataTypes final : public DataTypes<4> -{ -public: - SignedDataTypes() - : DataTypes{ DataType::S8, DataType::S16, DataType::S32, DataType::S64 } - { - } - - ~SignedDataTypes() = default; -}; - -/** Data set containing all floating point data types. */ -class FloatDataTypes final : public DataTypes<3> -{ -public: - FloatDataTypes() - : DataTypes{ DataType::F16, DataType::F32, DataType::F64 } - { - } - - ~FloatDataTypes() = default; -}; - -/** Data set containing all fixed point data types. */ -class FixedPointDataTypes final : public DataTypes<2> -{ -public: - FixedPointDataTypes() - : DataTypes{ DataType::QS8, DataType::QS16 } - { - } - - ~FixedPointDataTypes() = default; -}; - -/** Supported CNN float types. */ -class CNNFloatDataTypes final : public DataTypes<1> -{ -public: - CNNFloatDataTypes() - : DataTypes{ DataType::F32 } - { - } - - ~CNNFloatDataTypes() = default; -}; - -/** Supported CNN fixed point types. */ -class CNNFixedPointDataTypes final : public DataTypes<2> -{ -public: - CNNFixedPointDataTypes() - : DataTypes{ DataType::QS8, DataType::QS16 } - { - } - - ~CNNFixedPointDataTypes() = default; -}; - -/** Supported CNN types. */ -class CNNDataTypes final : public DataTypes<2> -{ -public: - CNNDataTypes() - : DataTypes{ DataType::F32, DataType::QS8 } - { - } - - ~CNNDataTypes() = default; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DATA_TYPE_DATASET_H__ */ diff --git a/tests/dataset/FullyConnectedLayerDataset.h b/tests/dataset/FullyConnectedLayerDataset.h deleted file mode 100644 index cf43a6302a..0000000000 --- a/tests/dataset/FullyConnectedLayerDataset.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_DATASET_FULLY_CONNECTED_LAYER_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_FULLY_CONNECTED_LAYER_DATASET_H__ - -#include "TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "dataset/GenericDataset.h" - -#include -#include - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -class FullyConnectedLayerDataObject -{ -public: - operator std::string() const - { - std::stringstream ss; - ss << "FullyConnectedLayer"; - ss << "_I" << src_shape; - ss << "_K" << weights_shape; - return ss.str(); - } - - friend std::ostream &operator<<(std::ostream &os, const FullyConnectedLayerDataObject &obj) - { - os << static_cast(obj); - return os; - } - -public: - TensorShape src_shape; - TensorShape weights_shape; - TensorShape bias_shape; - TensorShape dst_shape; - bool transpose_weights; - bool are_weights_reshaped; -}; - -template -using FullyConnectedLayerDataset = GenericDataset; - -class SmallFullyConnectedLayerDataset final : public FullyConnectedLayerDataset<5> -{ -public: - SmallFullyConnectedLayerDataset() - : GenericDataset - { - FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 7U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U), true, false }, - FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 7U, 3U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U, 3U), true, false }, - FullyConnectedLayerDataObject{ TensorShape(201U), TensorShape(201U, 529U), TensorShape(529U), TensorShape(529U), true, false }, - FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 7U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U), true, true }, - FullyConnectedLayerDataObject{ TensorShape(201U), TensorShape(201U, 529U), TensorShape(529U), TensorShape(529U), true, true }, - } - { - } - - ~SmallFullyConnectedLayerDataset() = default; -}; - -class LargeFullyConnectedLayerDataset final : public FullyConnectedLayerDataset<5> -{ -public: - LargeFullyConnectedLayerDataset() - : GenericDataset - { - FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 257U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U), true, false }, - FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 257U, 2U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U, 2U), true, false }, - FullyConnectedLayerDataObject{ TensorShape(3127U), TensorShape(3127U, 989U), TensorShape(989U), TensorShape(989U), true, false }, - FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 257U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U), true, true }, - FullyConnectedLayerDataObject{ TensorShape(3127U), TensorShape(3127U, 989U), TensorShape(989U), TensorShape(989U), true, true }, - } - { - } - - ~LargeFullyConnectedLayerDataset() = default; -}; - -class AlexNetFullyConnectedLayerDataset final : public FullyConnectedLayerDataset<3> -{ -public: - AlexNetFullyConnectedLayerDataset() - : GenericDataset - { - FullyConnectedLayerDataObject{ TensorShape(6U, 6U, 256U), TensorShape(9216U, 4096U), TensorShape(4096U), TensorShape(4096U), true }, - FullyConnectedLayerDataObject{ TensorShape(4096U), TensorShape(4096U, 4096U), TensorShape(4096U), TensorShape(4096U), true }, - FullyConnectedLayerDataObject{ TensorShape(4096U), TensorShape(4096U, 1000U), TensorShape(1000U), TensorShape(1000U), true }, - } - { - } - - ~AlexNetFullyConnectedLayerDataset() = default; -}; - -class LeNet5FullyConnectedLayerDataset final : public FullyConnectedLayerDataset<2> -{ -public: - LeNet5FullyConnectedLayerDataset() - : GenericDataset - { - FullyConnectedLayerDataObject{ TensorShape(4U, 4U, 50U), TensorShape(800U, 500U), TensorShape(500U), TensorShape(500U) }, - FullyConnectedLayerDataObject{ TensorShape(500U), TensorShape(500U, 10U), TensorShape(10U), TensorShape(10U) }, - } - { - } - - ~LeNet5FullyConnectedLayerDataset() = default; -}; - -class GoogLeNetFullyConnectedLayerDataset final : public FullyConnectedLayerDataset<1> -{ -public: - GoogLeNetFullyConnectedLayerDataset() - : GenericDataset - { - FullyConnectedLayerDataObject{ TensorShape(1024U), TensorShape(1024U, 1000U), TensorShape(1000U), TensorShape(1000U), true }, - } - { - } - - ~GoogLeNetFullyConnectedLayerDataset() = default; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DATASET_FULLY_CONNECTED_LAYER_DATASET_H__ */ diff --git a/tests/dataset/GEMMDataset.h b/tests/dataset/GEMMDataset.h deleted file mode 100644 index ce05557231..0000000000 --- a/tests/dataset/GEMMDataset.h +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_DATASET_GEMM_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_GEMM_DATASET_H__ - -#include "TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "dataset/GenericDataset.h" - -#include -#include - -#include -#include - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -class GEMMDataObject -{ -public: - //Data object used for matrix multiple - //D = alpha * A * B + beta * C; - TensorShape shape_a; - TensorShape shape_b; - TensorShape shape_c; - TensorShape shape_d; - float alpha; - float beta; - - operator std::string() const - { - std::stringstream ss; - ss << "GEMM"; - ss << "_A" << shape_a; - ss << "_B" << shape_b; - ss << "_C" << shape_c; - ss << "_D" << shape_d; - ss << "_alpha" << alpha; - ss << "_beta" << beta; - return ss.str(); - } - - friend std::ostream &operator<<(std::ostream &os, const GEMMDataObject &obj) - { - os << static_cast(obj); - return os; - } -}; - -class SmallGEMMDataset : public GenericDataset -{ -public: - SmallGEMMDataset() - : GenericDataset - { - GEMMDataObject{ TensorShape(21U, 13U), TensorShape(33U, 21U), TensorShape(33U, 13U), TensorShape(33U, 13U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(31U, 1U), TensorShape(23U, 31U), TensorShape(23U, 1U), TensorShape(23U, 1U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(38U, 12U), TensorShape(21U, 38U), TensorShape(21U, 12U), TensorShape(21U, 12U), 0.2f, 1.2f }, - GEMMDataObject{ TensorShape(32U, 1U), TensorShape(17U, 32U), TensorShape(17U, 1U), TensorShape(17U, 1U), 0.4f, 0.7f }, - } - { - } - - ~SmallGEMMDataset() = default; -}; - -class LargeGEMMDataset : public GenericDataset -{ -public: - LargeGEMMDataset() - : GenericDataset - { - GEMMDataObject{ TensorShape(923U, 429U), TensorShape(871U, 923U), TensorShape(871U, 429U), TensorShape(871U, 429U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1021U, 1U), TensorShape(783U, 1021U), TensorShape(783U, 1U), TensorShape(783U, 1U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(681U, 1023U), TensorShape(213U, 681U), TensorShape(213U, 1023U), TensorShape(213U, 1023U), 0.2f, 1.2f }, - GEMMDataObject{ TensorShape(941U, 1U), TensorShape(623U, 941U), TensorShape(623U, 1U), TensorShape(623U, 1U), 0.4f, 0.7f }, - } - { - } - - ~LargeGEMMDataset() = default; -}; - -class GoogLeNetGEMMDataset1 : public GenericDataset -{ -public: - GoogLeNetGEMMDataset1() - : GenericDataset - { - GEMMDataObject{ TensorShape(147U, 12544U), TensorShape(64U, 147U), TensorShape(64U, 12544U), TensorShape(64U, 12544U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(64U, 3136U), TensorShape(64U, 64U), TensorShape(64U, 3136U), TensorShape(64U, 3136U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(576U, 3136U), TensorShape(192U, 576U), TensorShape(192U, 3136U), TensorShape(192U, 3136U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(192U, 784U), TensorShape(64U, 192U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(192U, 784U), TensorShape(96U, 192U), TensorShape(96U, 784U), TensorShape(96U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(864U, 784U), TensorShape(128U, 864U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(192U, 784U), TensorShape(16U, 192U), TensorShape(16U, 784U), TensorShape(16U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(400U, 784U), TensorShape(32U, 400U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(192U, 784U), TensorShape(32U, 192U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(256U, 784U), TensorShape(128U, 256U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(256U, 784U), TensorShape(128U, 256U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1152U, 784U), TensorShape(192U, 1152U), TensorShape(192U, 784U), TensorShape(192U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(256U, 784U), TensorShape(32U, 256U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(800U, 784U), TensorShape(96U, 800U), TensorShape(96U, 784U), TensorShape(96U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(256U, 784U), TensorShape(64U, 256U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(480U, 196U), TensorShape(192U, 480U), TensorShape(192U, 196U), TensorShape(192U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(480U, 196U), TensorShape(96U, 480U), TensorShape(96U, 196U), TensorShape(96U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(864U, 196U), TensorShape(204U, 864U), TensorShape(204U, 196U), TensorShape(204U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(480U, 196U), TensorShape(16U, 480U), TensorShape(16U, 196U), TensorShape(16U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(400U, 196U), TensorShape(48U, 400U), TensorShape(48U, 196U), TensorShape(48U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(480U, 196U), TensorShape(64U, 480U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(508U, 196U), TensorShape(160U, 508U), TensorShape(160U, 196U), TensorShape(160U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(508U, 196U), TensorShape(112U, 508U), TensorShape(112U, 196U), TensorShape(112U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1008U, 196U), TensorShape(224U, 1008U), TensorShape(224U, 196U), TensorShape(224U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(508U, 196U), TensorShape(24U, 508U), TensorShape(24U, 196U), TensorShape(24U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(600U, 196U), TensorShape(64U, 600U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(508U, 196U), TensorShape(64U, 508U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(512U, 196U), TensorShape(128U, 512U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(512U, 196U), TensorShape(128U, 512U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1152U, 196U), TensorShape(256U, 1152U), TensorShape(256U, 196U), TensorShape(256U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(512U, 196U), TensorShape(24U, 512U), TensorShape(24U, 196U), TensorShape(24U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(600U, 196U), TensorShape(64U, 600U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f } - } - { - } - - ~GoogLeNetGEMMDataset1() = default; -}; - -class GoogLeNetGEMMDataset2 : public GenericDataset -{ -public: - GoogLeNetGEMMDataset2() - : GenericDataset - { - GEMMDataObject{ TensorShape(512U, 196U), TensorShape(64U, 512U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(512U, 196U), TensorShape(112U, 512U), TensorShape(112U, 196U), TensorShape(112U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(512U, 196U), TensorShape(144U, 512U), TensorShape(144U, 196U), TensorShape(144U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1296U, 196U), TensorShape(288U, 1296U), TensorShape(288U, 196U), TensorShape(288U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(512U, 196U), TensorShape(32U, 512U), TensorShape(32U, 196U), TensorShape(32U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(800U, 196U), TensorShape(64U, 800U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(512U, 196U), TensorShape(64U, 512U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(528U, 196U), TensorShape(256U, 528U), TensorShape(256U, 196U), TensorShape(256U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(528U, 196U), TensorShape(160U, 528U), TensorShape(160U, 196U), TensorShape(160U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1440U, 196U), TensorShape(320U, 1440U), TensorShape(320U, 196U), TensorShape(320U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(528U, 196U), TensorShape(32U, 528U), TensorShape(32U, 196U), TensorShape(32U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(800U, 196U), TensorShape(128U, 800U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(528U, 196U), TensorShape(128U, 528U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(832U, 49U), TensorShape(256U, 832U), TensorShape(256U, 49U), TensorShape(256U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(832U, 49U), TensorShape(160U, 832U), TensorShape(160U, 49U), TensorShape(160U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1440U, 49U), TensorShape(320U, 1440U), TensorShape(320U, 49U), TensorShape(320U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(832U, 49U), TensorShape(48U, 832U), TensorShape(48U, 49U), TensorShape(48U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1200U, 49U), TensorShape(128U, 1200U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(832U, 49U), TensorShape(128U, 832U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(832U, 49U), TensorShape(384U, 832U), TensorShape(384U, 49U), TensorShape(384U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(832U, 49U), TensorShape(192U, 832U), TensorShape(192U, 49U), TensorShape(192U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1728U, 49U), TensorShape(384U, 1728U), TensorShape(384U, 49U), TensorShape(384U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(832U, 49U), TensorShape(48U, 832U), TensorShape(48U, 49U), TensorShape(48U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1200U, 49U), TensorShape(128U, 1200U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(832U, 49U), TensorShape(128U, 832U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(508U, 16U), TensorShape(128U, 508U), TensorShape(128U, 16U), TensorShape(128U, 16U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(2048U, 1U), TensorShape(1024U, 2048U), TensorShape(1024U, 1U), TensorShape(1024U, 1U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(528U, 16U), TensorShape(128U, 528U), TensorShape(128U, 16U), TensorShape(128U, 16U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(2048U, 1U), TensorShape(1024U, 2048U), TensorShape(1024U, 1U), TensorShape(1024U, 1U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f } - } - { - } - - ~GoogLeNetGEMMDataset2() = default; -}; - -class MatrixMultiplyDataset : public GenericDataset -{ -public: - MatrixMultiplyDataset() - : GenericDataset - { - GEMMDataObject{ TensorShape(1024U, 1U), TensorShape(1000U, 1024U), TensorShape(1000U, 1U), TensorShape(1000U, 1U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(256U, 784U), TensorShape(64U, 256U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1152U, 2704U), TensorShape(256U, 1152U), TensorShape(256U, 2704U), TensorShape(256U, 2704U), 1.0f, 0.0f }, - } - { - } - - ~MatrixMultiplyDataset() = default; -}; -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_DATASET_GEMM_DATASET_H__ diff --git a/tests/dataset/GenericDataset.h b/tests/dataset/GenericDataset.h deleted file mode 100644 index 48754fccf8..0000000000 --- a/tests/dataset/GenericDataset.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_DATASET_GENERIC_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_GENERIC_DATASET_H__ - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -#include - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Abstract data set containing multiple objects T. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on different configurations. - */ -template -class GenericDataset -{ -public: - /** Type of the samples in the data set. */ - using sample = T; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _data.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const T *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _data.data(); - } - -protected: - /** Protected constructor to make the class abstract. */ - template - GenericDataset(Ts... objs) - : _data{ { objs... } } - { - } - - /** Protected destructor to prevent deletion of derived class through a - * pointer to the base class. - */ - ~GenericDataset() = default; - -private: - std::array _data; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DATASET_GENERIC_DATASET_H__ */ diff --git a/tests/dataset/ImageDatasets.h b/tests/dataset/ImageDatasets.h deleted file mode 100644 index 6aa25cf942..0000000000 --- a/tests/dataset/ImageDatasets.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_IMAGE_DATASETS_H__ -#define __ARM_COMPUTE_TEST_IMAGE_DATASETS_H__ - -#include -#include - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Abstract data set containing image names. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on different images. - */ -template -class ImageDataset -{ -public: - /** Type of the samples in the data set. */ - using sample = const std::string; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _images.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const std::string *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _images.data(); - } - -protected: - /** Protected constructor to make the class abstract. */ - template - ImageDataset(Ts... images) - : _images{ { images... } } - { - } - - /** Protected destructor to prevent deletion of derived class through a - * pointer to the base class. - */ - ~ImageDataset() = default; - -private: - std::array _images; -}; - -/** Data set containing names of small images. */ -class SmallImages final : public ImageDataset<2> -{ -public: - SmallImages() - : ImageDataset("128x128.ppm", "640x480.ppm") - { - } -}; - -/** Data set containing names of large images. */ -class LargeImages final : public ImageDataset<3> -{ -public: - LargeImages() -#ifdef INTERNAL_ONLY - : ImageDataset("1280x720.ppm", "1920x1080.ppm", "4160x3120.ppm") - // The 4k image is too large to distribute -#else /* INTERNAL_ONLY */ - : ImageDataset("1280x720.ppm", "1920x1080.ppm") -#endif /* INTERNAL_ONLY */ - { - } -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_IMAGE_DATASETS_H__ */ diff --git a/tests/dataset/InterpolationPolicyDataset.h b/tests/dataset/InterpolationPolicyDataset.h deleted file mode 100644 index 0f3184c81a..0000000000 --- a/tests/dataset/InterpolationPolicyDataset.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_INTERPOLATION_POLICY_DATASET_H__ -#define __ARM_COMPUTE_TEST_INTERPOLATION_POLICY_DATASET_H__ - -#include "arm_compute/core/Types.h" - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible interpolation policies. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on all interpolation policies. - */ -class InterpolationPolicies -{ -public: - /** Type of the samples in the data set. */ - using sample = InterpolationPolicy; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _policies.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const InterpolationPolicy *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _policies.data(); - } - -private: - std::array _policies{ { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR, InterpolationPolicy::AREA } }; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_INTERPOLATION_POLICY_DATASET_H__ */ diff --git a/tests/dataset/MatrixPatternDataset.h b/tests/dataset/MatrixPatternDataset.h deleted file mode 100644 index 050c4d9cfd..0000000000 --- a/tests/dataset/MatrixPatternDataset.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_MATRIX_PATTERN_DATASET_H__ -#define __ARM_COMPUTE_TEST_MATRIX_PATTERN_DATASET_H__ - -#include "arm_compute/core/Types.h" - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -#include - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible border modes. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on all border modes. - */ -class MatrixPatterns -{ -public: - /** Type of the samples in the data set. */ - using sample = MatrixPattern; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _patterns.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const MatrixPattern *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _patterns.data(); - } - -private: - std::array _patterns{ { MatrixPattern::BOX, MatrixPattern::CROSS, MatrixPattern::DISK, MatrixPattern::OTHER } }; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_MATRIX_PATTERN_DATASET_H__ */ diff --git a/tests/dataset/NonLinearFilterFunctionDataset.h b/tests/dataset/NonLinearFilterFunctionDataset.h deleted file mode 100644 index a2db3239c3..0000000000 --- a/tests/dataset/NonLinearFilterFunctionDataset.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_NON_LINEAR_FILTER_FUNCTION_DATASET_H__ -#define __ARM_COMPUTE_TEST_NON_LINEAR_FILTER_FUNCTION_DATASET_H__ - -#include "arm_compute/core/Types.h" - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -#include - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible non linear filter function. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on all border modes. - */ -class NonLinearFilterFunctions -{ -public: - /** Type of the samples in the data set. */ - using sample = NonLinearFilterFunction; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _functions.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const NonLinearFilterFunction *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _functions.data(); - } - -private: - std::array _functions{ { NonLinearFilterFunction::MAX, NonLinearFilterFunction::MEDIAN, NonLinearFilterFunction::MIN } }; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_NON_LINEAR_FILTER_FUNCTION_DATASET_H__ */ diff --git a/tests/dataset/NormalizationLayerDataset.h b/tests/dataset/NormalizationLayerDataset.h deleted file mode 100644 index fc56694dc8..0000000000 --- a/tests/dataset/NormalizationLayerDataset.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_DATASET_NORMALIZATION_LAYER_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_NORMALIZATION_LAYER_DATASET_H__ - -#include "TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "dataset/GenericDataset.h" - -#include -#include - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -class NormalizationLayerDataObject -{ -public: - operator std::string() const - { - std::stringstream ss; - ss << "NormalizationLayer"; - ss << "_I" << shape; - ss << "_F_" << info.type(); - ss << "_S_" << info.norm_size(); - return ss.str(); - } - -public: - TensorShape shape; - NormalizationLayerInfo info; -}; - -template -using NormalizationLayerDataset = GenericDataset; - -class GoogLeNetNormalizationLayerDataset final : public NormalizationLayerDataset<2> -{ -public: - GoogLeNetNormalizationLayerDataset() - : GenericDataset - { - // conv2/norm2 - NormalizationLayerDataObject{ TensorShape(56U, 56U, 192U), NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f) }, - // pool1/norm1 - NormalizationLayerDataObject{ TensorShape(56U, 56U, 64U), NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f) } - } - { - } - - ~GoogLeNetNormalizationLayerDataset() = default; -}; - -class AlexNetNormalizationLayerDataset final : public NormalizationLayerDataset<2> -{ -public: - AlexNetNormalizationLayerDataset() - : GenericDataset - { - NormalizationLayerDataObject{ TensorShape(55U, 55U, 96U), NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f) }, - NormalizationLayerDataObject{ TensorShape(27U, 27U, 256U), NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f) }, - } - { - } - - ~AlexNetNormalizationLayerDataset() = default; -}; - -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DATASET_NORMALIZATION_LAYER_DATASET_H__ */ diff --git a/tests/dataset/NormalizationTypeDataset.h b/tests/dataset/NormalizationTypeDataset.h deleted file mode 100644 index 756772ee8f..0000000000 --- a/tests/dataset/NormalizationTypeDataset.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_NORMALIZATION_TYPE_DATASET_H__ -#define __ARM_COMPUTE_TEST_NORMALIZATION_TYPE_DATASET_H__ - -#include "arm_compute/core/Types.h" - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible normalization types. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on all normalization types. - */ -class NormalizationTypes -{ -public: - /** Type of the samples in the data set. */ - using sample = NormType; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _types.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const NormType *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _types.data(); - } - -private: - const std::array _types{ { NormType::IN_MAP_1D, NormType::IN_MAP_2D, NormType::CROSS_MAP } }; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_NORMALIZATION_TYPE_DATASET_H__ */ diff --git a/tests/dataset/PoolingLayerDataset.h b/tests/dataset/PoolingLayerDataset.h deleted file mode 100644 index ee3e6dc4aa..0000000000 --- a/tests/dataset/PoolingLayerDataset.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_DATASET_POOLING_LAYER_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_POOLING_LAYER_DATASET_H__ - -#include "TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "dataset/GenericDataset.h" - -#include - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -class PoolingLayerDataObject -{ -public: - operator std::string() const - { - std::stringstream ss; - ss << "PoolingLayer"; - ss << "_I" << src_shape; - ss << "_S_" << info.pool_size(); - ss << "_F_" << info.pool_type(); - ss << "_PS" << info.pad_stride_info(); - return ss.str(); - } - - friend std::ostream &operator<<(std::ostream &s, const PoolingLayerDataObject &obj) - { - s << static_cast(obj); - return s; - } - -public: - TensorShape src_shape; - TensorShape dst_shape; - PoolingLayerInfo info; -}; - -template -using PoolingLayerDataset = GenericDataset; - -class AlexNetPoolingLayerDataset final : public PoolingLayerDataset<3> -{ -public: - AlexNetPoolingLayerDataset() - : GenericDataset - { - PoolingLayerDataObject{ TensorShape(55U, 55U, 96U), TensorShape(27U, 27U, 96U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) }, - PoolingLayerDataObject{ TensorShape(27U, 27U, 256U), TensorShape(13U, 13U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) }, - PoolingLayerDataObject{ TensorShape(13U, 13U, 256U), TensorShape(6U, 6U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) }, - } - { - } - - ~AlexNetPoolingLayerDataset() = default; -}; - -class LeNet5PoolingLayerDataset final : public PoolingLayerDataset<2> -{ -public: - LeNet5PoolingLayerDataset() - : GenericDataset - { - PoolingLayerDataObject{ TensorShape(24U, 24U, 20U), TensorShape(12U, 12U, 20U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0)) }, - PoolingLayerDataObject{ TensorShape(8U, 8U, 50U), TensorShape(4U, 4U, 50U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0)) }, - } - { - } - - ~LeNet5PoolingLayerDataset() = default; -}; - -class GoogLeNetPoolingLayerDataset final : public PoolingLayerDataset<10> -{ -public: - GoogLeNetPoolingLayerDataset() - : GenericDataset - { - // FIXME: Add support for 7x7 pooling layer pool5/7x7_s1 - // pool1/3x3_s2 - PoolingLayerDataObject{ TensorShape(112U, 112U, 64U), TensorShape(56U, 56U, 64U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) }, - // pool2/3x3_s2 - PoolingLayerDataObject{ TensorShape(56U, 56U, 192U), TensorShape(28U, 28U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) }, - // inception_3a/pool - PoolingLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(28U, 28U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, - // inception_3b/pool - PoolingLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(28U, 28U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, - // pool3/3x3_s2 - PoolingLayerDataObject{ TensorShape(28U, 28U, 480U), TensorShape(14U, 14U, 480U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) }, - // inception_4a/pool - PoolingLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(14U, 14U, 480U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, - // inception_4b/pool, inception_4c/pool, inception_4d/pool - PoolingLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(14U, 14U, 512U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, - // inception_4e/pool - PoolingLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(14U, 14U, 528U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, - // pool4/3x3_s2 - PoolingLayerDataObject{ TensorShape(14U, 14U, 832U), TensorShape(7U, 7U, 832U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) }, - // inception_5a/pool, inception_5b/pool - PoolingLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(7U, 7U, 832U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, - } - { - } - - ~GoogLeNetPoolingLayerDataset() = default; -}; -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_DATASET_POOLING_LAYER_DATASET_H__ diff --git a/tests/dataset/PoolingTypesDataset.h b/tests/dataset/PoolingTypesDataset.h deleted file mode 100644 index c8e34665f4..0000000000 --- a/tests/dataset/PoolingTypesDataset.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_DATASET_POOLING_TYPE_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_POOLING_TYPE_DATASET_H__ - -#include "arm_compute/core/Types.h" -#include "dataset/GenericDataset.h" - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible pooling types. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on all pooling types. - */ -class PoolingTypes final : public GenericDataset -{ -public: - PoolingTypes() - : GenericDataset{ PoolingType::MAX, PoolingType::AVG } - { - } - - ~PoolingTypes() = default; -}; -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_DATASET_POOLING_TYPE_DATASET_H__ diff --git a/tests/dataset/RoundingPolicyDataset.h b/tests/dataset/RoundingPolicyDataset.h deleted file mode 100644 index 0e7c7ba0c5..0000000000 --- a/tests/dataset/RoundingPolicyDataset.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_ROUNDING_POLICY_DATASETS_H__ -#define __ARM_COMPUTE_TEST_ROUNDING_POLICY_DATASETS_H__ - -#include "arm_compute/core/Types.h" - -#include - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible rounding policies. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on different rounding policies. - */ -class RoundingPolicies -{ -public: - /** Type of the samples in the data set. */ - using sample = RoundingPolicy; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _policies.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const RoundingPolicy *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _policies.data(); - } - -private: - std::array _policies{ { RoundingPolicy::TO_ZERO, RoundingPolicy::TO_NEAREST_UP, RoundingPolicy::TO_NEAREST_EVEN } }; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_ROUNDING_POLICY_DATASETS_H__ */ diff --git a/tests/dataset/ShapeDatasets.h b/tests/dataset/ShapeDatasets.h deleted file mode 100644 index ccdfc9a7dd..0000000000 --- a/tests/dataset/ShapeDatasets.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ -#define __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ - -#include "arm_compute/core/TensorShape.h" - -#include - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Abstract data set containing tensor shapes. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on different tensor shapes. - */ -template -class ShapeDataset -{ -public: - /** Type of the samples in the data set. */ - using sample = TensorShape; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _shapes.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const TensorShape *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _shapes.data(); - } - -protected: - /** Protected constructor to make the class abstract. */ - template - ShapeDataset(Ts... shapes) - : _shapes{ { shapes... } } - { - } - - /** Protected destructor to prevent deletion of derived class through a - * pointer to the base class. - */ - ~ShapeDataset() = default; - -private: - std::array _shapes; -}; - -/** Data set containing one 1D tensor shape. */ -class Small1DShape final : public ShapeDataset<1> -{ -public: - Small1DShape() - : ShapeDataset(TensorShape(256U)) - { - } -}; - -/** Data set containing two small 2D tensor shapes. */ -class Small2DShapes final : public ShapeDataset<2> -{ -public: - Small2DShapes() - : ShapeDataset(TensorShape(17U, 17U), - TensorShape(640U, 480U)) - { - } -}; - -/** Data set containing small tensor shapes. */ -class SmallShapes final : public ShapeDataset<3> -{ -public: - SmallShapes() - : ShapeDataset(TensorShape(7U, 7U), - TensorShape(27U, 13U, 2U), - TensorShape(128U, 64U, 1U, 3U)) - { - } -}; - -/** Data set containing large tensor shapes. */ -class LargeShapes final : public ShapeDataset<3> -{ -public: - LargeShapes() - : ShapeDataset(TensorShape(1920U, 1080U), - TensorShape(1245U, 652U, 1U, 3U), - TensorShape(4160U, 3120U)) - { - } -}; - -/** Data set containing two 2D large tensor shapes. */ -class Large2DShapes final : public ShapeDataset<2> -{ -public: - Large2DShapes() - : ShapeDataset(TensorShape(1920U, 1080U), - TensorShape(4160U, 3120U)) - { - } -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ */ diff --git a/tests/dataset/ThresholdDataset.h b/tests/dataset/ThresholdDataset.h deleted file mode 100644 index e5a1e375ff..0000000000 --- a/tests/dataset/ThresholdDataset.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_DATASET_THRESHOLD_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_THRESHOLD_DATASET_H__ - -#include "TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "dataset/GenericDataset.h" - -#include -#include - -#include -#include - -#ifdef BOOST -#include "boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -class ThresholdDataObject -{ -public: - uint8_t threshold; - uint8_t false_value; - uint8_t true_value; - ThresholdType type; - uint8_t upper; - - operator std::string() const - { - std::stringstream ss; - ss << "Threshold"; - ss << "_threshold_value" << threshold; - ss << "_false_value" << std::boolalpha << false_value; - ss << "_true_value" << std::boolalpha << true_value; - ss << "_type"; - ss << ((type == ThresholdType::BINARY) ? "binary" : "range"); - ss << "_upper" << upper; - return ss.str(); - } - - friend std::ostream &operator<<(std::ostream &os, const ThresholdDataObject &obj) - { - os << static_cast(obj); - return os; - } -}; - -class ThresholdDataset : public GenericDataset -{ -public: - ThresholdDataset() - : GenericDataset - { - ThresholdDataObject{ 10U, 25U, 3U, ThresholdType::BINARY, 0U }, - ThresholdDataObject{ 20U, 1U, 0U, ThresholdType::BINARY, 0U }, - ThresholdDataObject{ 30U, 1U, 0U, ThresholdType::RANGE, 100U }, - ThresholdDataObject{ 100U, 1U, 0U, ThresholdType::RANGE, 200U }, - } - { - } - - ~ThresholdDataset() = default; -}; - -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DATASET_THRESHOLD_DATASET_H__ */ diff --git a/tests/datasets/ActivationFunctionsDataset.h b/tests/datasets/ActivationFunctionsDataset.h new file mode 100644 index 0000000000..3e4f408614 --- /dev/null +++ b/tests/datasets/ActivationFunctionsDataset.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_ACTIVATIONFUNCTIONS_DATASET_H__ +#define __ARM_COMPUTE_TEST_ACTIVATIONFUNCTIONS_DATASET_H__ + +#include "arm_compute/core/Types.h" +#include "tests/framework/datasets/ContainerDataset.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class ActivationFunctions final : public framework::dataset::ContainerDataset> +{ +public: + ActivationFunctions() + : ContainerDataset("ActivationFunction", + { + ActivationLayerInfo::ActivationFunction::ABS, + ActivationLayerInfo::ActivationFunction::LINEAR, + ActivationLayerInfo::ActivationFunction::LOGISTIC, + ActivationLayerInfo::ActivationFunction::RELU, + ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, + ActivationLayerInfo::ActivationFunction::LEAKY_RELU, + ActivationLayerInfo::ActivationFunction::SOFT_RELU, + ActivationLayerInfo::ActivationFunction::SQRT, + ActivationLayerInfo::ActivationFunction::SQUARE, + ActivationLayerInfo::ActivationFunction::TANH + }) + { + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_ACTIVATIONFUNCTIONS_DATASET_H__ */ diff --git a/tests/datasets/BatchNormalizationLayerDataset.h b/tests/datasets/BatchNormalizationLayerDataset.h new file mode 100644 index 0000000000..25e65d931c --- /dev/null +++ b/tests/datasets/BatchNormalizationLayerDataset.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_BATCHNORMALIZATION_LAYER_DATASET +#define ARM_COMPUTE_TEST_BATCHNORMALIZATION_LAYER_DATASET + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class BatchNormalizationLayerDataset +{ +public: + using type = std::tuple; + + struct iterator + { + iterator(std::vector::const_iterator tensor_it, + std::vector::const_iterator param_it, + std::vector::const_iterator epsilon_it) + : _tensor_it{ std::move(tensor_it) }, + _param_it{ std::move(param_it) }, + _epsilon_it{ std::move(epsilon_it) } + { + } + + std::string description() const + { + std::stringstream description; + description << "In=" << *_tensor_it << ":"; + description << "Out=" << *_tensor_it << ":"; + description << "Mean=" << *_param_it << ":"; + description << "Variance=" << *_param_it << ":"; + description << "Beta=" << *_param_it << ":"; + description << "Gamma=" << *_param_it << ":"; + description << "Epsilon=" << *_epsilon_it; + return description.str(); + } + + BatchNormalizationLayerDataset::type operator*() const + { + return std::make_tuple(*_tensor_it, *_param_it, *_epsilon_it); + } + + iterator &operator++() + { + ++_tensor_it; + ++_param_it; + ++_epsilon_it; + + return *this; + } + + private: + std::vector::const_iterator _tensor_it; + std::vector::const_iterator _param_it; + std::vector::const_iterator _epsilon_it; + }; + + iterator begin() const + { + return iterator(_tensor_shapes.begin(), _param_shapes.begin(), _epsilons.begin()); + } + + int size() const + { + return std::min(_tensor_shapes.size(), std::min(_param_shapes.size(), _epsilons.size())); + } + + void add_config(TensorShape tensor, TensorShape param, float epsilon) + { + _tensor_shapes.emplace_back(std::move(tensor)); + _param_shapes.emplace_back(std::move(param)); + _epsilons.emplace_back(std::move(epsilon)); + } + +protected: + BatchNormalizationLayerDataset() = default; + BatchNormalizationLayerDataset(BatchNormalizationLayerDataset &&) = default; + +private: + std::vector _tensor_shapes{}; + std::vector _param_shapes{}; + std::vector _epsilons{}; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_BATCHNORMALIZATION_LAYER_DATASET */ diff --git a/tests/datasets/BorderModeDataset.h b/tests/datasets/BorderModeDataset.h new file mode 100644 index 0000000000..df024a7dbf --- /dev/null +++ b/tests/datasets/BorderModeDataset.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_BORDER_MODE_DATASET_H__ +#define __ARM_COMPUTE_TEST_BORDER_MODE_DATASET_H__ + +#include "arm_compute/core/Types.h" +#include "tests/framework/datasets/ContainerDataset.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class BorderModes final : public framework::dataset::ContainerDataset> +{ +public: + BorderModes() + : ContainerDataset("BorderMode", + { + BorderMode::UNDEFINED, + BorderMode::CONSTANT, + BorderMode::REPLICATE + }) + { + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_BORDER_MODE_DATASET_H__ */ diff --git a/tests/datasets/ConvolutionLayerDataset.h b/tests/datasets/ConvolutionLayerDataset.h new file mode 100644 index 0000000000..ba11bd5d6d --- /dev/null +++ b/tests/datasets/ConvolutionLayerDataset.h @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_CONVOLUTION_LAYER_DATASET + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class ConvolutionLayerDataset +{ +public: + using type = std::tuple; + + struct iterator + { + iterator(std::vector::const_iterator src_it, + std::vector::const_iterator weights_it, + std::vector::const_iterator biases_it, + std::vector::const_iterator dst_it, + std::vector::const_iterator infos_it) + : _src_it{ std::move(src_it) }, + _weights_it{ std::move(weights_it) }, + _biases_it{ std::move(biases_it) }, + _dst_it{ std::move(dst_it) }, + _infos_it{ std::move(infos_it) } + { + } + + std::string description() const + { + std::stringstream description; + description << "In=" << *_src_it << ":"; + description << "Weights=" << *_weights_it << ":"; + description << "Biases=" << *_biases_it << ":"; + description << "Out=" << *_dst_it << ":"; + description << "Info=" << *_infos_it; + return description.str(); + } + + ConvolutionLayerDataset::type operator*() const + { + return std::make_tuple(*_src_it, *_weights_it, *_biases_it, *_dst_it, *_infos_it); + } + + iterator &operator++() + { + ++_src_it; + ++_weights_it; + ++_biases_it; + ++_dst_it; + ++_infos_it; + + return *this; + } + + private: + std::vector::const_iterator _src_it; + std::vector::const_iterator _weights_it; + std::vector::const_iterator _biases_it; + std::vector::const_iterator _dst_it; + std::vector::const_iterator _infos_it; + }; + + iterator begin() const + { + return iterator(_src_shapes.begin(), _weight_shapes.begin(), _bias_shapes.begin(), _dst_shapes.begin(), _infos.begin()); + } + + int size() const + { + return std::min(_src_shapes.size(), std::min(_weight_shapes.size(), std::min(_bias_shapes.size(), std::min(_dst_shapes.size(), _infos.size())))); + } + + void add_config(TensorShape src, TensorShape weights, TensorShape biases, TensorShape dst, PadStrideInfo info) + { + _src_shapes.emplace_back(std::move(src)); + _weight_shapes.emplace_back(std::move(weights)); + _bias_shapes.emplace_back(std::move(biases)); + _dst_shapes.emplace_back(std::move(dst)); + _infos.emplace_back(std::move(info)); + } + +protected: + ConvolutionLayerDataset() = default; + ConvolutionLayerDataset(ConvolutionLayerDataset &&) = default; + +private: + std::vector _src_shapes{}; + std::vector _weight_shapes{}; + std::vector _bias_shapes{}; + std::vector _dst_shapes{}; + std::vector _infos{}; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets/DepthwiseConvolutionDataset.h b/tests/datasets/DepthwiseConvolutionDataset.h new file mode 100644 index 0000000000..93da37532f --- /dev/null +++ b/tests/datasets/DepthwiseConvolutionDataset.h @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_DATASET +#define ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_DATASET + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class DepthwiseConvolutionDataset +{ +public: + using type = std::tuple; + + struct iterator + { + iterator(std::vector::const_iterator src_it, + std::vector::const_iterator weights_it, + std::vector::const_iterator dst_it, + std::vector::const_iterator infos_it) + : _src_it{ std::move(src_it) }, + _weights_it{ std::move(weights_it) }, + _dst_it{ std::move(dst_it) }, + _infos_it{ std::move(infos_it) } + { + } + + std::string description() const + { + std::stringstream description; + description << "In=" << *_src_it << ":"; + description << "Weights=" << *_weights_it << ":"; + description << "Out=" << *_dst_it << ":"; + description << "Info=" << *_infos_it; + return description.str(); + } + + DepthwiseConvolutionDataset::type operator*() const + { + return std::make_tuple(*_src_it, *_weights_it, *_dst_it, *_infos_it); + } + + iterator &operator++() + { + ++_src_it; + ++_weights_it; + ++_dst_it; + ++_infos_it; + + return *this; + } + + private: + std::vector::const_iterator _src_it; + std::vector::const_iterator _weights_it; + std::vector::const_iterator _dst_it; + std::vector::const_iterator _infos_it; + }; + + iterator begin() const + { + return iterator(_src_shapes.begin(), _weight_shapes.begin(), _dst_shapes.begin(), _infos.begin()); + } + + int size() const + { + return std::min(_src_shapes.size(), std::min(_weight_shapes.size(), std::min(_dst_shapes.size(), _infos.size()))); + } + + void add_config(TensorShape src, TensorShape weights, TensorShape dst, PadStrideInfo info) + { + _src_shapes.emplace_back(std::move(src)); + _weight_shapes.emplace_back(std::move(weights)); + _dst_shapes.emplace_back(std::move(dst)); + _infos.emplace_back(std::move(info)); + } + +protected: + DepthwiseConvolutionDataset() = default; + DepthwiseConvolutionDataset(DepthwiseConvolutionDataset &&) = default; + +private: + std::vector _src_shapes{}; + std::vector _weight_shapes{}; + std::vector _dst_shapes{}; + std::vector _infos{}; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_DATASET */ diff --git a/tests/datasets/DepthwiseSeparableConvolutionLayerDataset.h b/tests/datasets/DepthwiseSeparableConvolutionLayerDataset.h new file mode 100644 index 0000000000..4391379833 --- /dev/null +++ b/tests/datasets/DepthwiseSeparableConvolutionLayerDataset.h @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_DATASET + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class DepthwiseSeparableConvolutionLayerDataset +{ +public: + using type = std::tuple; + + struct iterator + { + iterator(std::vector::const_iterator src_it, + std::vector::const_iterator filter_it, + std::vector::const_iterator depthwise_out_it, + std::vector::const_iterator weights_it, + std::vector::const_iterator biases_it, + std::vector::const_iterator dst_it, + std::vector::const_iterator depthwise_infos_it, + std::vector::const_iterator pointwise_infos_it) + : _src_it{ std::move(src_it) }, + _filter_it{ std::move(filter_it) }, + _depthwise_out_it{ std::move(depthwise_out_it) }, + _weights_it{ std::move(weights_it) }, + _biases_it{ std::move(biases_it) }, + _dst_it{ std::move(dst_it) }, + _depthwise_infos_it{ std::move(depthwise_infos_it) }, + _pointwise_infos_it{ std::move(pointwise_infos_it) } + { + } + + std::string description() const + { + std::stringstream description; + description << "In=" << *_src_it << ":"; + description << "Filter=" << *_filter_it << ":"; + description << "DepthwiseOut=" << *_depthwise_out_it << ":"; + description << "Weights=" << *_weights_it << ":"; + description << "Biases=" << *_biases_it << ":"; + description << "Out=" << *_dst_it << ":"; + description << "DepthwiseInfo=" << *_depthwise_infos_it << ":"; + description << "PointwiseInfo=" << *_pointwise_infos_it; + return description.str(); + } + + DepthwiseSeparableConvolutionLayerDataset::type operator*() const + { + return std::make_tuple(*_src_it, *_filter_it, *_depthwise_out_it, *_weights_it, *_biases_it, *_dst_it, *_depthwise_infos_it, *_pointwise_infos_it); + } + + iterator &operator++() + { + ++_src_it; + ++_filter_it; + ++_depthwise_out_it; + ++_weights_it; + ++_biases_it; + ++_dst_it; + ++_depthwise_infos_it; + ++_pointwise_infos_it; + + return *this; + } + + private: + std::vector::const_iterator _src_it; + std::vector::const_iterator _filter_it; + std::vector::const_iterator _depthwise_out_it; + std::vector::const_iterator _weights_it; + std::vector::const_iterator _biases_it; + std::vector::const_iterator _dst_it; + std::vector::const_iterator _depthwise_infos_it; + std::vector::const_iterator _pointwise_infos_it; + }; + + iterator begin() const + { + return iterator(_src_shapes.begin(), _filter_shapes.begin(), _depthwise_out_shapes.begin(), _weight_shapes.begin(), _bias_shapes.begin(), _dst_shapes.begin(), _depthwise_infos.begin(), + _pointwise_infos.begin()); + } + + int size() const + { + return std::min(_src_shapes.size(), std::min(_filter_shapes.size(), std::min(_depthwise_out_shapes.size(), std::min(_weight_shapes.size(), std::min(_bias_shapes.size(), std::min(_dst_shapes.size(), + std::min(_depthwise_infos.size(), _pointwise_infos.size()))))))); + } + + void add_config(TensorShape src, TensorShape filter, TensorShape depthwise_out, TensorShape weights, TensorShape biases, TensorShape dst, PadStrideInfo depthwise_info, PadStrideInfo pointwise_info) + { + _src_shapes.emplace_back(std::move(src)); + _filter_shapes.emplace_back(std::move(filter)); + _depthwise_out_shapes.emplace_back(std::move(depthwise_out)); + _weight_shapes.emplace_back(std::move(weights)); + _bias_shapes.emplace_back(std::move(biases)); + _dst_shapes.emplace_back(std::move(dst)); + _depthwise_infos.emplace_back(std::move(depthwise_info)); + _pointwise_infos.emplace_back(std::move(pointwise_info)); + } + +protected: + DepthwiseSeparableConvolutionLayerDataset() = default; + DepthwiseSeparableConvolutionLayerDataset(DepthwiseSeparableConvolutionLayerDataset &&) = default; + +private: + std::vector _src_shapes{}; + std::vector _filter_shapes{}; + std::vector _depthwise_out_shapes{}; + std::vector _weight_shapes{}; + std::vector _bias_shapes{}; + std::vector _dst_shapes{}; + std::vector _depthwise_infos{}; + std::vector _pointwise_infos{}; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets/DirectConvolutionLayerDataset.h b/tests/datasets/DirectConvolutionLayerDataset.h new file mode 100644 index 0000000000..dca38b5858 --- /dev/null +++ b/tests/datasets/DirectConvolutionLayerDataset.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DIRECT_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_DIRECT_CONVOLUTION_LAYER_DATASET + +#include "tests/datasets/ConvolutionLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +/** Stripped down version of AlexNet as not all kernel sizes and strides are supported. */ +class DirectConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + DirectConvolutionLayerDataset() + { + add_config(TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 3U), TensorShape(3U), TensorShape(13U, 13U, 3U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 4U), TensorShape(4U), TensorShape(13U, 13U, 4U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 5U), TensorShape(5U), TensorShape(13U, 13U, 5U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 3U), TensorShape(3U), TensorShape(13U, 13U, 3U), PadStrideInfo(2, 2, 1, 1)); + add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 4U), TensorShape(4U), TensorShape(13U, 13U, 4U), PadStrideInfo(2, 2, 1, 1)); + add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 5U), TensorShape(5U), TensorShape(13U, 13U, 5U), PadStrideInfo(2, 2, 1, 1)); + add_config(TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 3U), TensorShape(3U), TensorShape(13U, 13U, 3U), PadStrideInfo(3, 3, 1, 1)); + add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 4U), TensorShape(4U), TensorShape(13U, 13U, 4U), PadStrideInfo(3, 3, 1, 1)); + add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 5U), TensorShape(5U), TensorShape(13U, 13U, 5U), PadStrideInfo(3, 3, 1, 1)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DIRECT_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets/FullyConnectedLayerDataset.h b/tests/datasets/FullyConnectedLayerDataset.h new file mode 100644 index 0000000000..8401e39ece --- /dev/null +++ b/tests/datasets/FullyConnectedLayerDataset.h @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_FULLYCONNECTED_LAYER_DATASET +#define ARM_COMPUTE_TEST_FULLYCONNECTED_LAYER_DATASET + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class FullyConnectedLayerDataset +{ +public: + using type = std::tuple; + + struct iterator + { + iterator(std::vector::const_iterator src_it, + std::vector::const_iterator weights_it, + std::vector::const_iterator biases_it, + std::vector::const_iterator dst_it) + : _src_it{ std::move(src_it) }, + _weights_it{ std::move(weights_it) }, + _biases_it{ std::move(biases_it) }, + _dst_it{ std::move(dst_it) } + { + } + + std::string description() const + { + std::stringstream description; + description << "In=" << *_src_it << ":"; + description << "Weights=" << *_weights_it << ":"; + description << "Biases=" << *_biases_it << ":"; + description << "Out=" << *_dst_it; + return description.str(); + } + + FullyConnectedLayerDataset::type operator*() const + { + return std::make_tuple(*_src_it, *_weights_it, *_biases_it, *_dst_it); + } + + iterator &operator++() + { + ++_src_it; + ++_weights_it; + ++_biases_it; + ++_dst_it; + + return *this; + } + + private: + std::vector::const_iterator _src_it; + std::vector::const_iterator _weights_it; + std::vector::const_iterator _biases_it; + std::vector::const_iterator _dst_it; + }; + + iterator begin() const + { + return iterator(_src_shapes.begin(), _weight_shapes.begin(), _bias_shapes.begin(), _dst_shapes.begin()); + } + + int size() const + { + return std::min(_src_shapes.size(), std::min(_weight_shapes.size(), std::min(_bias_shapes.size(), _dst_shapes.size()))); + } + + void add_config(TensorShape src, TensorShape weights, TensorShape biases, TensorShape dst) + { + _src_shapes.emplace_back(std::move(src)); + _weight_shapes.emplace_back(std::move(weights)); + _bias_shapes.emplace_back(std::move(biases)); + _dst_shapes.emplace_back(std::move(dst)); + } + +protected: + FullyConnectedLayerDataset() = default; + FullyConnectedLayerDataset(FullyConnectedLayerDataset &&) = default; + +private: + std::vector _src_shapes{}; + std::vector _weight_shapes{}; + std::vector _bias_shapes{}; + std::vector _dst_shapes{}; +}; + +class SmallFullyConnectedLayerDataset final : public FullyConnectedLayerDataset +{ +public: + SmallFullyConnectedLayerDataset() + { + // Conv -> FC + add_config(TensorShape(9U, 5U, 7U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U)); + // Conv -> FC (batched) + add_config(TensorShape(9U, 5U, 7U, 3U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U, 3U)); + // FC -> FC + add_config(TensorShape(201U), TensorShape(201U, 529U), TensorShape(529U), TensorShape(529U)); + // FC -> FC (batched) + add_config(TensorShape(201U, 3U), TensorShape(201U, 529U), TensorShape(529U), TensorShape(529U, 3U)); + + add_config(TensorShape(9U, 5U, 7U, 3U, 2U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U, 3U, 2U)); + } +}; + +class LargeFullyConnectedLayerDataset final : public FullyConnectedLayerDataset +{ +public: + LargeFullyConnectedLayerDataset() + { + add_config(TensorShape(9U, 5U, 257U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U)); + add_config(TensorShape(9U, 5U, 257U, 2U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U, 2U)); + add_config(TensorShape(3127U), TensorShape(3127U, 989U), TensorShape(989U), TensorShape(989U)); + add_config(TensorShape(3127U, 2U), TensorShape(3127U, 989U), TensorShape(989U), TensorShape(989U, 2U)); + + add_config(TensorShape(9U, 5U, 257U, 2U, 3U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U, 2U, 3U)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_FULLYCONNECTED_LAYER_DATASET */ diff --git a/tests/datasets/GEMMDataset.h b/tests/datasets/GEMMDataset.h new file mode 100644 index 0000000000..bb8a328b0c --- /dev/null +++ b/tests/datasets/GEMMDataset.h @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_GEMM_DATASET +#define ARM_COMPUTE_TEST_GEMM_DATASET + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class GEMMDataset +{ +public: + using type = std::tuple; + + struct iterator + { + iterator(std::vector::const_iterator a_it, + std::vector::const_iterator b_it, + std::vector::const_iterator c_it, + std::vector::const_iterator dst_it, + std::vector::const_iterator alpha_it, + std::vector::const_iterator beta_it) + : _a_it{ std::move(a_it) }, + _b_it{ std::move(b_it) }, + _c_it{ std::move(c_it) }, + _dst_it{ std::move(dst_it) }, + _alpha_it{ std::move(alpha_it) }, + _beta_it{ std::move(beta_it) } + { + } + + std::string description() const + { + std::stringstream description; + description << "A=" << *_a_it << ":"; + description << "B=" << *_b_it << ":"; + description << "C=" << *_c_it << ":"; + description << "Out=" << *_dst_it << ":"; + description << "Alpha=" << *_alpha_it << ":"; + description << "Beta=" << *_beta_it; + return description.str(); + } + + GEMMDataset::type operator*() const + { + return std::make_tuple(*_a_it, *_b_it, *_c_it, *_dst_it, *_alpha_it, *_beta_it); + } + + iterator &operator++() + { + ++_a_it; + ++_b_it; + ++_c_it; + ++_dst_it; + ++_alpha_it; + ++_beta_it; + + return *this; + } + + private: + std::vector::const_iterator _a_it; + std::vector::const_iterator _b_it; + std::vector::const_iterator _c_it; + std::vector::const_iterator _dst_it; + std::vector::const_iterator _alpha_it; + std::vector::const_iterator _beta_it; + }; + + iterator begin() const + { + return iterator(_a_shapes.begin(), _b_shapes.begin(), _c_shapes.begin(), _dst_shapes.begin(), _alpha.begin(), _beta.begin()); + } + + int size() const + { + return std::min(_a_shapes.size(), std::min(_b_shapes.size(), std::min(_c_shapes.size(), std::min(_dst_shapes.size(), std::min(_alpha.size(), _beta.size()))))); + } + + void add_config(TensorShape a, TensorShape b, TensorShape c, TensorShape dst, float alpha, float beta) + { + _a_shapes.emplace_back(std::move(a)); + _b_shapes.emplace_back(std::move(b)); + _c_shapes.emplace_back(std::move(c)); + _dst_shapes.emplace_back(std::move(dst)); + _alpha.emplace_back(std::move(alpha)); + _beta.emplace_back(std::move(beta)); + } + +protected: + GEMMDataset() = default; + GEMMDataset(GEMMDataset &&) = default; + +private: + std::vector _a_shapes{}; + std::vector _b_shapes{}; + std::vector _c_shapes{}; + std::vector _dst_shapes{}; + std::vector _alpha{}; + std::vector _beta{}; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GEMM_DATASET */ diff --git a/tests/datasets/InterpolationPolicyDataset.h b/tests/datasets/InterpolationPolicyDataset.h new file mode 100644 index 0000000000..154f887962 --- /dev/null +++ b/tests/datasets/InterpolationPolicyDataset.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_INTEPOLATIONPOLICY_DATASET_H__ +#define __ARM_COMPUTE_TEST_INTEPOLATIONPOLICY_DATASET_H__ + +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class InterpolationPolicies final : public framework::dataset::ContainerDataset> +{ +public: + InterpolationPolicies() + : ContainerDataset("InterpolationPolicy", + { + InterpolationPolicy::NEAREST_NEIGHBOR, + InterpolationPolicy::BILINEAR, + InterpolationPolicy::AREA + }) + { + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_INTEPOLATIONPOLICY_DATASET_H__ */ diff --git a/tests/datasets/LargeConvolutionLayerDataset.h b/tests/datasets/LargeConvolutionLayerDataset.h new file mode 100644 index 0000000000..721530ae19 --- /dev/null +++ b/tests/datasets/LargeConvolutionLayerDataset.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_LARGE_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_LARGE_CONVOLUTION_LAYER_DATASET + +#include "tests/datasets/ConvolutionLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class LargeConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + LargeConvolutionLayerDataset() + { + // Batch size 1 + add_config(TensorShape(227U, 227U, 3U), TensorShape(11U, 11U, 3U, 96U), TensorShape(96U), TensorShape(55U, 55U, 96U), PadStrideInfo(4, 4, 0, 0)); + add_config(TensorShape(27U, 27U, 96U), TensorShape(5U, 5U, 96U, 256U), TensorShape(256U), TensorShape(27U, 27U, 256U), PadStrideInfo(1, 1, 2, 2)); + add_config(TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(224U, 224U, 3U), TensorShape(7U, 7U, 3U, 64U), TensorShape(64U), TensorShape(112U, 112U, 64U), PadStrideInfo(2, 2, 3, 3)); + add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0)); + // Batch size 4 + add_config(TensorShape(227U, 227U, 3U, 4U), TensorShape(11U, 11U, 3U, 96U), TensorShape(96U), TensorShape(55U, 55U, 96U, 4U), PadStrideInfo(4, 4, 0, 0)); + add_config(TensorShape(27U, 27U, 96U, 4U), TensorShape(5U, 5U, 96U, 256U), TensorShape(256U), TensorShape(27U, 27U, 256U, 4U), PadStrideInfo(1, 1, 2, 2)); + add_config(TensorShape(13U, 13U, 256U, 4U), TensorShape(3U, 3U, 256U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U, 4U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 384U, 4U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U, 4U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 384U, 4U), TensorShape(3U, 3U, 384U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U, 4U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(224U, 224U, 3U, 4U), TensorShape(7U, 7U, 3U, 64U), TensorShape(64U), TensorShape(112U, 112U, 64U, 4U), PadStrideInfo(2, 2, 3, 3)); + add_config(TensorShape(28U, 28U, 256U, 4U), TensorShape(1U, 1U, 256U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U, 4U), PadStrideInfo(1, 1, 0, 0)); + // Batch size 8 + add_config(TensorShape(227U, 227U, 3U, 8U), TensorShape(11U, 11U, 3U, 96U), TensorShape(96U), TensorShape(55U, 55U, 96U, 8U), PadStrideInfo(4, 4, 0, 0)); + add_config(TensorShape(27U, 27U, 96U, 8U), TensorShape(5U, 5U, 96U, 256U), TensorShape(256U), TensorShape(27U, 27U, 256U, 8U), PadStrideInfo(1, 1, 2, 2)); + add_config(TensorShape(13U, 13U, 256U, 8U), TensorShape(3U, 3U, 256U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U, 8U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 384U, 8U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U, 8U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 384U, 8U), TensorShape(3U, 3U, 384U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U, 8U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(224U, 224U, 3U, 8U), TensorShape(7U, 7U, 3U, 64U), TensorShape(64U), TensorShape(112U, 112U, 64U, 8U), PadStrideInfo(2, 2, 3, 3)); + add_config(TensorShape(28U, 28U, 256U, 8U), TensorShape(1U, 1U, 256U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U, 8U), PadStrideInfo(1, 1, 0, 0)); + // Arbitrary batch size + add_config(TensorShape(227U, 227U, 3U, 5U), TensorShape(11U, 11U, 3U, 96U), TensorShape(96U), TensorShape(55U, 55U, 96U, 5U), PadStrideInfo(4, 4, 0, 0)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_LARGE_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets/LargeDepthwiseConvolutionDataset.h b/tests/datasets/LargeDepthwiseConvolutionDataset.h new file mode 100644 index 0000000000..22b1516d20 --- /dev/null +++ b/tests/datasets/LargeDepthwiseConvolutionDataset.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_LARGE_DEPTHWISE_CONVOLUTION_DATASET +#define ARM_COMPUTE_TEST_LARGE_DEPTHWISE_CONVOLUTION_DATASET + +#include "tests/datasets/DepthwiseConvolutionDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class LargeDepthwiseConvolutionDataset final : public DepthwiseConvolutionDataset +{ +public: + LargeDepthwiseConvolutionDataset() + { + add_config(TensorShape(233U, 277U, 55U), TensorShape(3U, 3U, 55U), TensorShape(116U, 275U, 55U), PadStrideInfo(2, 1, 0, 0)); + add_config(TensorShape(333U, 277U, 77U), TensorShape(3U, 3U, 77U), TensorShape(111U, 138U, 77U), PadStrideInfo(3, 2, 1, 0)); + add_config(TensorShape(177U, 311U, 22U), TensorShape(3U, 3U, 22U), TensorShape(177U, 156U, 22U), PadStrideInfo(1, 2, 1, 1)); + add_config(TensorShape(233U, 277U, 55U), TensorShape(3U, 3U, 55U), TensorShape(231U, 138U, 55U), PadStrideInfo(1, 2, 0, 0)); + add_config(TensorShape(333U, 277U, 77U), TensorShape(3U, 3U, 77U), TensorShape(166U, 93U, 77U), PadStrideInfo(2, 3, 0, 1)); + add_config(TensorShape(177U, 311U, 22U), TensorShape(3U, 3U, 22U), TensorShape(89U, 311U, 22U), PadStrideInfo(2, 1, 1, 1)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_LARGE_DEPTHWISE_CONVOLUTION_DATASET */ diff --git a/tests/datasets/LargeGEMMDataset.h b/tests/datasets/LargeGEMMDataset.h new file mode 100644 index 0000000000..37cdfaa99f --- /dev/null +++ b/tests/datasets/LargeGEMMDataset.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_LARGE_GEMM_DATASET +#define ARM_COMPUTE_TEST_LARGE_GEMM_DATASET + +#include "tests/datasets/GEMMDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class LargeGEMMDataset final : public GEMMDataset +{ +public: + LargeGEMMDataset() + { + add_config(TensorShape(923U, 429U), TensorShape(871U, 923U), TensorShape(871U, 429U), TensorShape(871U, 429U), 1.0f, 0.0f); + add_config(TensorShape(1021U, 1U), TensorShape(783U, 1021U), TensorShape(783U, 1U), TensorShape(783U, 1U), 1.0f, 0.0f); + add_config(TensorShape(681U, 1023U), TensorShape(213U, 681U), TensorShape(213U, 1023U), TensorShape(213U, 1023U), 0.2f, 1.2f); + add_config(TensorShape(941U, 1U), TensorShape(623U, 941U), TensorShape(623U, 1U), TensorShape(623U, 1U), 0.4f, 0.7f); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_LARGE_GEMM_DATASET */ diff --git a/tests/datasets/MatrixMultiplyGEMMDataset.h b/tests/datasets/MatrixMultiplyGEMMDataset.h new file mode 100644 index 0000000000..771403ba96 --- /dev/null +++ b/tests/datasets/MatrixMultiplyGEMMDataset.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_MATRIXMULTIPLY_GEMM_DATASET +#define ARM_COMPUTE_TEST_MATRIXMULTIPLY_GEMM_DATASET + +#include "tests/datasets/GEMMDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class MatrixMultiplyGEMMDataset final : public GEMMDataset +{ +public: + MatrixMultiplyGEMMDataset() + { + add_config(TensorShape(1024U, 1U), TensorShape(1000U, 1024U), TensorShape(1000U, 1U), TensorShape(1000U, 1U), 1.0f, 0.0f); + add_config(TensorShape(256U, 784U), TensorShape(64U, 256U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f); + add_config(TensorShape(1152U, 2704U), TensorShape(256U, 1152U), TensorShape(256U, 2704U), TensorShape(256U, 2704U), 1.0f, 0.0f); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_MATRIXMULTIPLY_GEMM_DATASET */ diff --git a/tests/datasets/MobileNetDepthwiseConvolutionDataset.h b/tests/datasets/MobileNetDepthwiseConvolutionDataset.h new file mode 100644 index 0000000000..c417f18a51 --- /dev/null +++ b/tests/datasets/MobileNetDepthwiseConvolutionDataset.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_MOBILENET_DEPTHWISE_CONVOLUTION_DATASET +#define ARM_COMPUTE_TEST_MOBILENET_DEPTHWISE_CONVOLUTION_DATASET + +#include "tests/datasets/DepthwiseConvolutionDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class MobileNetDepthwiseConvolutionDataset final : public DepthwiseConvolutionDataset +{ +public: + MobileNetDepthwiseConvolutionDataset() + { + add_config(TensorShape(7U, 7U, 1024U), TensorShape(3U, 3U, 1024U), TensorShape(3U, 3U, 1024U), PadStrideInfo(2, 2, 1, 1)); + add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U), TensorShape(7U, 7U, 512U), PadStrideInfo(2, 2, 1, 1)); + add_config(TensorShape(28U, 28U, 256U), TensorShape(3U, 3U, 256U), TensorShape(14U, 14U, 256U), PadStrideInfo(2, 2, 1, 1)); + add_config(TensorShape(28U, 28U, 256U), TensorShape(3U, 3U, 256U), TensorShape(28U, 28U, 256U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(56U, 56U, 128U), TensorShape(3U, 3U, 128U), TensorShape(28U, 28U, 128U), PadStrideInfo(2, 2, 1, 1)); + add_config(TensorShape(56U, 56U, 128U), TensorShape(3U, 3U, 128U), TensorShape(56U, 56U, 128U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(112U, 112U, 64U), TensorShape(3U, 3U, 64U), TensorShape(56U, 56U, 64U), PadStrideInfo(2, 2, 1, 1)); + add_config(TensorShape(112U, 112U, 32U), TensorShape(3U, 3U, 32U), TensorShape(112U, 112U, 32U), PadStrideInfo(1, 1, 1, 1)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_MOBILENET_DEPTHWISE_CONVOLUTION_DATASET */ diff --git a/tests/datasets/MobileNetDepthwiseSeparableConvolutionLayerDataset.h b/tests/datasets/MobileNetDepthwiseSeparableConvolutionLayerDataset.h new file mode 100644 index 0000000000..c7784c399c --- /dev/null +++ b/tests/datasets/MobileNetDepthwiseSeparableConvolutionLayerDataset.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_MOBILENET_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_MOBILENET_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_DATASET + +#include "tests/datasets/DepthwiseSeparableConvolutionLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class MobileNetDepthwiseSeparableConvolutionLayerDataset final : public DepthwiseSeparableConvolutionLayerDataset +{ +public: + MobileNetDepthwiseSeparableConvolutionLayerDataset() + { + add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U), TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 512U), TensorShape(512U), TensorShape(14U, 14U, 512U), PadStrideInfo(1, 1, 1, + 1, + DimensionRoundingType::FLOOR), + PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::FLOOR)); + add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U), TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 512U), TensorShape(512U), TensorShape(14U, 14U, 512U), PadStrideInfo(1, 1, 1, + 1, + DimensionRoundingType::FLOOR), + PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::FLOOR)); + add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U), TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 512U), TensorShape(512U), TensorShape(14U, 14U, 512U), PadStrideInfo(1, 1, 1, + 1, + DimensionRoundingType::FLOOR), + PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::FLOOR)); + add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U), TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 512U), TensorShape(512U), TensorShape(14U, 14U, 512U), PadStrideInfo(1, 1, 1, + 1, + DimensionRoundingType::FLOOR), + PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::FLOOR)); + add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U), TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 512U), TensorShape(512U), TensorShape(14U, 14U, 512U), PadStrideInfo(1, 1, 1, + 1, + DimensionRoundingType::FLOOR), + PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::FLOOR)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_MOBILENET_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets/NormalizationTypesDataset.h b/tests/datasets/NormalizationTypesDataset.h new file mode 100644 index 0000000000..9b218a7905 --- /dev/null +++ b/tests/datasets/NormalizationTypesDataset.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_NORMALIZATION_TYPES_DATASET_H__ +#define __ARM_COMPUTE_TEST_NORMALIZATION_TYPES_DATASET_H__ + +#include "arm_compute/core/Types.h" +#include "tests/framework/datasets/ContainerDataset.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class NormalizationTypes final : public framework::dataset::ContainerDataset> +{ +public: + NormalizationTypes() + : ContainerDataset("NormType", + { + NormType::IN_MAP_1D, NormType::IN_MAP_2D, NormType::CROSS_MAP + }) + { + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_NORMALIZATION_TYPES_DATASET_H__ */ diff --git a/tests/datasets/PoolingLayerDataset.h b/tests/datasets/PoolingLayerDataset.h new file mode 100644 index 0000000000..e5e9cd70f0 --- /dev/null +++ b/tests/datasets/PoolingLayerDataset.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_POOLING_LAYER_DATASET +#define ARM_COMPUTE_TEST_POOLING_LAYER_DATASET + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/TypePrinter.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class PoolingLayerDataset +{ +public: + using type = std::tuple; + + struct iterator + { + iterator(std::vector::const_iterator src_it, + std::vector::const_iterator dst_it, + std::vector::const_iterator infos_it) + : _src_it{ std::move(src_it) }, + _dst_it{ std::move(dst_it) }, + _infos_it{ std::move(infos_it) } + { + } + + std::string description() const + { + std::stringstream description; + description << "In=" << *_src_it << ":"; + description << "Out=" << *_dst_it << ":"; + description << "Info=" << *_infos_it; + return description.str(); + } + + PoolingLayerDataset::type operator*() const + { + return std::make_tuple(*_src_it, *_dst_it, *_infos_it); + } + + iterator &operator++() + { + ++_src_it; + ++_dst_it; + ++_infos_it; + + return *this; + } + + private: + std::vector::const_iterator _src_it; + std::vector::const_iterator _dst_it; + std::vector::const_iterator _infos_it; + }; + + iterator begin() const + { + return iterator(_src_shapes.begin(), _dst_shapes.begin(), _infos.begin()); + } + + int size() const + { + return std::min(_src_shapes.size(), std::min(_dst_shapes.size(), _infos.size())); + } + + void add_config(TensorShape src, TensorShape dst, PoolingLayerInfo info) + { + _src_shapes.emplace_back(std::move(src)); + _dst_shapes.emplace_back(std::move(dst)); + _infos.emplace_back(std::move(info)); + } + +protected: + PoolingLayerDataset() = default; + PoolingLayerDataset(PoolingLayerDataset &&) = default; + +private: + std::vector _src_shapes{}; + std::vector _dst_shapes{}; + std::vector _infos{}; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_POOLING_LAYER_DATASET */ diff --git a/tests/datasets/PoolingTypesDataset.h b/tests/datasets/PoolingTypesDataset.h new file mode 100644 index 0000000000..5ba8aaf6d0 --- /dev/null +++ b/tests/datasets/PoolingTypesDataset.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_POOLING_TYPES_DATASET_H__ +#define __ARM_COMPUTE_TEST_POOLING_TYPES_DATASET_H__ + +#include "arm_compute/core/Types.h" +#include "tests/framework/datasets/ContainerDataset.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class PoolingTypes final : public framework::dataset::ContainerDataset> +{ +public: + PoolingTypes() + : ContainerDataset("PoolType", + { + PoolingType::MAX, PoolingType::AVG + }) + { + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_NORMALIZATION_TYPES_DATASET_H__ */ diff --git a/tests/datasets/ROIPoolingLayerDataset.h b/tests/datasets/ROIPoolingLayerDataset.h new file mode 100644 index 0000000000..65d589eb97 --- /dev/null +++ b/tests/datasets/ROIPoolingLayerDataset.h @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_ROI_POOLING_LAYER_DATASET +#define ARM_COMPUTE_TEST_ROI_POOLING_LAYER_DATASET + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class ROIPoolingLayerDataset +{ +public: + using type = std::tuple; + + struct iterator + { + iterator(std::vector::const_iterator tensor_shape_it, + std::vector::const_iterator infos_it, + std::vector::const_iterator num_rois_it) + : _tensor_shape_it{ std::move(tensor_shape_it) }, + _infos_it{ std::move(infos_it) }, + _num_rois_it{ std::move(num_rois_it) } + { + } + + std::string description() const + { + std::stringstream description; + description << "In=" << *_tensor_shape_it << ":"; + description << "Info=" << *_infos_it << ":"; + description << "NumROIS=" << *_num_rois_it; + return description.str(); + } + + ROIPoolingLayerDataset::type operator*() const + { + return std::make_tuple(*_tensor_shape_it, *_infos_it, *_num_rois_it); + } + + iterator &operator++() + { + ++_tensor_shape_it; + ++_infos_it; + ++_num_rois_it; + + return *this; + } + + private: + std::vector::const_iterator _tensor_shape_it; + std::vector::const_iterator _infos_it; + std::vector::const_iterator _num_rois_it; + }; + + iterator begin() const + { + return iterator(_tensor_shapes.begin(), _infos.begin(), _num_rois.begin()); + } + + int size() const + { + return std::min(std::min(_tensor_shapes.size(), _infos.size()), _num_rois.size()); + } + + void add_config(TensorShape tensor_shape, ROIPoolingLayerInfo info, unsigned int num_rois) + { + _tensor_shapes.emplace_back(std::move(tensor_shape)); + _infos.emplace_back(std::move(info)); + _num_rois.emplace_back(std::move(num_rois)); + } + +protected: + ROIPoolingLayerDataset() = default; + ROIPoolingLayerDataset(ROIPoolingLayerDataset &&) = default; + +private: + std::vector _tensor_shapes{}; + std::vector _infos{}; + std::vector _num_rois{}; +}; + +class SmallROIPoolingLayerDataset final : public ROIPoolingLayerDataset +{ +public: + SmallROIPoolingLayerDataset() + { + add_config(TensorShape(50U, 47U, 3U), ROIPoolingLayerInfo(7U, 7U, 1.f / 8.f), 40U); + add_config(TensorShape(50U, 47U, 10U), ROIPoolingLayerInfo(7U, 7U, 1.f / 8.f), 80U); + add_config(TensorShape(50U, 47U, 80U), ROIPoolingLayerInfo(7U, 7U, 1.f / 8.f), 80U); + add_config(TensorShape(50U, 47U, 3U), ROIPoolingLayerInfo(9U, 9U, 1.f / 8.f), 40U); + add_config(TensorShape(50U, 47U, 10U), ROIPoolingLayerInfo(9U, 9U, 1.f / 8.f), 80U); + add_config(TensorShape(50U, 47U, 80U), ROIPoolingLayerInfo(9U, 9U, 1.f / 8.f), 80U); + } +}; + +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ROI_POOLING_LAYER_DATASET */ diff --git a/tests/datasets/ReductionOperationDataset.h b/tests/datasets/ReductionOperationDataset.h new file mode 100644 index 0000000000..ce1bcb8501 --- /dev/null +++ b/tests/datasets/ReductionOperationDataset.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_REDUCTION_OPERATION_DATASET_H__ +#define __ARM_COMPUTE_TEST_REDUCTION_OPERATION_DATASET_H__ + +#include "arm_compute/core/Types.h" +#include "tests/TypePrinter.h" +#include "tests/framework/datasets/ContainerDataset.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class ReductionOperations final : public framework::dataset::ContainerDataset> +{ +public: + ReductionOperations() + : ContainerDataset("ReductionOperation", + { + ReductionOperation::SUM_SQUARE + }) + { + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_REDUCTION_OPERATION_DATASET_H__ */ diff --git a/tests/datasets/ShapeDatasets.h b/tests/datasets/ShapeDatasets.h new file mode 100644 index 0000000000..4c449a702f --- /dev/null +++ b/tests/datasets/ShapeDatasets.h @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ +#define __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ + +#include "arm_compute/core/TensorShape.h" +#include "tests/framework/datasets/Datasets.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +/** Data set containing 1D tensor shapes. */ +class Small1DShape final : public framework::dataset::SingletonDataset +{ +public: + Small1DShape() + : SingletonDataset("Shape", TensorShape{ 256U }) + { + } +}; + +/** Parent type for all for shape datasets. */ +using ShapeDataset = framework::dataset::ContainerDataset>; + +/** Data set containing small 2D tensor shapes. */ +class Small2DShapes final : public ShapeDataset +{ +public: + Small2DShapes() + : ShapeDataset("Shape", + { + TensorShape{ 7U, 7U }, + TensorShape{ 27U, 13U }, + TensorShape{ 128U, 64U } + }) + { + } +}; + +/** Data set containing small tensor shapes. */ +class SmallShapes final : public ShapeDataset +{ +public: + SmallShapes() + : ShapeDataset("Shape", + { + // Batch size 1 + TensorShape{ 7U, 7U }, + TensorShape{ 27U, 13U, 2U }, + TensorShape{ 128U, 64U, 1U, 3U }, + // Batch size 4 + TensorShape{ 7U, 7U, 3U, 4U }, + TensorShape{ 27U, 13U, 2U, 4U }, + // Arbitrary batch size + TensorShape{ 7U, 7U, 3U, 5U } + }) + { + } +}; + +/** Data set containing large tensor shapes. */ +class LargeShapes final : public ShapeDataset +{ +public: + LargeShapes() + : ShapeDataset("Shape", + { + // Batch size 1 + TensorShape{ 1920U, 1080U }, + TensorShape{ 640U, 480U, 2U, 3U }, + TensorShape{ 4160U, 3120U }, + // Batch size 4 + TensorShape{ 800U, 600U, 1U, 4U }, + }) + { + } +}; + +/** Data set containing large 2D tensor shapes. */ +class Large2DShapes final : public ShapeDataset +{ +public: + Large2DShapes() + : ShapeDataset("Shape", + { + TensorShape{ 1920U, 1080U }, + TensorShape{ 1245U, 652U }, + TensorShape{ 4160U, 3120U } + }) + { + } +}; + +/** Data set containing small tensor shapes for direct convolution. */ +class SmallDirectConvolutionShapes final : public ShapeDataset +{ +public: + SmallDirectConvolutionShapes() + : ShapeDataset("InputShape", + { + // Batch size 1 + TensorShape{ 5U, 5U, 3U }, + TensorShape{ 32U, 37U, 3U }, + TensorShape{ 13U, 15U, 8U }, + // Batch size 4 + TensorShape{ 5U, 5U, 3U, 4U }, + TensorShape{ 32U, 37U, 3U, 4U }, + TensorShape{ 13U, 15U, 8U, 4U }, + // Batch size 8 + TensorShape{ 5U, 5U, 3U, 8U }, + TensorShape{ 32U, 37U, 3U, 8U }, + TensorShape{ 13U, 15U, 8U, 8U }, + // Arbitrary batch size + TensorShape{ 32U, 37U, 3U, 8U } + }) + { + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ */ diff --git a/tests/datasets/SmallConvolutionLayerDataset.h b/tests/datasets/SmallConvolutionLayerDataset.h new file mode 100644 index 0000000000..1a26fa5917 --- /dev/null +++ b/tests/datasets/SmallConvolutionLayerDataset.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_SMALL_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_SMALL_CONVOLUTION_LAYER_DATASET + +#include "tests/datasets/ConvolutionLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class SmallConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + SmallConvolutionLayerDataset() + { + // Batch size 1 + add_config(TensorShape(23U, 27U, 5U), TensorShape(3U, 3U, 5U, 21U), TensorShape(21U), TensorShape(11U, 25U, 21U), PadStrideInfo(2, 1, 0, 0)); + add_config(TensorShape(33U, 27U, 7U), TensorShape(5U, 5U, 7U, 16U), TensorShape(16U), TensorShape(11U, 12U, 16U), PadStrideInfo(3, 2, 1, 0)); + add_config(TensorShape(17U, 31U, 2U), TensorShape(5U, 5U, 2U, 19U), TensorShape(19U), TensorShape(15U, 15U, 19U), PadStrideInfo(1, 2, 1, 1)); + add_config(TensorShape(23U, 27U, 5U), TensorShape(3U, 1U, 5U, 21U), TensorShape(21U), TensorShape(11U, 27U, 21U), PadStrideInfo(2, 1, 0, 0)); + add_config(TensorShape(33U, 27U, 7U), TensorShape(5U, 7U, 7U, 16U), TensorShape(16U), TensorShape(11U, 11U, 16U), PadStrideInfo(3, 2, 1, 0)); + add_config(TensorShape(17U, 31U, 2U), TensorShape(5U, 3U, 2U, 19U), TensorShape(19U), TensorShape(15U, 16U, 19U), PadStrideInfo(1, 2, 1, 1)); + // Batch size 4 + add_config(TensorShape(23U, 27U, 5U, 4U), TensorShape(3U, 3U, 5U, 21U), TensorShape(21U), TensorShape(11U, 25U, 21U, 4U), PadStrideInfo(2, 1, 0, 0)); + add_config(TensorShape(33U, 27U, 7U, 4U), TensorShape(5U, 5U, 7U, 16U), TensorShape(16U), TensorShape(11U, 12U, 16U, 4U), PadStrideInfo(3, 2, 1, 0)); + add_config(TensorShape(17U, 31U, 2U, 4U), TensorShape(5U, 5U, 2U, 19U), TensorShape(19U), TensorShape(15U, 15U, 19U, 4U), PadStrideInfo(1, 2, 1, 1)); + add_config(TensorShape(23U, 27U, 5U, 4U), TensorShape(3U, 1U, 5U, 21U), TensorShape(21U), TensorShape(11U, 27U, 21U, 4U), PadStrideInfo(2, 1, 0, 0)); + add_config(TensorShape(33U, 27U, 7U, 4U), TensorShape(5U, 7U, 7U, 16U), TensorShape(16U), TensorShape(11U, 11U, 16U, 4U), PadStrideInfo(3, 2, 1, 0)); + add_config(TensorShape(17U, 31U, 2U, 4U), TensorShape(5U, 3U, 2U, 19U), TensorShape(19U), TensorShape(15U, 16U, 19U, 4U), PadStrideInfo(1, 2, 1, 1)); + // Arbitrary batch size + add_config(TensorShape(33U, 27U, 7U, 5U), TensorShape(5U, 7U, 7U, 16U), TensorShape(16U), TensorShape(11U, 11U, 16U, 5U), PadStrideInfo(3, 2, 1, 0)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_SMALL_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets/SmallDepthwiseConvolutionDataset.h b/tests/datasets/SmallDepthwiseConvolutionDataset.h new file mode 100644 index 0000000000..17d01fb5d6 --- /dev/null +++ b/tests/datasets/SmallDepthwiseConvolutionDataset.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_SMALL_DEPTHWISE_CONVOLUTION_DATASET +#define ARM_COMPUTE_TEST_SMALL_DEPTHWISE_CONVOLUTION_DATASET + +#include "tests/datasets/DepthwiseConvolutionDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class SmallDepthwiseConvolutionDataset final : public DepthwiseConvolutionDataset +{ +public: + SmallDepthwiseConvolutionDataset() + { + add_config(TensorShape(23U, 27U, 5U), TensorShape(3U, 3U, 5U), TensorShape(11U, 25U, 5U), PadStrideInfo(2, 1, 0, 0)); + add_config(TensorShape(33U, 27U, 7U), TensorShape(3U, 3U, 7U), TensorShape(11U, 13U, 7U), PadStrideInfo(3, 2, 1, 0)); + add_config(TensorShape(17U, 31U, 2U), TensorShape(3U, 3U, 2U), TensorShape(17U, 16U, 2U), PadStrideInfo(1, 2, 1, 1)); + add_config(TensorShape(23U, 27U, 5U), TensorShape(3U, 3U, 5U), TensorShape(21U, 13U, 5U), PadStrideInfo(1, 2, 0, 0)); + add_config(TensorShape(33U, 27U, 7U), TensorShape(3U, 3U, 7U), TensorShape(16U, 9U, 7U), PadStrideInfo(2, 3, 0, 1)); + add_config(TensorShape(17U, 31U, 2U), TensorShape(3U, 3U, 2U), TensorShape(9U, 31U, 2U), PadStrideInfo(2, 1, 1, 1)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_SMALL_DEPTHWISE_CONVOLUTION_DATASET */ diff --git a/tests/datasets/SmallGEMMDataset.h b/tests/datasets/SmallGEMMDataset.h new file mode 100644 index 0000000000..0cc3c3aa8c --- /dev/null +++ b/tests/datasets/SmallGEMMDataset.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_SMALL_GEMM_DATASET +#define ARM_COMPUTE_TEST_SMALL_GEMM_DATASET + +#include "tests/datasets/GEMMDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class SmallGEMMDataset final : public GEMMDataset +{ +public: + SmallGEMMDataset() + { + add_config(TensorShape(21U, 13U), TensorShape(33U, 21U), TensorShape(33U, 13U), TensorShape(33U, 13U), 1.0f, 0.0f); + add_config(TensorShape(31U, 1U), TensorShape(23U, 31U), TensorShape(23U, 1U), TensorShape(23U, 1U), 1.0f, 0.0f); + add_config(TensorShape(38U, 12U), TensorShape(21U, 38U), TensorShape(21U, 12U), TensorShape(21U, 12U), 0.2f, 1.2f); + add_config(TensorShape(32U, 1U), TensorShape(17U, 32U), TensorShape(17U, 1U), TensorShape(17U, 1U), 0.4f, 0.7f); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_SMALL_GEMM_DATASET */ diff --git a/tests/datasets/system_tests/alexnet/AlexNetActivationLayerDataset.h b/tests/datasets/system_tests/alexnet/AlexNetActivationLayerDataset.h new file mode 100644 index 0000000000..4030e97436 --- /dev/null +++ b/tests/datasets/system_tests/alexnet/AlexNetActivationLayerDataset.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_ALEXNET_ACTIVATION_LAYER_DATASET +#define ARM_COMPUTE_TEST_ALEXNET_ACTIVATION_LAYER_DATASET + +#include "tests/framework/datasets/Datasets.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class AlexNetActivationLayerDataset final : public + framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> +{ +public: + AlexNetActivationLayerDataset() + : CartesianProductDataset + { + framework::dataset::make("Shape", { TensorShape(55U, 55U, 96U), TensorShape(27U, 27U, 256U), TensorShape(13U, 13U, 384U), TensorShape(13U, 13U, 256U), TensorShape(4096U) }), + framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) + } + { + } + AlexNetActivationLayerDataset(AlexNetActivationLayerDataset &&) = default; + ~AlexNetActivationLayerDataset() = default; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ALEXNET_ACTIVATION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/alexnet/AlexNetConvolutionLayerDataset.h b/tests/datasets/system_tests/alexnet/AlexNetConvolutionLayerDataset.h new file mode 100644 index 0000000000..d0b901a9a1 --- /dev/null +++ b/tests/datasets/system_tests/alexnet/AlexNetConvolutionLayerDataset.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_ALEXNET_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_ALEXNET_CONVOLUTION_LAYER_DATASET + +#include "tests/datasets/ConvolutionLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class AlexNetConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + AlexNetConvolutionLayerDataset() + { + add_config(TensorShape(227U, 227U, 3U), TensorShape(11U, 11U, 3U, 96U), TensorShape(96U), TensorShape(55U, 55U, 96U), PadStrideInfo(4, 4, 0, 0)); + add_config(TensorShape(27U, 27U, 96U), TensorShape(5U, 5U, 96U, 256U), TensorShape(256U), TensorShape(27U, 27U, 256U), PadStrideInfo(1, 1, 2, 2)); + add_config(TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U), PadStrideInfo(1, 1, 1, 1)); + } +}; + +class AlexNetDirectConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + AlexNetDirectConvolutionLayerDataset() + { + add_config(TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1)); + add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U), PadStrideInfo(1, 1, 1, 1)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ALEXNET_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/alexnet/AlexNetFullyConnectedLayerDataset.h b/tests/datasets/system_tests/alexnet/AlexNetFullyConnectedLayerDataset.h new file mode 100644 index 0000000000..50b0f7d75d --- /dev/null +++ b/tests/datasets/system_tests/alexnet/AlexNetFullyConnectedLayerDataset.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_ALEXNET_FULLYCONNECTED_LAYER_DATASET +#define ARM_COMPUTE_TEST_ALEXNET_FULLYCONNECTED_LAYER_DATASET + +#include "tests/datasets/FullyConnectedLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class AlexNetFullyConnectedLayerDataset final : public FullyConnectedLayerDataset +{ +public: + AlexNetFullyConnectedLayerDataset() + { + add_config(TensorShape(6U, 6U, 256U), TensorShape(9216U, 4096U), TensorShape(4096U), TensorShape(4096U)); + add_config(TensorShape(4096U), TensorShape(4096U, 4096U), TensorShape(4096U), TensorShape(4096U)); + add_config(TensorShape(4096U), TensorShape(4096U, 1000U), TensorShape(1000U), TensorShape(1000U)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ALEXNET_FULLYCONNECTED_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/alexnet/AlexNetNormalizationLayerDataset.h b/tests/datasets/system_tests/alexnet/AlexNetNormalizationLayerDataset.h new file mode 100644 index 0000000000..33b7423442 --- /dev/null +++ b/tests/datasets/system_tests/alexnet/AlexNetNormalizationLayerDataset.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_ALEXNET_NORMALIZATION_LAYER_DATASET +#define ARM_COMPUTE_TEST_ALEXNET_NORMALIZATION_LAYER_DATASET + +#include "tests/framework/datasets/Datasets.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class AlexNetNormalizationLayerDataset final : public + framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> +{ +public: + AlexNetNormalizationLayerDataset() + : CartesianProductDataset + { + framework::dataset::make("Shape", { TensorShape(55U, 55U, 96U), TensorShape(27U, 27U, 256U) }), + framework::dataset::make("Info", NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)) + } + { + } + AlexNetNormalizationLayerDataset(AlexNetNormalizationLayerDataset &&) = default; + ~AlexNetNormalizationLayerDataset() = default; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ALEXNET_NORMALIZATION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/alexnet/AlexNetPoolingLayerDataset.h b/tests/datasets/system_tests/alexnet/AlexNetPoolingLayerDataset.h new file mode 100644 index 0000000000..ab2749b36e --- /dev/null +++ b/tests/datasets/system_tests/alexnet/AlexNetPoolingLayerDataset.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_ALEXNET_POOLING_LAYER_DATASET +#define ARM_COMPUTE_TEST_ALEXNET_POOLING_LAYER_DATASET + +#include "tests/datasets/PoolingLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class AlexNetPoolingLayerDataset final : public PoolingLayerDataset +{ +public: + AlexNetPoolingLayerDataset() + { + add_config(TensorShape(55U, 55U, 96U), TensorShape(27U, 27U, 96U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); + add_config(TensorShape(27U, 27U, 256U), TensorShape(13U, 13U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); + add_config(TensorShape(13U, 13U, 256U), TensorShape(6U, 6U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ALEXNET_POOLING_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ActivationLayerDataset.h b/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ActivationLayerDataset.h new file mode 100644 index 0000000000..dc4ffe4e4e --- /dev/null +++ b/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ActivationLayerDataset.h @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_ACTIVATION_LAYER_DATASET +#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_ACTIVATION_LAYER_DATASET + +#include "tests/framework/datasets/Datasets.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class GoogLeNetInceptionV1ActivationLayerDataset final : public + framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> +{ +public: + GoogLeNetInceptionV1ActivationLayerDataset() + : CartesianProductDataset + { + framework::dataset::make("Shape", { // conv1/relu_7x7 + TensorShape(112U, 112U, 64U), + // conv2/relu_3x3_reduce + TensorShape(56U, 56U, 64U), + // conv2/relu_3x3 + TensorShape(56U, 56U, 192U), + // inception_3a/relu_1x1, inception_3b/relu_pool_proj + TensorShape(28U, 28U, 64U), + // inception_3a/relu_3x3_reduce, inception_3b/relu_5x5 + TensorShape(28U, 28U, 96U), + // inception_3a/relu_3x3, inception_3b/relu_1x1, inception_3b/relu_3x3_reduce + TensorShape(28U, 28U, 128U), + // inception_3a/relu_5x5_reduce + TensorShape(28U, 28U, 16U), + // inception_3a/relu_5x5, inception_3a/relu_pool_proj, inception_3b/relu_5x5_reduce + TensorShape(28U, 28U, 32U), + // inception_3b/relu_3x3 + TensorShape(28U, 28U, 192U), + // inception_4a/relu_1x1 + TensorShape(14U, 14U, 192U), + // inception_4a/relu_3x3_reduce + TensorShape(14U, 14U, 96U), + // inception_4a/relu_3x3 + TensorShape(14U, 14U, 208U), + // inception_4a/relu_5x5_reduce + TensorShape(14U, 14U, 16U), + // inception_4a/relu_5x5 + TensorShape(14U, 14U, 48U), + // inception_4a/relu_pool_proj, inception_4b/relu_5x5, inception_4b/relu_pool_proj, inception_4c/relu_5x5, inception_4c/relu_pool_proj, inception_4d/relu_5x5, inception_4d/relu_pool_proj + TensorShape(14U, 14U, 64U), + // inception_4b/relu_1x1, inception_4e/relu_3x3_reduce + TensorShape(14U, 14U, 160U), + // inception_4b/relu_3x3_reduce, inception_4d/relu_1x1 + TensorShape(14U, 14U, 112U), + // inception_4b/relu_3x3 + TensorShape(14U, 14U, 224U), + // inception_4b/relu_5x5_reduce, inception_4c/relu_5x5_reduce + TensorShape(14U, 14U, 24U), + // inception_4c/relu_1x1, inception_4c/relu_3x3_reduce, inception_4e/relu_5x5, inception_4e/relu_pool_proj + TensorShape(14U, 14U, 128U), + // inception_4c/relu_3x3, inception_4e/relu_1x1 + TensorShape(14U, 14U, 256U), + // inception_4d/relu_3x3_reduce + TensorShape(14U, 14U, 144U), + // inception_4d/relu_3x3 + TensorShape(14U, 14U, 288U), + // inception_4d/relu_5x5_reduce, inception_4e/relu_5x5_reduce + TensorShape(14U, 14U, 32U), + // inception_4e/relu_3x3 + TensorShape(14U, 14U, 320U), + // inception_5a/relu_1x1 + TensorShape(7U, 7U, 256U), + // inception_5a/relu_3x3_reduce + TensorShape(7U, 7U, 160U), + // inception_5a/relu_3x3 + TensorShape(7U, 7U, 320U), + // inception_5a/relu_5x5_reduce + TensorShape(7U, 7U, 32U), + // inception_5a/relu_5x5, inception_5a/relu_pool_proj, inception_5b/relu_5x5, inception_5b/relu_pool_proj + TensorShape(7U, 7U, 128U), + // inception_5b/relu_1x1, inception_5b/relu_3x3 + TensorShape(7U, 7U, 384U), + // inception_5b/relu_3x3_reduce + TensorShape(7U, 7U, 192U), + // inception_5b/relu_5x5_reduce + TensorShape(7U, 7U, 48U) }), + framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) + } + { + } + GoogLeNetInceptionV1ActivationLayerDataset(GoogLeNetInceptionV1ActivationLayerDataset &&) = default; + ~GoogLeNetInceptionV1ActivationLayerDataset() = default; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_ACTIVATION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ConvolutionLayerDataset.h b/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ConvolutionLayerDataset.h new file mode 100644 index 0000000000..a4002d124d --- /dev/null +++ b/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ConvolutionLayerDataset.h @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_CONVOLUTION_LAYER_DATASET + +#include "tests/datasets/ConvolutionLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class GoogLeNetInceptionV1ConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + // GoogLeNetInceptionV1 inception v1 dataset + GoogLeNetInceptionV1ConvolutionLayerDataset() + { + // conv1/7x7_s2 + add_config(TensorShape(224U, 224U, 3U), TensorShape(7U, 7U, 3U, 64U), TensorShape(64U), TensorShape(112U, 112U, 64U), PadStrideInfo(2, 2, 3, 3)); + // conv2/3x3_reduce + add_config(TensorShape(56U, 56U, 64U), TensorShape(1U, 1U, 64U, 64U), TensorShape(64U), TensorShape(56U, 56U, 64U), PadStrideInfo(1, 1, 0, 0)); + // conv2/3x3 + add_config(TensorShape(56U, 56U, 64U), TensorShape(3U, 3U, 64U, 192U), TensorShape(192U), TensorShape(56U, 56U, 192U), PadStrideInfo(1, 1, 1, 1)); + // inception_3a/1x1 + add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0)); + // inception_3a/3x3_reduce + add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 96U), TensorShape(96U), TensorShape(28U, 28U, 96U), PadStrideInfo(1, 1, 0, 0)); + // inception_3a/3x3 + add_config(TensorShape(28U, 28U, 96U), TensorShape(3U, 3U, 96U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 1, 1)); + // inception_3a/5x5_reduce + add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 16U), TensorShape(16U), TensorShape(28U, 28U, 16U), PadStrideInfo(1, 1, 0, 0)); + // inception_3a/5x5 + add_config(TensorShape(28U, 28U, 16U), TensorShape(5U, 5U, 16U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 2, 2)); + // inception_3a/pool_proj + add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0)); + // inception_3b/1x1, inception_3b/3x3_reduce + add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 0, 0)); + // inception_3b/3x3 + add_config(TensorShape(28U, 28U, 128U), TensorShape(3U, 3U, 128U, 192U), TensorShape(192U), TensorShape(28U, 28U, 192U), PadStrideInfo(1, 1, 1, 1)); + // inception_3b/5x5_reduce + add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0)); + // inception_3b/5x5 + add_config(TensorShape(28U, 28U, 32U), TensorShape(5U, 5U, 32U, 96U), TensorShape(96U), TensorShape(28U, 28U, 96U), PadStrideInfo(1, 1, 2, 2)); + // inception_3b/pool_proj + add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0)); + // inception_4a/1x1 + add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 192U), TensorShape(192U), TensorShape(14U, 14U, 192U), PadStrideInfo(1, 1, 0, 0)); + // inception_4a/3x3_reduce + add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 96U), TensorShape(96U), TensorShape(14U, 14U, 96U), PadStrideInfo(1, 1, 0, 0)); + // inception_4a/3x3 + add_config(TensorShape(14U, 14U, 96U), TensorShape(3U, 3U, 96U, 208U), TensorShape(208U), TensorShape(14U, 14U, 208U), PadStrideInfo(1, 1, 1, 1)); + // inception_4a/5x5_reduce + add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 16U), TensorShape(16U), TensorShape(14U, 14U, 16U), PadStrideInfo(1, 1, 0, 0)); + // inception_4a/5x5 + add_config(TensorShape(14U, 14U, 16U), TensorShape(5U, 5U, 16U, 48U), TensorShape(48U), TensorShape(14U, 14U, 48U), PadStrideInfo(1, 1, 2, 2)); + // inception_4a/pool_proj + add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0)); + // inception_4b/1x1 + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0)); + // inception_4b/3x3_reduce, inception_4d/1x1 + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 112U), TensorShape(112U), TensorShape(14U, 14U, 112U), PadStrideInfo(1, 1, 0, 0)); + // inception_4b/3x3 + add_config(TensorShape(14U, 14U, 112U), TensorShape(3U, 3U, 112U, 224U), TensorShape(224U), TensorShape(14U, 14U, 224U), PadStrideInfo(1, 1, 1, 1)); + // inception_4b/5x5_reduce, inception_4c/5x5_reduce + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 24U), TensorShape(24U), TensorShape(14U, 14U, 24U), PadStrideInfo(1, 1, 0, 0)); + // inception_4b/5x5, inception_4c/5x5 + add_config(TensorShape(14U, 14U, 24U), TensorShape(5U, 5U, 24U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 2, 2)); + // inception_4b/pool_proj, inception_4c/pool_proj, inception_4d/pool_proj + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0)); + // inception_4c/1x1, inception_4c/3x3_reduce + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0)); + // inception_4c/3x3 + add_config(TensorShape(14U, 14U, 128U), TensorShape(3U, 3U, 128U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 1, 1)); + // inception_4d/3x3_reduce + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 144U), TensorShape(144U), TensorShape(14U, 14U, 144U), PadStrideInfo(1, 1, 0, 0)); + // inception_4d/3x3 + add_config(TensorShape(14U, 14U, 144U), TensorShape(3U, 3U, 144U, 288U), TensorShape(288U), TensorShape(14U, 14U, 288U), PadStrideInfo(1, 1, 1, 1)); + // inception_4d/5x5_reduce + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0)); + // inception_4d/5x5 + add_config(TensorShape(14U, 14U, 32U), TensorShape(5U, 5U, 32U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 2, 2)); + // inception_4e/1x1 + add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 0, 0)); + // inception_4e/3x3_reduce + add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0)); + // inception_4e/3x3 + add_config(TensorShape(14U, 14U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(14U, 14U, 320U), PadStrideInfo(1, 1, 1, 1)); + // inception_4e/5x5_reduce + add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0)); + // inception_4e/5x5 + add_config(TensorShape(14U, 14U, 32U), TensorShape(5U, 5U, 32U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 2, 2)); + // inception_4e/pool_proj + add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0)); + // inception_5a/1x1 + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 256U), TensorShape(256U), TensorShape(7U, 7U, 256U), PadStrideInfo(1, 1, 0, 0)); + // inception_5a/3x3_reduce + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 160U), TensorShape(160U), TensorShape(7U, 7U, 160U), PadStrideInfo(1, 1, 0, 0)); + // inception_5a/3x3 + add_config(TensorShape(7U, 7U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(7U, 7U, 320U), PadStrideInfo(1, 1, 1, 1)); + // inception_5a/5x5_reduce + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 32U), TensorShape(32U), TensorShape(7U, 7U, 32U), PadStrideInfo(1, 1, 0, 0)); + // inception_5a/5x5 + add_config(TensorShape(7U, 7U, 32U), TensorShape(5U, 5U, 32U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 2, 2)); + // inception_5a/pool_proj, inception_5b/pool_proj + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 0, 0)); + // inception_5b/1x1 + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 0, 0)); + // inception_5b/3x3_reduce + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 192U), TensorShape(192U), TensorShape(7U, 7U, 192U), PadStrideInfo(1, 1, 0, 0)); + // inception_5b/3x3 + add_config(TensorShape(7U, 7U, 192U), TensorShape(3U, 3U, 192U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 1, 1)); + // inception_5b/5x5_reduce + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 48U), TensorShape(48U), TensorShape(7U, 7U, 48U), PadStrideInfo(1, 1, 0, 0)); + // inception_5b/5x5 + add_config(TensorShape(7U, 7U, 48U), TensorShape(5U, 5U, 48U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 2, 2)); + } +}; + +class GoogLeNetInceptionV1DirectConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + // subset of GoogLeNetInceptionV1 inception v1 dataset + GoogLeNetInceptionV1DirectConvolutionLayerDataset() + { + // conv2/3x3_reduce + add_config(TensorShape(56U, 56U, 64U), TensorShape(1U, 1U, 64U, 64U), TensorShape(64U), TensorShape(56U, 56U, 64U), PadStrideInfo(1, 1, 0, 0)); + // conv2/3x3 + add_config(TensorShape(56U, 56U, 64U), TensorShape(3U, 3U, 64U, 192U), TensorShape(192U), TensorShape(56U, 56U, 192U), PadStrideInfo(1, 1, 1, 1)); + // inception_3a/1x1 + add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0)); + // inception_3a/3x3_reduce + add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 96U), TensorShape(96U), TensorShape(28U, 28U, 96U), PadStrideInfo(1, 1, 0, 0)); + // inception_3a/3x3 + add_config(TensorShape(28U, 28U, 96U), TensorShape(3U, 3U, 96U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 1, 1)); + // inception_3a/5x5_reduce + add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 16U), TensorShape(16U), TensorShape(28U, 28U, 16U), PadStrideInfo(1, 1, 0, 0)); + // inception_3a/pool_proj + add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0)); + // inception_3b/1x1, inception_3b/3x3_reduce + add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 0, 0)); + // inception_3b/3x3 + add_config(TensorShape(28U, 28U, 128U), TensorShape(3U, 3U, 128U, 192U), TensorShape(192U), TensorShape(28U, 28U, 192U), PadStrideInfo(1, 1, 1, 1)); + // inception_3b/5x5_reduce + add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0)); + // inception_3b/pool_proj + add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0)); + // inception_4a/1x1 + add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 192U), TensorShape(192U), TensorShape(14U, 14U, 192U), PadStrideInfo(1, 1, 0, 0)); + // inception_4a/3x3_reduce + add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 96U), TensorShape(96U), TensorShape(14U, 14U, 96U), PadStrideInfo(1, 1, 0, 0)); + // inception_4a/3x3 + add_config(TensorShape(14U, 14U, 96U), TensorShape(3U, 3U, 96U, 208U), TensorShape(208U), TensorShape(14U, 14U, 208U), PadStrideInfo(1, 1, 1, 1)); + // inception_4a/pool_proj + add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0)); + // inception_4b/1x1 + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0)); + // inception_4b/3x3_reduce, inception_4d/1x1 + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 112U), TensorShape(112U), TensorShape(14U, 14U, 112U), PadStrideInfo(1, 1, 0, 0)); + // inception_4b/3x3 + add_config(TensorShape(14U, 14U, 112U), TensorShape(3U, 3U, 112U, 224U), TensorShape(224U), TensorShape(14U, 14U, 224U), PadStrideInfo(1, 1, 1, 1)); + // inception_4b/5x5_reduce, inception_4c/5x5_reduce + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 24U), TensorShape(24U), TensorShape(14U, 14U, 24U), PadStrideInfo(1, 1, 0, 0)); + // inception_4b/pool_proj, inception_4c/pool_proj, inception_4d/pool_proj + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0)); + // inception_4c/1x1, inception_4c/3x3_reduce + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0)); + // inception_4c/3x3 + add_config(TensorShape(14U, 14U, 128U), TensorShape(3U, 3U, 128U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 1, 1)); + // inception_4d/3x3_reduce + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 144U), TensorShape(144U), TensorShape(14U, 14U, 144U), PadStrideInfo(1, 1, 0, 0)); + // inception_4d/3x3 + add_config(TensorShape(14U, 14U, 144U), TensorShape(3U, 3U, 144U, 288U), TensorShape(288U), TensorShape(14U, 14U, 288U), PadStrideInfo(1, 1, 1, 1)); + // inception_4d/5x5_reduce + add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0)); + // inception_4e/1x1 + add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 0, 0)); + // inception_4e/3x3_reduce + add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0)); + // inception_4e/3x3 + add_config(TensorShape(14U, 14U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(14U, 14U, 320U), PadStrideInfo(1, 1, 1, 1)); + // inception_4e/5x5_reduce + add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0)); + // inception_4e/pool_proj + add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0)); + // inception_5a/1x1 + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 256U), TensorShape(256U), TensorShape(7U, 7U, 256U), PadStrideInfo(1, 1, 0, 0)); + // inception_5a/3x3_reduce + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 160U), TensorShape(160U), TensorShape(7U, 7U, 160U), PadStrideInfo(1, 1, 0, 0)); + // inception_5a/3x3 + add_config(TensorShape(7U, 7U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(7U, 7U, 320U), PadStrideInfo(1, 1, 1, 1)); + // inception_5a/5x5_reduce + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 32U), TensorShape(32U), TensorShape(7U, 7U, 32U), PadStrideInfo(1, 1, 0, 0)); + // inception_5a/pool_proj, inception_5b/pool_proj + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 0, 0)); + // inception_5b/1x1 + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 0, 0)); + // inception_5b/3x3_reduce + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 192U), TensorShape(192U), TensorShape(7U, 7U, 192U), PadStrideInfo(1, 1, 0, 0)); + // inception_5b/3x3 + add_config(TensorShape(7U, 7U, 192U), TensorShape(3U, 3U, 192U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 1, 1)); + // inception_5b/5x5_reduce + add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 48U), TensorShape(48U), TensorShape(7U, 7U, 48U), PadStrideInfo(1, 1, 0, 0)); + } +}; + +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1FullyConnectedLayerDataset.h b/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1FullyConnectedLayerDataset.h new file mode 100644 index 0000000000..80a3473bc7 --- /dev/null +++ b/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1FullyConnectedLayerDataset.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_FULLYCONNECTED_LAYER_DATASET +#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_FULLYCONNECTED_LAYER_DATASET + +#include "tests/datasets/FullyConnectedLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class GoogLeNetInceptionV1FullyConnectedLayerDataset final : public FullyConnectedLayerDataset +{ +public: + GoogLeNetInceptionV1FullyConnectedLayerDataset() + { + add_config(TensorShape(1024U), TensorShape(1024U, 1000U), TensorShape(1000U), TensorShape(1000U)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_FULLYCONNECTED_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1GEMMDataset.h b/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1GEMMDataset.h new file mode 100644 index 0000000000..806ca9378a --- /dev/null +++ b/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1GEMMDataset.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_GEMM_DATASET +#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_GEMM_DATASET + +#include "tests/datasets/GEMMDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class GoogLeNetInceptionV1GEMMDataset final : public GEMMDataset +{ +public: + GoogLeNetInceptionV1GEMMDataset() + { + add_config(TensorShape(147U, 12544U), TensorShape(64U, 147U), TensorShape(64U, 12544U), TensorShape(64U, 12544U), 1.0f, 0.0f); + add_config(TensorShape(64U, 3136U), TensorShape(64U, 64U), TensorShape(64U, 3136U), TensorShape(64U, 3136U), 1.0f, 0.0f); + add_config(TensorShape(576U, 3136U), TensorShape(192U, 576U), TensorShape(192U, 3136U), TensorShape(192U, 3136U), 1.0f, 0.0f); + add_config(TensorShape(192U, 784U), TensorShape(64U, 192U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f); + add_config(TensorShape(192U, 784U), TensorShape(96U, 192U), TensorShape(96U, 784U), TensorShape(96U, 784U), 1.0f, 0.0f); + add_config(TensorShape(864U, 784U), TensorShape(128U, 864U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f); + add_config(TensorShape(192U, 784U), TensorShape(16U, 192U), TensorShape(16U, 784U), TensorShape(16U, 784U), 1.0f, 0.0f); + add_config(TensorShape(400U, 784U), TensorShape(32U, 400U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f); + add_config(TensorShape(192U, 784U), TensorShape(32U, 192U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f); + add_config(TensorShape(256U, 784U), TensorShape(128U, 256U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f); + add_config(TensorShape(256U, 784U), TensorShape(128U, 256U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f); + add_config(TensorShape(1152U, 784U), TensorShape(192U, 1152U), TensorShape(192U, 784U), TensorShape(192U, 784U), 1.0f, 0.0f); + add_config(TensorShape(256U, 784U), TensorShape(32U, 256U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f); + add_config(TensorShape(800U, 784U), TensorShape(96U, 800U), TensorShape(96U, 784U), TensorShape(96U, 784U), 1.0f, 0.0f); + add_config(TensorShape(256U, 784U), TensorShape(64U, 256U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f); + add_config(TensorShape(480U, 196U), TensorShape(192U, 480U), TensorShape(192U, 196U), TensorShape(192U, 196U), 1.0f, 0.0f); + add_config(TensorShape(480U, 196U), TensorShape(96U, 480U), TensorShape(96U, 196U), TensorShape(96U, 196U), 1.0f, 0.0f); + add_config(TensorShape(864U, 196U), TensorShape(204U, 864U), TensorShape(204U, 196U), TensorShape(204U, 196U), 1.0f, 0.0f); + add_config(TensorShape(480U, 196U), TensorShape(16U, 480U), TensorShape(16U, 196U), TensorShape(16U, 196U), 1.0f, 0.0f); + add_config(TensorShape(400U, 196U), TensorShape(48U, 400U), TensorShape(48U, 196U), TensorShape(48U, 196U), 1.0f, 0.0f); + add_config(TensorShape(480U, 196U), TensorShape(64U, 480U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); + add_config(TensorShape(508U, 196U), TensorShape(160U, 508U), TensorShape(160U, 196U), TensorShape(160U, 196U), 1.0f, 0.0f); + add_config(TensorShape(508U, 196U), TensorShape(112U, 508U), TensorShape(112U, 196U), TensorShape(112U, 196U), 1.0f, 0.0f); + add_config(TensorShape(1008U, 196U), TensorShape(224U, 1008U), TensorShape(224U, 196U), TensorShape(224U, 196U), 1.0f, 0.0f); + add_config(TensorShape(508U, 196U), TensorShape(24U, 508U), TensorShape(24U, 196U), TensorShape(24U, 196U), 1.0f, 0.0f); + add_config(TensorShape(600U, 196U), TensorShape(64U, 600U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); + add_config(TensorShape(508U, 196U), TensorShape(64U, 508U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); + add_config(TensorShape(512U, 196U), TensorShape(128U, 512U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f); + add_config(TensorShape(512U, 196U), TensorShape(128U, 512U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f); + add_config(TensorShape(1152U, 196U), TensorShape(256U, 1152U), TensorShape(256U, 196U), TensorShape(256U, 196U), 1.0f, 0.0f); + add_config(TensorShape(512U, 196U), TensorShape(24U, 512U), TensorShape(24U, 196U), TensorShape(24U, 196U), 1.0f, 0.0f); + add_config(TensorShape(600U, 196U), TensorShape(64U, 600U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); + add_config(TensorShape(512U, 196U), TensorShape(64U, 512U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); + add_config(TensorShape(512U, 196U), TensorShape(112U, 512U), TensorShape(112U, 196U), TensorShape(112U, 196U), 1.0f, 0.0f); + add_config(TensorShape(512U, 196U), TensorShape(144U, 512U), TensorShape(144U, 196U), TensorShape(144U, 196U), 1.0f, 0.0f); + add_config(TensorShape(1296U, 196U), TensorShape(288U, 1296U), TensorShape(288U, 196U), TensorShape(288U, 196U), 1.0f, 0.0f); + add_config(TensorShape(512U, 196U), TensorShape(32U, 512U), TensorShape(32U, 196U), TensorShape(32U, 196U), 1.0f, 0.0f); + add_config(TensorShape(800U, 196U), TensorShape(64U, 800U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); + add_config(TensorShape(512U, 196U), TensorShape(64U, 512U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); + add_config(TensorShape(528U, 196U), TensorShape(256U, 528U), TensorShape(256U, 196U), TensorShape(256U, 196U), 1.0f, 0.0f); + add_config(TensorShape(528U, 196U), TensorShape(160U, 528U), TensorShape(160U, 196U), TensorShape(160U, 196U), 1.0f, 0.0f); + add_config(TensorShape(1440U, 196U), TensorShape(320U, 1440U), TensorShape(320U, 196U), TensorShape(320U, 196U), 1.0f, 0.0f); + add_config(TensorShape(528U, 196U), TensorShape(32U, 528U), TensorShape(32U, 196U), TensorShape(32U, 196U), 1.0f, 0.0f); + add_config(TensorShape(800U, 196U), TensorShape(128U, 800U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f); + add_config(TensorShape(528U, 196U), TensorShape(128U, 528U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f); + add_config(TensorShape(832U, 49U), TensorShape(256U, 832U), TensorShape(256U, 49U), TensorShape(256U, 49U), 1.0f, 0.0f); + add_config(TensorShape(832U, 49U), TensorShape(160U, 832U), TensorShape(160U, 49U), TensorShape(160U, 49U), 1.0f, 0.0f); + add_config(TensorShape(1440U, 49U), TensorShape(320U, 1440U), TensorShape(320U, 49U), TensorShape(320U, 49U), 1.0f, 0.0f); + add_config(TensorShape(832U, 49U), TensorShape(48U, 832U), TensorShape(48U, 49U), TensorShape(48U, 49U), 1.0f, 0.0f); + add_config(TensorShape(1200U, 49U), TensorShape(128U, 1200U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f); + add_config(TensorShape(832U, 49U), TensorShape(128U, 832U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f); + add_config(TensorShape(832U, 49U), TensorShape(384U, 832U), TensorShape(384U, 49U), TensorShape(384U, 49U), 1.0f, 0.0f); + add_config(TensorShape(832U, 49U), TensorShape(192U, 832U), TensorShape(192U, 49U), TensorShape(192U, 49U), 1.0f, 0.0f); + add_config(TensorShape(1728U, 49U), TensorShape(384U, 1728U), TensorShape(384U, 49U), TensorShape(384U, 49U), 1.0f, 0.0f); + add_config(TensorShape(832U, 49U), TensorShape(48U, 832U), TensorShape(48U, 49U), TensorShape(48U, 49U), 1.0f, 0.0f); + add_config(TensorShape(1200U, 49U), TensorShape(128U, 1200U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f); + add_config(TensorShape(832U, 49U), TensorShape(128U, 832U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f); + add_config(TensorShape(508U, 16U), TensorShape(128U, 508U), TensorShape(128U, 16U), TensorShape(128U, 16U), 1.0f, 0.0f); + add_config(TensorShape(2048U, 1U), TensorShape(1024U, 2048U), TensorShape(1024U, 1U), TensorShape(1024U, 1U), 1.0f, 0.0f); + add_config(TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f); + add_config(TensorShape(528U, 16U), TensorShape(128U, 528U), TensorShape(128U, 16U), TensorShape(128U, 16U), 1.0f, 0.0f); + add_config(TensorShape(2048U, 1U), TensorShape(1024U, 2048U), TensorShape(1024U, 1U), TensorShape(1024U, 1U), 1.0f, 0.0f); + add_config(TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f); + add_config(TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_GEMM_DATASET */ diff --git a/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1NormalizationLayerDataset.h b/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1NormalizationLayerDataset.h new file mode 100644 index 0000000000..d8fd061b66 --- /dev/null +++ b/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1NormalizationLayerDataset.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_NORMALIZATION_LAYER_DATASET +#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_NORMALIZATION_LAYER_DATASET + +#include "tests/framework/datasets/Datasets.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class GoogLeNetInceptionV1NormalizationLayerDataset final : public + framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> +{ +public: + GoogLeNetInceptionV1NormalizationLayerDataset() + : CartesianProductDataset + { + framework::dataset::make("Shape", { // conv2/norm2 + TensorShape(56U, 56U, 192U), + // pool1/norm1 + TensorShape(56U, 56U, 64U) }), + framework::dataset::make("Info", NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)) + } + { + } + GoogLeNetInceptionV1NormalizationLayerDataset(GoogLeNetInceptionV1NormalizationLayerDataset &&) = default; + ~GoogLeNetInceptionV1NormalizationLayerDataset() = default; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_NORMALIZATION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1PoolingLayerDataset.h b/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1PoolingLayerDataset.h new file mode 100644 index 0000000000..6164bbacea --- /dev/null +++ b/tests/datasets/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1PoolingLayerDataset.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_POOLING_LAYER_DATASET +#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_POOLING_LAYER_DATASET + +#include "tests/datasets/PoolingLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class GoogLeNetInceptionV1PoolingLayerDataset final : public PoolingLayerDataset +{ +public: + GoogLeNetInceptionV1PoolingLayerDataset() + { + // FIXME: Add support for 7x7 pooling layer pool5/7x7_s1 + // pool1/3x3_s2 + add_config(TensorShape(112U, 112U, 64U), TensorShape(56U, 56U, 64U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // pool2/3x3_s2 + add_config(TensorShape(56U, 56U, 192U), TensorShape(28U, 28U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // inception_3a/pool + add_config(TensorShape(28U, 28U, 192U), TensorShape(28U, 28U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); + // inception_3b/pool + add_config(TensorShape(28U, 28U, 256U), TensorShape(28U, 28U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); + // pool3/3x3_s2 + add_config(TensorShape(28U, 28U, 480U), TensorShape(14U, 14U, 480U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // inception_4a/pool + add_config(TensorShape(14U, 14U, 480U), TensorShape(14U, 14U, 480U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); + // inception_4b/pool, inception_4c/pool, inception_4d/pool + add_config(TensorShape(14U, 14U, 512U), TensorShape(14U, 14U, 512U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); + // inception_4e/pool + add_config(TensorShape(14U, 14U, 528U), TensorShape(14U, 14U, 528U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); + // pool4/3x3_s2 + add_config(TensorShape(14U, 14U, 832U), TensorShape(7U, 7U, 832U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // inception_5a/pool, inception_5b/pool + add_config(TensorShape(7U, 7U, 832U), TensorShape(7U, 7U, 832U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_POOLING_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ActivationLayerDataset.h b/tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ActivationLayerDataset.h new file mode 100644 index 0000000000..2d586390ec --- /dev/null +++ b/tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ActivationLayerDataset.h @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_ACTIVATION_LAYER_DATASET +#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_ACTIVATION_LAYER_DATASET + +#include "tests/framework/datasets/Datasets.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class GoogLeNetInceptionV4ActivationLayerDataset final : public + framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> +{ +public: + GoogLeNetInceptionV4ActivationLayerDataset() + : CartesianProductDataset + { + framework::dataset::make("Shape", { // conv1_3x3_s2_relu + TensorShape(149U, 149U, 32U), + // conv2_3x3_s1_relu + TensorShape(147U, 147U, 32U), + // conv3_3x3_s1_relu + TensorShape(147U, 147U, 64U), + // inception_stem1_3x3_s2_relu + TensorShape(73U, 73U, 96U), + // inception_stem2_3x3_reduce_relu, inception_stem2_1x7_reduce_relu, inception_stem2_1x7_relu, inception_stem2_7x1_relu + TensorShape(73U, 73U, 64U), + // inception_stem2_3x3_relu, inception_stem2_3x3_2_relu + TensorShape(71U, 71U, 96U), + // inception_stem3_3x3_s2_relu, reduction_a_3x3_2_reduce_relu + TensorShape(35U, 35U, 192U), + // inception_a1_1x1_2_relu, inception_a1_3x3_relu, inception_a1_3x3_2_relu, inception_a1_3x3_3_relu, inception_a1_1x1_relu, inception_a2_1x1_2_relu, inception_a2_3x3_relu, inception_a2_3x3_2_relu, inception_a2_3x3_3_relu, inception_a2_1x1_relu, inception_a3_1x1_2_relu, inception_a3_3x3_relu, inception_a3_3x3_2_relu, inception_a3_3x3_3_relu, inception_a3_1x1_relu, inception_a4_1x1_2_relu, inception_a4_3x3_relu, inception_a4_3x3_2_relu, inception_a4_3x3_3_relu, inception_a4_1x1_relu + TensorShape(35U, 35U, 96U), + // inception_a1_3x3_reduce_relu, inception_a1_3x3_2_reduce_relu, inception_a2_3x3_reduce_relu, inception_a2_3x3_2_reduce_relu, inception_a3_3x3_reduce_relu, inception_a3_3x3_2_reduce_relu, inception_a4_3x3_reduce_relu, inception_a4_3x3_2_reduce_relu + TensorShape(35U, 35U, 64U), + // reduction_a_3x3_relu, inception_b1_1x1_2_relu, inception_b2_1x1_2_relu, inception_b3_1x1_2_relu, inception_b4_1x1_2_relu, inception_b5_1x1_2_relu, inception_b6_1x1_2_relu, inception_b7_1x1_2_relu + TensorShape(17U, 17U, 384U), + // reduction_a_3x3_2_relu + TensorShape(35U, 35U, 224U), + // reduction_a_3x3_3_relu, inception_b1_7x1_relu, inception_b1_1x7_3_relu, inception_b2_7x1_relu, inception_b2_1x7_3_relu, inception_b3_7x1_relu, inception_b3_1x7_3_relu, inception_b4_7x1_relu, inception_b4_1x7_3_relu, inception_b5_7x1_relu, inception_b5_1x7_3_relu, inception_b6_7x1_relu, inception_b6_1x7_3_relu, inception_b7_7x1_relu, inception_b7_1x7_3_relu, reduction_b_1x7_reduce_relu, reduction_b_1x7_relu + TensorShape(17U, 17U, 256U), + // inception_b1_1x7_reduce_relu, inception_b1_7x1_2_reduce_relu, inception_b1_7x1_2_relu, inception_b2_1x7_reduce_relu, inception_b2_7x1_2_reduce_relu, inception_b2_7x1_2_relu, inception_b3_1x7_reduce_relu, inception_b3_7x1_2_reduce_relu, inception_b3_7x1_2_relu, inception_b4_1x7_reduce_relu, inception_b4_7x1_2_reduce_relu, inception_b4_7x1_2_relu, inception_b5_1x7_reduce_relu, inception_b5_7x1_2_reduce_relu, inception_b5_7x1_2_relu, inception_b6_1x7_reduce_relu, inception_b6_7x1_2_reduce_relu, inception_b6_7x1_2_relu, inception_b7_1x7_reduce_relu, inception_b7_7x1_2_reduce_relu, inception_b7_7x1_2_relu, reduction_b_3x3_reduce_relu + TensorShape(17U, 17U, 192U), + // inception_b1_1x7_relu, inception_b1_1x7_2_relu, inception_b1_7x1_3_relu, inception_b2_1x7_relu, inception_b2_1x7_2_relu, inception_b2_7x1_3_relu, inception_b3_1x7_relu, inception_b3_1x7_2_relu, inception_b3_7x1_3_relu, inception_b4_1x7_relu, inception_b4_1x7_2_relu, inception_b4_7x1_3_relu, inception_b5_1x7_relu, inception_b5_1x7_2_relu, inception_b5_7x1_3_relu, inception_b6_1x7_relu, inception_b6_1x7_2_relu, inception_b6_7x1_3_relu, inception_b7_1x7_relu, inception_b7_1x7_2_relu, inception_b7_7x1_3_relu + TensorShape(17U, 17U, 224U), + // inception_b1_1x1_relu, inception_b2_1x1_relu, inception_b3_1x1_relu, inception_b4_1x1_relu, inception_b5_1x1_relu, inception_b6_1x1_relu, inception_b7_1x1_relu + TensorShape(17U, 17U, 128U), + // reduction_b_3x3_relu + TensorShape(8U, 8U, 192U), + // reduction_b_7x1_relu + TensorShape(17U, 17U, 320U), + // reduction_b_3x3_2_relu + TensorShape(8U, 8U, 320U), + // inception_c1_1x1_2_relu, inception_c1_1x3_relu, inception_c1_3x1_relu, inception_c1_1x3_3_relu, inception_c1_3x1_3_relu, inception_c1_1x1_relu, inception_c2_1x1_2_relu, inception_c2_1x3_relu, inception_c2_3x1_relu, inception_c2_1x3_3_relu, inception_c2_3x1_3_relu, inception_c2_1x1_relu, inception_c3_1x1_2_relu, inception_c3_1x3_relu, inception_c3_3x1_relu, inception_c3_1x3_3_relu, inception_c3_3x1_3_relu, inception_c3_1x1_relu + TensorShape(8U, 8U, 256U), + // inception_c1_1x1_3_relu, inception_c1_1x1_4_relu, inception_c2_1x1_3_relu, inception_c2_1x1_4_relu, inception_c3_1x1_3_relu, inception_c3_1x1_4_relu + TensorShape(8U, 8U, 384U), + // inception_c1_3x1_2_relu, inception_c2_3x1_2_relu, inception_c3_3x1_2_relu + TensorShape(8U, 8U, 448U), + // inception_c1_1x3_2_relu, inception_c2_1x3_2_relu, inception_c3_1x3_2_relu + TensorShape(8U, 8U, 512U) }), + framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) + } + { + } + GoogLeNetInceptionV4ActivationLayerDataset(GoogLeNetInceptionV4ActivationLayerDataset &&) = default; + ~GoogLeNetInceptionV4ActivationLayerDataset() = default; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_ACTIVATION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4BatchNormalizationLayerDataset.h b/tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4BatchNormalizationLayerDataset.h new file mode 100644 index 0000000000..d96410f9eb --- /dev/null +++ b/tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4BatchNormalizationLayerDataset.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_BATCHNORMALIZATION_LAYER_DATASET +#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_BATCHNORMALIZATION_LAYER_DATASET + +#include "tests/datasets/BatchNormalizationLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class GoogLeNetInceptionV4BatchNormalizationLayerDataset final : public BatchNormalizationLayerDataset +{ +public: + GoogLeNetInceptionV4BatchNormalizationLayerDataset() + { + // conv1_3x3_s2_bn + add_config(TensorShape(149U, 149U, 32U), TensorShape(32U), 0.000010f); + // conv2_3x3_s1_bn + add_config(TensorShape(147U, 147U, 32U), TensorShape(32U), 0.000010f); + // conv3_3x3_s1_bn + add_config(TensorShape(147U, 147U, 64U), TensorShape(64U), 0.000010f); + // inception_stem1_3x3_s2_bn + add_config(TensorShape(73U, 73U, 96U), TensorShape(96U), 0.000010f); + // inception_stem2_3x3_reduce_bn, inception_stem2_1x7_reduce_bn, inception_stem2_1x7_bn, inception_stem2_7x1_bn + add_config(TensorShape(73U, 73U, 64U), TensorShape(64U), 0.000010f); + // inception_stem2_3x3_bn, inception_stem2_3x3_2_bn + add_config(TensorShape(71U, 71U, 96U), TensorShape(96U), 0.000010f); + // inception_stem3_3x3_s2_bn, reduction_a_3x3_2_reduce_bn + add_config(TensorShape(35U, 35U, 192U), TensorShape(192U), 0.000010f); + // inception_a1_1x1_2_bn, inception_a1_3x3_bn, inception_a1_3x3_2_bn, inception_a1_3x3_3_bn, inception_a1_1x1_bn, inception_a2_1x1_2_bn, inception_a2_3x3_bn, inception_a2_3x3_2_bn, inception_a2_3x3_3_bn, inception_a2_1x1_bn, inception_a3_1x1_2_bn, inception_a3_3x3_bn, inception_a3_3x3_2_bn, inception_a3_3x3_3_bn, inception_a3_1x1_bn, inception_a4_1x1_2_bn, inception_a4_3x3_bn, inception_a4_3x3_2_bn, inception_a4_3x3_3_bn, inception_a4_1x1_bn + add_config(TensorShape(35U, 35U, 96U), TensorShape(96U), 0.000010f); + // inception_a1_3x3_reduce_bn, inception_a1_3x3_2_reduce_bn, inception_a2_3x3_reduce_bn, inception_a2_3x3_2_reduce_bn, inception_a3_3x3_reduce_bn, inception_a3_3x3_2_reduce_bn, inception_a4_3x3_reduce_bn, inception_a4_3x3_2_reduce_bn + add_config(TensorShape(35U, 35U, 64U), TensorShape(64U), 0.000010f); + // reduction_a_3x3_bn, inception_b1_1x1_2_bn, inception_b2_1x1_2_bn, inception_b3_1x1_2_bn, inception_b4_1x1_2_bn, inception_b5_1x1_2_bn, inception_b6_1x1_2_bn, inception_b7_1x1_2_bn + add_config(TensorShape(17U, 17U, 384U), TensorShape(384U), 0.000010f); + // reduction_a_3x3_2_bn + add_config(TensorShape(35U, 35U, 224U), TensorShape(224U), 0.000010f); + // reduction_a_3x3_3_bn, inception_b1_7x1_bn, inception_b1_1x7_3_bn, inception_b2_7x1_bn, inception_b2_1x7_3_bn, inception_b3_7x1_bn, inception_b3_1x7_3_bn, inception_b4_7x1_bn, inception_b4_1x7_3_bn, inception_b5_7x1_bn, inception_b5_1x7_3_bn, inception_b6_7x1_bn, inception_b6_1x7_3_bn, inception_b7_7x1_bn, inception_b7_1x7_3_bn, reduction_b_1x7_reduce_bn, reduction_b_1x7_bn + add_config(TensorShape(17U, 17U, 256U), TensorShape(256U), 0.000010f); + // inception_b1_1x7_reduce_bn, inception_b1_7x1_2_reduce_bn, inception_b1_7x1_2_bn, inception_b2_1x7_reduce_bn, inception_b2_7x1_2_reduce_bn, inception_b2_7x1_2_bn, inception_b3_1x7_reduce_bn, inception_b3_7x1_2_reduce_bn, inception_b3_7x1_2_bn, inception_b4_1x7_reduce_bn, inception_b4_7x1_2_reduce_bn, inception_b4_7x1_2_bn, inception_b5_1x7_reduce_bn, inception_b5_7x1_2_reduce_bn, inception_b5_7x1_2_bn, inception_b6_1x7_reduce_bn, inception_b6_7x1_2_reduce_bn, inception_b6_7x1_2_bn, inception_b7_1x7_reduce_bn, inception_b7_7x1_2_reduce_bn, inception_b7_7x1_2_bn, reduction_b_3x3_reduce_bn + add_config(TensorShape(17U, 17U, 192U), TensorShape(192U), 0.000010f); + // inception_b1_1x7_bn, inception_b1_1x7_2_bn, inception_b1_7x1_3_bn, inception_b2_1x7_bn, inception_b2_1x7_2_bn, inception_b2_7x1_3_bn, inception_b3_1x7_bn, inception_b3_1x7_2_bn, inception_b3_7x1_3_bn, inception_b4_1x7_bn, inception_b4_1x7_2_bn, inception_b4_7x1_3_bn, inception_b5_1x7_bn, inception_b5_1x7_2_bn, inception_b5_7x1_3_bn, inception_b6_1x7_bn, inception_b6_1x7_2_bn, inception_b6_7x1_3_bn, inception_b7_1x7_bn, inception_b7_1x7_2_bn, inception_b7_7x1_3_bn + add_config(TensorShape(17U, 17U, 224U), TensorShape(224U), 0.000010f); + // inception_b1_1x1_bn, inception_b2_1x1_bn, inception_b3_1x1_bn, inception_b4_1x1_bn, inception_b5_1x1_bn, inception_b6_1x1_bn, inception_b7_1x1_bn + add_config(TensorShape(17U, 17U, 128U), TensorShape(128U), 0.000010f); + // reduction_b_3x3_bn + add_config(TensorShape(8U, 8U, 192U), TensorShape(192U), 0.000010f); + // reduction_b_7x1_bn + add_config(TensorShape(17U, 17U, 320U), TensorShape(320U), 0.000010f); + // reduction_b_3x3_2_bn + add_config(TensorShape(8U, 8U, 320U), TensorShape(320U), 0.000010f); + // inception_c1_1x1_2_bn, inception_c1_1x3_bn, inception_c1_3x1_bn, inception_c1_1x3_3_bn, inception_c1_3x1_3_bn, inception_c1_1x1_bn, inception_c2_1x1_2_bn, inception_c2_1x3_bn, inception_c2_3x1_bn, inception_c2_1x3_3_bn, inception_c2_3x1_3_bn, inception_c2_1x1_bn, inception_c3_1x1_2_bn, inception_c3_1x3_bn, inception_c3_3x1_bn, inception_c3_1x3_3_bn, inception_c3_3x1_3_bn, inception_c3_1x1_bn + add_config(TensorShape(8U, 8U, 256U), TensorShape(256U), 0.000010f); + // inception_c1_1x1_3_bn, inception_c1_1x1_4_bn, inception_c2_1x1_3_bn, inception_c2_1x1_4_bn, inception_c3_1x1_3_bn, inception_c3_1x1_4_bn + add_config(TensorShape(8U, 8U, 384U), TensorShape(384U), 0.000010f); + // inception_c1_3x1_2_bn, inception_c2_3x1_2_bn, inception_c3_3x1_2_bn + add_config(TensorShape(8U, 8U, 448U), TensorShape(448U), 0.000010f); + // inception_c1_1x3_2_bn, inception_c2_1x3_2_bn, inception_c3_1x3_2_bn + add_config(TensorShape(8U, 8U, 512U), TensorShape(512U), 0.000010f); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_BATCHNORMALIZATION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ConvolutionLayerDataset.h b/tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ConvolutionLayerDataset.h new file mode 100644 index 0000000000..a050d3da74 --- /dev/null +++ b/tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ConvolutionLayerDataset.h @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_CONVOLUTION_LAYER_DATASET + +#include "tests/datasets/ConvolutionLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class GoogLeNetInceptionV4ConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + // GoogLeNetInceptionV4 inception v1 dataset + GoogLeNetInceptionV4ConvolutionLayerDataset() + { + // conv1_3x3_s2 + add_config(TensorShape(299U, 299U, 3U), TensorShape(3U, 3U, 3U, 32U), TensorShape(32U), TensorShape(149U, 149U, 32U), PadStrideInfo(2, 2, 0, 0)); + // conv2_3x3_s1 + add_config(TensorShape(149U, 149U, 32U), TensorShape(3U, 3U, 32U, 32U), TensorShape(32U), TensorShape(147U, 147U, 32U), PadStrideInfo(1, 1, 0, 0)); + // conv3_3x3_s1 + add_config(TensorShape(147U, 147U, 32U), TensorShape(3U, 3U, 32U, 64U), TensorShape(64U), TensorShape(147U, 147U, 64U), PadStrideInfo(1, 1, 1, 1)); + // inception_stem1_3x3_s2 + add_config(TensorShape(147U, 147U, 64U), TensorShape(3U, 3U, 64U, 96U), TensorShape(96U), TensorShape(73U, 73U, 96U), PadStrideInfo(2, 2, 0, 0)); + // inception_stem2_3x3_reduce, inception_stem2_1x7_reduce + add_config(TensorShape(73U, 73U, 160U), TensorShape(1U, 1U, 160U, 64U), TensorShape(64U), TensorShape(73U, 73U, 64U), PadStrideInfo(1, 1, 0, 0)); + // inception_stem2_3x3, inception_stem2_3x3_2 + add_config(TensorShape(73U, 73U, 64U), TensorShape(3U, 3U, 64U, 96U), TensorShape(96U), TensorShape(71U, 71U, 96U), PadStrideInfo(1, 1, 0, 0)); + // inception_stem2_1x7 + add_config(TensorShape(73U, 73U, 64U), TensorShape(7U, 1U, 64U, 64U), TensorShape(64U), TensorShape(73U, 73U, 64U), PadStrideInfo(1, 1, 3, 0)); + // inception_stem2_7x1 + add_config(TensorShape(73U, 73U, 64U), TensorShape(1U, 7U, 64U, 64U), TensorShape(64U), TensorShape(73U, 73U, 64U), PadStrideInfo(1, 1, 0, 3)); + // inception_stem3_3x3_s2 + add_config(TensorShape(71U, 71U, 192U), TensorShape(3U, 3U, 192U, 192U), TensorShape(192U), TensorShape(35U, 35U, 192U), PadStrideInfo(2, 2, 0, 0)); + // inception_a1_1x1_2, inception_a1_1x1, inception_a2_1x1_2, inception_a2_1x1, inception_a3_1x1_2, inception_a3_1x1, inception_a4_1x1_2, inception_a4_1x1 + add_config(TensorShape(35U, 35U, 384U), TensorShape(1U, 1U, 384U, 96U), TensorShape(96U), TensorShape(35U, 35U, 96U), PadStrideInfo(1, 1, 0, 0)); + // inception_a1_3x3_reduce, inception_a1_3x3_2_reduce, inception_a2_3x3_reduce, inception_a2_3x3_2_reduce, inception_a3_3x3_reduce, inception_a3_3x3_2_reduce, inception_a4_3x3_reduce, inception_a4_3x3_2_reduce + add_config(TensorShape(35U, 35U, 384U), TensorShape(1U, 1U, 384U, 64U), TensorShape(64U), TensorShape(35U, 35U, 64U), PadStrideInfo(1, 1, 0, 0)); + // inception_a1_3x3, inception_a1_3x3_2, inception_a2_3x3, inception_a2_3x3_2, inception_a3_3x3, inception_a3_3x3_2, inception_a4_3x3, inception_a4_3x3_2 + add_config(TensorShape(35U, 35U, 64U), TensorShape(3U, 3U, 64U, 96U), TensorShape(96U), TensorShape(35U, 35U, 96U), PadStrideInfo(1, 1, 1, 1)); + // inception_a1_3x3_3, inception_a2_3x3_3, inception_a3_3x3_3, inception_a4_3x3_3 + add_config(TensorShape(35U, 35U, 96U), TensorShape(3U, 3U, 96U, 96U), TensorShape(96U), TensorShape(35U, 35U, 96U), PadStrideInfo(1, 1, 1, 1)); + // reduction_a_3x3 + add_config(TensorShape(35U, 35U, 384U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(17U, 17U, 384U), PadStrideInfo(2, 2, 0, 0)); + // reduction_a_3x3_2_reduce + add_config(TensorShape(35U, 35U, 384U), TensorShape(1U, 1U, 384U, 192U), TensorShape(192U), TensorShape(35U, 35U, 192U), PadStrideInfo(1, 1, 0, 0)); + // reduction_a_3x3_2 + add_config(TensorShape(35U, 35U, 192U), TensorShape(3U, 3U, 192U, 224U), TensorShape(224U), TensorShape(35U, 35U, 224U), PadStrideInfo(1, 1, 1, 1)); + // reduction_a_3x3_3 + add_config(TensorShape(35U, 35U, 224U), TensorShape(3U, 3U, 224U, 256U), TensorShape(256U), TensorShape(17U, 17U, 256U), PadStrideInfo(2, 2, 0, 0)); + // inception_b1_1x1_2, inception_b2_1x1_2, inception_b3_1x1_2, inception_b4_1x1_2, inception_b5_1x1_2, inception_b6_1x1_2, inception_b7_1x1_2 + add_config(TensorShape(17U, 17U, 1024U), TensorShape(1U, 1U, 1024U, 384U), TensorShape(384U), TensorShape(17U, 17U, 384U), PadStrideInfo(1, 1, 0, 0)); + // inception_b1_1x7_reduce, inception_b1_7x1_2_reduce, inception_b2_1x7_reduce, inception_b2_7x1_2_reduce, inception_b3_1x7_reduce, inception_b3_7x1_2_reduce, inception_b4_1x7_reduce, inception_b4_7x1_2_reduce, inception_b5_1x7_reduce, inception_b5_7x1_2_reduce, inception_b6_1x7_reduce, inception_b6_7x1_2_reduce, inception_b7_1x7_reduce, inception_b7_7x1_2_reduce, reduction_b_3x3_reduce + add_config(TensorShape(17U, 17U, 1024U), TensorShape(1U, 1U, 1024U, 192U), TensorShape(192U), TensorShape(17U, 17U, 192U), PadStrideInfo(1, 1, 0, 0)); + // inception_b1_1x7, inception_b1_1x7_2, inception_b2_1x7, inception_b2_1x7_2, inception_b3_1x7, inception_b3_1x7_2, inception_b4_1x7, inception_b4_1x7_2, inception_b5_1x7, inception_b5_1x7_2, inception_b6_1x7, inception_b6_1x7_2, inception_b7_1x7, inception_b7_1x7_2 + add_config(TensorShape(17U, 17U, 192U), TensorShape(7U, 1U, 192U, 224U), TensorShape(224U), TensorShape(17U, 17U, 224U), PadStrideInfo(1, 1, 3, 0)); + // inception_b1_7x1, inception_b2_7x1, inception_b3_7x1, inception_b4_7x1, inception_b5_7x1, inception_b6_7x1, inception_b7_7x1 + add_config(TensorShape(17U, 17U, 224U), TensorShape(1U, 7U, 224U, 256U), TensorShape(256U), TensorShape(17U, 17U, 256U), PadStrideInfo(1, 1, 0, 3)); + // inception_b1_7x1_2, inception_b2_7x1_2, inception_b3_7x1_2, inception_b4_7x1_2, inception_b5_7x1_2, inception_b6_7x1_2, inception_b7_7x1_2 + add_config(TensorShape(17U, 17U, 192U), TensorShape(1U, 7U, 192U, 192U), TensorShape(192U), TensorShape(17U, 17U, 192U), PadStrideInfo(1, 1, 0, 3)); + // inception_b1_7x1_3, inception_b2_7x1_3, inception_b3_7x1_3, inception_b4_7x1_3, inception_b5_7x1_3, inception_b6_7x1_3, inception_b7_7x1_3 + add_config(TensorShape(17U, 17U, 224U), TensorShape(1U, 7U, 224U, 224U), TensorShape(224U), TensorShape(17U, 17U, 224U), PadStrideInfo(1, 1, 0, 3)); + // inception_b1_1x7_3, inception_b2_1x7_3, inception_b3_1x7_3, inception_b4_1x7_3, inception_b5_1x7_3, inception_b6_1x7_3, inception_b7_1x7_3 + add_config(TensorShape(17U, 17U, 224U), TensorShape(7U, 1U, 224U, 256U), TensorShape(256U), TensorShape(17U, 17U, 256U), PadStrideInfo(1, 1, 3, 0)); + // inception_b1_1x1, inception_b2_1x1, inception_b3_1x1, inception_b4_1x1, inception_b5_1x1, inception_b6_1x1, inception_b7_1x1 + add_config(TensorShape(17U, 17U, 1024U), TensorShape(1U, 1U, 1024U, 128U), TensorShape(128U), TensorShape(17U, 17U, 128U), PadStrideInfo(1, 1, 0, 0)); + // reduction_b_3x3 + add_config(TensorShape(17U, 17U, 192U), TensorShape(3U, 3U, 192U, 192U), TensorShape(192U), TensorShape(8U, 8U, 192U), PadStrideInfo(2, 2, 0, 0)); + // reduction_b_1x7_reduce + add_config(TensorShape(17U, 17U, 1024U), TensorShape(1U, 1U, 1024U, 256U), TensorShape(256U), TensorShape(17U, 17U, 256U), PadStrideInfo(1, 1, 0, 0)); + // reduction_b_1x7 + add_config(TensorShape(17U, 17U, 256U), TensorShape(7U, 1U, 256U, 256U), TensorShape(256U), TensorShape(17U, 17U, 256U), PadStrideInfo(1, 1, 3, 0)); + // reduction_b_7x1 + add_config(TensorShape(17U, 17U, 256U), TensorShape(1U, 7U, 256U, 320U), TensorShape(320U), TensorShape(17U, 17U, 320U), PadStrideInfo(1, 1, 0, 3)); + // reduction_b_3x3_2 + add_config(TensorShape(17U, 17U, 320U), TensorShape(3U, 3U, 320U, 320U), TensorShape(320U), TensorShape(8U, 8U, 320U), PadStrideInfo(2, 2, 0, 0)); + // inception_c1_1x1_2, inception_c1_1x1, inception_c2_1x1_2, inception_c2_1x1, inception_c3_1x1_2, inception_c3_1x1 + add_config(TensorShape(8U, 8U, 1536U), TensorShape(1U, 1U, 1536U, 256U), TensorShape(256U), TensorShape(8U, 8U, 256U), PadStrideInfo(1, 1, 0, 0)); + // inception_c1_1x1_3, inception_c1_1x1_4, inception_c2_1x1_3, inception_c2_1x1_4, inception_c3_1x1_3, inception_c3_1x1_4 + add_config(TensorShape(8U, 8U, 1536U), TensorShape(1U, 1U, 1536U, 384U), TensorShape(384U), TensorShape(8U, 8U, 384U), PadStrideInfo(1, 1, 0, 0)); + // inception_c1_1x3, inception_c2_1x3, inception_c3_1x3 + add_config(TensorShape(8U, 8U, 384U), TensorShape(3U, 1U, 384U, 256U), TensorShape(256U), TensorShape(8U, 8U, 256U), PadStrideInfo(1, 1, 1, 0)); + // inception_c1_3x1, inception_c2_3x1, inception_c3_3x1 + add_config(TensorShape(8U, 8U, 384U), TensorShape(1U, 3U, 384U, 256U), TensorShape(256U), TensorShape(8U, 8U, 256U), PadStrideInfo(1, 1, 0, 1)); + // inception_c1_3x1_2, inception_c2_3x1_2, inception_c3_3x1_2 + add_config(TensorShape(8U, 8U, 384U), TensorShape(1U, 3U, 384U, 448U), TensorShape(448U), TensorShape(8U, 8U, 448U), PadStrideInfo(1, 1, 0, 1)); + // inception_c1_1x3_2, inception_c2_1x3_2, inception_c3_1x3_2 + add_config(TensorShape(8U, 8U, 448U), TensorShape(3U, 1U, 448U, 512U), TensorShape(512U), TensorShape(8U, 8U, 512U), PadStrideInfo(1, 1, 1, 0)); + // inception_c1_1x3_3, inception_c2_1x3_3, inception_c3_1x3_3 + add_config(TensorShape(8U, 8U, 512U), TensorShape(3U, 1U, 512U, 256U), TensorShape(256U), TensorShape(8U, 8U, 256U), PadStrideInfo(1, 1, 1, 0)); + // inception_c1_3x1_3, inception_c2_3x1_3, inception_c3_3x1_3 + add_config(TensorShape(8U, 8U, 512U), TensorShape(1U, 3U, 512U, 256U), TensorShape(256U), TensorShape(8U, 8U, 256U), PadStrideInfo(1, 1, 0, 1)); + } +}; + +/** A subset of GoogLeNetInceptionV4 convolution layers with filter dimensions supported by DirectConvolution kernel */ +class GoogLeNetInceptionV4DirectConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + // subset of GoogLeNetInceptionV4 inception v1 dataset + GoogLeNetInceptionV4DirectConvolutionLayerDataset() + { + // conv1_3x3_s2 + add_config(TensorShape(299U, 299U, 3U), TensorShape(3U, 3U, 3U, 32U), TensorShape(32U), TensorShape(149U, 149U, 32U), PadStrideInfo(2, 2, 0, 0)); + // conv2_3x3_s1 + add_config(TensorShape(149U, 149U, 32U), TensorShape(3U, 3U, 32U, 32U), TensorShape(32U), TensorShape(147U, 147U, 32U), PadStrideInfo(1, 1, 0, 0)); + // conv3_3x3_s1 + add_config(TensorShape(147U, 147U, 32U), TensorShape(3U, 3U, 32U, 64U), TensorShape(64U), TensorShape(147U, 147U, 64U), PadStrideInfo(1, 1, 1, 1)); + // inception_stem1_3x3_s2 + add_config(TensorShape(147U, 147U, 64U), TensorShape(3U, 3U, 64U, 96U), TensorShape(96U), TensorShape(73U, 73U, 96U), PadStrideInfo(2, 2, 0, 0)); + // inception_stem2_3x3_reduce, inception_stem2_1x7_reduce + add_config(TensorShape(73U, 73U, 160U), TensorShape(1U, 1U, 160U, 64U), TensorShape(64U), TensorShape(73U, 73U, 64U), PadStrideInfo(1, 1, 0, 0)); + // inception_stem2_3x3, inception_stem2_3x3_2 + add_config(TensorShape(73U, 73U, 64U), TensorShape(3U, 3U, 64U, 96U), TensorShape(96U), TensorShape(71U, 71U, 96U), PadStrideInfo(1, 1, 0, 0)); + // inception_stem3_3x3_s2 + add_config(TensorShape(71U, 71U, 192U), TensorShape(3U, 3U, 192U, 192U), TensorShape(192U), TensorShape(35U, 35U, 192U), PadStrideInfo(2, 2, 0, 0)); + // inception_a1_1x1_2, inception_a1_1x1, inception_a2_1x1_2, inception_a2_1x1, inception_a3_1x1_2, inception_a3_1x1, inception_a4_1x1_2, inception_a4_1x1 + add_config(TensorShape(35U, 35U, 384U), TensorShape(1U, 1U, 384U, 96U), TensorShape(96U), TensorShape(35U, 35U, 96U), PadStrideInfo(1, 1, 0, 0)); + // inception_a1_3x3_reduce, inception_a1_3x3_2_reduce, inception_a2_3x3_reduce, inception_a2_3x3_2_reduce, inception_a3_3x3_reduce, inception_a3_3x3_2_reduce, inception_a4_3x3_reduce, inception_a4_3x3_2_reduce + add_config(TensorShape(35U, 35U, 384U), TensorShape(1U, 1U, 384U, 64U), TensorShape(64U), TensorShape(35U, 35U, 64U), PadStrideInfo(1, 1, 0, 0)); + // inception_a1_3x3, inception_a1_3x3_2, inception_a2_3x3, inception_a2_3x3_2, inception_a3_3x3, inception_a3_3x3_2, inception_a4_3x3, inception_a4_3x3_2 + add_config(TensorShape(35U, 35U, 64U), TensorShape(3U, 3U, 64U, 96U), TensorShape(96U), TensorShape(35U, 35U, 96U), PadStrideInfo(1, 1, 1, 1)); + // inception_a1_3x3_3, inception_a2_3x3_3, inception_a3_3x3_3, inception_a4_3x3_3 + add_config(TensorShape(35U, 35U, 96U), TensorShape(3U, 3U, 96U, 96U), TensorShape(96U), TensorShape(35U, 35U, 96U), PadStrideInfo(1, 1, 1, 1)); + // reduction_a_3x3 + add_config(TensorShape(35U, 35U, 384U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(17U, 17U, 384U), PadStrideInfo(2, 2, 0, 0)); + // reduction_a_3x3_2_reduce + add_config(TensorShape(35U, 35U, 384U), TensorShape(1U, 1U, 384U, 192U), TensorShape(192U), TensorShape(35U, 35U, 192U), PadStrideInfo(1, 1, 0, 0)); + // reduction_a_3x3_2 + add_config(TensorShape(35U, 35U, 192U), TensorShape(3U, 3U, 192U, 224U), TensorShape(224U), TensorShape(35U, 35U, 224U), PadStrideInfo(1, 1, 1, 1)); + // reduction_a_3x3_3 + add_config(TensorShape(35U, 35U, 224U), TensorShape(3U, 3U, 224U, 256U), TensorShape(256U), TensorShape(17U, 17U, 256U), PadStrideInfo(2, 2, 0, 0)); + // inception_b1_1x1_2, inception_b2_1x1_2, inception_b3_1x1_2, inception_b4_1x1_2, inception_b5_1x1_2, inception_b6_1x1_2, inception_b7_1x1_2 + add_config(TensorShape(17U, 17U, 1024U), TensorShape(1U, 1U, 1024U, 384U), TensorShape(384U), TensorShape(17U, 17U, 384U), PadStrideInfo(1, 1, 0, 0)); + // inception_b1_1x7_reduce, inception_b1_7x1_2_reduce, inception_b2_1x7_reduce, inception_b2_7x1_2_reduce, inception_b3_1x7_reduce, inception_b3_7x1_2_reduce, inception_b4_1x7_reduce, inception_b4_7x1_2_reduce, inception_b5_1x7_reduce, inception_b5_7x1_2_reduce, inception_b6_1x7_reduce, inception_b6_7x1_2_reduce, inception_b7_1x7_reduce, inception_b7_7x1_2_reduce, reduction_b_3x3_reduce + add_config(TensorShape(17U, 17U, 1024U), TensorShape(1U, 1U, 1024U, 192U), TensorShape(192U), TensorShape(17U, 17U, 192U), PadStrideInfo(1, 1, 0, 0)); + // inception_b1_1x1, inception_b2_1x1, inception_b3_1x1, inception_b4_1x1, inception_b5_1x1, inception_b6_1x1, inception_b7_1x1 + add_config(TensorShape(17U, 17U, 1024U), TensorShape(1U, 1U, 1024U, 128U), TensorShape(128U), TensorShape(17U, 17U, 128U), PadStrideInfo(1, 1, 0, 0)); + // reduction_b_3x3 + add_config(TensorShape(17U, 17U, 192U), TensorShape(3U, 3U, 192U, 192U), TensorShape(192U), TensorShape(8U, 8U, 192U), PadStrideInfo(2, 2, 0, 0)); + // reduction_b_1x7_reduce + add_config(TensorShape(17U, 17U, 1024U), TensorShape(1U, 1U, 1024U, 256U), TensorShape(256U), TensorShape(17U, 17U, 256U), PadStrideInfo(1, 1, 0, 0)); + // reduction_b_3x3_2 + add_config(TensorShape(17U, 17U, 320U), TensorShape(3U, 3U, 320U, 320U), TensorShape(320U), TensorShape(8U, 8U, 320U), PadStrideInfo(2, 2, 0, 0)); + // inception_c1_1x1_2, inception_c1_1x1, inception_c2_1x1_2, inception_c2_1x1, inception_c3_1x1_2, inception_c3_1x1 + add_config(TensorShape(8U, 8U, 1536U), TensorShape(1U, 1U, 1536U, 256U), TensorShape(256U), TensorShape(8U, 8U, 256U), PadStrideInfo(1, 1, 0, 0)); + // inception_c1_1x1_3, inception_c1_1x1_4, inception_c2_1x1_3, inception_c2_1x1_4, inception_c3_1x1_3, inception_c3_1x1_4 + add_config(TensorShape(8U, 8U, 1536U), TensorShape(1U, 1U, 1536U, 384U), TensorShape(384U), TensorShape(8U, 8U, 384U), PadStrideInfo(1, 1, 0, 0)); + } +}; + +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4FullyConnectedLayerDataset.h b/tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4FullyConnectedLayerDataset.h new file mode 100644 index 0000000000..8cf59e8207 --- /dev/null +++ b/tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4FullyConnectedLayerDataset.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_FULLYCONNECTED_LAYER_DATASET +#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_FULLYCONNECTED_LAYER_DATASET + +#include "tests/datasets/FullyConnectedLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class GoogLeNetInceptionV4FullyConnectedLayerDataset final : public FullyConnectedLayerDataset +{ +public: + GoogLeNetInceptionV4FullyConnectedLayerDataset() + { + add_config(TensorShape(1536U), TensorShape(1536U, 1000U), TensorShape(1000U), TensorShape(1000U)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_FULLYCONNECTED_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4PoolingLayerDataset.h b/tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4PoolingLayerDataset.h new file mode 100644 index 0000000000..3b1ee8dcb4 --- /dev/null +++ b/tests/datasets/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4PoolingLayerDataset.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_POOLING_LAYER_DATASET +#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_POOLING_LAYER_DATASET + +#include "tests/datasets/PoolingLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class GoogLeNetInceptionV4PoolingLayerDataset final : public PoolingLayerDataset +{ +public: + GoogLeNetInceptionV4PoolingLayerDataset() + { + // FIXME: Add support for global pooling layer pool_8x8_s1 + // inception_stem1_pool + add_config(TensorShape(147U, 147U, 64U), TensorShape(73U, 73U, 64U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // inception_stem3_pool + add_config(TensorShape(71U, 71U, 192U), TensorShape(35U, 35U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // inception_a1_pool_ave, inception_a2_pool_ave, inception_a3_pool_ave, inception_a4_pool_ave + add_config(TensorShape(35U, 35U, 384U), TensorShape(35U, 35U, 384U), PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); + // reduction_a_pool + add_config(TensorShape(35U, 35U, 384U), TensorShape(17U, 17U, 384U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // inception_b1_pool_ave, inception_b2_pool_ave, inception_b3_pool_ave, inception_b4_pool_ave, inception_b5_pool_ave, inception_b6_pool_ave, inception_b7_pool_ave + add_config(TensorShape(17U, 17U, 1024U), TensorShape(17U, 17U, 1024U), PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); + // reduction_b_pool + add_config(TensorShape(17U, 17U, 1024U), TensorShape(8U, 8U, 1024U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // inception_c1_pool_ave, inception_c2_pool_ave, inception_c3_pool_ave + add_config(TensorShape(8U, 8U, 1536U), TensorShape(8U, 8U, 1536U), PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_POOLING_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/lenet5/LeNet5ActivationLayerDataset.h b/tests/datasets/system_tests/lenet5/LeNet5ActivationLayerDataset.h new file mode 100644 index 0000000000..4c88cde58d --- /dev/null +++ b/tests/datasets/system_tests/lenet5/LeNet5ActivationLayerDataset.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_LENET5_ACTIVATION_LAYER_DATASET +#define ARM_COMPUTE_TEST_LENET5_ACTIVATION_LAYER_DATASET + +#include "tests/framework/datasets/Datasets.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class LeNet5ActivationLayerDataset final : public + framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> +{ +public: + LeNet5ActivationLayerDataset() + : CartesianProductDataset + { + framework::dataset::make("Shape", TensorShape(500U)), + framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) + } + { + } + LeNet5ActivationLayerDataset(LeNet5ActivationLayerDataset &&) = default; + ~LeNet5ActivationLayerDataset() = default; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_LENET5_ACTIVATION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/lenet5/LeNet5ConvolutionLayerDataset.h b/tests/datasets/system_tests/lenet5/LeNet5ConvolutionLayerDataset.h new file mode 100644 index 0000000000..e1d3ead65b --- /dev/null +++ b/tests/datasets/system_tests/lenet5/LeNet5ConvolutionLayerDataset.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_LENET5_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_LENET5_CONVOLUTION_LAYER_DATASET + +#include "tests/datasets/ConvolutionLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class LeNet5ConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + LeNet5ConvolutionLayerDataset() + { + add_config(TensorShape(28U, 28U, 1U), TensorShape(5U, 5U, 1U, 20U), TensorShape(20U), TensorShape(24U, 24U, 20U), PadStrideInfo(1, 1, 0, 0)); + add_config(TensorShape(12U, 12U, 20U), TensorShape(5U, 5U, 20U, 50U), TensorShape(50U), TensorShape(8U, 8U, 50U), PadStrideInfo(1, 1, 0, 0)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_LENET5_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/lenet5/LeNet5FullyConnectedLayerDataset.h b/tests/datasets/system_tests/lenet5/LeNet5FullyConnectedLayerDataset.h new file mode 100644 index 0000000000..343ecc0190 --- /dev/null +++ b/tests/datasets/system_tests/lenet5/LeNet5FullyConnectedLayerDataset.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_LENET5_FULLYCONNECTED_LAYER_DATASET +#define ARM_COMPUTE_TEST_LENET5_FULLYCONNECTED_LAYER_DATASET + +#include "tests/datasets/FullyConnectedLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +using namespace arm_compute; + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class LeNet5FullyConnectedLayerDataset final : public FullyConnectedLayerDataset +{ +public: + LeNet5FullyConnectedLayerDataset() + { + add_config(TensorShape(4U, 4U, 50U), TensorShape(800U, 500U), TensorShape(500U), TensorShape(500U)); + add_config(TensorShape(500U), TensorShape(500U, 10U), TensorShape(10U), TensorShape(10U)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_LENET5_FULLYCONNECTED_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/lenet5/LeNet5PoolingLayerDataset.h b/tests/datasets/system_tests/lenet5/LeNet5PoolingLayerDataset.h new file mode 100644 index 0000000000..bc2de7b235 --- /dev/null +++ b/tests/datasets/system_tests/lenet5/LeNet5PoolingLayerDataset.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_LENET5_POOLING_LAYER_DATASET +#define ARM_COMPUTE_TEST_LENET5_POOLING_LAYER_DATASET + +#include "tests/datasets/PoolingLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class LeNet5PoolingLayerDataset final : public PoolingLayerDataset +{ +public: + LeNet5PoolingLayerDataset() + { + add_config(TensorShape(24U, 24U, 20U), TensorShape(12U, 12U, 20U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0))); + add_config(TensorShape(8U, 8U, 50U), TensorShape(4U, 4U, 50U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0))); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_LENET5_POOLING_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/squeezenet/SqueezeNetActivationLayerDataset.h b/tests/datasets/system_tests/squeezenet/SqueezeNetActivationLayerDataset.h new file mode 100644 index 0000000000..7644387384 --- /dev/null +++ b/tests/datasets/system_tests/squeezenet/SqueezeNetActivationLayerDataset.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_SQUEEZENET_ACTIVATION_LAYER_DATASET +#define ARM_COMPUTE_TEST_SQUEEZENET_ACTIVATION_LAYER_DATASET + +#include "tests/framework/datasets/Datasets.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class SqueezeNetActivationLayerDataset final : public + framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> +{ +public: + SqueezeNetActivationLayerDataset() + : CartesianProductDataset + { + framework::dataset::make("Shape", { // relu_conv1 + TensorShape(111U, 111U, 64U), + // fire2/relu_squeeze1x1, fire3/relu_squeeze1x1 + TensorShape(55U, 55U, 16U), + // fire2/relu_expand1x1, fire2/relu_expand3x3, fire3/relu_expand1x1, fire3/relu_expand3x3 + TensorShape(55U, 55U, 64U), + // fire4/relu_squeeze1x1, fire5/relu_squeeze1x1 + TensorShape(27U, 27U, 32U), + // fire4/relu_expand1x1, fire4/relu_expand3x3, fire5/relu_expand1x1, fire5/relu_expand3x3 + TensorShape(27U, 27U, 128U), + // fire6/relu_squeeze1x1, fire7/relu_squeeze1x1 + TensorShape(13U, 13U, 48U), + // fire6/relu_expand1x1, fire6/relu_expand3x3, fire7/relu_expand1x1, fire7/relu_expand3x3 + TensorShape(13U, 13U, 192U), + // fire8/relu_squeeze1x1, fire9/relu_squeeze1x1 + TensorShape(13U, 13U, 64U), + // fire8/relu_expand1x1, fire8/relu_expand3x3, fire9/relu_expand1x1, fire9/relu_expand3x3 + TensorShape(13U, 13U, 256U), + // relu_conv10 + TensorShape(13U, 13U, 1000U) }), + framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) + } + { + } + SqueezeNetActivationLayerDataset(SqueezeNetActivationLayerDataset &&) = default; + ~SqueezeNetActivationLayerDataset() = default; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_SQUEEZENET_ACTIVATION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/squeezenet/SqueezeNetConvolutionLayerDataset.h b/tests/datasets/system_tests/squeezenet/SqueezeNetConvolutionLayerDataset.h new file mode 100644 index 0000000000..2d447b0156 --- /dev/null +++ b/tests/datasets/system_tests/squeezenet/SqueezeNetConvolutionLayerDataset.h @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_SQUEEZENET_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_SQUEEZENET_CONVOLUTION_LAYER_DATASET + +#include "tests/datasets/ConvolutionLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class SqueezeNetConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + SqueezeNetConvolutionLayerDataset() + { + // conv1 + add_config(TensorShape(224U, 224U, 3U), TensorShape(3U, 3U, 3U, 64U), TensorShape(64U), TensorShape(111U, 111U, 64U), PadStrideInfo(2, 2, 0, 0)); + // fire2/squeeze1x1 + add_config(TensorShape(55U, 55U, 64U), TensorShape(1U, 1U, 64U, 16U), TensorShape(16U), TensorShape(55U, 55U, 16U), PadStrideInfo(1, 1, 0, 0)); + // fire2/expand1x1, fire3/expand1x1 + add_config(TensorShape(55U, 55U, 16U), TensorShape(1U, 1U, 16U, 64U), TensorShape(64U), TensorShape(55U, 55U, 64U), PadStrideInfo(1, 1, 0, 0)); + // fire2/expand3x3, fire3/expand3x3 + add_config(TensorShape(55U, 55U, 16U), TensorShape(3U, 3U, 16U, 64U), TensorShape(64U), TensorShape(55U, 55U, 64U), PadStrideInfo(1, 1, 1, 1)); + // fire3/squeeze1x1 + add_config(TensorShape(55U, 55U, 128U), TensorShape(1U, 1U, 128U, 16U), TensorShape(16U), TensorShape(55U, 55U, 16U), PadStrideInfo(1, 1, 0, 0)); + // fire4/squeeze1x1 + add_config(TensorShape(27U, 27U, 128U), TensorShape(1U, 1U, 128U, 32U), TensorShape(32U), TensorShape(27U, 27U, 32U), PadStrideInfo(1, 1, 0, 0)); + // fire4/expand1x1, fire5/expand1x1 + add_config(TensorShape(27U, 27U, 32U), TensorShape(1U, 1U, 32U, 128U), TensorShape(128U), TensorShape(27U, 27U, 128U), PadStrideInfo(1, 1, 0, 0)); + // fire4/expand3x3, fire5/expand3x3 + add_config(TensorShape(27U, 27U, 32U), TensorShape(3U, 3U, 32U, 128U), TensorShape(128U), TensorShape(27U, 27U, 128U), PadStrideInfo(1, 1, 1, 1)); + // fire5/squeeze1x1 + add_config(TensorShape(27U, 27U, 256U), TensorShape(1U, 1U, 256U, 32U), TensorShape(32U), TensorShape(27U, 27U, 32U), PadStrideInfo(1, 1, 0, 0)); + // fire6/squeeze1x1 + add_config(TensorShape(13U, 13U, 256U), TensorShape(1U, 1U, 256U, 48U), TensorShape(48U), TensorShape(13U, 13U, 48U), PadStrideInfo(1, 1, 0, 0)); + // fire6/expand1x1, fire7/expand1x1 + add_config(TensorShape(13U, 13U, 48U), TensorShape(1U, 1U, 48U, 192U), TensorShape(192U), TensorShape(13U, 13U, 192U), PadStrideInfo(1, 1, 0, 0)); + // fire6/expand3x3, fire7/expand3x3 + add_config(TensorShape(13U, 13U, 48U), TensorShape(3U, 3U, 48U, 192U), TensorShape(192U), TensorShape(13U, 13U, 192U), PadStrideInfo(1, 1, 1, 1)); + // fire7/squeeze1x1 + add_config(TensorShape(13U, 13U, 384U), TensorShape(1U, 1U, 384U, 48U), TensorShape(48U), TensorShape(13U, 13U, 48U), PadStrideInfo(1, 1, 0, 0)); + // fire8/squeeze1x1 + add_config(TensorShape(13U, 13U, 384U), TensorShape(1U, 1U, 384U, 64U), TensorShape(64U), TensorShape(13U, 13U, 64U), PadStrideInfo(1, 1, 0, 0)); + // fire8/expand1x1, fire9/expand1x1 + add_config(TensorShape(13U, 13U, 64U), TensorShape(1U, 1U, 64U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U), PadStrideInfo(1, 1, 0, 0)); + // fire8/expand3x3, fire9/expand3x3 + add_config(TensorShape(13U, 13U, 64U), TensorShape(3U, 3U, 64U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U), PadStrideInfo(1, 1, 1, 1)); + // fire9/squeeze1x1 + add_config(TensorShape(13U, 13U, 512U), TensorShape(1U, 1U, 512U, 64U), TensorShape(64U), TensorShape(13U, 13U, 64U), PadStrideInfo(1, 1, 0, 0)); + // conv10 + add_config(TensorShape(13U, 13U, 512U), TensorShape(1U, 1U, 512U, 1000U), TensorShape(1000U), TensorShape(13U, 13U, 1000U), PadStrideInfo(1, 1, 0, 0)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_SQUEEZENET_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/squeezenet/SqueezeNetPoolingLayerDataset.h b/tests/datasets/system_tests/squeezenet/SqueezeNetPoolingLayerDataset.h new file mode 100644 index 0000000000..69d04db7e1 --- /dev/null +++ b/tests/datasets/system_tests/squeezenet/SqueezeNetPoolingLayerDataset.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_SQUEEZENET_POOLING_LAYER_DATASET +#define ARM_COMPUTE_TEST_SQUEEZENET_POOLING_LAYER_DATASET + +#include "tests/datasets/PoolingLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class SqueezeNetPoolingLayerDataset final : public PoolingLayerDataset +{ +public: + SqueezeNetPoolingLayerDataset() + { + // pool1 + add_config(TensorShape(111U, 111U, 64U), TensorShape(55U, 55U, 64U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // pool3 + add_config(TensorShape(55U, 55U, 128U), TensorShape(27U, 27U, 128U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // pool5 + add_config(TensorShape(27U, 27U, 256U), TensorShape(13U, 13U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + //FIXME: Add support for global pooling. + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_SQUEEZENET_POOLING_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/vgg/vgg16/VGG16ActivationLayerDataset.h b/tests/datasets/system_tests/vgg/vgg16/VGG16ActivationLayerDataset.h new file mode 100644 index 0000000000..66301ddf08 --- /dev/null +++ b/tests/datasets/system_tests/vgg/vgg16/VGG16ActivationLayerDataset.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_VGG16_ACTIVATION_LAYER_DATASET +#define ARM_COMPUTE_TEST_VGG16_ACTIVATION_LAYER_DATASET + +#include "tests/framework/datasets/Datasets.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class VGG16ActivationLayerDataset final : public + framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> +{ +public: + VGG16ActivationLayerDataset() + : CartesianProductDataset + { + framework::dataset::make("Shape", { // relu1_1, relu1_2 + TensorShape(224U, 224U, 64U), + // relu2_1, relu2_2 + TensorShape(112U, 112U, 128U), + // relu3_1, relu3_2, relu3_3 + TensorShape(56U, 56U, 256U), + // relu4_1, relu4_2, relu4_3 + TensorShape(28U, 28U, 512U), + // relu5_1, relu5_2, relu5_3 + TensorShape(14U, 14U, 512U), + // relu6, relu7 + TensorShape(4096U) }), + framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) + } + { + } + VGG16ActivationLayerDataset(VGG16ActivationLayerDataset &&) = default; + ~VGG16ActivationLayerDataset() = default; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_VGG16_ACTIVATION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/vgg/vgg16/VGG16ConvolutionLayerDataset.h b/tests/datasets/system_tests/vgg/vgg16/VGG16ConvolutionLayerDataset.h new file mode 100644 index 0000000000..36cb5d93aa --- /dev/null +++ b/tests/datasets/system_tests/vgg/vgg16/VGG16ConvolutionLayerDataset.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_VGG16_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_VGG16_CONVOLUTION_LAYER_DATASET + +#include "tests/datasets/ConvolutionLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class VGG16ConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + VGG16ConvolutionLayerDataset() + { + // conv1_1 + add_config(TensorShape(224U, 224U, 3U), TensorShape(3U, 3U, 3U, 64U), TensorShape(64U), TensorShape(224U, 224U, 64U), PadStrideInfo(1, 1, 1, 1)); + // conv1_2 + add_config(TensorShape(224U, 224U, 64U), TensorShape(3U, 3U, 64U, 64U), TensorShape(64U), TensorShape(224U, 224U, 64U), PadStrideInfo(1, 1, 1, 1)); + // conv2_1 + add_config(TensorShape(112U, 112U, 64U), TensorShape(3U, 3U, 64U, 128U), TensorShape(128U), TensorShape(112U, 112U, 128U), PadStrideInfo(1, 1, 1, 1)); + // conv2_2 + add_config(TensorShape(112U, 112U, 128U), TensorShape(3U, 3U, 128U, 128U), TensorShape(128U), TensorShape(112U, 112U, 128U), PadStrideInfo(1, 1, 1, 1)); + // conv3_1 + add_config(TensorShape(56U, 56U, 128U), TensorShape(3U, 3U, 128U, 256U), TensorShape(256U), TensorShape(56U, 56U, 256U), PadStrideInfo(1, 1, 1, 1)); + // conv3_2, conv3_3 + add_config(TensorShape(56U, 56U, 256U), TensorShape(3U, 3U, 256U, 256U), TensorShape(256U), TensorShape(56U, 56U, 256U), PadStrideInfo(1, 1, 1, 1)); + // conv4_1 + add_config(TensorShape(28U, 28U, 256U), TensorShape(3U, 3U, 256U, 512U), TensorShape(512U), TensorShape(28U, 28U, 512U), PadStrideInfo(1, 1, 1, 1)); + // conv4_2, conv4_3 + add_config(TensorShape(28U, 28U, 512U), TensorShape(3U, 3U, 512U, 512U), TensorShape(512U), TensorShape(28U, 28U, 512U), PadStrideInfo(1, 1, 1, 1)); + // conv5_1, conv5_2, conv5_3 + add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U, 512U), TensorShape(512U), TensorShape(14U, 14U, 512U), PadStrideInfo(1, 1, 1, 1)); + } +}; + +class VGG16DirectConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + VGG16DirectConvolutionLayerDataset() + { + // conv1_1 + add_config(TensorShape(224U, 224U, 3U), TensorShape(3U, 3U, 3U, 64U), TensorShape(64U), TensorShape(224U, 224U, 64U), PadStrideInfo(1, 1, 1, 1)); + // conv1_2 + add_config(TensorShape(224U, 224U, 64U), TensorShape(3U, 3U, 64U, 64U), TensorShape(64U), TensorShape(224U, 224U, 64U), PadStrideInfo(1, 1, 1, 1)); + // conv2_1 + add_config(TensorShape(112U, 112U, 64U), TensorShape(3U, 3U, 64U, 128U), TensorShape(128U), TensorShape(112U, 112U, 128U), PadStrideInfo(1, 1, 1, 1)); + // conv2_2 + add_config(TensorShape(112U, 112U, 128U), TensorShape(3U, 3U, 128U, 128U), TensorShape(128U), TensorShape(112U, 112U, 128U), PadStrideInfo(1, 1, 1, 1)); + // conv3_1 + add_config(TensorShape(56U, 56U, 128U), TensorShape(3U, 3U, 128U, 256U), TensorShape(256U), TensorShape(56U, 56U, 256U), PadStrideInfo(1, 1, 1, 1)); + // conv3_2, conv3_3 + add_config(TensorShape(56U, 56U, 256U), TensorShape(3U, 3U, 256U, 256U), TensorShape(256U), TensorShape(56U, 56U, 256U), PadStrideInfo(1, 1, 1, 1)); + // conv4_1 + add_config(TensorShape(28U, 28U, 256U), TensorShape(3U, 3U, 256U, 512U), TensorShape(512U), TensorShape(28U, 28U, 512U), PadStrideInfo(1, 1, 1, 1)); + // conv4_2, conv4_3 + add_config(TensorShape(28U, 28U, 512U), TensorShape(3U, 3U, 512U, 512U), TensorShape(512U), TensorShape(28U, 28U, 512U), PadStrideInfo(1, 1, 1, 1)); + // conv5_1, conv5_2, conv5_3 + add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U, 512U), TensorShape(512U), TensorShape(14U, 14U, 512U), PadStrideInfo(1, 1, 1, 1)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_VGG16_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/vgg/vgg16/VGG16FullyConnectedLayerDataset.h b/tests/datasets/system_tests/vgg/vgg16/VGG16FullyConnectedLayerDataset.h new file mode 100644 index 0000000000..d34dc3f87e --- /dev/null +++ b/tests/datasets/system_tests/vgg/vgg16/VGG16FullyConnectedLayerDataset.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_VGG16_FULLYCONNECTED_LAYER_DATASET +#define ARM_COMPUTE_TEST_VGG16_FULLYCONNECTED_LAYER_DATASET + +#include "tests/datasets/FullyConnectedLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class VGG16FullyConnectedLayerDataset final : public FullyConnectedLayerDataset +{ +public: + VGG16FullyConnectedLayerDataset() + { + // fc6 + add_config(TensorShape(7U, 7U, 512U), TensorShape(25088U, 4096U), TensorShape(4096U), TensorShape(4096U)); + // fc7 + add_config(TensorShape(4096U), TensorShape(4096U, 4096U), TensorShape(4096U), TensorShape(4096U)); + // fc8 + add_config(TensorShape(4096U), TensorShape(4096U, 1000U), TensorShape(1000U), TensorShape(1000U)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_VGG16_FULLYCONNECTED_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/vgg/vgg16/VGG16PoolingLayerDataset.h b/tests/datasets/system_tests/vgg/vgg16/VGG16PoolingLayerDataset.h new file mode 100644 index 0000000000..4db20870f2 --- /dev/null +++ b/tests/datasets/system_tests/vgg/vgg16/VGG16PoolingLayerDataset.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_VGG16_POOLING_LAYER_DATASET +#define ARM_COMPUTE_TEST_VGG16_POOLING_LAYER_DATASET + +#include "tests/datasets/PoolingLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class VGG16PoolingLayerDataset final : public PoolingLayerDataset +{ +public: + VGG16PoolingLayerDataset() + { + // pool1 + add_config(TensorShape(224U, 224U, 64U), TensorShape(112U, 112U, 64U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // pool2 + add_config(TensorShape(112U, 112U, 128U), TensorShape(56U, 56U, 128U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // pool3 + add_config(TensorShape(56U, 56U, 256U), TensorShape(28U, 28U, 256U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // pool4 + add_config(TensorShape(28U, 28U, 512U), TensorShape(14U, 14U, 512U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // pool5 + add_config(TensorShape(14U, 14U, 512U), TensorShape(7U, 7U, 512U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_VGG16_POOLING_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/yolo/v2/YOLOV2ActivationLayerDataset.h b/tests/datasets/system_tests/yolo/v2/YOLOV2ActivationLayerDataset.h new file mode 100644 index 0000000000..8a2cd1665e --- /dev/null +++ b/tests/datasets/system_tests/yolo/v2/YOLOV2ActivationLayerDataset.h @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_YOLOV2_ACTIVATION_LAYER_DATASET +#define ARM_COMPUTE_TEST_YOLOV2_ACTIVATION_LAYER_DATASET + +#include "tests/framework/datasets/Datasets.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class YOLOV2ActivationLayerRELUDataset final : public + framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> +{ +public: + YOLOV2ActivationLayerRELUDataset() + : CartesianProductDataset + { + framework::dataset::make("Shape", { // relu1 + TensorShape(416U, 416U, 32U), + // relu2 + TensorShape(208U, 208U, 64U), + // relu3, relu5 + TensorShape(104U, 104U, 128U), + // relu4 + TensorShape(104U, 104U, 64U), + // relu6, relu8 + TensorShape(52U, 52U, 256U), + // relu7 + TensorShape(52U, 52U, 128U), + // relu9, relu11, relu13 + TensorShape(26U, 26U, 512U), + // relu10, relu12 + TensorShape(26U, 26U, 256U), + // relu14, relu16, relu18, relu19, relu20, relu21 + TensorShape(13U, 13U, 1024U), + // relu15, relu17 + TensorShape(13U, 13U, 512U) }), + framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) + } + { + } + YOLOV2ActivationLayerRELUDataset(YOLOV2ActivationLayerRELUDataset &&) = default; + ~YOLOV2ActivationLayerRELUDataset() = default; +}; + +class YOLOV2ActivationLayerLINEARDataset final : public + framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> +{ +public: + YOLOV2ActivationLayerLINEARDataset() + : CartesianProductDataset + { + framework::dataset::make("Shape", { // linear22 + TensorShape(15U, 15U, 425U) }), + framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LINEAR)) + } + { + } + YOLOV2ActivationLayerLINEARDataset(YOLOV2ActivationLayerLINEARDataset &&) = default; + ~YOLOV2ActivationLayerLINEARDataset() = default; +}; + +class YOLOV2ActivationLayerDataset final : public framework::dataset::JoinDataset +{ +public: + YOLOV2ActivationLayerDataset() + : JoinDataset + { + YOLOV2ActivationLayerRELUDataset(), + YOLOV2ActivationLayerLINEARDataset() + } + { + } + YOLOV2ActivationLayerDataset(YOLOV2ActivationLayerDataset &&) = default; + ~YOLOV2ActivationLayerDataset() = default; +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_YOLOV2_ACTIVATION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/yolo/v2/YOLOV2BatchNormalizationLayerDataset.h b/tests/datasets/system_tests/yolo/v2/YOLOV2BatchNormalizationLayerDataset.h new file mode 100644 index 0000000000..cc6a6dcccc --- /dev/null +++ b/tests/datasets/system_tests/yolo/v2/YOLOV2BatchNormalizationLayerDataset.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_YOLOV2_BATCHNORMALIZATION_LAYER_DATASET +#define ARM_COMPUTE_TEST_YOLOV2_BATCHNORMALIZATION_LAYER_DATASET + +#include "tests/datasets/BatchNormalizationLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class YOLOV2BatchNormalizationLayerDataset final : public BatchNormalizationLayerDataset +{ +public: + YOLOV2BatchNormalizationLayerDataset() + { + // conv1_bn + add_config(TensorShape(416U, 416U, 32U), TensorShape(32U), 0.00001f); + // conv2_bn + add_config(TensorShape(208U, 208U, 64U), TensorShape(64U), 0.00001f); + // conv3_bn, conv5_bn + add_config(TensorShape(104U, 104U, 128U), TensorShape(128U), 0.00001f); + // conv4_bn + add_config(TensorShape(104U, 104U, 64U), TensorShape(64U), 0.00001f); + // conv6_bn, conv8_bn + add_config(TensorShape(52U, 52U, 256U), TensorShape(256U), 0.00001f); + // conv7_bn + add_config(TensorShape(52U, 52U, 128U), TensorShape(128U), 0.00001f); + // conv9_bn, conv11_bn, conv13_bn + add_config(TensorShape(26U, 26U, 512U), TensorShape(512U), 0.00001f); + // conv10_bn, conv12_bn + add_config(TensorShape(26U, 26U, 256U), TensorShape(256U), 0.00001f); + // conv14_bn, conv16_bn, conv18_bn, conv19_bn, conv20_bn, conv21_bn + add_config(TensorShape(13U, 13U, 1024U), TensorShape(1024U), 0.00001f); + // conv15_bn, conv17_bn + add_config(TensorShape(13U, 13U, 512U), TensorShape(512U), 0.00001f); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_YOLOV2_BATCHNORMALIZATION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/yolo/v2/YOLOV2ConvolutionLayerDataset.h b/tests/datasets/system_tests/yolo/v2/YOLOV2ConvolutionLayerDataset.h new file mode 100644 index 0000000000..41f48b0958 --- /dev/null +++ b/tests/datasets/system_tests/yolo/v2/YOLOV2ConvolutionLayerDataset.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_YOLOV2_CONVOLUTION_LAYER_DATASET +#define ARM_COMPUTE_TEST_YOLOV2_CONVOLUTION_LAYER_DATASET + +#include "tests/datasets/ConvolutionLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class YOLOV2ConvolutionLayerDataset final : public ConvolutionLayerDataset +{ +public: + YOLOV2ConvolutionLayerDataset() + { + // conv1 + add_config(TensorShape(416U, 416U, 3U), TensorShape(3U, 3U, 3U, 32U), TensorShape(32U), TensorShape(416U, 416U, 32U), PadStrideInfo(1, 1, 1, 1)); + // conv2 + add_config(TensorShape(208U, 208U, 32U), TensorShape(3U, 3U, 32U, 64U), TensorShape(64U), TensorShape(208U, 208U, 64U), PadStrideInfo(1, 1, 1, 1)); + // conv3, conv5 + add_config(TensorShape(104U, 104U, 64U), TensorShape(3U, 3U, 64U, 128U), TensorShape(128U), TensorShape(104U, 104U, 128U), PadStrideInfo(1, 1, 1, 1)); + // conv4 + add_config(TensorShape(104U, 104U, 128U), TensorShape(1U, 1U, 128U, 64U), TensorShape(64U), TensorShape(104U, 104U, 64U), PadStrideInfo(1, 1, 0, 0)); + // conv6, conv8 + add_config(TensorShape(52U, 52U, 128U), TensorShape(3U, 3U, 128U, 256U), TensorShape(256U), TensorShape(52U, 52U, 256U), PadStrideInfo(1, 1, 1, 1)); + // conv7 + add_config(TensorShape(52U, 52U, 256U), TensorShape(1U, 1U, 256U, 128U), TensorShape(128U), TensorShape(52U, 52U, 128U), PadStrideInfo(1, 1, 0, 0)); + // conv9, conv11, conv13 + add_config(TensorShape(26U, 26U, 256U), TensorShape(3U, 3U, 256U, 512U), TensorShape(512U), TensorShape(26U, 26U, 512U), PadStrideInfo(1, 1, 1, 1)); + // conv10, conv12 + add_config(TensorShape(26U, 26U, 512U), TensorShape(1U, 1U, 512U, 256U), TensorShape(256U), TensorShape(26U, 26U, 256U), PadStrideInfo(1, 1, 0, 0)); + // conv14, conv16, conv18 + add_config(TensorShape(13U, 13U, 512U), TensorShape(3U, 3U, 512U, 1024U), TensorShape(1024U), TensorShape(13U, 13U, 1024U), PadStrideInfo(1, 1, 1, 1)); + // conv15, conv17 + add_config(TensorShape(13U, 13U, 1024U), TensorShape(1U, 1U, 1024U, 512U), TensorShape(512U), TensorShape(13U, 13U, 512U), PadStrideInfo(1, 1, 0, 0)); + // conv19, conv20 + add_config(TensorShape(13U, 13U, 1024U), TensorShape(3U, 3U, 1024U, 1024U), TensorShape(1024U), TensorShape(13U, 13U, 1024U), PadStrideInfo(1, 1, 1, 1)); + // conv21 + add_config(TensorShape(13U, 13U, 3072U), TensorShape(3U, 3U, 3072U, 1024U), TensorShape(1024U), TensorShape(13U, 13U, 1024U), PadStrideInfo(1, 1, 1, 1)); + // conv22 + add_config(TensorShape(13U, 13U, 1024U), TensorShape(1U, 1U, 1024U, 425U), TensorShape(425U), TensorShape(15U, 15U, 425U), PadStrideInfo(1, 1, 1, 1)); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_YOLOV2_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets/system_tests/yolo/v2/YOLOV2PoolingLayerDataset.h b/tests/datasets/system_tests/yolo/v2/YOLOV2PoolingLayerDataset.h new file mode 100644 index 0000000000..3763d63588 --- /dev/null +++ b/tests/datasets/system_tests/yolo/v2/YOLOV2PoolingLayerDataset.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_YOLOV2_POOLING_LAYER_DATASET +#define ARM_COMPUTE_TEST_YOLOV2_POOLING_LAYER_DATASET + +#include "tests/datasets/PoolingLayerDataset.h" + +#include "tests/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class YOLOV2PoolingLayerDataset final : public PoolingLayerDataset +{ +public: + YOLOV2PoolingLayerDataset() + { + // pool1 + add_config(TensorShape(416U, 416U, 32U), TensorShape(208U, 208U, 32U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // pool2 + add_config(TensorShape(208U, 208U, 64U), TensorShape(104U, 104U, 64U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // pool5 + add_config(TensorShape(104U, 104U, 128U), TensorShape(52U, 52U, 128U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // pool8 + add_config(TensorShape(52U, 52U, 256U), TensorShape(26U, 26U, 256U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + // pool13 + add_config(TensorShape(26U, 26U, 512U), TensorShape(13U, 13U, 512U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_YOLOV2_POOLING_LAYER_DATASET */ diff --git a/tests/datasets_new/ActivationFunctionsDataset.h b/tests/datasets_new/ActivationFunctionsDataset.h deleted file mode 100644 index 0a11902d51..0000000000 --- a/tests/datasets_new/ActivationFunctionsDataset.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_ACTIVATIONFUNCTIONS_DATASET_H__ -#define __ARM_COMPUTE_TEST_ACTIVATIONFUNCTIONS_DATASET_H__ - -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class ActivationFunctions final : public framework::dataset::ContainerDataset> -{ -public: - ActivationFunctions() - : ContainerDataset("ActivationFunction", - { - ActivationLayerInfo::ActivationFunction::ABS, - ActivationLayerInfo::ActivationFunction::LINEAR, - ActivationLayerInfo::ActivationFunction::LOGISTIC, - ActivationLayerInfo::ActivationFunction::RELU, - ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, - ActivationLayerInfo::ActivationFunction::LEAKY_RELU, - ActivationLayerInfo::ActivationFunction::SOFT_RELU, - ActivationLayerInfo::ActivationFunction::SQRT, - ActivationLayerInfo::ActivationFunction::SQUARE, - ActivationLayerInfo::ActivationFunction::TANH - }) - { - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_ACTIVATIONFUNCTIONS_DATASET_H__ */ diff --git a/tests/datasets_new/BatchNormalizationLayerDataset.h b/tests/datasets_new/BatchNormalizationLayerDataset.h deleted file mode 100644 index 25e65d931c..0000000000 --- a/tests/datasets_new/BatchNormalizationLayerDataset.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_BATCHNORMALIZATION_LAYER_DATASET -#define ARM_COMPUTE_TEST_BATCHNORMALIZATION_LAYER_DATASET - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class BatchNormalizationLayerDataset -{ -public: - using type = std::tuple; - - struct iterator - { - iterator(std::vector::const_iterator tensor_it, - std::vector::const_iterator param_it, - std::vector::const_iterator epsilon_it) - : _tensor_it{ std::move(tensor_it) }, - _param_it{ std::move(param_it) }, - _epsilon_it{ std::move(epsilon_it) } - { - } - - std::string description() const - { - std::stringstream description; - description << "In=" << *_tensor_it << ":"; - description << "Out=" << *_tensor_it << ":"; - description << "Mean=" << *_param_it << ":"; - description << "Variance=" << *_param_it << ":"; - description << "Beta=" << *_param_it << ":"; - description << "Gamma=" << *_param_it << ":"; - description << "Epsilon=" << *_epsilon_it; - return description.str(); - } - - BatchNormalizationLayerDataset::type operator*() const - { - return std::make_tuple(*_tensor_it, *_param_it, *_epsilon_it); - } - - iterator &operator++() - { - ++_tensor_it; - ++_param_it; - ++_epsilon_it; - - return *this; - } - - private: - std::vector::const_iterator _tensor_it; - std::vector::const_iterator _param_it; - std::vector::const_iterator _epsilon_it; - }; - - iterator begin() const - { - return iterator(_tensor_shapes.begin(), _param_shapes.begin(), _epsilons.begin()); - } - - int size() const - { - return std::min(_tensor_shapes.size(), std::min(_param_shapes.size(), _epsilons.size())); - } - - void add_config(TensorShape tensor, TensorShape param, float epsilon) - { - _tensor_shapes.emplace_back(std::move(tensor)); - _param_shapes.emplace_back(std::move(param)); - _epsilons.emplace_back(std::move(epsilon)); - } - -protected: - BatchNormalizationLayerDataset() = default; - BatchNormalizationLayerDataset(BatchNormalizationLayerDataset &&) = default; - -private: - std::vector _tensor_shapes{}; - std::vector _param_shapes{}; - std::vector _epsilons{}; -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_BATCHNORMALIZATION_LAYER_DATASET */ diff --git a/tests/datasets_new/BorderModeDataset.h b/tests/datasets_new/BorderModeDataset.h deleted file mode 100644 index b45e7835c1..0000000000 --- a/tests/datasets_new/BorderModeDataset.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_BORDER_MODE_DATASET_H__ -#define __ARM_COMPUTE_TEST_BORDER_MODE_DATASET_H__ - -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class BorderModes final : public framework::dataset::ContainerDataset> -{ -public: - BorderModes() - : ContainerDataset("BorderMode", - { - BorderMode::UNDEFINED, - BorderMode::CONSTANT, - BorderMode::REPLICATE - }) - { - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_BORDER_MODE_DATASET_H__ */ diff --git a/tests/datasets_new/ConvolutionLayerDataset.h b/tests/datasets_new/ConvolutionLayerDataset.h deleted file mode 100644 index ba11bd5d6d..0000000000 --- a/tests/datasets_new/ConvolutionLayerDataset.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_CONVOLUTION_LAYER_DATASET -#define ARM_COMPUTE_TEST_CONVOLUTION_LAYER_DATASET - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class ConvolutionLayerDataset -{ -public: - using type = std::tuple; - - struct iterator - { - iterator(std::vector::const_iterator src_it, - std::vector::const_iterator weights_it, - std::vector::const_iterator biases_it, - std::vector::const_iterator dst_it, - std::vector::const_iterator infos_it) - : _src_it{ std::move(src_it) }, - _weights_it{ std::move(weights_it) }, - _biases_it{ std::move(biases_it) }, - _dst_it{ std::move(dst_it) }, - _infos_it{ std::move(infos_it) } - { - } - - std::string description() const - { - std::stringstream description; - description << "In=" << *_src_it << ":"; - description << "Weights=" << *_weights_it << ":"; - description << "Biases=" << *_biases_it << ":"; - description << "Out=" << *_dst_it << ":"; - description << "Info=" << *_infos_it; - return description.str(); - } - - ConvolutionLayerDataset::type operator*() const - { - return std::make_tuple(*_src_it, *_weights_it, *_biases_it, *_dst_it, *_infos_it); - } - - iterator &operator++() - { - ++_src_it; - ++_weights_it; - ++_biases_it; - ++_dst_it; - ++_infos_it; - - return *this; - } - - private: - std::vector::const_iterator _src_it; - std::vector::const_iterator _weights_it; - std::vector::const_iterator _biases_it; - std::vector::const_iterator _dst_it; - std::vector::const_iterator _infos_it; - }; - - iterator begin() const - { - return iterator(_src_shapes.begin(), _weight_shapes.begin(), _bias_shapes.begin(), _dst_shapes.begin(), _infos.begin()); - } - - int size() const - { - return std::min(_src_shapes.size(), std::min(_weight_shapes.size(), std::min(_bias_shapes.size(), std::min(_dst_shapes.size(), _infos.size())))); - } - - void add_config(TensorShape src, TensorShape weights, TensorShape biases, TensorShape dst, PadStrideInfo info) - { - _src_shapes.emplace_back(std::move(src)); - _weight_shapes.emplace_back(std::move(weights)); - _bias_shapes.emplace_back(std::move(biases)); - _dst_shapes.emplace_back(std::move(dst)); - _infos.emplace_back(std::move(info)); - } - -protected: - ConvolutionLayerDataset() = default; - ConvolutionLayerDataset(ConvolutionLayerDataset &&) = default; - -private: - std::vector _src_shapes{}; - std::vector _weight_shapes{}; - std::vector _bias_shapes{}; - std::vector _dst_shapes{}; - std::vector _infos{}; -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets_new/DepthwiseConvolutionDataset.h b/tests/datasets_new/DepthwiseConvolutionDataset.h deleted file mode 100644 index 93da37532f..0000000000 --- a/tests/datasets_new/DepthwiseConvolutionDataset.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_DATASET -#define ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_DATASET - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class DepthwiseConvolutionDataset -{ -public: - using type = std::tuple; - - struct iterator - { - iterator(std::vector::const_iterator src_it, - std::vector::const_iterator weights_it, - std::vector::const_iterator dst_it, - std::vector::const_iterator infos_it) - : _src_it{ std::move(src_it) }, - _weights_it{ std::move(weights_it) }, - _dst_it{ std::move(dst_it) }, - _infos_it{ std::move(infos_it) } - { - } - - std::string description() const - { - std::stringstream description; - description << "In=" << *_src_it << ":"; - description << "Weights=" << *_weights_it << ":"; - description << "Out=" << *_dst_it << ":"; - description << "Info=" << *_infos_it; - return description.str(); - } - - DepthwiseConvolutionDataset::type operator*() const - { - return std::make_tuple(*_src_it, *_weights_it, *_dst_it, *_infos_it); - } - - iterator &operator++() - { - ++_src_it; - ++_weights_it; - ++_dst_it; - ++_infos_it; - - return *this; - } - - private: - std::vector::const_iterator _src_it; - std::vector::const_iterator _weights_it; - std::vector::const_iterator _dst_it; - std::vector::const_iterator _infos_it; - }; - - iterator begin() const - { - return iterator(_src_shapes.begin(), _weight_shapes.begin(), _dst_shapes.begin(), _infos.begin()); - } - - int size() const - { - return std::min(_src_shapes.size(), std::min(_weight_shapes.size(), std::min(_dst_shapes.size(), _infos.size()))); - } - - void add_config(TensorShape src, TensorShape weights, TensorShape dst, PadStrideInfo info) - { - _src_shapes.emplace_back(std::move(src)); - _weight_shapes.emplace_back(std::move(weights)); - _dst_shapes.emplace_back(std::move(dst)); - _infos.emplace_back(std::move(info)); - } - -protected: - DepthwiseConvolutionDataset() = default; - DepthwiseConvolutionDataset(DepthwiseConvolutionDataset &&) = default; - -private: - std::vector _src_shapes{}; - std::vector _weight_shapes{}; - std::vector _dst_shapes{}; - std::vector _infos{}; -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_DATASET */ diff --git a/tests/datasets_new/DepthwiseSeparableConvolutionLayerDataset.h b/tests/datasets_new/DepthwiseSeparableConvolutionLayerDataset.h deleted file mode 100644 index 4391379833..0000000000 --- a/tests/datasets_new/DepthwiseSeparableConvolutionLayerDataset.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_DATASET -#define ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_DATASET - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class DepthwiseSeparableConvolutionLayerDataset -{ -public: - using type = std::tuple; - - struct iterator - { - iterator(std::vector::const_iterator src_it, - std::vector::const_iterator filter_it, - std::vector::const_iterator depthwise_out_it, - std::vector::const_iterator weights_it, - std::vector::const_iterator biases_it, - std::vector::const_iterator dst_it, - std::vector::const_iterator depthwise_infos_it, - std::vector::const_iterator pointwise_infos_it) - : _src_it{ std::move(src_it) }, - _filter_it{ std::move(filter_it) }, - _depthwise_out_it{ std::move(depthwise_out_it) }, - _weights_it{ std::move(weights_it) }, - _biases_it{ std::move(biases_it) }, - _dst_it{ std::move(dst_it) }, - _depthwise_infos_it{ std::move(depthwise_infos_it) }, - _pointwise_infos_it{ std::move(pointwise_infos_it) } - { - } - - std::string description() const - { - std::stringstream description; - description << "In=" << *_src_it << ":"; - description << "Filter=" << *_filter_it << ":"; - description << "DepthwiseOut=" << *_depthwise_out_it << ":"; - description << "Weights=" << *_weights_it << ":"; - description << "Biases=" << *_biases_it << ":"; - description << "Out=" << *_dst_it << ":"; - description << "DepthwiseInfo=" << *_depthwise_infos_it << ":"; - description << "PointwiseInfo=" << *_pointwise_infos_it; - return description.str(); - } - - DepthwiseSeparableConvolutionLayerDataset::type operator*() const - { - return std::make_tuple(*_src_it, *_filter_it, *_depthwise_out_it, *_weights_it, *_biases_it, *_dst_it, *_depthwise_infos_it, *_pointwise_infos_it); - } - - iterator &operator++() - { - ++_src_it; - ++_filter_it; - ++_depthwise_out_it; - ++_weights_it; - ++_biases_it; - ++_dst_it; - ++_depthwise_infos_it; - ++_pointwise_infos_it; - - return *this; - } - - private: - std::vector::const_iterator _src_it; - std::vector::const_iterator _filter_it; - std::vector::const_iterator _depthwise_out_it; - std::vector::const_iterator _weights_it; - std::vector::const_iterator _biases_it; - std::vector::const_iterator _dst_it; - std::vector::const_iterator _depthwise_infos_it; - std::vector::const_iterator _pointwise_infos_it; - }; - - iterator begin() const - { - return iterator(_src_shapes.begin(), _filter_shapes.begin(), _depthwise_out_shapes.begin(), _weight_shapes.begin(), _bias_shapes.begin(), _dst_shapes.begin(), _depthwise_infos.begin(), - _pointwise_infos.begin()); - } - - int size() const - { - return std::min(_src_shapes.size(), std::min(_filter_shapes.size(), std::min(_depthwise_out_shapes.size(), std::min(_weight_shapes.size(), std::min(_bias_shapes.size(), std::min(_dst_shapes.size(), - std::min(_depthwise_infos.size(), _pointwise_infos.size()))))))); - } - - void add_config(TensorShape src, TensorShape filter, TensorShape depthwise_out, TensorShape weights, TensorShape biases, TensorShape dst, PadStrideInfo depthwise_info, PadStrideInfo pointwise_info) - { - _src_shapes.emplace_back(std::move(src)); - _filter_shapes.emplace_back(std::move(filter)); - _depthwise_out_shapes.emplace_back(std::move(depthwise_out)); - _weight_shapes.emplace_back(std::move(weights)); - _bias_shapes.emplace_back(std::move(biases)); - _dst_shapes.emplace_back(std::move(dst)); - _depthwise_infos.emplace_back(std::move(depthwise_info)); - _pointwise_infos.emplace_back(std::move(pointwise_info)); - } - -protected: - DepthwiseSeparableConvolutionLayerDataset() = default; - DepthwiseSeparableConvolutionLayerDataset(DepthwiseSeparableConvolutionLayerDataset &&) = default; - -private: - std::vector _src_shapes{}; - std::vector _filter_shapes{}; - std::vector _depthwise_out_shapes{}; - std::vector _weight_shapes{}; - std::vector _bias_shapes{}; - std::vector _dst_shapes{}; - std::vector _depthwise_infos{}; - std::vector _pointwise_infos{}; -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets_new/DirectConvolutionLayerDataset.h b/tests/datasets_new/DirectConvolutionLayerDataset.h deleted file mode 100644 index 1d7b06ce41..0000000000 --- a/tests/datasets_new/DirectConvolutionLayerDataset.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DIRECT_CONVOLUTION_LAYER_DATASET -#define ARM_COMPUTE_TEST_DIRECT_CONVOLUTION_LAYER_DATASET - -#include "tests/datasets_new/ConvolutionLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -/** Stripped down version of AlexNet as not all kernel sizes and strides are supported. */ -class DirectConvolutionLayerDataset final : public ConvolutionLayerDataset -{ -public: - DirectConvolutionLayerDataset() - { - add_config(TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 3U), TensorShape(3U), TensorShape(13U, 13U, 3U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 4U), TensorShape(4U), TensorShape(13U, 13U, 4U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 5U), TensorShape(5U), TensorShape(13U, 13U, 5U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 3U), TensorShape(3U), TensorShape(13U, 13U, 3U), PadStrideInfo(2, 2, 1, 1)); - add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 4U), TensorShape(4U), TensorShape(13U, 13U, 4U), PadStrideInfo(2, 2, 1, 1)); - add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 5U), TensorShape(5U), TensorShape(13U, 13U, 5U), PadStrideInfo(2, 2, 1, 1)); - add_config(TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 3U), TensorShape(3U), TensorShape(13U, 13U, 3U), PadStrideInfo(3, 3, 1, 1)); - add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 4U), TensorShape(4U), TensorShape(13U, 13U, 4U), PadStrideInfo(3, 3, 1, 1)); - add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 5U), TensorShape(5U), TensorShape(13U, 13U, 5U), PadStrideInfo(3, 3, 1, 1)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DIRECT_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets_new/FullyConnectedLayerDataset.h b/tests/datasets_new/FullyConnectedLayerDataset.h deleted file mode 100644 index 8401e39ece..0000000000 --- a/tests/datasets_new/FullyConnectedLayerDataset.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_FULLYCONNECTED_LAYER_DATASET -#define ARM_COMPUTE_TEST_FULLYCONNECTED_LAYER_DATASET - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class FullyConnectedLayerDataset -{ -public: - using type = std::tuple; - - struct iterator - { - iterator(std::vector::const_iterator src_it, - std::vector::const_iterator weights_it, - std::vector::const_iterator biases_it, - std::vector::const_iterator dst_it) - : _src_it{ std::move(src_it) }, - _weights_it{ std::move(weights_it) }, - _biases_it{ std::move(biases_it) }, - _dst_it{ std::move(dst_it) } - { - } - - std::string description() const - { - std::stringstream description; - description << "In=" << *_src_it << ":"; - description << "Weights=" << *_weights_it << ":"; - description << "Biases=" << *_biases_it << ":"; - description << "Out=" << *_dst_it; - return description.str(); - } - - FullyConnectedLayerDataset::type operator*() const - { - return std::make_tuple(*_src_it, *_weights_it, *_biases_it, *_dst_it); - } - - iterator &operator++() - { - ++_src_it; - ++_weights_it; - ++_biases_it; - ++_dst_it; - - return *this; - } - - private: - std::vector::const_iterator _src_it; - std::vector::const_iterator _weights_it; - std::vector::const_iterator _biases_it; - std::vector::const_iterator _dst_it; - }; - - iterator begin() const - { - return iterator(_src_shapes.begin(), _weight_shapes.begin(), _bias_shapes.begin(), _dst_shapes.begin()); - } - - int size() const - { - return std::min(_src_shapes.size(), std::min(_weight_shapes.size(), std::min(_bias_shapes.size(), _dst_shapes.size()))); - } - - void add_config(TensorShape src, TensorShape weights, TensorShape biases, TensorShape dst) - { - _src_shapes.emplace_back(std::move(src)); - _weight_shapes.emplace_back(std::move(weights)); - _bias_shapes.emplace_back(std::move(biases)); - _dst_shapes.emplace_back(std::move(dst)); - } - -protected: - FullyConnectedLayerDataset() = default; - FullyConnectedLayerDataset(FullyConnectedLayerDataset &&) = default; - -private: - std::vector _src_shapes{}; - std::vector _weight_shapes{}; - std::vector _bias_shapes{}; - std::vector _dst_shapes{}; -}; - -class SmallFullyConnectedLayerDataset final : public FullyConnectedLayerDataset -{ -public: - SmallFullyConnectedLayerDataset() - { - // Conv -> FC - add_config(TensorShape(9U, 5U, 7U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U)); - // Conv -> FC (batched) - add_config(TensorShape(9U, 5U, 7U, 3U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U, 3U)); - // FC -> FC - add_config(TensorShape(201U), TensorShape(201U, 529U), TensorShape(529U), TensorShape(529U)); - // FC -> FC (batched) - add_config(TensorShape(201U, 3U), TensorShape(201U, 529U), TensorShape(529U), TensorShape(529U, 3U)); - - add_config(TensorShape(9U, 5U, 7U, 3U, 2U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U, 3U, 2U)); - } -}; - -class LargeFullyConnectedLayerDataset final : public FullyConnectedLayerDataset -{ -public: - LargeFullyConnectedLayerDataset() - { - add_config(TensorShape(9U, 5U, 257U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U)); - add_config(TensorShape(9U, 5U, 257U, 2U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U, 2U)); - add_config(TensorShape(3127U), TensorShape(3127U, 989U), TensorShape(989U), TensorShape(989U)); - add_config(TensorShape(3127U, 2U), TensorShape(3127U, 989U), TensorShape(989U), TensorShape(989U, 2U)); - - add_config(TensorShape(9U, 5U, 257U, 2U, 3U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U, 2U, 3U)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_FULLYCONNECTED_LAYER_DATASET */ diff --git a/tests/datasets_new/GEMMDataset.h b/tests/datasets_new/GEMMDataset.h deleted file mode 100644 index bb8a328b0c..0000000000 --- a/tests/datasets_new/GEMMDataset.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GEMM_DATASET -#define ARM_COMPUTE_TEST_GEMM_DATASET - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class GEMMDataset -{ -public: - using type = std::tuple; - - struct iterator - { - iterator(std::vector::const_iterator a_it, - std::vector::const_iterator b_it, - std::vector::const_iterator c_it, - std::vector::const_iterator dst_it, - std::vector::const_iterator alpha_it, - std::vector::const_iterator beta_it) - : _a_it{ std::move(a_it) }, - _b_it{ std::move(b_it) }, - _c_it{ std::move(c_it) }, - _dst_it{ std::move(dst_it) }, - _alpha_it{ std::move(alpha_it) }, - _beta_it{ std::move(beta_it) } - { - } - - std::string description() const - { - std::stringstream description; - description << "A=" << *_a_it << ":"; - description << "B=" << *_b_it << ":"; - description << "C=" << *_c_it << ":"; - description << "Out=" << *_dst_it << ":"; - description << "Alpha=" << *_alpha_it << ":"; - description << "Beta=" << *_beta_it; - return description.str(); - } - - GEMMDataset::type operator*() const - { - return std::make_tuple(*_a_it, *_b_it, *_c_it, *_dst_it, *_alpha_it, *_beta_it); - } - - iterator &operator++() - { - ++_a_it; - ++_b_it; - ++_c_it; - ++_dst_it; - ++_alpha_it; - ++_beta_it; - - return *this; - } - - private: - std::vector::const_iterator _a_it; - std::vector::const_iterator _b_it; - std::vector::const_iterator _c_it; - std::vector::const_iterator _dst_it; - std::vector::const_iterator _alpha_it; - std::vector::const_iterator _beta_it; - }; - - iterator begin() const - { - return iterator(_a_shapes.begin(), _b_shapes.begin(), _c_shapes.begin(), _dst_shapes.begin(), _alpha.begin(), _beta.begin()); - } - - int size() const - { - return std::min(_a_shapes.size(), std::min(_b_shapes.size(), std::min(_c_shapes.size(), std::min(_dst_shapes.size(), std::min(_alpha.size(), _beta.size()))))); - } - - void add_config(TensorShape a, TensorShape b, TensorShape c, TensorShape dst, float alpha, float beta) - { - _a_shapes.emplace_back(std::move(a)); - _b_shapes.emplace_back(std::move(b)); - _c_shapes.emplace_back(std::move(c)); - _dst_shapes.emplace_back(std::move(dst)); - _alpha.emplace_back(std::move(alpha)); - _beta.emplace_back(std::move(beta)); - } - -protected: - GEMMDataset() = default; - GEMMDataset(GEMMDataset &&) = default; - -private: - std::vector _a_shapes{}; - std::vector _b_shapes{}; - std::vector _c_shapes{}; - std::vector _dst_shapes{}; - std::vector _alpha{}; - std::vector _beta{}; -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GEMM_DATASET */ diff --git a/tests/datasets_new/InterpolationPolicyDataset.h b/tests/datasets_new/InterpolationPolicyDataset.h deleted file mode 100644 index 154f887962..0000000000 --- a/tests/datasets_new/InterpolationPolicyDataset.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_INTEPOLATIONPOLICY_DATASET_H__ -#define __ARM_COMPUTE_TEST_INTEPOLATIONPOLICY_DATASET_H__ - -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class InterpolationPolicies final : public framework::dataset::ContainerDataset> -{ -public: - InterpolationPolicies() - : ContainerDataset("InterpolationPolicy", - { - InterpolationPolicy::NEAREST_NEIGHBOR, - InterpolationPolicy::BILINEAR, - InterpolationPolicy::AREA - }) - { - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_INTEPOLATIONPOLICY_DATASET_H__ */ diff --git a/tests/datasets_new/LargeConvolutionLayerDataset.h b/tests/datasets_new/LargeConvolutionLayerDataset.h deleted file mode 100644 index 36692f9881..0000000000 --- a/tests/datasets_new/LargeConvolutionLayerDataset.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_LARGE_CONVOLUTION_LAYER_DATASET -#define ARM_COMPUTE_TEST_LARGE_CONVOLUTION_LAYER_DATASET - -#include "tests/datasets_new/ConvolutionLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class LargeConvolutionLayerDataset final : public ConvolutionLayerDataset -{ -public: - LargeConvolutionLayerDataset() - { - // Batch size 1 - add_config(TensorShape(227U, 227U, 3U), TensorShape(11U, 11U, 3U, 96U), TensorShape(96U), TensorShape(55U, 55U, 96U), PadStrideInfo(4, 4, 0, 0)); - add_config(TensorShape(27U, 27U, 96U), TensorShape(5U, 5U, 96U, 256U), TensorShape(256U), TensorShape(27U, 27U, 256U), PadStrideInfo(1, 1, 2, 2)); - add_config(TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(224U, 224U, 3U), TensorShape(7U, 7U, 3U, 64U), TensorShape(64U), TensorShape(112U, 112U, 64U), PadStrideInfo(2, 2, 3, 3)); - add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0)); - // Batch size 4 - add_config(TensorShape(227U, 227U, 3U, 4U), TensorShape(11U, 11U, 3U, 96U), TensorShape(96U), TensorShape(55U, 55U, 96U, 4U), PadStrideInfo(4, 4, 0, 0)); - add_config(TensorShape(27U, 27U, 96U, 4U), TensorShape(5U, 5U, 96U, 256U), TensorShape(256U), TensorShape(27U, 27U, 256U, 4U), PadStrideInfo(1, 1, 2, 2)); - add_config(TensorShape(13U, 13U, 256U, 4U), TensorShape(3U, 3U, 256U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U, 4U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(13U, 13U, 384U, 4U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U, 4U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(13U, 13U, 384U, 4U), TensorShape(3U, 3U, 384U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U, 4U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(224U, 224U, 3U, 4U), TensorShape(7U, 7U, 3U, 64U), TensorShape(64U), TensorShape(112U, 112U, 64U, 4U), PadStrideInfo(2, 2, 3, 3)); - add_config(TensorShape(28U, 28U, 256U, 4U), TensorShape(1U, 1U, 256U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U, 4U), PadStrideInfo(1, 1, 0, 0)); - // Batch size 8 - add_config(TensorShape(227U, 227U, 3U, 8U), TensorShape(11U, 11U, 3U, 96U), TensorShape(96U), TensorShape(55U, 55U, 96U, 8U), PadStrideInfo(4, 4, 0, 0)); - add_config(TensorShape(27U, 27U, 96U, 8U), TensorShape(5U, 5U, 96U, 256U), TensorShape(256U), TensorShape(27U, 27U, 256U, 8U), PadStrideInfo(1, 1, 2, 2)); - add_config(TensorShape(13U, 13U, 256U, 8U), TensorShape(3U, 3U, 256U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U, 8U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(13U, 13U, 384U, 8U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U, 8U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(13U, 13U, 384U, 8U), TensorShape(3U, 3U, 384U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U, 8U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(224U, 224U, 3U, 8U), TensorShape(7U, 7U, 3U, 64U), TensorShape(64U), TensorShape(112U, 112U, 64U, 8U), PadStrideInfo(2, 2, 3, 3)); - add_config(TensorShape(28U, 28U, 256U, 8U), TensorShape(1U, 1U, 256U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U, 8U), PadStrideInfo(1, 1, 0, 0)); - // Arbitrary batch size - add_config(TensorShape(227U, 227U, 3U, 5U), TensorShape(11U, 11U, 3U, 96U), TensorShape(96U), TensorShape(55U, 55U, 96U, 5U), PadStrideInfo(4, 4, 0, 0)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_LARGE_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets_new/LargeDepthwiseConvolutionDataset.h b/tests/datasets_new/LargeDepthwiseConvolutionDataset.h deleted file mode 100644 index 8fd87f780d..0000000000 --- a/tests/datasets_new/LargeDepthwiseConvolutionDataset.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_LARGE_DEPTHWISE_CONVOLUTION_DATASET -#define ARM_COMPUTE_TEST_LARGE_DEPTHWISE_CONVOLUTION_DATASET - -#include "tests/datasets_new/DepthwiseConvolutionDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class LargeDepthwiseConvolutionDataset final : public DepthwiseConvolutionDataset -{ -public: - LargeDepthwiseConvolutionDataset() - { - add_config(TensorShape(233U, 277U, 55U), TensorShape(3U, 3U, 55U), TensorShape(116U, 275U, 55U), PadStrideInfo(2, 1, 0, 0)); - add_config(TensorShape(333U, 277U, 77U), TensorShape(3U, 3U, 77U), TensorShape(111U, 138U, 77U), PadStrideInfo(3, 2, 1, 0)); - add_config(TensorShape(177U, 311U, 22U), TensorShape(3U, 3U, 22U), TensorShape(177U, 156U, 22U), PadStrideInfo(1, 2, 1, 1)); - add_config(TensorShape(233U, 277U, 55U), TensorShape(3U, 3U, 55U), TensorShape(231U, 138U, 55U), PadStrideInfo(1, 2, 0, 0)); - add_config(TensorShape(333U, 277U, 77U), TensorShape(3U, 3U, 77U), TensorShape(166U, 93U, 77U), PadStrideInfo(2, 3, 0, 1)); - add_config(TensorShape(177U, 311U, 22U), TensorShape(3U, 3U, 22U), TensorShape(89U, 311U, 22U), PadStrideInfo(2, 1, 1, 1)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_LARGE_DEPTHWISE_CONVOLUTION_DATASET */ diff --git a/tests/datasets_new/LargeGEMMDataset.h b/tests/datasets_new/LargeGEMMDataset.h deleted file mode 100644 index f757ef34c6..0000000000 --- a/tests/datasets_new/LargeGEMMDataset.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_LARGE_GEMM_DATASET -#define ARM_COMPUTE_TEST_LARGE_GEMM_DATASET - -#include "tests/datasets_new/GEMMDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class LargeGEMMDataset final : public GEMMDataset -{ -public: - LargeGEMMDataset() - { - add_config(TensorShape(923U, 429U), TensorShape(871U, 923U), TensorShape(871U, 429U), TensorShape(871U, 429U), 1.0f, 0.0f); - add_config(TensorShape(1021U, 1U), TensorShape(783U, 1021U), TensorShape(783U, 1U), TensorShape(783U, 1U), 1.0f, 0.0f); - add_config(TensorShape(681U, 1023U), TensorShape(213U, 681U), TensorShape(213U, 1023U), TensorShape(213U, 1023U), 0.2f, 1.2f); - add_config(TensorShape(941U, 1U), TensorShape(623U, 941U), TensorShape(623U, 1U), TensorShape(623U, 1U), 0.4f, 0.7f); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_LARGE_GEMM_DATASET */ diff --git a/tests/datasets_new/MatrixMultiplyGEMMDataset.h b/tests/datasets_new/MatrixMultiplyGEMMDataset.h deleted file mode 100644 index 3c482cb244..0000000000 --- a/tests/datasets_new/MatrixMultiplyGEMMDataset.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_MATRIXMULTIPLY_GEMM_DATASET -#define ARM_COMPUTE_TEST_MATRIXMULTIPLY_GEMM_DATASET - -#include "tests/datasets_new/GEMMDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class MatrixMultiplyGEMMDataset final : public GEMMDataset -{ -public: - MatrixMultiplyGEMMDataset() - { - add_config(TensorShape(1024U, 1U), TensorShape(1000U, 1024U), TensorShape(1000U, 1U), TensorShape(1000U, 1U), 1.0f, 0.0f); - add_config(TensorShape(256U, 784U), TensorShape(64U, 256U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f); - add_config(TensorShape(1152U, 2704U), TensorShape(256U, 1152U), TensorShape(256U, 2704U), TensorShape(256U, 2704U), 1.0f, 0.0f); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_MATRIXMULTIPLY_GEMM_DATASET */ diff --git a/tests/datasets_new/MobileNetDepthwiseConvolutionDataset.h b/tests/datasets_new/MobileNetDepthwiseConvolutionDataset.h deleted file mode 100644 index 377bee6665..0000000000 --- a/tests/datasets_new/MobileNetDepthwiseConvolutionDataset.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_MOBILENET_DEPTHWISE_CONVOLUTION_DATASET -#define ARM_COMPUTE_TEST_MOBILENET_DEPTHWISE_CONVOLUTION_DATASET - -#include "tests/datasets_new/DepthwiseConvolutionDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class MobileNetDepthwiseConvolutionDataset final : public DepthwiseConvolutionDataset -{ -public: - MobileNetDepthwiseConvolutionDataset() - { - add_config(TensorShape(7U, 7U, 1024U), TensorShape(3U, 3U, 1024U), TensorShape(3U, 3U, 1024U), PadStrideInfo(2, 2, 1, 1)); - add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U), TensorShape(7U, 7U, 512U), PadStrideInfo(2, 2, 1, 1)); - add_config(TensorShape(28U, 28U, 256U), TensorShape(3U, 3U, 256U), TensorShape(14U, 14U, 256U), PadStrideInfo(2, 2, 1, 1)); - add_config(TensorShape(28U, 28U, 256U), TensorShape(3U, 3U, 256U), TensorShape(28U, 28U, 256U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(56U, 56U, 128U), TensorShape(3U, 3U, 128U), TensorShape(28U, 28U, 128U), PadStrideInfo(2, 2, 1, 1)); - add_config(TensorShape(56U, 56U, 128U), TensorShape(3U, 3U, 128U), TensorShape(56U, 56U, 128U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(112U, 112U, 64U), TensorShape(3U, 3U, 64U), TensorShape(56U, 56U, 64U), PadStrideInfo(2, 2, 1, 1)); - add_config(TensorShape(112U, 112U, 32U), TensorShape(3U, 3U, 32U), TensorShape(112U, 112U, 32U), PadStrideInfo(1, 1, 1, 1)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_MOBILENET_DEPTHWISE_CONVOLUTION_DATASET */ diff --git a/tests/datasets_new/MobileNetDepthwiseSeparableConvolutionLayerDataset.h b/tests/datasets_new/MobileNetDepthwiseSeparableConvolutionLayerDataset.h deleted file mode 100644 index d0d3bb3351..0000000000 --- a/tests/datasets_new/MobileNetDepthwiseSeparableConvolutionLayerDataset.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_MOBILENET_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_DATASET -#define ARM_COMPUTE_TEST_MOBILENET_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_DATASET - -#include "tests/datasets_new/DepthwiseSeparableConvolutionLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class MobileNetDepthwiseSeparableConvolutionLayerDataset final : public DepthwiseSeparableConvolutionLayerDataset -{ -public: - MobileNetDepthwiseSeparableConvolutionLayerDataset() - { - add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U), TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 512U), TensorShape(512U), TensorShape(14U, 14U, 512U), PadStrideInfo(1, 1, 1, - 1, - DimensionRoundingType::FLOOR), - PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::FLOOR)); - add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U), TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 512U), TensorShape(512U), TensorShape(14U, 14U, 512U), PadStrideInfo(1, 1, 1, - 1, - DimensionRoundingType::FLOOR), - PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::FLOOR)); - add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U), TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 512U), TensorShape(512U), TensorShape(14U, 14U, 512U), PadStrideInfo(1, 1, 1, - 1, - DimensionRoundingType::FLOOR), - PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::FLOOR)); - add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U), TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 512U), TensorShape(512U), TensorShape(14U, 14U, 512U), PadStrideInfo(1, 1, 1, - 1, - DimensionRoundingType::FLOOR), - PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::FLOOR)); - add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U), TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 512U), TensorShape(512U), TensorShape(14U, 14U, 512U), PadStrideInfo(1, 1, 1, - 1, - DimensionRoundingType::FLOOR), - PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::FLOOR)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_MOBILENET_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets_new/NormalizationTypesDataset.h b/tests/datasets_new/NormalizationTypesDataset.h deleted file mode 100644 index 4e087e9eff..0000000000 --- a/tests/datasets_new/NormalizationTypesDataset.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_NORMALIZATION_TYPES_DATASET_H__ -#define __ARM_COMPUTE_TEST_NORMALIZATION_TYPES_DATASET_H__ - -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class NormalizationTypes final : public framework::dataset::ContainerDataset> -{ -public: - NormalizationTypes() - : ContainerDataset("NormType", - { - NormType::IN_MAP_1D, NormType::IN_MAP_2D, NormType::CROSS_MAP - }) - { - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_NORMALIZATION_TYPES_DATASET_H__ */ diff --git a/tests/datasets_new/PoolingLayerDataset.h b/tests/datasets_new/PoolingLayerDataset.h deleted file mode 100644 index 8b35ac6076..0000000000 --- a/tests/datasets_new/PoolingLayerDataset.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_POOLING_LAYER_DATASET -#define ARM_COMPUTE_TEST_POOLING_LAYER_DATASET - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class PoolingLayerDataset -{ -public: - using type = std::tuple; - - struct iterator - { - iterator(std::vector::const_iterator src_it, - std::vector::const_iterator dst_it, - std::vector::const_iterator infos_it) - : _src_it{ std::move(src_it) }, - _dst_it{ std::move(dst_it) }, - _infos_it{ std::move(infos_it) } - { - } - - std::string description() const - { - std::stringstream description; - description << "In=" << *_src_it << ":"; - description << "Out=" << *_dst_it << ":"; - description << "Info=" << *_infos_it; - return description.str(); - } - - PoolingLayerDataset::type operator*() const - { - return std::make_tuple(*_src_it, *_dst_it, *_infos_it); - } - - iterator &operator++() - { - ++_src_it; - ++_dst_it; - ++_infos_it; - - return *this; - } - - private: - std::vector::const_iterator _src_it; - std::vector::const_iterator _dst_it; - std::vector::const_iterator _infos_it; - }; - - iterator begin() const - { - return iterator(_src_shapes.begin(), _dst_shapes.begin(), _infos.begin()); - } - - int size() const - { - return std::min(_src_shapes.size(), std::min(_dst_shapes.size(), _infos.size())); - } - - void add_config(TensorShape src, TensorShape dst, PoolingLayerInfo info) - { - _src_shapes.emplace_back(std::move(src)); - _dst_shapes.emplace_back(std::move(dst)); - _infos.emplace_back(std::move(info)); - } - -protected: - PoolingLayerDataset() = default; - PoolingLayerDataset(PoolingLayerDataset &&) = default; - -private: - std::vector _src_shapes{}; - std::vector _dst_shapes{}; - std::vector _infos{}; -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_POOLING_LAYER_DATASET */ diff --git a/tests/datasets_new/PoolingTypesDataset.h b/tests/datasets_new/PoolingTypesDataset.h deleted file mode 100644 index 4e4fa26ca4..0000000000 --- a/tests/datasets_new/PoolingTypesDataset.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_POOLING_TYPES_DATASET_H__ -#define __ARM_COMPUTE_TEST_POOLING_TYPES_DATASET_H__ - -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class PoolingTypes final : public framework::dataset::ContainerDataset> -{ -public: - PoolingTypes() - : ContainerDataset("PoolType", - { - PoolingType::MAX, PoolingType::AVG - }) - { - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_NORMALIZATION_TYPES_DATASET_H__ */ diff --git a/tests/datasets_new/ROIPoolingLayerDataset.h b/tests/datasets_new/ROIPoolingLayerDataset.h deleted file mode 100644 index 65d589eb97..0000000000 --- a/tests/datasets_new/ROIPoolingLayerDataset.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_ROI_POOLING_LAYER_DATASET -#define ARM_COMPUTE_TEST_ROI_POOLING_LAYER_DATASET - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class ROIPoolingLayerDataset -{ -public: - using type = std::tuple; - - struct iterator - { - iterator(std::vector::const_iterator tensor_shape_it, - std::vector::const_iterator infos_it, - std::vector::const_iterator num_rois_it) - : _tensor_shape_it{ std::move(tensor_shape_it) }, - _infos_it{ std::move(infos_it) }, - _num_rois_it{ std::move(num_rois_it) } - { - } - - std::string description() const - { - std::stringstream description; - description << "In=" << *_tensor_shape_it << ":"; - description << "Info=" << *_infos_it << ":"; - description << "NumROIS=" << *_num_rois_it; - return description.str(); - } - - ROIPoolingLayerDataset::type operator*() const - { - return std::make_tuple(*_tensor_shape_it, *_infos_it, *_num_rois_it); - } - - iterator &operator++() - { - ++_tensor_shape_it; - ++_infos_it; - ++_num_rois_it; - - return *this; - } - - private: - std::vector::const_iterator _tensor_shape_it; - std::vector::const_iterator _infos_it; - std::vector::const_iterator _num_rois_it; - }; - - iterator begin() const - { - return iterator(_tensor_shapes.begin(), _infos.begin(), _num_rois.begin()); - } - - int size() const - { - return std::min(std::min(_tensor_shapes.size(), _infos.size()), _num_rois.size()); - } - - void add_config(TensorShape tensor_shape, ROIPoolingLayerInfo info, unsigned int num_rois) - { - _tensor_shapes.emplace_back(std::move(tensor_shape)); - _infos.emplace_back(std::move(info)); - _num_rois.emplace_back(std::move(num_rois)); - } - -protected: - ROIPoolingLayerDataset() = default; - ROIPoolingLayerDataset(ROIPoolingLayerDataset &&) = default; - -private: - std::vector _tensor_shapes{}; - std::vector _infos{}; - std::vector _num_rois{}; -}; - -class SmallROIPoolingLayerDataset final : public ROIPoolingLayerDataset -{ -public: - SmallROIPoolingLayerDataset() - { - add_config(TensorShape(50U, 47U, 3U), ROIPoolingLayerInfo(7U, 7U, 1.f / 8.f), 40U); - add_config(TensorShape(50U, 47U, 10U), ROIPoolingLayerInfo(7U, 7U, 1.f / 8.f), 80U); - add_config(TensorShape(50U, 47U, 80U), ROIPoolingLayerInfo(7U, 7U, 1.f / 8.f), 80U); - add_config(TensorShape(50U, 47U, 3U), ROIPoolingLayerInfo(9U, 9U, 1.f / 8.f), 40U); - add_config(TensorShape(50U, 47U, 10U), ROIPoolingLayerInfo(9U, 9U, 1.f / 8.f), 80U); - add_config(TensorShape(50U, 47U, 80U), ROIPoolingLayerInfo(9U, 9U, 1.f / 8.f), 80U); - } -}; - -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ROI_POOLING_LAYER_DATASET */ diff --git a/tests/datasets_new/ReductionOperationDataset.h b/tests/datasets_new/ReductionOperationDataset.h deleted file mode 100644 index e46b8b1118..0000000000 --- a/tests/datasets_new/ReductionOperationDataset.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_REDUCTION_OPERATION_DATASET_H__ -#define __ARM_COMPUTE_TEST_REDUCTION_OPERATION_DATASET_H__ - -#include "arm_compute/core/Types.h" -#include "tests/TypePrinter.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class ReductionOperations final : public framework::dataset::ContainerDataset> -{ -public: - ReductionOperations() - : ContainerDataset("ReductionOperation", - { - ReductionOperation::SUM_SQUARE - }) - { - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_REDUCTION_OPERATION_DATASET_H__ */ diff --git a/tests/datasets_new/ShapeDatasets.h b/tests/datasets_new/ShapeDatasets.h deleted file mode 100644 index 477d8758cb..0000000000 --- a/tests/datasets_new/ShapeDatasets.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ -#define __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ - -#include "arm_compute/core/TensorShape.h" -#include "framework/datasets/Datasets.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -/** Data set containing 1D tensor shapes. */ -class Small1DShape final : public framework::dataset::SingletonDataset -{ -public: - Small1DShape() - : SingletonDataset("Shape", TensorShape{ 256U }) - { - } -}; - -/** Parent type for all for shape datasets. */ -using ShapeDataset = framework::dataset::ContainerDataset>; - -/** Data set containing small 2D tensor shapes. */ -class Small2DShapes final : public ShapeDataset -{ -public: - Small2DShapes() - : ShapeDataset("Shape", - { - TensorShape{ 7U, 7U }, - TensorShape{ 27U, 13U }, - TensorShape{ 128U, 64U } - }) - { - } -}; - -/** Data set containing small tensor shapes. */ -class SmallShapes final : public ShapeDataset -{ -public: - SmallShapes() - : ShapeDataset("Shape", - { - // Batch size 1 - TensorShape{ 7U, 7U }, - TensorShape{ 27U, 13U, 2U }, - TensorShape{ 128U, 64U, 1U, 3U }, - // Batch size 4 - TensorShape{ 7U, 7U, 3U, 4U }, - TensorShape{ 27U, 13U, 2U, 4U }, - // Arbitrary batch size - TensorShape{ 7U, 7U, 3U, 5U } - }) - { - } -}; - -/** Data set containing large tensor shapes. */ -class LargeShapes final : public ShapeDataset -{ -public: - LargeShapes() - : ShapeDataset("Shape", - { - // Batch size 1 - TensorShape{ 1920U, 1080U }, - TensorShape{ 640U, 480U, 2U, 3U }, - TensorShape{ 4160U, 3120U }, - // Batch size 4 - TensorShape{ 800U, 600U, 1U, 4U }, - }) - { - } -}; - -/** Data set containing large 2D tensor shapes. */ -class Large2DShapes final : public ShapeDataset -{ -public: - Large2DShapes() - : ShapeDataset("Shape", - { - TensorShape{ 1920U, 1080U }, - TensorShape{ 1245U, 652U }, - TensorShape{ 4160U, 3120U } - }) - { - } -}; - -/** Data set containing small tensor shapes for direct convolution. */ -class SmallDirectConvolutionShapes final : public ShapeDataset -{ -public: - SmallDirectConvolutionShapes() - : ShapeDataset("InputShape", - { - // Batch size 1 - TensorShape{ 5U, 5U, 3U }, - TensorShape{ 32U, 37U, 3U }, - TensorShape{ 13U, 15U, 8U }, - // Batch size 4 - TensorShape{ 5U, 5U, 3U, 4U }, - TensorShape{ 32U, 37U, 3U, 4U }, - TensorShape{ 13U, 15U, 8U, 4U }, - // Batch size 8 - TensorShape{ 5U, 5U, 3U, 8U }, - TensorShape{ 32U, 37U, 3U, 8U }, - TensorShape{ 13U, 15U, 8U, 8U }, - // Arbitrary batch size - TensorShape{ 32U, 37U, 3U, 8U } - }) - { - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ */ diff --git a/tests/datasets_new/SmallConvolutionLayerDataset.h b/tests/datasets_new/SmallConvolutionLayerDataset.h deleted file mode 100644 index 59765c4a51..0000000000 --- a/tests/datasets_new/SmallConvolutionLayerDataset.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_SMALL_CONVOLUTION_LAYER_DATASET -#define ARM_COMPUTE_TEST_SMALL_CONVOLUTION_LAYER_DATASET - -#include "tests/datasets_new/ConvolutionLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class SmallConvolutionLayerDataset final : public ConvolutionLayerDataset -{ -public: - SmallConvolutionLayerDataset() - { - // Batch size 1 - add_config(TensorShape(23U, 27U, 5U), TensorShape(3U, 3U, 5U, 21U), TensorShape(21U), TensorShape(11U, 25U, 21U), PadStrideInfo(2, 1, 0, 0)); - add_config(TensorShape(33U, 27U, 7U), TensorShape(5U, 5U, 7U, 16U), TensorShape(16U), TensorShape(11U, 12U, 16U), PadStrideInfo(3, 2, 1, 0)); - add_config(TensorShape(17U, 31U, 2U), TensorShape(5U, 5U, 2U, 19U), TensorShape(19U), TensorShape(15U, 15U, 19U), PadStrideInfo(1, 2, 1, 1)); - add_config(TensorShape(23U, 27U, 5U), TensorShape(3U, 1U, 5U, 21U), TensorShape(21U), TensorShape(11U, 27U, 21U), PadStrideInfo(2, 1, 0, 0)); - add_config(TensorShape(33U, 27U, 7U), TensorShape(5U, 7U, 7U, 16U), TensorShape(16U), TensorShape(11U, 11U, 16U), PadStrideInfo(3, 2, 1, 0)); - add_config(TensorShape(17U, 31U, 2U), TensorShape(5U, 3U, 2U, 19U), TensorShape(19U), TensorShape(15U, 16U, 19U), PadStrideInfo(1, 2, 1, 1)); - // Batch size 4 - add_config(TensorShape(23U, 27U, 5U, 4U), TensorShape(3U, 3U, 5U, 21U), TensorShape(21U), TensorShape(11U, 25U, 21U, 4U), PadStrideInfo(2, 1, 0, 0)); - add_config(TensorShape(33U, 27U, 7U, 4U), TensorShape(5U, 5U, 7U, 16U), TensorShape(16U), TensorShape(11U, 12U, 16U, 4U), PadStrideInfo(3, 2, 1, 0)); - add_config(TensorShape(17U, 31U, 2U, 4U), TensorShape(5U, 5U, 2U, 19U), TensorShape(19U), TensorShape(15U, 15U, 19U, 4U), PadStrideInfo(1, 2, 1, 1)); - add_config(TensorShape(23U, 27U, 5U, 4U), TensorShape(3U, 1U, 5U, 21U), TensorShape(21U), TensorShape(11U, 27U, 21U, 4U), PadStrideInfo(2, 1, 0, 0)); - add_config(TensorShape(33U, 27U, 7U, 4U), TensorShape(5U, 7U, 7U, 16U), TensorShape(16U), TensorShape(11U, 11U, 16U, 4U), PadStrideInfo(3, 2, 1, 0)); - add_config(TensorShape(17U, 31U, 2U, 4U), TensorShape(5U, 3U, 2U, 19U), TensorShape(19U), TensorShape(15U, 16U, 19U, 4U), PadStrideInfo(1, 2, 1, 1)); - // Arbitrary batch size - add_config(TensorShape(33U, 27U, 7U, 5U), TensorShape(5U, 7U, 7U, 16U), TensorShape(16U), TensorShape(11U, 11U, 16U, 5U), PadStrideInfo(3, 2, 1, 0)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_SMALL_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets_new/SmallDepthwiseConvolutionDataset.h b/tests/datasets_new/SmallDepthwiseConvolutionDataset.h deleted file mode 100644 index 364673a256..0000000000 --- a/tests/datasets_new/SmallDepthwiseConvolutionDataset.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_SMALL_DEPTHWISE_CONVOLUTION_DATASET -#define ARM_COMPUTE_TEST_SMALL_DEPTHWISE_CONVOLUTION_DATASET - -#include "tests/datasets_new/DepthwiseConvolutionDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class SmallDepthwiseConvolutionDataset final : public DepthwiseConvolutionDataset -{ -public: - SmallDepthwiseConvolutionDataset() - { - add_config(TensorShape(23U, 27U, 5U), TensorShape(3U, 3U, 5U), TensorShape(11U, 25U, 5U), PadStrideInfo(2, 1, 0, 0)); - add_config(TensorShape(33U, 27U, 7U), TensorShape(3U, 3U, 7U), TensorShape(11U, 13U, 7U), PadStrideInfo(3, 2, 1, 0)); - add_config(TensorShape(17U, 31U, 2U), TensorShape(3U, 3U, 2U), TensorShape(17U, 16U, 2U), PadStrideInfo(1, 2, 1, 1)); - add_config(TensorShape(23U, 27U, 5U), TensorShape(3U, 3U, 5U), TensorShape(21U, 13U, 5U), PadStrideInfo(1, 2, 0, 0)); - add_config(TensorShape(33U, 27U, 7U), TensorShape(3U, 3U, 7U), TensorShape(16U, 9U, 7U), PadStrideInfo(2, 3, 0, 1)); - add_config(TensorShape(17U, 31U, 2U), TensorShape(3U, 3U, 2U), TensorShape(9U, 31U, 2U), PadStrideInfo(2, 1, 1, 1)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_SMALL_DEPTHWISE_CONVOLUTION_DATASET */ diff --git a/tests/datasets_new/SmallGEMMDataset.h b/tests/datasets_new/SmallGEMMDataset.h deleted file mode 100644 index 7856ff9127..0000000000 --- a/tests/datasets_new/SmallGEMMDataset.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_SMALL_GEMM_DATASET -#define ARM_COMPUTE_TEST_SMALL_GEMM_DATASET - -#include "tests/datasets_new/GEMMDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class SmallGEMMDataset final : public GEMMDataset -{ -public: - SmallGEMMDataset() - { - add_config(TensorShape(21U, 13U), TensorShape(33U, 21U), TensorShape(33U, 13U), TensorShape(33U, 13U), 1.0f, 0.0f); - add_config(TensorShape(31U, 1U), TensorShape(23U, 31U), TensorShape(23U, 1U), TensorShape(23U, 1U), 1.0f, 0.0f); - add_config(TensorShape(38U, 12U), TensorShape(21U, 38U), TensorShape(21U, 12U), TensorShape(21U, 12U), 0.2f, 1.2f); - add_config(TensorShape(32U, 1U), TensorShape(17U, 32U), TensorShape(17U, 1U), TensorShape(17U, 1U), 0.4f, 0.7f); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_SMALL_GEMM_DATASET */ diff --git a/tests/datasets_new/system_tests/alexnet/AlexNetActivationLayerDataset.h b/tests/datasets_new/system_tests/alexnet/AlexNetActivationLayerDataset.h deleted file mode 100644 index 7062c2e6b8..0000000000 --- a/tests/datasets_new/system_tests/alexnet/AlexNetActivationLayerDataset.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_ALEXNET_ACTIVATION_LAYER_DATASET -#define ARM_COMPUTE_TEST_ALEXNET_ACTIVATION_LAYER_DATASET - -#include "framework/datasets/Datasets.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class AlexNetActivationLayerDataset final : public - framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> -{ -public: - AlexNetActivationLayerDataset() - : CartesianProductDataset - { - framework::dataset::make("Shape", { TensorShape(55U, 55U, 96U), TensorShape(27U, 27U, 256U), TensorShape(13U, 13U, 384U), TensorShape(13U, 13U, 256U), TensorShape(4096U) }), - framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) - } - { - } - AlexNetActivationLayerDataset(AlexNetActivationLayerDataset &&) = default; - ~AlexNetActivationLayerDataset() = default; -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ALEXNET_ACTIVATION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/alexnet/AlexNetConvolutionLayerDataset.h b/tests/datasets_new/system_tests/alexnet/AlexNetConvolutionLayerDataset.h deleted file mode 100644 index 18421cffe6..0000000000 --- a/tests/datasets_new/system_tests/alexnet/AlexNetConvolutionLayerDataset.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_ALEXNET_CONVOLUTION_LAYER_DATASET -#define ARM_COMPUTE_TEST_ALEXNET_CONVOLUTION_LAYER_DATASET - -#include "tests/datasets_new/ConvolutionLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class AlexNetConvolutionLayerDataset final : public ConvolutionLayerDataset -{ -public: - AlexNetConvolutionLayerDataset() - { - add_config(TensorShape(227U, 227U, 3U), TensorShape(11U, 11U, 3U, 96U), TensorShape(96U), TensorShape(55U, 55U, 96U), PadStrideInfo(4, 4, 0, 0)); - add_config(TensorShape(27U, 27U, 96U), TensorShape(5U, 5U, 96U, 256U), TensorShape(256U), TensorShape(27U, 27U, 256U), PadStrideInfo(1, 1, 2, 2)); - add_config(TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U), PadStrideInfo(1, 1, 1, 1)); - } -}; - -class AlexNetDirectConvolutionLayerDataset final : public ConvolutionLayerDataset -{ -public: - AlexNetDirectConvolutionLayerDataset() - { - add_config(TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1)); - add_config(TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U), PadStrideInfo(1, 1, 1, 1)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ALEXNET_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/alexnet/AlexNetFullyConnectedLayerDataset.h b/tests/datasets_new/system_tests/alexnet/AlexNetFullyConnectedLayerDataset.h deleted file mode 100644 index 4aa4f4d861..0000000000 --- a/tests/datasets_new/system_tests/alexnet/AlexNetFullyConnectedLayerDataset.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_ALEXNET_FULLYCONNECTED_LAYER_DATASET -#define ARM_COMPUTE_TEST_ALEXNET_FULLYCONNECTED_LAYER_DATASET - -#include "tests/datasets_new/FullyConnectedLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class AlexNetFullyConnectedLayerDataset final : public FullyConnectedLayerDataset -{ -public: - AlexNetFullyConnectedLayerDataset() - { - add_config(TensorShape(6U, 6U, 256U), TensorShape(9216U, 4096U), TensorShape(4096U), TensorShape(4096U)); - add_config(TensorShape(4096U), TensorShape(4096U, 4096U), TensorShape(4096U), TensorShape(4096U)); - add_config(TensorShape(4096U), TensorShape(4096U, 1000U), TensorShape(1000U), TensorShape(1000U)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ALEXNET_FULLYCONNECTED_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/alexnet/AlexNetNormalizationLayerDataset.h b/tests/datasets_new/system_tests/alexnet/AlexNetNormalizationLayerDataset.h deleted file mode 100644 index 5714c5cf27..0000000000 --- a/tests/datasets_new/system_tests/alexnet/AlexNetNormalizationLayerDataset.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_ALEXNET_NORMALIZATION_LAYER_DATASET -#define ARM_COMPUTE_TEST_ALEXNET_NORMALIZATION_LAYER_DATASET - -#include "framework/datasets/Datasets.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class AlexNetNormalizationLayerDataset final : public - framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> -{ -public: - AlexNetNormalizationLayerDataset() - : CartesianProductDataset - { - framework::dataset::make("Shape", { TensorShape(55U, 55U, 96U), TensorShape(27U, 27U, 256U) }), - framework::dataset::make("Info", NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)) - } - { - } - AlexNetNormalizationLayerDataset(AlexNetNormalizationLayerDataset &&) = default; - ~AlexNetNormalizationLayerDataset() = default; -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ALEXNET_NORMALIZATION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/alexnet/AlexNetPoolingLayerDataset.h b/tests/datasets_new/system_tests/alexnet/AlexNetPoolingLayerDataset.h deleted file mode 100644 index 714bca0777..0000000000 --- a/tests/datasets_new/system_tests/alexnet/AlexNetPoolingLayerDataset.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_ALEXNET_POOLING_LAYER_DATASET -#define ARM_COMPUTE_TEST_ALEXNET_POOLING_LAYER_DATASET - -#include "tests/datasets_new/PoolingLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class AlexNetPoolingLayerDataset final : public PoolingLayerDataset -{ -public: - AlexNetPoolingLayerDataset() - { - add_config(TensorShape(55U, 55U, 96U), TensorShape(27U, 27U, 96U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); - add_config(TensorShape(27U, 27U, 256U), TensorShape(13U, 13U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); - add_config(TensorShape(13U, 13U, 256U), TensorShape(6U, 6U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ALEXNET_POOLING_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ActivationLayerDataset.h b/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ActivationLayerDataset.h deleted file mode 100644 index 9f3c38fe66..0000000000 --- a/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ActivationLayerDataset.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_ACTIVATION_LAYER_DATASET -#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_ACTIVATION_LAYER_DATASET - -#include "framework/datasets/Datasets.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class GoogLeNetInceptionV1ActivationLayerDataset final : public - framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> -{ -public: - GoogLeNetInceptionV1ActivationLayerDataset() - : CartesianProductDataset - { - framework::dataset::make("Shape", { // conv1/relu_7x7 - TensorShape(112U, 112U, 64U), - // conv2/relu_3x3_reduce - TensorShape(56U, 56U, 64U), - // conv2/relu_3x3 - TensorShape(56U, 56U, 192U), - // inception_3a/relu_1x1, inception_3b/relu_pool_proj - TensorShape(28U, 28U, 64U), - // inception_3a/relu_3x3_reduce, inception_3b/relu_5x5 - TensorShape(28U, 28U, 96U), - // inception_3a/relu_3x3, inception_3b/relu_1x1, inception_3b/relu_3x3_reduce - TensorShape(28U, 28U, 128U), - // inception_3a/relu_5x5_reduce - TensorShape(28U, 28U, 16U), - // inception_3a/relu_5x5, inception_3a/relu_pool_proj, inception_3b/relu_5x5_reduce - TensorShape(28U, 28U, 32U), - // inception_3b/relu_3x3 - TensorShape(28U, 28U, 192U), - // inception_4a/relu_1x1 - TensorShape(14U, 14U, 192U), - // inception_4a/relu_3x3_reduce - TensorShape(14U, 14U, 96U), - // inception_4a/relu_3x3 - TensorShape(14U, 14U, 208U), - // inception_4a/relu_5x5_reduce - TensorShape(14U, 14U, 16U), - // inception_4a/relu_5x5 - TensorShape(14U, 14U, 48U), - // inception_4a/relu_pool_proj, inception_4b/relu_5x5, inception_4b/relu_pool_proj, inception_4c/relu_5x5, inception_4c/relu_pool_proj, inception_4d/relu_5x5, inception_4d/relu_pool_proj - TensorShape(14U, 14U, 64U), - // inception_4b/relu_1x1, inception_4e/relu_3x3_reduce - TensorShape(14U, 14U, 160U), - // inception_4b/relu_3x3_reduce, inception_4d/relu_1x1 - TensorShape(14U, 14U, 112U), - // inception_4b/relu_3x3 - TensorShape(14U, 14U, 224U), - // inception_4b/relu_5x5_reduce, inception_4c/relu_5x5_reduce - TensorShape(14U, 14U, 24U), - // inception_4c/relu_1x1, inception_4c/relu_3x3_reduce, inception_4e/relu_5x5, inception_4e/relu_pool_proj - TensorShape(14U, 14U, 128U), - // inception_4c/relu_3x3, inception_4e/relu_1x1 - TensorShape(14U, 14U, 256U), - // inception_4d/relu_3x3_reduce - TensorShape(14U, 14U, 144U), - // inception_4d/relu_3x3 - TensorShape(14U, 14U, 288U), - // inception_4d/relu_5x5_reduce, inception_4e/relu_5x5_reduce - TensorShape(14U, 14U, 32U), - // inception_4e/relu_3x3 - TensorShape(14U, 14U, 320U), - // inception_5a/relu_1x1 - TensorShape(7U, 7U, 256U), - // inception_5a/relu_3x3_reduce - TensorShape(7U, 7U, 160U), - // inception_5a/relu_3x3 - TensorShape(7U, 7U, 320U), - // inception_5a/relu_5x5_reduce - TensorShape(7U, 7U, 32U), - // inception_5a/relu_5x5, inception_5a/relu_pool_proj, inception_5b/relu_5x5, inception_5b/relu_pool_proj - TensorShape(7U, 7U, 128U), - // inception_5b/relu_1x1, inception_5b/relu_3x3 - TensorShape(7U, 7U, 384U), - // inception_5b/relu_3x3_reduce - TensorShape(7U, 7U, 192U), - // inception_5b/relu_5x5_reduce - TensorShape(7U, 7U, 48U) }), - framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) - } - { - } - GoogLeNetInceptionV1ActivationLayerDataset(GoogLeNetInceptionV1ActivationLayerDataset &&) = default; - ~GoogLeNetInceptionV1ActivationLayerDataset() = default; -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_ACTIVATION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ConvolutionLayerDataset.h b/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ConvolutionLayerDataset.h deleted file mode 100644 index dfa59ab084..0000000000 --- a/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1ConvolutionLayerDataset.h +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_CONVOLUTION_LAYER_DATASET -#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_CONVOLUTION_LAYER_DATASET - -#include "tests/datasets_new/ConvolutionLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class GoogLeNetInceptionV1ConvolutionLayerDataset final : public ConvolutionLayerDataset -{ -public: - // GoogLeNetInceptionV1 inception v1 dataset - GoogLeNetInceptionV1ConvolutionLayerDataset() - { - // conv1/7x7_s2 - add_config(TensorShape(224U, 224U, 3U), TensorShape(7U, 7U, 3U, 64U), TensorShape(64U), TensorShape(112U, 112U, 64U), PadStrideInfo(2, 2, 3, 3)); - // conv2/3x3_reduce - add_config(TensorShape(56U, 56U, 64U), TensorShape(1U, 1U, 64U, 64U), TensorShape(64U), TensorShape(56U, 56U, 64U), PadStrideInfo(1, 1, 0, 0)); - // conv2/3x3 - add_config(TensorShape(56U, 56U, 64U), TensorShape(3U, 3U, 64U, 192U), TensorShape(192U), TensorShape(56U, 56U, 192U), PadStrideInfo(1, 1, 1, 1)); - // inception_3a/1x1 - add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0)); - // inception_3a/3x3_reduce - add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 96U), TensorShape(96U), TensorShape(28U, 28U, 96U), PadStrideInfo(1, 1, 0, 0)); - // inception_3a/3x3 - add_config(TensorShape(28U, 28U, 96U), TensorShape(3U, 3U, 96U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 1, 1)); - // inception_3a/5x5_reduce - add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 16U), TensorShape(16U), TensorShape(28U, 28U, 16U), PadStrideInfo(1, 1, 0, 0)); - // inception_3a/5x5 - add_config(TensorShape(28U, 28U, 16U), TensorShape(5U, 5U, 16U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 2, 2)); - // inception_3a/pool_proj - add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0)); - // inception_3b/1x1, inception_3b/3x3_reduce - add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 0, 0)); - // inception_3b/3x3 - add_config(TensorShape(28U, 28U, 128U), TensorShape(3U, 3U, 128U, 192U), TensorShape(192U), TensorShape(28U, 28U, 192U), PadStrideInfo(1, 1, 1, 1)); - // inception_3b/5x5_reduce - add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0)); - // inception_3b/5x5 - add_config(TensorShape(28U, 28U, 32U), TensorShape(5U, 5U, 32U, 96U), TensorShape(96U), TensorShape(28U, 28U, 96U), PadStrideInfo(1, 1, 2, 2)); - // inception_3b/pool_proj - add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0)); - // inception_4a/1x1 - add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 192U), TensorShape(192U), TensorShape(14U, 14U, 192U), PadStrideInfo(1, 1, 0, 0)); - // inception_4a/3x3_reduce - add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 96U), TensorShape(96U), TensorShape(14U, 14U, 96U), PadStrideInfo(1, 1, 0, 0)); - // inception_4a/3x3 - add_config(TensorShape(14U, 14U, 96U), TensorShape(3U, 3U, 96U, 208U), TensorShape(208U), TensorShape(14U, 14U, 208U), PadStrideInfo(1, 1, 1, 1)); - // inception_4a/5x5_reduce - add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 16U), TensorShape(16U), TensorShape(14U, 14U, 16U), PadStrideInfo(1, 1, 0, 0)); - // inception_4a/5x5 - add_config(TensorShape(14U, 14U, 16U), TensorShape(5U, 5U, 16U, 48U), TensorShape(48U), TensorShape(14U, 14U, 48U), PadStrideInfo(1, 1, 2, 2)); - // inception_4a/pool_proj - add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0)); - // inception_4b/1x1 - add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0)); - // inception_4b/3x3_reduce, inception_4d/1x1 - add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 112U), TensorShape(112U), TensorShape(14U, 14U, 112U), PadStrideInfo(1, 1, 0, 0)); - // inception_4b/3x3 - add_config(TensorShape(14U, 14U, 112U), TensorShape(3U, 3U, 112U, 224U), TensorShape(224U), TensorShape(14U, 14U, 224U), PadStrideInfo(1, 1, 1, 1)); - // inception_4b/5x5_reduce, inception_4c/5x5_reduce - add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 24U), TensorShape(24U), TensorShape(14U, 14U, 24U), PadStrideInfo(1, 1, 0, 0)); - // inception_4b/5x5, inception_4c/5x5 - add_config(TensorShape(14U, 14U, 24U), TensorShape(5U, 5U, 24U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 2, 2)); - // inception_4b/pool_proj, inception_4c/pool_proj, inception_4d/pool_proj - add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0)); - // inception_4c/1x1, inception_4c/3x3_reduce - add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0)); - // inception_4c/3x3 - add_config(TensorShape(14U, 14U, 128U), TensorShape(3U, 3U, 128U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 1, 1)); - // inception_4d/3x3_reduce - add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 144U), TensorShape(144U), TensorShape(14U, 14U, 144U), PadStrideInfo(1, 1, 0, 0)); - // inception_4d/3x3 - add_config(TensorShape(14U, 14U, 144U), TensorShape(3U, 3U, 144U, 288U), TensorShape(288U), TensorShape(14U, 14U, 288U), PadStrideInfo(1, 1, 1, 1)); - // inception_4d/5x5_reduce - add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0)); - // inception_4d/5x5 - add_config(TensorShape(14U, 14U, 32U), TensorShape(5U, 5U, 32U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 2, 2)); - // inception_4e/1x1 - add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 0, 0)); - // inception_4e/3x3_reduce - add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0)); - // inception_4e/3x3 - add_config(TensorShape(14U, 14U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(14U, 14U, 320U), PadStrideInfo(1, 1, 1, 1)); - // inception_4e/5x5_reduce - add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0)); - // inception_4e/5x5 - add_config(TensorShape(14U, 14U, 32U), TensorShape(5U, 5U, 32U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 2, 2)); - // inception_4e/pool_proj - add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0)); - // inception_5a/1x1 - add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 256U), TensorShape(256U), TensorShape(7U, 7U, 256U), PadStrideInfo(1, 1, 0, 0)); - // inception_5a/3x3_reduce - add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 160U), TensorShape(160U), TensorShape(7U, 7U, 160U), PadStrideInfo(1, 1, 0, 0)); - // inception_5a/3x3 - add_config(TensorShape(7U, 7U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(7U, 7U, 320U), PadStrideInfo(1, 1, 1, 1)); - // inception_5a/5x5_reduce - add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 32U), TensorShape(32U), TensorShape(7U, 7U, 32U), PadStrideInfo(1, 1, 0, 0)); - // inception_5a/5x5 - add_config(TensorShape(7U, 7U, 32U), TensorShape(5U, 5U, 32U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 2, 2)); - // inception_5a/pool_proj, inception_5b/pool_proj - add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 0, 0)); - // inception_5b/1x1 - add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 0, 0)); - // inception_5b/3x3_reduce - add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 192U), TensorShape(192U), TensorShape(7U, 7U, 192U), PadStrideInfo(1, 1, 0, 0)); - // inception_5b/3x3 - add_config(TensorShape(7U, 7U, 192U), TensorShape(3U, 3U, 192U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 1, 1)); - // inception_5b/5x5_reduce - add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 48U), TensorShape(48U), TensorShape(7U, 7U, 48U), PadStrideInfo(1, 1, 0, 0)); - // inception_5b/5x5 - add_config(TensorShape(7U, 7U, 48U), TensorShape(5U, 5U, 48U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 2, 2)); - } -}; - -class GoogLeNetInceptionV1DirectConvolutionLayerDataset final : public ConvolutionLayerDataset -{ -public: - // subset of GoogLeNetInceptionV1 inception v1 dataset - GoogLeNetInceptionV1DirectConvolutionLayerDataset() - { - // conv2/3x3_reduce - add_config(TensorShape(56U, 56U, 64U), TensorShape(1U, 1U, 64U, 64U), TensorShape(64U), TensorShape(56U, 56U, 64U), PadStrideInfo(1, 1, 0, 0)); - // conv2/3x3 - add_config(TensorShape(56U, 56U, 64U), TensorShape(3U, 3U, 64U, 192U), TensorShape(192U), TensorShape(56U, 56U, 192U), PadStrideInfo(1, 1, 1, 1)); - // inception_3a/1x1 - add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0)); - // inception_3a/3x3_reduce - add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 96U), TensorShape(96U), TensorShape(28U, 28U, 96U), PadStrideInfo(1, 1, 0, 0)); - // inception_3a/3x3 - add_config(TensorShape(28U, 28U, 96U), TensorShape(3U, 3U, 96U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 1, 1)); - // inception_3a/5x5_reduce - add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 16U), TensorShape(16U), TensorShape(28U, 28U, 16U), PadStrideInfo(1, 1, 0, 0)); - // inception_3a/pool_proj - add_config(TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0)); - // inception_3b/1x1, inception_3b/3x3_reduce - add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 0, 0)); - // inception_3b/3x3 - add_config(TensorShape(28U, 28U, 128U), TensorShape(3U, 3U, 128U, 192U), TensorShape(192U), TensorShape(28U, 28U, 192U), PadStrideInfo(1, 1, 1, 1)); - // inception_3b/5x5_reduce - add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0)); - // inception_3b/pool_proj - add_config(TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0)); - // inception_4a/1x1 - add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 192U), TensorShape(192U), TensorShape(14U, 14U, 192U), PadStrideInfo(1, 1, 0, 0)); - // inception_4a/3x3_reduce - add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 96U), TensorShape(96U), TensorShape(14U, 14U, 96U), PadStrideInfo(1, 1, 0, 0)); - // inception_4a/3x3 - add_config(TensorShape(14U, 14U, 96U), TensorShape(3U, 3U, 96U, 208U), TensorShape(208U), TensorShape(14U, 14U, 208U), PadStrideInfo(1, 1, 1, 1)); - // inception_4a/pool_proj - add_config(TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0)); - // inception_4b/1x1 - add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0)); - // inception_4b/3x3_reduce, inception_4d/1x1 - add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 112U), TensorShape(112U), TensorShape(14U, 14U, 112U), PadStrideInfo(1, 1, 0, 0)); - // inception_4b/3x3 - add_config(TensorShape(14U, 14U, 112U), TensorShape(3U, 3U, 112U, 224U), TensorShape(224U), TensorShape(14U, 14U, 224U), PadStrideInfo(1, 1, 1, 1)); - // inception_4b/5x5_reduce, inception_4c/5x5_reduce - add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 24U), TensorShape(24U), TensorShape(14U, 14U, 24U), PadStrideInfo(1, 1, 0, 0)); - // inception_4b/pool_proj, inception_4c/pool_proj, inception_4d/pool_proj - add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0)); - // inception_4c/1x1, inception_4c/3x3_reduce - add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0)); - // inception_4c/3x3 - add_config(TensorShape(14U, 14U, 128U), TensorShape(3U, 3U, 128U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 1, 1)); - // inception_4d/3x3_reduce - add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 144U), TensorShape(144U), TensorShape(14U, 14U, 144U), PadStrideInfo(1, 1, 0, 0)); - // inception_4d/3x3 - add_config(TensorShape(14U, 14U, 144U), TensorShape(3U, 3U, 144U, 288U), TensorShape(288U), TensorShape(14U, 14U, 288U), PadStrideInfo(1, 1, 1, 1)); - // inception_4d/5x5_reduce - add_config(TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0)); - // inception_4e/1x1 - add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 0, 0)); - // inception_4e/3x3_reduce - add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0)); - // inception_4e/3x3 - add_config(TensorShape(14U, 14U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(14U, 14U, 320U), PadStrideInfo(1, 1, 1, 1)); - // inception_4e/5x5_reduce - add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0)); - // inception_4e/pool_proj - add_config(TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0)); - // inception_5a/1x1 - add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 256U), TensorShape(256U), TensorShape(7U, 7U, 256U), PadStrideInfo(1, 1, 0, 0)); - // inception_5a/3x3_reduce - add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 160U), TensorShape(160U), TensorShape(7U, 7U, 160U), PadStrideInfo(1, 1, 0, 0)); - // inception_5a/3x3 - add_config(TensorShape(7U, 7U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(7U, 7U, 320U), PadStrideInfo(1, 1, 1, 1)); - // inception_5a/5x5_reduce - add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 32U), TensorShape(32U), TensorShape(7U, 7U, 32U), PadStrideInfo(1, 1, 0, 0)); - // inception_5a/pool_proj, inception_5b/pool_proj - add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 0, 0)); - // inception_5b/1x1 - add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 0, 0)); - // inception_5b/3x3_reduce - add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 192U), TensorShape(192U), TensorShape(7U, 7U, 192U), PadStrideInfo(1, 1, 0, 0)); - // inception_5b/3x3 - add_config(TensorShape(7U, 7U, 192U), TensorShape(3U, 3U, 192U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 1, 1)); - // inception_5b/5x5_reduce - add_config(TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 48U), TensorShape(48U), TensorShape(7U, 7U, 48U), PadStrideInfo(1, 1, 0, 0)); - } -}; - -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1FullyConnectedLayerDataset.h b/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1FullyConnectedLayerDataset.h deleted file mode 100644 index 346bb521ad..0000000000 --- a/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1FullyConnectedLayerDataset.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_FULLYCONNECTED_LAYER_DATASET -#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_FULLYCONNECTED_LAYER_DATASET - -#include "tests/datasets_new/FullyConnectedLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class GoogLeNetInceptionV1FullyConnectedLayerDataset final : public FullyConnectedLayerDataset -{ -public: - GoogLeNetInceptionV1FullyConnectedLayerDataset() - { - add_config(TensorShape(1024U), TensorShape(1024U, 1000U), TensorShape(1000U), TensorShape(1000U)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_FULLYCONNECTED_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1GEMMDataset.h b/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1GEMMDataset.h deleted file mode 100644 index 6df3b92397..0000000000 --- a/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1GEMMDataset.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_GEMM_DATASET -#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_GEMM_DATASET - -#include "tests/datasets_new/GEMMDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class GoogLeNetInceptionV1GEMMDataset final : public GEMMDataset -{ -public: - GoogLeNetInceptionV1GEMMDataset() - { - add_config(TensorShape(147U, 12544U), TensorShape(64U, 147U), TensorShape(64U, 12544U), TensorShape(64U, 12544U), 1.0f, 0.0f); - add_config(TensorShape(64U, 3136U), TensorShape(64U, 64U), TensorShape(64U, 3136U), TensorShape(64U, 3136U), 1.0f, 0.0f); - add_config(TensorShape(576U, 3136U), TensorShape(192U, 576U), TensorShape(192U, 3136U), TensorShape(192U, 3136U), 1.0f, 0.0f); - add_config(TensorShape(192U, 784U), TensorShape(64U, 192U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f); - add_config(TensorShape(192U, 784U), TensorShape(96U, 192U), TensorShape(96U, 784U), TensorShape(96U, 784U), 1.0f, 0.0f); - add_config(TensorShape(864U, 784U), TensorShape(128U, 864U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f); - add_config(TensorShape(192U, 784U), TensorShape(16U, 192U), TensorShape(16U, 784U), TensorShape(16U, 784U), 1.0f, 0.0f); - add_config(TensorShape(400U, 784U), TensorShape(32U, 400U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f); - add_config(TensorShape(192U, 784U), TensorShape(32U, 192U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f); - add_config(TensorShape(256U, 784U), TensorShape(128U, 256U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f); - add_config(TensorShape(256U, 784U), TensorShape(128U, 256U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f); - add_config(TensorShape(1152U, 784U), TensorShape(192U, 1152U), TensorShape(192U, 784U), TensorShape(192U, 784U), 1.0f, 0.0f); - add_config(TensorShape(256U, 784U), TensorShape(32U, 256U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f); - add_config(TensorShape(800U, 784U), TensorShape(96U, 800U), TensorShape(96U, 784U), TensorShape(96U, 784U), 1.0f, 0.0f); - add_config(TensorShape(256U, 784U), TensorShape(64U, 256U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f); - add_config(TensorShape(480U, 196U), TensorShape(192U, 480U), TensorShape(192U, 196U), TensorShape(192U, 196U), 1.0f, 0.0f); - add_config(TensorShape(480U, 196U), TensorShape(96U, 480U), TensorShape(96U, 196U), TensorShape(96U, 196U), 1.0f, 0.0f); - add_config(TensorShape(864U, 196U), TensorShape(204U, 864U), TensorShape(204U, 196U), TensorShape(204U, 196U), 1.0f, 0.0f); - add_config(TensorShape(480U, 196U), TensorShape(16U, 480U), TensorShape(16U, 196U), TensorShape(16U, 196U), 1.0f, 0.0f); - add_config(TensorShape(400U, 196U), TensorShape(48U, 400U), TensorShape(48U, 196U), TensorShape(48U, 196U), 1.0f, 0.0f); - add_config(TensorShape(480U, 196U), TensorShape(64U, 480U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); - add_config(TensorShape(508U, 196U), TensorShape(160U, 508U), TensorShape(160U, 196U), TensorShape(160U, 196U), 1.0f, 0.0f); - add_config(TensorShape(508U, 196U), TensorShape(112U, 508U), TensorShape(112U, 196U), TensorShape(112U, 196U), 1.0f, 0.0f); - add_config(TensorShape(1008U, 196U), TensorShape(224U, 1008U), TensorShape(224U, 196U), TensorShape(224U, 196U), 1.0f, 0.0f); - add_config(TensorShape(508U, 196U), TensorShape(24U, 508U), TensorShape(24U, 196U), TensorShape(24U, 196U), 1.0f, 0.0f); - add_config(TensorShape(600U, 196U), TensorShape(64U, 600U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); - add_config(TensorShape(508U, 196U), TensorShape(64U, 508U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); - add_config(TensorShape(512U, 196U), TensorShape(128U, 512U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f); - add_config(TensorShape(512U, 196U), TensorShape(128U, 512U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f); - add_config(TensorShape(1152U, 196U), TensorShape(256U, 1152U), TensorShape(256U, 196U), TensorShape(256U, 196U), 1.0f, 0.0f); - add_config(TensorShape(512U, 196U), TensorShape(24U, 512U), TensorShape(24U, 196U), TensorShape(24U, 196U), 1.0f, 0.0f); - add_config(TensorShape(600U, 196U), TensorShape(64U, 600U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); - add_config(TensorShape(512U, 196U), TensorShape(64U, 512U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); - add_config(TensorShape(512U, 196U), TensorShape(112U, 512U), TensorShape(112U, 196U), TensorShape(112U, 196U), 1.0f, 0.0f); - add_config(TensorShape(512U, 196U), TensorShape(144U, 512U), TensorShape(144U, 196U), TensorShape(144U, 196U), 1.0f, 0.0f); - add_config(TensorShape(1296U, 196U), TensorShape(288U, 1296U), TensorShape(288U, 196U), TensorShape(288U, 196U), 1.0f, 0.0f); - add_config(TensorShape(512U, 196U), TensorShape(32U, 512U), TensorShape(32U, 196U), TensorShape(32U, 196U), 1.0f, 0.0f); - add_config(TensorShape(800U, 196U), TensorShape(64U, 800U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); - add_config(TensorShape(512U, 196U), TensorShape(64U, 512U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f); - add_config(TensorShape(528U, 196U), TensorShape(256U, 528U), TensorShape(256U, 196U), TensorShape(256U, 196U), 1.0f, 0.0f); - add_config(TensorShape(528U, 196U), TensorShape(160U, 528U), TensorShape(160U, 196U), TensorShape(160U, 196U), 1.0f, 0.0f); - add_config(TensorShape(1440U, 196U), TensorShape(320U, 1440U), TensorShape(320U, 196U), TensorShape(320U, 196U), 1.0f, 0.0f); - add_config(TensorShape(528U, 196U), TensorShape(32U, 528U), TensorShape(32U, 196U), TensorShape(32U, 196U), 1.0f, 0.0f); - add_config(TensorShape(800U, 196U), TensorShape(128U, 800U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f); - add_config(TensorShape(528U, 196U), TensorShape(128U, 528U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f); - add_config(TensorShape(832U, 49U), TensorShape(256U, 832U), TensorShape(256U, 49U), TensorShape(256U, 49U), 1.0f, 0.0f); - add_config(TensorShape(832U, 49U), TensorShape(160U, 832U), TensorShape(160U, 49U), TensorShape(160U, 49U), 1.0f, 0.0f); - add_config(TensorShape(1440U, 49U), TensorShape(320U, 1440U), TensorShape(320U, 49U), TensorShape(320U, 49U), 1.0f, 0.0f); - add_config(TensorShape(832U, 49U), TensorShape(48U, 832U), TensorShape(48U, 49U), TensorShape(48U, 49U), 1.0f, 0.0f); - add_config(TensorShape(1200U, 49U), TensorShape(128U, 1200U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f); - add_config(TensorShape(832U, 49U), TensorShape(128U, 832U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f); - add_config(TensorShape(832U, 49U), TensorShape(384U, 832U), TensorShape(384U, 49U), TensorShape(384U, 49U), 1.0f, 0.0f); - add_config(TensorShape(832U, 49U), TensorShape(192U, 832U), TensorShape(192U, 49U), TensorShape(192U, 49U), 1.0f, 0.0f); - add_config(TensorShape(1728U, 49U), TensorShape(384U, 1728U), TensorShape(384U, 49U), TensorShape(384U, 49U), 1.0f, 0.0f); - add_config(TensorShape(832U, 49U), TensorShape(48U, 832U), TensorShape(48U, 49U), TensorShape(48U, 49U), 1.0f, 0.0f); - add_config(TensorShape(1200U, 49U), TensorShape(128U, 1200U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f); - add_config(TensorShape(832U, 49U), TensorShape(128U, 832U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f); - add_config(TensorShape(508U, 16U), TensorShape(128U, 508U), TensorShape(128U, 16U), TensorShape(128U, 16U), 1.0f, 0.0f); - add_config(TensorShape(2048U, 1U), TensorShape(1024U, 2048U), TensorShape(1024U, 1U), TensorShape(1024U, 1U), 1.0f, 0.0f); - add_config(TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f); - add_config(TensorShape(528U, 16U), TensorShape(128U, 528U), TensorShape(128U, 16U), TensorShape(128U, 16U), 1.0f, 0.0f); - add_config(TensorShape(2048U, 1U), TensorShape(1024U, 2048U), TensorShape(1024U, 1U), TensorShape(1024U, 1U), 1.0f, 0.0f); - add_config(TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f); - add_config(TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_GEMM_DATASET */ diff --git a/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1NormalizationLayerDataset.h b/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1NormalizationLayerDataset.h deleted file mode 100644 index 4751dcd511..0000000000 --- a/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1NormalizationLayerDataset.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_NORMALIZATION_LAYER_DATASET -#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_NORMALIZATION_LAYER_DATASET - -#include "framework/datasets/Datasets.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class GoogLeNetInceptionV1NormalizationLayerDataset final : public - framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> -{ -public: - GoogLeNetInceptionV1NormalizationLayerDataset() - : CartesianProductDataset - { - framework::dataset::make("Shape", { // conv2/norm2 - TensorShape(56U, 56U, 192U), - // pool1/norm1 - TensorShape(56U, 56U, 64U) }), - framework::dataset::make("Info", NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)) - } - { - } - GoogLeNetInceptionV1NormalizationLayerDataset(GoogLeNetInceptionV1NormalizationLayerDataset &&) = default; - ~GoogLeNetInceptionV1NormalizationLayerDataset() = default; -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_NORMALIZATION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1PoolingLayerDataset.h b/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1PoolingLayerDataset.h deleted file mode 100644 index 007175c4db..0000000000 --- a/tests/datasets_new/system_tests/googlenet/inceptionv1/GoogLeNetInceptionV1PoolingLayerDataset.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_POOLING_LAYER_DATASET -#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_POOLING_LAYER_DATASET - -#include "tests/datasets_new/PoolingLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class GoogLeNetInceptionV1PoolingLayerDataset final : public PoolingLayerDataset -{ -public: - GoogLeNetInceptionV1PoolingLayerDataset() - { - // FIXME: Add support for 7x7 pooling layer pool5/7x7_s1 - // pool1/3x3_s2 - add_config(TensorShape(112U, 112U, 64U), TensorShape(56U, 56U, 64U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // pool2/3x3_s2 - add_config(TensorShape(56U, 56U, 192U), TensorShape(28U, 28U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // inception_3a/pool - add_config(TensorShape(28U, 28U, 192U), TensorShape(28U, 28U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); - // inception_3b/pool - add_config(TensorShape(28U, 28U, 256U), TensorShape(28U, 28U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); - // pool3/3x3_s2 - add_config(TensorShape(28U, 28U, 480U), TensorShape(14U, 14U, 480U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // inception_4a/pool - add_config(TensorShape(14U, 14U, 480U), TensorShape(14U, 14U, 480U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); - // inception_4b/pool, inception_4c/pool, inception_4d/pool - add_config(TensorShape(14U, 14U, 512U), TensorShape(14U, 14U, 512U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); - // inception_4e/pool - add_config(TensorShape(14U, 14U, 528U), TensorShape(14U, 14U, 528U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); - // pool4/3x3_s2 - add_config(TensorShape(14U, 14U, 832U), TensorShape(7U, 7U, 832U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // inception_5a/pool, inception_5b/pool - add_config(TensorShape(7U, 7U, 832U), TensorShape(7U, 7U, 832U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV1_POOLING_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ActivationLayerDataset.h b/tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ActivationLayerDataset.h deleted file mode 100644 index d93b548452..0000000000 --- a/tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ActivationLayerDataset.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_ACTIVATION_LAYER_DATASET -#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_ACTIVATION_LAYER_DATASET - -#include "framework/datasets/Datasets.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class GoogLeNetInceptionV4ActivationLayerDataset final : public - framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> -{ -public: - GoogLeNetInceptionV4ActivationLayerDataset() - : CartesianProductDataset - { - framework::dataset::make("Shape", { // conv1_3x3_s2_relu - TensorShape(149U, 149U, 32U), - // conv2_3x3_s1_relu - TensorShape(147U, 147U, 32U), - // conv3_3x3_s1_relu - TensorShape(147U, 147U, 64U), - // inception_stem1_3x3_s2_relu - TensorShape(73U, 73U, 96U), - // inception_stem2_3x3_reduce_relu, inception_stem2_1x7_reduce_relu, inception_stem2_1x7_relu, inception_stem2_7x1_relu - TensorShape(73U, 73U, 64U), - // inception_stem2_3x3_relu, inception_stem2_3x3_2_relu - TensorShape(71U, 71U, 96U), - // inception_stem3_3x3_s2_relu, reduction_a_3x3_2_reduce_relu - TensorShape(35U, 35U, 192U), - // inception_a1_1x1_2_relu, inception_a1_3x3_relu, inception_a1_3x3_2_relu, inception_a1_3x3_3_relu, inception_a1_1x1_relu, inception_a2_1x1_2_relu, inception_a2_3x3_relu, inception_a2_3x3_2_relu, inception_a2_3x3_3_relu, inception_a2_1x1_relu, inception_a3_1x1_2_relu, inception_a3_3x3_relu, inception_a3_3x3_2_relu, inception_a3_3x3_3_relu, inception_a3_1x1_relu, inception_a4_1x1_2_relu, inception_a4_3x3_relu, inception_a4_3x3_2_relu, inception_a4_3x3_3_relu, inception_a4_1x1_relu - TensorShape(35U, 35U, 96U), - // inception_a1_3x3_reduce_relu, inception_a1_3x3_2_reduce_relu, inception_a2_3x3_reduce_relu, inception_a2_3x3_2_reduce_relu, inception_a3_3x3_reduce_relu, inception_a3_3x3_2_reduce_relu, inception_a4_3x3_reduce_relu, inception_a4_3x3_2_reduce_relu - TensorShape(35U, 35U, 64U), - // reduction_a_3x3_relu, inception_b1_1x1_2_relu, inception_b2_1x1_2_relu, inception_b3_1x1_2_relu, inception_b4_1x1_2_relu, inception_b5_1x1_2_relu, inception_b6_1x1_2_relu, inception_b7_1x1_2_relu - TensorShape(17U, 17U, 384U), - // reduction_a_3x3_2_relu - TensorShape(35U, 35U, 224U), - // reduction_a_3x3_3_relu, inception_b1_7x1_relu, inception_b1_1x7_3_relu, inception_b2_7x1_relu, inception_b2_1x7_3_relu, inception_b3_7x1_relu, inception_b3_1x7_3_relu, inception_b4_7x1_relu, inception_b4_1x7_3_relu, inception_b5_7x1_relu, inception_b5_1x7_3_relu, inception_b6_7x1_relu, inception_b6_1x7_3_relu, inception_b7_7x1_relu, inception_b7_1x7_3_relu, reduction_b_1x7_reduce_relu, reduction_b_1x7_relu - TensorShape(17U, 17U, 256U), - // inception_b1_1x7_reduce_relu, inception_b1_7x1_2_reduce_relu, inception_b1_7x1_2_relu, inception_b2_1x7_reduce_relu, inception_b2_7x1_2_reduce_relu, inception_b2_7x1_2_relu, inception_b3_1x7_reduce_relu, inception_b3_7x1_2_reduce_relu, inception_b3_7x1_2_relu, inception_b4_1x7_reduce_relu, inception_b4_7x1_2_reduce_relu, inception_b4_7x1_2_relu, inception_b5_1x7_reduce_relu, inception_b5_7x1_2_reduce_relu, inception_b5_7x1_2_relu, inception_b6_1x7_reduce_relu, inception_b6_7x1_2_reduce_relu, inception_b6_7x1_2_relu, inception_b7_1x7_reduce_relu, inception_b7_7x1_2_reduce_relu, inception_b7_7x1_2_relu, reduction_b_3x3_reduce_relu - TensorShape(17U, 17U, 192U), - // inception_b1_1x7_relu, inception_b1_1x7_2_relu, inception_b1_7x1_3_relu, inception_b2_1x7_relu, inception_b2_1x7_2_relu, inception_b2_7x1_3_relu, inception_b3_1x7_relu, inception_b3_1x7_2_relu, inception_b3_7x1_3_relu, inception_b4_1x7_relu, inception_b4_1x7_2_relu, inception_b4_7x1_3_relu, inception_b5_1x7_relu, inception_b5_1x7_2_relu, inception_b5_7x1_3_relu, inception_b6_1x7_relu, inception_b6_1x7_2_relu, inception_b6_7x1_3_relu, inception_b7_1x7_relu, inception_b7_1x7_2_relu, inception_b7_7x1_3_relu - TensorShape(17U, 17U, 224U), - // inception_b1_1x1_relu, inception_b2_1x1_relu, inception_b3_1x1_relu, inception_b4_1x1_relu, inception_b5_1x1_relu, inception_b6_1x1_relu, inception_b7_1x1_relu - TensorShape(17U, 17U, 128U), - // reduction_b_3x3_relu - TensorShape(8U, 8U, 192U), - // reduction_b_7x1_relu - TensorShape(17U, 17U, 320U), - // reduction_b_3x3_2_relu - TensorShape(8U, 8U, 320U), - // inception_c1_1x1_2_relu, inception_c1_1x3_relu, inception_c1_3x1_relu, inception_c1_1x3_3_relu, inception_c1_3x1_3_relu, inception_c1_1x1_relu, inception_c2_1x1_2_relu, inception_c2_1x3_relu, inception_c2_3x1_relu, inception_c2_1x3_3_relu, inception_c2_3x1_3_relu, inception_c2_1x1_relu, inception_c3_1x1_2_relu, inception_c3_1x3_relu, inception_c3_3x1_relu, inception_c3_1x3_3_relu, inception_c3_3x1_3_relu, inception_c3_1x1_relu - TensorShape(8U, 8U, 256U), - // inception_c1_1x1_3_relu, inception_c1_1x1_4_relu, inception_c2_1x1_3_relu, inception_c2_1x1_4_relu, inception_c3_1x1_3_relu, inception_c3_1x1_4_relu - TensorShape(8U, 8U, 384U), - // inception_c1_3x1_2_relu, inception_c2_3x1_2_relu, inception_c3_3x1_2_relu - TensorShape(8U, 8U, 448U), - // inception_c1_1x3_2_relu, inception_c2_1x3_2_relu, inception_c3_1x3_2_relu - TensorShape(8U, 8U, 512U) }), - framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) - } - { - } - GoogLeNetInceptionV4ActivationLayerDataset(GoogLeNetInceptionV4ActivationLayerDataset &&) = default; - ~GoogLeNetInceptionV4ActivationLayerDataset() = default; -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_ACTIVATION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4BatchNormalizationLayerDataset.h b/tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4BatchNormalizationLayerDataset.h deleted file mode 100644 index 53bbca4b2f..0000000000 --- a/tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4BatchNormalizationLayerDataset.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_BATCHNORMALIZATION_LAYER_DATASET -#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_BATCHNORMALIZATION_LAYER_DATASET - -#include "tests/datasets_new/BatchNormalizationLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class GoogLeNetInceptionV4BatchNormalizationLayerDataset final : public BatchNormalizationLayerDataset -{ -public: - GoogLeNetInceptionV4BatchNormalizationLayerDataset() - { - // conv1_3x3_s2_bn - add_config(TensorShape(149U, 149U, 32U), TensorShape(32U), 0.000010f); - // conv2_3x3_s1_bn - add_config(TensorShape(147U, 147U, 32U), TensorShape(32U), 0.000010f); - // conv3_3x3_s1_bn - add_config(TensorShape(147U, 147U, 64U), TensorShape(64U), 0.000010f); - // inception_stem1_3x3_s2_bn - add_config(TensorShape(73U, 73U, 96U), TensorShape(96U), 0.000010f); - // inception_stem2_3x3_reduce_bn, inception_stem2_1x7_reduce_bn, inception_stem2_1x7_bn, inception_stem2_7x1_bn - add_config(TensorShape(73U, 73U, 64U), TensorShape(64U), 0.000010f); - // inception_stem2_3x3_bn, inception_stem2_3x3_2_bn - add_config(TensorShape(71U, 71U, 96U), TensorShape(96U), 0.000010f); - // inception_stem3_3x3_s2_bn, reduction_a_3x3_2_reduce_bn - add_config(TensorShape(35U, 35U, 192U), TensorShape(192U), 0.000010f); - // inception_a1_1x1_2_bn, inception_a1_3x3_bn, inception_a1_3x3_2_bn, inception_a1_3x3_3_bn, inception_a1_1x1_bn, inception_a2_1x1_2_bn, inception_a2_3x3_bn, inception_a2_3x3_2_bn, inception_a2_3x3_3_bn, inception_a2_1x1_bn, inception_a3_1x1_2_bn, inception_a3_3x3_bn, inception_a3_3x3_2_bn, inception_a3_3x3_3_bn, inception_a3_1x1_bn, inception_a4_1x1_2_bn, inception_a4_3x3_bn, inception_a4_3x3_2_bn, inception_a4_3x3_3_bn, inception_a4_1x1_bn - add_config(TensorShape(35U, 35U, 96U), TensorShape(96U), 0.000010f); - // inception_a1_3x3_reduce_bn, inception_a1_3x3_2_reduce_bn, inception_a2_3x3_reduce_bn, inception_a2_3x3_2_reduce_bn, inception_a3_3x3_reduce_bn, inception_a3_3x3_2_reduce_bn, inception_a4_3x3_reduce_bn, inception_a4_3x3_2_reduce_bn - add_config(TensorShape(35U, 35U, 64U), TensorShape(64U), 0.000010f); - // reduction_a_3x3_bn, inception_b1_1x1_2_bn, inception_b2_1x1_2_bn, inception_b3_1x1_2_bn, inception_b4_1x1_2_bn, inception_b5_1x1_2_bn, inception_b6_1x1_2_bn, inception_b7_1x1_2_bn - add_config(TensorShape(17U, 17U, 384U), TensorShape(384U), 0.000010f); - // reduction_a_3x3_2_bn - add_config(TensorShape(35U, 35U, 224U), TensorShape(224U), 0.000010f); - // reduction_a_3x3_3_bn, inception_b1_7x1_bn, inception_b1_1x7_3_bn, inception_b2_7x1_bn, inception_b2_1x7_3_bn, inception_b3_7x1_bn, inception_b3_1x7_3_bn, inception_b4_7x1_bn, inception_b4_1x7_3_bn, inception_b5_7x1_bn, inception_b5_1x7_3_bn, inception_b6_7x1_bn, inception_b6_1x7_3_bn, inception_b7_7x1_bn, inception_b7_1x7_3_bn, reduction_b_1x7_reduce_bn, reduction_b_1x7_bn - add_config(TensorShape(17U, 17U, 256U), TensorShape(256U), 0.000010f); - // inception_b1_1x7_reduce_bn, inception_b1_7x1_2_reduce_bn, inception_b1_7x1_2_bn, inception_b2_1x7_reduce_bn, inception_b2_7x1_2_reduce_bn, inception_b2_7x1_2_bn, inception_b3_1x7_reduce_bn, inception_b3_7x1_2_reduce_bn, inception_b3_7x1_2_bn, inception_b4_1x7_reduce_bn, inception_b4_7x1_2_reduce_bn, inception_b4_7x1_2_bn, inception_b5_1x7_reduce_bn, inception_b5_7x1_2_reduce_bn, inception_b5_7x1_2_bn, inception_b6_1x7_reduce_bn, inception_b6_7x1_2_reduce_bn, inception_b6_7x1_2_bn, inception_b7_1x7_reduce_bn, inception_b7_7x1_2_reduce_bn, inception_b7_7x1_2_bn, reduction_b_3x3_reduce_bn - add_config(TensorShape(17U, 17U, 192U), TensorShape(192U), 0.000010f); - // inception_b1_1x7_bn, inception_b1_1x7_2_bn, inception_b1_7x1_3_bn, inception_b2_1x7_bn, inception_b2_1x7_2_bn, inception_b2_7x1_3_bn, inception_b3_1x7_bn, inception_b3_1x7_2_bn, inception_b3_7x1_3_bn, inception_b4_1x7_bn, inception_b4_1x7_2_bn, inception_b4_7x1_3_bn, inception_b5_1x7_bn, inception_b5_1x7_2_bn, inception_b5_7x1_3_bn, inception_b6_1x7_bn, inception_b6_1x7_2_bn, inception_b6_7x1_3_bn, inception_b7_1x7_bn, inception_b7_1x7_2_bn, inception_b7_7x1_3_bn - add_config(TensorShape(17U, 17U, 224U), TensorShape(224U), 0.000010f); - // inception_b1_1x1_bn, inception_b2_1x1_bn, inception_b3_1x1_bn, inception_b4_1x1_bn, inception_b5_1x1_bn, inception_b6_1x1_bn, inception_b7_1x1_bn - add_config(TensorShape(17U, 17U, 128U), TensorShape(128U), 0.000010f); - // reduction_b_3x3_bn - add_config(TensorShape(8U, 8U, 192U), TensorShape(192U), 0.000010f); - // reduction_b_7x1_bn - add_config(TensorShape(17U, 17U, 320U), TensorShape(320U), 0.000010f); - // reduction_b_3x3_2_bn - add_config(TensorShape(8U, 8U, 320U), TensorShape(320U), 0.000010f); - // inception_c1_1x1_2_bn, inception_c1_1x3_bn, inception_c1_3x1_bn, inception_c1_1x3_3_bn, inception_c1_3x1_3_bn, inception_c1_1x1_bn, inception_c2_1x1_2_bn, inception_c2_1x3_bn, inception_c2_3x1_bn, inception_c2_1x3_3_bn, inception_c2_3x1_3_bn, inception_c2_1x1_bn, inception_c3_1x1_2_bn, inception_c3_1x3_bn, inception_c3_3x1_bn, inception_c3_1x3_3_bn, inception_c3_3x1_3_bn, inception_c3_1x1_bn - add_config(TensorShape(8U, 8U, 256U), TensorShape(256U), 0.000010f); - // inception_c1_1x1_3_bn, inception_c1_1x1_4_bn, inception_c2_1x1_3_bn, inception_c2_1x1_4_bn, inception_c3_1x1_3_bn, inception_c3_1x1_4_bn - add_config(TensorShape(8U, 8U, 384U), TensorShape(384U), 0.000010f); - // inception_c1_3x1_2_bn, inception_c2_3x1_2_bn, inception_c3_3x1_2_bn - add_config(TensorShape(8U, 8U, 448U), TensorShape(448U), 0.000010f); - // inception_c1_1x3_2_bn, inception_c2_1x3_2_bn, inception_c3_1x3_2_bn - add_config(TensorShape(8U, 8U, 512U), TensorShape(512U), 0.000010f); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_BATCHNORMALIZATION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ConvolutionLayerDataset.h b/tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ConvolutionLayerDataset.h deleted file mode 100644 index fe0d15ac79..0000000000 --- a/tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4ConvolutionLayerDataset.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_CONVOLUTION_LAYER_DATASET -#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_CONVOLUTION_LAYER_DATASET - -#include "tests/datasets_new/ConvolutionLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class GoogLeNetInceptionV4ConvolutionLayerDataset final : public ConvolutionLayerDataset -{ -public: - // GoogLeNetInceptionV4 inception v1 dataset - GoogLeNetInceptionV4ConvolutionLayerDataset() - { - // conv1_3x3_s2 - add_config(TensorShape(299U, 299U, 3U), TensorShape(3U, 3U, 3U, 32U), TensorShape(32U), TensorShape(149U, 149U, 32U), PadStrideInfo(2, 2, 0, 0)); - // conv2_3x3_s1 - add_config(TensorShape(149U, 149U, 32U), TensorShape(3U, 3U, 32U, 32U), TensorShape(32U), TensorShape(147U, 147U, 32U), PadStrideInfo(1, 1, 0, 0)); - // conv3_3x3_s1 - add_config(TensorShape(147U, 147U, 32U), TensorShape(3U, 3U, 32U, 64U), TensorShape(64U), TensorShape(147U, 147U, 64U), PadStrideInfo(1, 1, 1, 1)); - // inception_stem1_3x3_s2 - add_config(TensorShape(147U, 147U, 64U), TensorShape(3U, 3U, 64U, 96U), TensorShape(96U), TensorShape(73U, 73U, 96U), PadStrideInfo(2, 2, 0, 0)); - // inception_stem2_3x3_reduce, inception_stem2_1x7_reduce - add_config(TensorShape(73U, 73U, 160U), TensorShape(1U, 1U, 160U, 64U), TensorShape(64U), TensorShape(73U, 73U, 64U), PadStrideInfo(1, 1, 0, 0)); - // inception_stem2_3x3, inception_stem2_3x3_2 - add_config(TensorShape(73U, 73U, 64U), TensorShape(3U, 3U, 64U, 96U), TensorShape(96U), TensorShape(71U, 71U, 96U), PadStrideInfo(1, 1, 0, 0)); - // inception_stem2_1x7 - add_config(TensorShape(73U, 73U, 64U), TensorShape(7U, 1U, 64U, 64U), TensorShape(64U), TensorShape(73U, 73U, 64U), PadStrideInfo(1, 1, 3, 0)); - // inception_stem2_7x1 - add_config(TensorShape(73U, 73U, 64U), TensorShape(1U, 7U, 64U, 64U), TensorShape(64U), TensorShape(73U, 73U, 64U), PadStrideInfo(1, 1, 0, 3)); - // inception_stem3_3x3_s2 - add_config(TensorShape(71U, 71U, 192U), TensorShape(3U, 3U, 192U, 192U), TensorShape(192U), TensorShape(35U, 35U, 192U), PadStrideInfo(2, 2, 0, 0)); - // inception_a1_1x1_2, inception_a1_1x1, inception_a2_1x1_2, inception_a2_1x1, inception_a3_1x1_2, inception_a3_1x1, inception_a4_1x1_2, inception_a4_1x1 - add_config(TensorShape(35U, 35U, 384U), TensorShape(1U, 1U, 384U, 96U), TensorShape(96U), TensorShape(35U, 35U, 96U), PadStrideInfo(1, 1, 0, 0)); - // inception_a1_3x3_reduce, inception_a1_3x3_2_reduce, inception_a2_3x3_reduce, inception_a2_3x3_2_reduce, inception_a3_3x3_reduce, inception_a3_3x3_2_reduce, inception_a4_3x3_reduce, inception_a4_3x3_2_reduce - add_config(TensorShape(35U, 35U, 384U), TensorShape(1U, 1U, 384U, 64U), TensorShape(64U), TensorShape(35U, 35U, 64U), PadStrideInfo(1, 1, 0, 0)); - // inception_a1_3x3, inception_a1_3x3_2, inception_a2_3x3, inception_a2_3x3_2, inception_a3_3x3, inception_a3_3x3_2, inception_a4_3x3, inception_a4_3x3_2 - add_config(TensorShape(35U, 35U, 64U), TensorShape(3U, 3U, 64U, 96U), TensorShape(96U), TensorShape(35U, 35U, 96U), PadStrideInfo(1, 1, 1, 1)); - // inception_a1_3x3_3, inception_a2_3x3_3, inception_a3_3x3_3, inception_a4_3x3_3 - add_config(TensorShape(35U, 35U, 96U), TensorShape(3U, 3U, 96U, 96U), TensorShape(96U), TensorShape(35U, 35U, 96U), PadStrideInfo(1, 1, 1, 1)); - // reduction_a_3x3 - add_config(TensorShape(35U, 35U, 384U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(17U, 17U, 384U), PadStrideInfo(2, 2, 0, 0)); - // reduction_a_3x3_2_reduce - add_config(TensorShape(35U, 35U, 384U), TensorShape(1U, 1U, 384U, 192U), TensorShape(192U), TensorShape(35U, 35U, 192U), PadStrideInfo(1, 1, 0, 0)); - // reduction_a_3x3_2 - add_config(TensorShape(35U, 35U, 192U), TensorShape(3U, 3U, 192U, 224U), TensorShape(224U), TensorShape(35U, 35U, 224U), PadStrideInfo(1, 1, 1, 1)); - // reduction_a_3x3_3 - add_config(TensorShape(35U, 35U, 224U), TensorShape(3U, 3U, 224U, 256U), TensorShape(256U), TensorShape(17U, 17U, 256U), PadStrideInfo(2, 2, 0, 0)); - // inception_b1_1x1_2, inception_b2_1x1_2, inception_b3_1x1_2, inception_b4_1x1_2, inception_b5_1x1_2, inception_b6_1x1_2, inception_b7_1x1_2 - add_config(TensorShape(17U, 17U, 1024U), TensorShape(1U, 1U, 1024U, 384U), TensorShape(384U), TensorShape(17U, 17U, 384U), PadStrideInfo(1, 1, 0, 0)); - // inception_b1_1x7_reduce, inception_b1_7x1_2_reduce, inception_b2_1x7_reduce, inception_b2_7x1_2_reduce, inception_b3_1x7_reduce, inception_b3_7x1_2_reduce, inception_b4_1x7_reduce, inception_b4_7x1_2_reduce, inception_b5_1x7_reduce, inception_b5_7x1_2_reduce, inception_b6_1x7_reduce, inception_b6_7x1_2_reduce, inception_b7_1x7_reduce, inception_b7_7x1_2_reduce, reduction_b_3x3_reduce - add_config(TensorShape(17U, 17U, 1024U), TensorShape(1U, 1U, 1024U, 192U), TensorShape(192U), TensorShape(17U, 17U, 192U), PadStrideInfo(1, 1, 0, 0)); - // inception_b1_1x7, inception_b1_1x7_2, inception_b2_1x7, inception_b2_1x7_2, inception_b3_1x7, inception_b3_1x7_2, inception_b4_1x7, inception_b4_1x7_2, inception_b5_1x7, inception_b5_1x7_2, inception_b6_1x7, inception_b6_1x7_2, inception_b7_1x7, inception_b7_1x7_2 - add_config(TensorShape(17U, 17U, 192U), TensorShape(7U, 1U, 192U, 224U), TensorShape(224U), TensorShape(17U, 17U, 224U), PadStrideInfo(1, 1, 3, 0)); - // inception_b1_7x1, inception_b2_7x1, inception_b3_7x1, inception_b4_7x1, inception_b5_7x1, inception_b6_7x1, inception_b7_7x1 - add_config(TensorShape(17U, 17U, 224U), TensorShape(1U, 7U, 224U, 256U), TensorShape(256U), TensorShape(17U, 17U, 256U), PadStrideInfo(1, 1, 0, 3)); - // inception_b1_7x1_2, inception_b2_7x1_2, inception_b3_7x1_2, inception_b4_7x1_2, inception_b5_7x1_2, inception_b6_7x1_2, inception_b7_7x1_2 - add_config(TensorShape(17U, 17U, 192U), TensorShape(1U, 7U, 192U, 192U), TensorShape(192U), TensorShape(17U, 17U, 192U), PadStrideInfo(1, 1, 0, 3)); - // inception_b1_7x1_3, inception_b2_7x1_3, inception_b3_7x1_3, inception_b4_7x1_3, inception_b5_7x1_3, inception_b6_7x1_3, inception_b7_7x1_3 - add_config(TensorShape(17U, 17U, 224U), TensorShape(1U, 7U, 224U, 224U), TensorShape(224U), TensorShape(17U, 17U, 224U), PadStrideInfo(1, 1, 0, 3)); - // inception_b1_1x7_3, inception_b2_1x7_3, inception_b3_1x7_3, inception_b4_1x7_3, inception_b5_1x7_3, inception_b6_1x7_3, inception_b7_1x7_3 - add_config(TensorShape(17U, 17U, 224U), TensorShape(7U, 1U, 224U, 256U), TensorShape(256U), TensorShape(17U, 17U, 256U), PadStrideInfo(1, 1, 3, 0)); - // inception_b1_1x1, inception_b2_1x1, inception_b3_1x1, inception_b4_1x1, inception_b5_1x1, inception_b6_1x1, inception_b7_1x1 - add_config(TensorShape(17U, 17U, 1024U), TensorShape(1U, 1U, 1024U, 128U), TensorShape(128U), TensorShape(17U, 17U, 128U), PadStrideInfo(1, 1, 0, 0)); - // reduction_b_3x3 - add_config(TensorShape(17U, 17U, 192U), TensorShape(3U, 3U, 192U, 192U), TensorShape(192U), TensorShape(8U, 8U, 192U), PadStrideInfo(2, 2, 0, 0)); - // reduction_b_1x7_reduce - add_config(TensorShape(17U, 17U, 1024U), TensorShape(1U, 1U, 1024U, 256U), TensorShape(256U), TensorShape(17U, 17U, 256U), PadStrideInfo(1, 1, 0, 0)); - // reduction_b_1x7 - add_config(TensorShape(17U, 17U, 256U), TensorShape(7U, 1U, 256U, 256U), TensorShape(256U), TensorShape(17U, 17U, 256U), PadStrideInfo(1, 1, 3, 0)); - // reduction_b_7x1 - add_config(TensorShape(17U, 17U, 256U), TensorShape(1U, 7U, 256U, 320U), TensorShape(320U), TensorShape(17U, 17U, 320U), PadStrideInfo(1, 1, 0, 3)); - // reduction_b_3x3_2 - add_config(TensorShape(17U, 17U, 320U), TensorShape(3U, 3U, 320U, 320U), TensorShape(320U), TensorShape(8U, 8U, 320U), PadStrideInfo(2, 2, 0, 0)); - // inception_c1_1x1_2, inception_c1_1x1, inception_c2_1x1_2, inception_c2_1x1, inception_c3_1x1_2, inception_c3_1x1 - add_config(TensorShape(8U, 8U, 1536U), TensorShape(1U, 1U, 1536U, 256U), TensorShape(256U), TensorShape(8U, 8U, 256U), PadStrideInfo(1, 1, 0, 0)); - // inception_c1_1x1_3, inception_c1_1x1_4, inception_c2_1x1_3, inception_c2_1x1_4, inception_c3_1x1_3, inception_c3_1x1_4 - add_config(TensorShape(8U, 8U, 1536U), TensorShape(1U, 1U, 1536U, 384U), TensorShape(384U), TensorShape(8U, 8U, 384U), PadStrideInfo(1, 1, 0, 0)); - // inception_c1_1x3, inception_c2_1x3, inception_c3_1x3 - add_config(TensorShape(8U, 8U, 384U), TensorShape(3U, 1U, 384U, 256U), TensorShape(256U), TensorShape(8U, 8U, 256U), PadStrideInfo(1, 1, 1, 0)); - // inception_c1_3x1, inception_c2_3x1, inception_c3_3x1 - add_config(TensorShape(8U, 8U, 384U), TensorShape(1U, 3U, 384U, 256U), TensorShape(256U), TensorShape(8U, 8U, 256U), PadStrideInfo(1, 1, 0, 1)); - // inception_c1_3x1_2, inception_c2_3x1_2, inception_c3_3x1_2 - add_config(TensorShape(8U, 8U, 384U), TensorShape(1U, 3U, 384U, 448U), TensorShape(448U), TensorShape(8U, 8U, 448U), PadStrideInfo(1, 1, 0, 1)); - // inception_c1_1x3_2, inception_c2_1x3_2, inception_c3_1x3_2 - add_config(TensorShape(8U, 8U, 448U), TensorShape(3U, 1U, 448U, 512U), TensorShape(512U), TensorShape(8U, 8U, 512U), PadStrideInfo(1, 1, 1, 0)); - // inception_c1_1x3_3, inception_c2_1x3_3, inception_c3_1x3_3 - add_config(TensorShape(8U, 8U, 512U), TensorShape(3U, 1U, 512U, 256U), TensorShape(256U), TensorShape(8U, 8U, 256U), PadStrideInfo(1, 1, 1, 0)); - // inception_c1_3x1_3, inception_c2_3x1_3, inception_c3_3x1_3 - add_config(TensorShape(8U, 8U, 512U), TensorShape(1U, 3U, 512U, 256U), TensorShape(256U), TensorShape(8U, 8U, 256U), PadStrideInfo(1, 1, 0, 1)); - } -}; - -/** A subset of GoogLeNetInceptionV4 convolution layers with filter dimensions supported by DirectConvolution kernel */ -class GoogLeNetInceptionV4DirectConvolutionLayerDataset final : public ConvolutionLayerDataset -{ -public: - // subset of GoogLeNetInceptionV4 inception v1 dataset - GoogLeNetInceptionV4DirectConvolutionLayerDataset() - { - // conv1_3x3_s2 - add_config(TensorShape(299U, 299U, 3U), TensorShape(3U, 3U, 3U, 32U), TensorShape(32U), TensorShape(149U, 149U, 32U), PadStrideInfo(2, 2, 0, 0)); - // conv2_3x3_s1 - add_config(TensorShape(149U, 149U, 32U), TensorShape(3U, 3U, 32U, 32U), TensorShape(32U), TensorShape(147U, 147U, 32U), PadStrideInfo(1, 1, 0, 0)); - // conv3_3x3_s1 - add_config(TensorShape(147U, 147U, 32U), TensorShape(3U, 3U, 32U, 64U), TensorShape(64U), TensorShape(147U, 147U, 64U), PadStrideInfo(1, 1, 1, 1)); - // inception_stem1_3x3_s2 - add_config(TensorShape(147U, 147U, 64U), TensorShape(3U, 3U, 64U, 96U), TensorShape(96U), TensorShape(73U, 73U, 96U), PadStrideInfo(2, 2, 0, 0)); - // inception_stem2_3x3_reduce, inception_stem2_1x7_reduce - add_config(TensorShape(73U, 73U, 160U), TensorShape(1U, 1U, 160U, 64U), TensorShape(64U), TensorShape(73U, 73U, 64U), PadStrideInfo(1, 1, 0, 0)); - // inception_stem2_3x3, inception_stem2_3x3_2 - add_config(TensorShape(73U, 73U, 64U), TensorShape(3U, 3U, 64U, 96U), TensorShape(96U), TensorShape(71U, 71U, 96U), PadStrideInfo(1, 1, 0, 0)); - // inception_stem3_3x3_s2 - add_config(TensorShape(71U, 71U, 192U), TensorShape(3U, 3U, 192U, 192U), TensorShape(192U), TensorShape(35U, 35U, 192U), PadStrideInfo(2, 2, 0, 0)); - // inception_a1_1x1_2, inception_a1_1x1, inception_a2_1x1_2, inception_a2_1x1, inception_a3_1x1_2, inception_a3_1x1, inception_a4_1x1_2, inception_a4_1x1 - add_config(TensorShape(35U, 35U, 384U), TensorShape(1U, 1U, 384U, 96U), TensorShape(96U), TensorShape(35U, 35U, 96U), PadStrideInfo(1, 1, 0, 0)); - // inception_a1_3x3_reduce, inception_a1_3x3_2_reduce, inception_a2_3x3_reduce, inception_a2_3x3_2_reduce, inception_a3_3x3_reduce, inception_a3_3x3_2_reduce, inception_a4_3x3_reduce, inception_a4_3x3_2_reduce - add_config(TensorShape(35U, 35U, 384U), TensorShape(1U, 1U, 384U, 64U), TensorShape(64U), TensorShape(35U, 35U, 64U), PadStrideInfo(1, 1, 0, 0)); - // inception_a1_3x3, inception_a1_3x3_2, inception_a2_3x3, inception_a2_3x3_2, inception_a3_3x3, inception_a3_3x3_2, inception_a4_3x3, inception_a4_3x3_2 - add_config(TensorShape(35U, 35U, 64U), TensorShape(3U, 3U, 64U, 96U), TensorShape(96U), TensorShape(35U, 35U, 96U), PadStrideInfo(1, 1, 1, 1)); - // inception_a1_3x3_3, inception_a2_3x3_3, inception_a3_3x3_3, inception_a4_3x3_3 - add_config(TensorShape(35U, 35U, 96U), TensorShape(3U, 3U, 96U, 96U), TensorShape(96U), TensorShape(35U, 35U, 96U), PadStrideInfo(1, 1, 1, 1)); - // reduction_a_3x3 - add_config(TensorShape(35U, 35U, 384U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(17U, 17U, 384U), PadStrideInfo(2, 2, 0, 0)); - // reduction_a_3x3_2_reduce - add_config(TensorShape(35U, 35U, 384U), TensorShape(1U, 1U, 384U, 192U), TensorShape(192U), TensorShape(35U, 35U, 192U), PadStrideInfo(1, 1, 0, 0)); - // reduction_a_3x3_2 - add_config(TensorShape(35U, 35U, 192U), TensorShape(3U, 3U, 192U, 224U), TensorShape(224U), TensorShape(35U, 35U, 224U), PadStrideInfo(1, 1, 1, 1)); - // reduction_a_3x3_3 - add_config(TensorShape(35U, 35U, 224U), TensorShape(3U, 3U, 224U, 256U), TensorShape(256U), TensorShape(17U, 17U, 256U), PadStrideInfo(2, 2, 0, 0)); - // inception_b1_1x1_2, inception_b2_1x1_2, inception_b3_1x1_2, inception_b4_1x1_2, inception_b5_1x1_2, inception_b6_1x1_2, inception_b7_1x1_2 - add_config(TensorShape(17U, 17U, 1024U), TensorShape(1U, 1U, 1024U, 384U), TensorShape(384U), TensorShape(17U, 17U, 384U), PadStrideInfo(1, 1, 0, 0)); - // inception_b1_1x7_reduce, inception_b1_7x1_2_reduce, inception_b2_1x7_reduce, inception_b2_7x1_2_reduce, inception_b3_1x7_reduce, inception_b3_7x1_2_reduce, inception_b4_1x7_reduce, inception_b4_7x1_2_reduce, inception_b5_1x7_reduce, inception_b5_7x1_2_reduce, inception_b6_1x7_reduce, inception_b6_7x1_2_reduce, inception_b7_1x7_reduce, inception_b7_7x1_2_reduce, reduction_b_3x3_reduce - add_config(TensorShape(17U, 17U, 1024U), TensorShape(1U, 1U, 1024U, 192U), TensorShape(192U), TensorShape(17U, 17U, 192U), PadStrideInfo(1, 1, 0, 0)); - // inception_b1_1x1, inception_b2_1x1, inception_b3_1x1, inception_b4_1x1, inception_b5_1x1, inception_b6_1x1, inception_b7_1x1 - add_config(TensorShape(17U, 17U, 1024U), TensorShape(1U, 1U, 1024U, 128U), TensorShape(128U), TensorShape(17U, 17U, 128U), PadStrideInfo(1, 1, 0, 0)); - // reduction_b_3x3 - add_config(TensorShape(17U, 17U, 192U), TensorShape(3U, 3U, 192U, 192U), TensorShape(192U), TensorShape(8U, 8U, 192U), PadStrideInfo(2, 2, 0, 0)); - // reduction_b_1x7_reduce - add_config(TensorShape(17U, 17U, 1024U), TensorShape(1U, 1U, 1024U, 256U), TensorShape(256U), TensorShape(17U, 17U, 256U), PadStrideInfo(1, 1, 0, 0)); - // reduction_b_3x3_2 - add_config(TensorShape(17U, 17U, 320U), TensorShape(3U, 3U, 320U, 320U), TensorShape(320U), TensorShape(8U, 8U, 320U), PadStrideInfo(2, 2, 0, 0)); - // inception_c1_1x1_2, inception_c1_1x1, inception_c2_1x1_2, inception_c2_1x1, inception_c3_1x1_2, inception_c3_1x1 - add_config(TensorShape(8U, 8U, 1536U), TensorShape(1U, 1U, 1536U, 256U), TensorShape(256U), TensorShape(8U, 8U, 256U), PadStrideInfo(1, 1, 0, 0)); - // inception_c1_1x1_3, inception_c1_1x1_4, inception_c2_1x1_3, inception_c2_1x1_4, inception_c3_1x1_3, inception_c3_1x1_4 - add_config(TensorShape(8U, 8U, 1536U), TensorShape(1U, 1U, 1536U, 384U), TensorShape(384U), TensorShape(8U, 8U, 384U), PadStrideInfo(1, 1, 0, 0)); - } -}; - -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4FullyConnectedLayerDataset.h b/tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4FullyConnectedLayerDataset.h deleted file mode 100644 index cf69969197..0000000000 --- a/tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4FullyConnectedLayerDataset.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_FULLYCONNECTED_LAYER_DATASET -#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_FULLYCONNECTED_LAYER_DATASET - -#include "tests/datasets_new/FullyConnectedLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class GoogLeNetInceptionV4FullyConnectedLayerDataset final : public FullyConnectedLayerDataset -{ -public: - GoogLeNetInceptionV4FullyConnectedLayerDataset() - { - add_config(TensorShape(1536U), TensorShape(1536U, 1000U), TensorShape(1000U), TensorShape(1000U)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_FULLYCONNECTED_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4PoolingLayerDataset.h b/tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4PoolingLayerDataset.h deleted file mode 100644 index f0eb1eab42..0000000000 --- a/tests/datasets_new/system_tests/googlenet/inceptionv4/GoogLeNetInceptionV4PoolingLayerDataset.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_POOLING_LAYER_DATASET -#define ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_POOLING_LAYER_DATASET - -#include "tests/datasets_new/PoolingLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class GoogLeNetInceptionV4PoolingLayerDataset final : public PoolingLayerDataset -{ -public: - GoogLeNetInceptionV4PoolingLayerDataset() - { - // FIXME: Add support for global pooling layer pool_8x8_s1 - // inception_stem1_pool - add_config(TensorShape(147U, 147U, 64U), TensorShape(73U, 73U, 64U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // inception_stem3_pool - add_config(TensorShape(71U, 71U, 192U), TensorShape(35U, 35U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // inception_a1_pool_ave, inception_a2_pool_ave, inception_a3_pool_ave, inception_a4_pool_ave - add_config(TensorShape(35U, 35U, 384U), TensorShape(35U, 35U, 384U), PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); - // reduction_a_pool - add_config(TensorShape(35U, 35U, 384U), TensorShape(17U, 17U, 384U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // inception_b1_pool_ave, inception_b2_pool_ave, inception_b3_pool_ave, inception_b4_pool_ave, inception_b5_pool_ave, inception_b6_pool_ave, inception_b7_pool_ave - add_config(TensorShape(17U, 17U, 1024U), TensorShape(17U, 17U, 1024U), PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); - // reduction_b_pool - add_config(TensorShape(17U, 17U, 1024U), TensorShape(8U, 8U, 1024U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // inception_c1_pool_ave, inception_c2_pool_ave, inception_c3_pool_ave - add_config(TensorShape(8U, 8U, 1536U), TensorShape(8U, 8U, 1536U), PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL))); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GOOGLENETINCEPTIONV4_POOLING_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/lenet5/LeNet5ActivationLayerDataset.h b/tests/datasets_new/system_tests/lenet5/LeNet5ActivationLayerDataset.h deleted file mode 100644 index 5d2a36bfd3..0000000000 --- a/tests/datasets_new/system_tests/lenet5/LeNet5ActivationLayerDataset.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_LENET5_ACTIVATION_LAYER_DATASET -#define ARM_COMPUTE_TEST_LENET5_ACTIVATION_LAYER_DATASET - -#include "framework/datasets/Datasets.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class LeNet5ActivationLayerDataset final : public - framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> -{ -public: - LeNet5ActivationLayerDataset() - : CartesianProductDataset - { - framework::dataset::make("Shape", TensorShape(500U)), - framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) - } - { - } - LeNet5ActivationLayerDataset(LeNet5ActivationLayerDataset &&) = default; - ~LeNet5ActivationLayerDataset() = default; -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_LENET5_ACTIVATION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/lenet5/LeNet5ConvolutionLayerDataset.h b/tests/datasets_new/system_tests/lenet5/LeNet5ConvolutionLayerDataset.h deleted file mode 100644 index 446a413663..0000000000 --- a/tests/datasets_new/system_tests/lenet5/LeNet5ConvolutionLayerDataset.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_LENET5_CONVOLUTION_LAYER_DATASET -#define ARM_COMPUTE_TEST_LENET5_CONVOLUTION_LAYER_DATASET - -#include "tests/datasets_new/ConvolutionLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class LeNet5ConvolutionLayerDataset final : public ConvolutionLayerDataset -{ -public: - LeNet5ConvolutionLayerDataset() - { - add_config(TensorShape(28U, 28U, 1U), TensorShape(5U, 5U, 1U, 20U), TensorShape(20U), TensorShape(24U, 24U, 20U), PadStrideInfo(1, 1, 0, 0)); - add_config(TensorShape(12U, 12U, 20U), TensorShape(5U, 5U, 20U, 50U), TensorShape(50U), TensorShape(8U, 8U, 50U), PadStrideInfo(1, 1, 0, 0)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_LENET5_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/lenet5/LeNet5FullyConnectedLayerDataset.h b/tests/datasets_new/system_tests/lenet5/LeNet5FullyConnectedLayerDataset.h deleted file mode 100644 index bbbf7121c3..0000000000 --- a/tests/datasets_new/system_tests/lenet5/LeNet5FullyConnectedLayerDataset.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_LENET5_FULLYCONNECTED_LAYER_DATASET -#define ARM_COMPUTE_TEST_LENET5_FULLYCONNECTED_LAYER_DATASET - -#include "tests/datasets_new/FullyConnectedLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -using namespace arm_compute; - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class LeNet5FullyConnectedLayerDataset final : public FullyConnectedLayerDataset -{ -public: - LeNet5FullyConnectedLayerDataset() - { - add_config(TensorShape(4U, 4U, 50U), TensorShape(800U, 500U), TensorShape(500U), TensorShape(500U)); - add_config(TensorShape(500U), TensorShape(500U, 10U), TensorShape(10U), TensorShape(10U)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_LENET5_FULLYCONNECTED_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/lenet5/LeNet5PoolingLayerDataset.h b/tests/datasets_new/system_tests/lenet5/LeNet5PoolingLayerDataset.h deleted file mode 100644 index bc234d858c..0000000000 --- a/tests/datasets_new/system_tests/lenet5/LeNet5PoolingLayerDataset.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_LENET5_POOLING_LAYER_DATASET -#define ARM_COMPUTE_TEST_LENET5_POOLING_LAYER_DATASET - -#include "tests/datasets_new/PoolingLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class LeNet5PoolingLayerDataset final : public PoolingLayerDataset -{ -public: - LeNet5PoolingLayerDataset() - { - add_config(TensorShape(24U, 24U, 20U), TensorShape(12U, 12U, 20U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0))); - add_config(TensorShape(8U, 8U, 50U), TensorShape(4U, 4U, 50U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0))); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_LENET5_POOLING_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/squeezenet/SqueezeNetActivationLayerDataset.h b/tests/datasets_new/system_tests/squeezenet/SqueezeNetActivationLayerDataset.h deleted file mode 100644 index 9cc9973f8f..0000000000 --- a/tests/datasets_new/system_tests/squeezenet/SqueezeNetActivationLayerDataset.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_SQUEEZENET_ACTIVATION_LAYER_DATASET -#define ARM_COMPUTE_TEST_SQUEEZENET_ACTIVATION_LAYER_DATASET - -#include "framework/datasets/Datasets.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class SqueezeNetActivationLayerDataset final : public - framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> -{ -public: - SqueezeNetActivationLayerDataset() - : CartesianProductDataset - { - framework::dataset::make("Shape", { // relu_conv1 - TensorShape(111U, 111U, 64U), - // fire2/relu_squeeze1x1, fire3/relu_squeeze1x1 - TensorShape(55U, 55U, 16U), - // fire2/relu_expand1x1, fire2/relu_expand3x3, fire3/relu_expand1x1, fire3/relu_expand3x3 - TensorShape(55U, 55U, 64U), - // fire4/relu_squeeze1x1, fire5/relu_squeeze1x1 - TensorShape(27U, 27U, 32U), - // fire4/relu_expand1x1, fire4/relu_expand3x3, fire5/relu_expand1x1, fire5/relu_expand3x3 - TensorShape(27U, 27U, 128U), - // fire6/relu_squeeze1x1, fire7/relu_squeeze1x1 - TensorShape(13U, 13U, 48U), - // fire6/relu_expand1x1, fire6/relu_expand3x3, fire7/relu_expand1x1, fire7/relu_expand3x3 - TensorShape(13U, 13U, 192U), - // fire8/relu_squeeze1x1, fire9/relu_squeeze1x1 - TensorShape(13U, 13U, 64U), - // fire8/relu_expand1x1, fire8/relu_expand3x3, fire9/relu_expand1x1, fire9/relu_expand3x3 - TensorShape(13U, 13U, 256U), - // relu_conv10 - TensorShape(13U, 13U, 1000U) }), - framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) - } - { - } - SqueezeNetActivationLayerDataset(SqueezeNetActivationLayerDataset &&) = default; - ~SqueezeNetActivationLayerDataset() = default; -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_SQUEEZENET_ACTIVATION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/squeezenet/SqueezeNetConvolutionLayerDataset.h b/tests/datasets_new/system_tests/squeezenet/SqueezeNetConvolutionLayerDataset.h deleted file mode 100644 index 07ec6c9eaf..0000000000 --- a/tests/datasets_new/system_tests/squeezenet/SqueezeNetConvolutionLayerDataset.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_SQUEEZENET_CONVOLUTION_LAYER_DATASET -#define ARM_COMPUTE_TEST_SQUEEZENET_CONVOLUTION_LAYER_DATASET - -#include "tests/datasets_new/ConvolutionLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class SqueezeNetConvolutionLayerDataset final : public ConvolutionLayerDataset -{ -public: - SqueezeNetConvolutionLayerDataset() - { - // conv1 - add_config(TensorShape(224U, 224U, 3U), TensorShape(3U, 3U, 3U, 64U), TensorShape(64U), TensorShape(111U, 111U, 64U), PadStrideInfo(2, 2, 0, 0)); - // fire2/squeeze1x1 - add_config(TensorShape(55U, 55U, 64U), TensorShape(1U, 1U, 64U, 16U), TensorShape(16U), TensorShape(55U, 55U, 16U), PadStrideInfo(1, 1, 0, 0)); - // fire2/expand1x1, fire3/expand1x1 - add_config(TensorShape(55U, 55U, 16U), TensorShape(1U, 1U, 16U, 64U), TensorShape(64U), TensorShape(55U, 55U, 64U), PadStrideInfo(1, 1, 0, 0)); - // fire2/expand3x3, fire3/expand3x3 - add_config(TensorShape(55U, 55U, 16U), TensorShape(3U, 3U, 16U, 64U), TensorShape(64U), TensorShape(55U, 55U, 64U), PadStrideInfo(1, 1, 1, 1)); - // fire3/squeeze1x1 - add_config(TensorShape(55U, 55U, 128U), TensorShape(1U, 1U, 128U, 16U), TensorShape(16U), TensorShape(55U, 55U, 16U), PadStrideInfo(1, 1, 0, 0)); - // fire4/squeeze1x1 - add_config(TensorShape(27U, 27U, 128U), TensorShape(1U, 1U, 128U, 32U), TensorShape(32U), TensorShape(27U, 27U, 32U), PadStrideInfo(1, 1, 0, 0)); - // fire4/expand1x1, fire5/expand1x1 - add_config(TensorShape(27U, 27U, 32U), TensorShape(1U, 1U, 32U, 128U), TensorShape(128U), TensorShape(27U, 27U, 128U), PadStrideInfo(1, 1, 0, 0)); - // fire4/expand3x3, fire5/expand3x3 - add_config(TensorShape(27U, 27U, 32U), TensorShape(3U, 3U, 32U, 128U), TensorShape(128U), TensorShape(27U, 27U, 128U), PadStrideInfo(1, 1, 1, 1)); - // fire5/squeeze1x1 - add_config(TensorShape(27U, 27U, 256U), TensorShape(1U, 1U, 256U, 32U), TensorShape(32U), TensorShape(27U, 27U, 32U), PadStrideInfo(1, 1, 0, 0)); - // fire6/squeeze1x1 - add_config(TensorShape(13U, 13U, 256U), TensorShape(1U, 1U, 256U, 48U), TensorShape(48U), TensorShape(13U, 13U, 48U), PadStrideInfo(1, 1, 0, 0)); - // fire6/expand1x1, fire7/expand1x1 - add_config(TensorShape(13U, 13U, 48U), TensorShape(1U, 1U, 48U, 192U), TensorShape(192U), TensorShape(13U, 13U, 192U), PadStrideInfo(1, 1, 0, 0)); - // fire6/expand3x3, fire7/expand3x3 - add_config(TensorShape(13U, 13U, 48U), TensorShape(3U, 3U, 48U, 192U), TensorShape(192U), TensorShape(13U, 13U, 192U), PadStrideInfo(1, 1, 1, 1)); - // fire7/squeeze1x1 - add_config(TensorShape(13U, 13U, 384U), TensorShape(1U, 1U, 384U, 48U), TensorShape(48U), TensorShape(13U, 13U, 48U), PadStrideInfo(1, 1, 0, 0)); - // fire8/squeeze1x1 - add_config(TensorShape(13U, 13U, 384U), TensorShape(1U, 1U, 384U, 64U), TensorShape(64U), TensorShape(13U, 13U, 64U), PadStrideInfo(1, 1, 0, 0)); - // fire8/expand1x1, fire9/expand1x1 - add_config(TensorShape(13U, 13U, 64U), TensorShape(1U, 1U, 64U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U), PadStrideInfo(1, 1, 0, 0)); - // fire8/expand3x3, fire9/expand3x3 - add_config(TensorShape(13U, 13U, 64U), TensorShape(3U, 3U, 64U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U), PadStrideInfo(1, 1, 1, 1)); - // fire9/squeeze1x1 - add_config(TensorShape(13U, 13U, 512U), TensorShape(1U, 1U, 512U, 64U), TensorShape(64U), TensorShape(13U, 13U, 64U), PadStrideInfo(1, 1, 0, 0)); - // conv10 - add_config(TensorShape(13U, 13U, 512U), TensorShape(1U, 1U, 512U, 1000U), TensorShape(1000U), TensorShape(13U, 13U, 1000U), PadStrideInfo(1, 1, 0, 0)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_SQUEEZENET_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/squeezenet/SqueezeNetPoolingLayerDataset.h b/tests/datasets_new/system_tests/squeezenet/SqueezeNetPoolingLayerDataset.h deleted file mode 100644 index dc443c8a03..0000000000 --- a/tests/datasets_new/system_tests/squeezenet/SqueezeNetPoolingLayerDataset.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_SQUEEZENET_POOLING_LAYER_DATASET -#define ARM_COMPUTE_TEST_SQUEEZENET_POOLING_LAYER_DATASET - -#include "tests/datasets_new/PoolingLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class SqueezeNetPoolingLayerDataset final : public PoolingLayerDataset -{ -public: - SqueezeNetPoolingLayerDataset() - { - // pool1 - add_config(TensorShape(111U, 111U, 64U), TensorShape(55U, 55U, 64U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // pool3 - add_config(TensorShape(55U, 55U, 128U), TensorShape(27U, 27U, 128U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // pool5 - add_config(TensorShape(27U, 27U, 256U), TensorShape(13U, 13U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - //FIXME: Add support for global pooling. - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_SQUEEZENET_POOLING_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/vgg/vgg16/VGG16ActivationLayerDataset.h b/tests/datasets_new/system_tests/vgg/vgg16/VGG16ActivationLayerDataset.h deleted file mode 100644 index 757357f62e..0000000000 --- a/tests/datasets_new/system_tests/vgg/vgg16/VGG16ActivationLayerDataset.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_VGG16_ACTIVATION_LAYER_DATASET -#define ARM_COMPUTE_TEST_VGG16_ACTIVATION_LAYER_DATASET - -#include "framework/datasets/Datasets.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class VGG16ActivationLayerDataset final : public - framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> -{ -public: - VGG16ActivationLayerDataset() - : CartesianProductDataset - { - framework::dataset::make("Shape", { // relu1_1, relu1_2 - TensorShape(224U, 224U, 64U), - // relu2_1, relu2_2 - TensorShape(112U, 112U, 128U), - // relu3_1, relu3_2, relu3_3 - TensorShape(56U, 56U, 256U), - // relu4_1, relu4_2, relu4_3 - TensorShape(28U, 28U, 512U), - // relu5_1, relu5_2, relu5_3 - TensorShape(14U, 14U, 512U), - // relu6, relu7 - TensorShape(4096U) }), - framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) - } - { - } - VGG16ActivationLayerDataset(VGG16ActivationLayerDataset &&) = default; - ~VGG16ActivationLayerDataset() = default; -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_VGG16_ACTIVATION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/vgg/vgg16/VGG16ConvolutionLayerDataset.h b/tests/datasets_new/system_tests/vgg/vgg16/VGG16ConvolutionLayerDataset.h deleted file mode 100644 index 4e5b2a6e74..0000000000 --- a/tests/datasets_new/system_tests/vgg/vgg16/VGG16ConvolutionLayerDataset.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_VGG16_CONVOLUTION_LAYER_DATASET -#define ARM_COMPUTE_TEST_VGG16_CONVOLUTION_LAYER_DATASET - -#include "tests/datasets_new/ConvolutionLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class VGG16ConvolutionLayerDataset final : public ConvolutionLayerDataset -{ -public: - VGG16ConvolutionLayerDataset() - { - // conv1_1 - add_config(TensorShape(224U, 224U, 3U), TensorShape(3U, 3U, 3U, 64U), TensorShape(64U), TensorShape(224U, 224U, 64U), PadStrideInfo(1, 1, 1, 1)); - // conv1_2 - add_config(TensorShape(224U, 224U, 64U), TensorShape(3U, 3U, 64U, 64U), TensorShape(64U), TensorShape(224U, 224U, 64U), PadStrideInfo(1, 1, 1, 1)); - // conv2_1 - add_config(TensorShape(112U, 112U, 64U), TensorShape(3U, 3U, 64U, 128U), TensorShape(128U), TensorShape(112U, 112U, 128U), PadStrideInfo(1, 1, 1, 1)); - // conv2_2 - add_config(TensorShape(112U, 112U, 128U), TensorShape(3U, 3U, 128U, 128U), TensorShape(128U), TensorShape(112U, 112U, 128U), PadStrideInfo(1, 1, 1, 1)); - // conv3_1 - add_config(TensorShape(56U, 56U, 128U), TensorShape(3U, 3U, 128U, 256U), TensorShape(256U), TensorShape(56U, 56U, 256U), PadStrideInfo(1, 1, 1, 1)); - // conv3_2, conv3_3 - add_config(TensorShape(56U, 56U, 256U), TensorShape(3U, 3U, 256U, 256U), TensorShape(256U), TensorShape(56U, 56U, 256U), PadStrideInfo(1, 1, 1, 1)); - // conv4_1 - add_config(TensorShape(28U, 28U, 256U), TensorShape(3U, 3U, 256U, 512U), TensorShape(512U), TensorShape(28U, 28U, 512U), PadStrideInfo(1, 1, 1, 1)); - // conv4_2, conv4_3 - add_config(TensorShape(28U, 28U, 512U), TensorShape(3U, 3U, 512U, 512U), TensorShape(512U), TensorShape(28U, 28U, 512U), PadStrideInfo(1, 1, 1, 1)); - // conv5_1, conv5_2, conv5_3 - add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U, 512U), TensorShape(512U), TensorShape(14U, 14U, 512U), PadStrideInfo(1, 1, 1, 1)); - } -}; - -class VGG16DirectConvolutionLayerDataset final : public ConvolutionLayerDataset -{ -public: - VGG16DirectConvolutionLayerDataset() - { - // conv1_1 - add_config(TensorShape(224U, 224U, 3U), TensorShape(3U, 3U, 3U, 64U), TensorShape(64U), TensorShape(224U, 224U, 64U), PadStrideInfo(1, 1, 1, 1)); - // conv1_2 - add_config(TensorShape(224U, 224U, 64U), TensorShape(3U, 3U, 64U, 64U), TensorShape(64U), TensorShape(224U, 224U, 64U), PadStrideInfo(1, 1, 1, 1)); - // conv2_1 - add_config(TensorShape(112U, 112U, 64U), TensorShape(3U, 3U, 64U, 128U), TensorShape(128U), TensorShape(112U, 112U, 128U), PadStrideInfo(1, 1, 1, 1)); - // conv2_2 - add_config(TensorShape(112U, 112U, 128U), TensorShape(3U, 3U, 128U, 128U), TensorShape(128U), TensorShape(112U, 112U, 128U), PadStrideInfo(1, 1, 1, 1)); - // conv3_1 - add_config(TensorShape(56U, 56U, 128U), TensorShape(3U, 3U, 128U, 256U), TensorShape(256U), TensorShape(56U, 56U, 256U), PadStrideInfo(1, 1, 1, 1)); - // conv3_2, conv3_3 - add_config(TensorShape(56U, 56U, 256U), TensorShape(3U, 3U, 256U, 256U), TensorShape(256U), TensorShape(56U, 56U, 256U), PadStrideInfo(1, 1, 1, 1)); - // conv4_1 - add_config(TensorShape(28U, 28U, 256U), TensorShape(3U, 3U, 256U, 512U), TensorShape(512U), TensorShape(28U, 28U, 512U), PadStrideInfo(1, 1, 1, 1)); - // conv4_2, conv4_3 - add_config(TensorShape(28U, 28U, 512U), TensorShape(3U, 3U, 512U, 512U), TensorShape(512U), TensorShape(28U, 28U, 512U), PadStrideInfo(1, 1, 1, 1)); - // conv5_1, conv5_2, conv5_3 - add_config(TensorShape(14U, 14U, 512U), TensorShape(3U, 3U, 512U, 512U), TensorShape(512U), TensorShape(14U, 14U, 512U), PadStrideInfo(1, 1, 1, 1)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_VGG16_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/vgg/vgg16/VGG16FullyConnectedLayerDataset.h b/tests/datasets_new/system_tests/vgg/vgg16/VGG16FullyConnectedLayerDataset.h deleted file mode 100644 index 19d22ba1a5..0000000000 --- a/tests/datasets_new/system_tests/vgg/vgg16/VGG16FullyConnectedLayerDataset.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_VGG16_FULLYCONNECTED_LAYER_DATASET -#define ARM_COMPUTE_TEST_VGG16_FULLYCONNECTED_LAYER_DATASET - -#include "tests/datasets_new/FullyConnectedLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class VGG16FullyConnectedLayerDataset final : public FullyConnectedLayerDataset -{ -public: - VGG16FullyConnectedLayerDataset() - { - // fc6 - add_config(TensorShape(7U, 7U, 512U), TensorShape(25088U, 4096U), TensorShape(4096U), TensorShape(4096U)); - // fc7 - add_config(TensorShape(4096U), TensorShape(4096U, 4096U), TensorShape(4096U), TensorShape(4096U)); - // fc8 - add_config(TensorShape(4096U), TensorShape(4096U, 1000U), TensorShape(1000U), TensorShape(1000U)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_VGG16_FULLYCONNECTED_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/vgg/vgg16/VGG16PoolingLayerDataset.h b/tests/datasets_new/system_tests/vgg/vgg16/VGG16PoolingLayerDataset.h deleted file mode 100644 index fcd9d2f1c3..0000000000 --- a/tests/datasets_new/system_tests/vgg/vgg16/VGG16PoolingLayerDataset.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_VGG16_POOLING_LAYER_DATASET -#define ARM_COMPUTE_TEST_VGG16_POOLING_LAYER_DATASET - -#include "tests/datasets_new/PoolingLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class VGG16PoolingLayerDataset final : public PoolingLayerDataset -{ -public: - VGG16PoolingLayerDataset() - { - // pool1 - add_config(TensorShape(224U, 224U, 64U), TensorShape(112U, 112U, 64U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // pool2 - add_config(TensorShape(112U, 112U, 128U), TensorShape(56U, 56U, 128U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // pool3 - add_config(TensorShape(56U, 56U, 256U), TensorShape(28U, 28U, 256U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // pool4 - add_config(TensorShape(28U, 28U, 512U), TensorShape(14U, 14U, 512U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // pool5 - add_config(TensorShape(14U, 14U, 512U), TensorShape(7U, 7U, 512U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_VGG16_POOLING_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/yolo/v2/YOLOV2ActivationLayerDataset.h b/tests/datasets_new/system_tests/yolo/v2/YOLOV2ActivationLayerDataset.h deleted file mode 100644 index 31327fa0d2..0000000000 --- a/tests/datasets_new/system_tests/yolo/v2/YOLOV2ActivationLayerDataset.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_YOLOV2_ACTIVATION_LAYER_DATASET -#define ARM_COMPUTE_TEST_YOLOV2_ACTIVATION_LAYER_DATASET - -#include "framework/datasets/Datasets.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class YOLOV2ActivationLayerRELUDataset final : public - framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> -{ -public: - YOLOV2ActivationLayerRELUDataset() - : CartesianProductDataset - { - framework::dataset::make("Shape", { // relu1 - TensorShape(416U, 416U, 32U), - // relu2 - TensorShape(208U, 208U, 64U), - // relu3, relu5 - TensorShape(104U, 104U, 128U), - // relu4 - TensorShape(104U, 104U, 64U), - // relu6, relu8 - TensorShape(52U, 52U, 256U), - // relu7 - TensorShape(52U, 52U, 128U), - // relu9, relu11, relu13 - TensorShape(26U, 26U, 512U), - // relu10, relu12 - TensorShape(26U, 26U, 256U), - // relu14, relu16, relu18, relu19, relu20, relu21 - TensorShape(13U, 13U, 1024U), - // relu15, relu17 - TensorShape(13U, 13U, 512U) }), - framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) - } - { - } - YOLOV2ActivationLayerRELUDataset(YOLOV2ActivationLayerRELUDataset &&) = default; - ~YOLOV2ActivationLayerRELUDataset() = default; -}; - -class YOLOV2ActivationLayerLINEARDataset final : public - framework::dataset::CartesianProductDataset, framework::dataset::SingletonDataset> -{ -public: - YOLOV2ActivationLayerLINEARDataset() - : CartesianProductDataset - { - framework::dataset::make("Shape", { // linear22 - TensorShape(15U, 15U, 425U) }), - framework::dataset::make("Info", ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LINEAR)) - } - { - } - YOLOV2ActivationLayerLINEARDataset(YOLOV2ActivationLayerLINEARDataset &&) = default; - ~YOLOV2ActivationLayerLINEARDataset() = default; -}; - -class YOLOV2ActivationLayerDataset final : public framework::dataset::JoinDataset -{ -public: - YOLOV2ActivationLayerDataset() - : JoinDataset - { - YOLOV2ActivationLayerRELUDataset(), - YOLOV2ActivationLayerLINEARDataset() - } - { - } - YOLOV2ActivationLayerDataset(YOLOV2ActivationLayerDataset &&) = default; - ~YOLOV2ActivationLayerDataset() = default; -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_YOLOV2_ACTIVATION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/yolo/v2/YOLOV2BatchNormalizationLayerDataset.h b/tests/datasets_new/system_tests/yolo/v2/YOLOV2BatchNormalizationLayerDataset.h deleted file mode 100644 index 8cb69db869..0000000000 --- a/tests/datasets_new/system_tests/yolo/v2/YOLOV2BatchNormalizationLayerDataset.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_YOLOV2_BATCHNORMALIZATION_LAYER_DATASET -#define ARM_COMPUTE_TEST_YOLOV2_BATCHNORMALIZATION_LAYER_DATASET - -#include "tests/datasets_new/BatchNormalizationLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class YOLOV2BatchNormalizationLayerDataset final : public BatchNormalizationLayerDataset -{ -public: - YOLOV2BatchNormalizationLayerDataset() - { - // conv1_bn - add_config(TensorShape(416U, 416U, 32U), TensorShape(32U), 0.00001f); - // conv2_bn - add_config(TensorShape(208U, 208U, 64U), TensorShape(64U), 0.00001f); - // conv3_bn, conv5_bn - add_config(TensorShape(104U, 104U, 128U), TensorShape(128U), 0.00001f); - // conv4_bn - add_config(TensorShape(104U, 104U, 64U), TensorShape(64U), 0.00001f); - // conv6_bn, conv8_bn - add_config(TensorShape(52U, 52U, 256U), TensorShape(256U), 0.00001f); - // conv7_bn - add_config(TensorShape(52U, 52U, 128U), TensorShape(128U), 0.00001f); - // conv9_bn, conv11_bn, conv13_bn - add_config(TensorShape(26U, 26U, 512U), TensorShape(512U), 0.00001f); - // conv10_bn, conv12_bn - add_config(TensorShape(26U, 26U, 256U), TensorShape(256U), 0.00001f); - // conv14_bn, conv16_bn, conv18_bn, conv19_bn, conv20_bn, conv21_bn - add_config(TensorShape(13U, 13U, 1024U), TensorShape(1024U), 0.00001f); - // conv15_bn, conv17_bn - add_config(TensorShape(13U, 13U, 512U), TensorShape(512U), 0.00001f); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_YOLOV2_BATCHNORMALIZATION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/yolo/v2/YOLOV2ConvolutionLayerDataset.h b/tests/datasets_new/system_tests/yolo/v2/YOLOV2ConvolutionLayerDataset.h deleted file mode 100644 index ad3c38570e..0000000000 --- a/tests/datasets_new/system_tests/yolo/v2/YOLOV2ConvolutionLayerDataset.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_YOLOV2_CONVOLUTION_LAYER_DATASET -#define ARM_COMPUTE_TEST_YOLOV2_CONVOLUTION_LAYER_DATASET - -#include "tests/datasets_new/ConvolutionLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class YOLOV2ConvolutionLayerDataset final : public ConvolutionLayerDataset -{ -public: - YOLOV2ConvolutionLayerDataset() - { - // conv1 - add_config(TensorShape(416U, 416U, 3U), TensorShape(3U, 3U, 3U, 32U), TensorShape(32U), TensorShape(416U, 416U, 32U), PadStrideInfo(1, 1, 1, 1)); - // conv2 - add_config(TensorShape(208U, 208U, 32U), TensorShape(3U, 3U, 32U, 64U), TensorShape(64U), TensorShape(208U, 208U, 64U), PadStrideInfo(1, 1, 1, 1)); - // conv3, conv5 - add_config(TensorShape(104U, 104U, 64U), TensorShape(3U, 3U, 64U, 128U), TensorShape(128U), TensorShape(104U, 104U, 128U), PadStrideInfo(1, 1, 1, 1)); - // conv4 - add_config(TensorShape(104U, 104U, 128U), TensorShape(1U, 1U, 128U, 64U), TensorShape(64U), TensorShape(104U, 104U, 64U), PadStrideInfo(1, 1, 0, 0)); - // conv6, conv8 - add_config(TensorShape(52U, 52U, 128U), TensorShape(3U, 3U, 128U, 256U), TensorShape(256U), TensorShape(52U, 52U, 256U), PadStrideInfo(1, 1, 1, 1)); - // conv7 - add_config(TensorShape(52U, 52U, 256U), TensorShape(1U, 1U, 256U, 128U), TensorShape(128U), TensorShape(52U, 52U, 128U), PadStrideInfo(1, 1, 0, 0)); - // conv9, conv11, conv13 - add_config(TensorShape(26U, 26U, 256U), TensorShape(3U, 3U, 256U, 512U), TensorShape(512U), TensorShape(26U, 26U, 512U), PadStrideInfo(1, 1, 1, 1)); - // conv10, conv12 - add_config(TensorShape(26U, 26U, 512U), TensorShape(1U, 1U, 512U, 256U), TensorShape(256U), TensorShape(26U, 26U, 256U), PadStrideInfo(1, 1, 0, 0)); - // conv14, conv16, conv18 - add_config(TensorShape(13U, 13U, 512U), TensorShape(3U, 3U, 512U, 1024U), TensorShape(1024U), TensorShape(13U, 13U, 1024U), PadStrideInfo(1, 1, 1, 1)); - // conv15, conv17 - add_config(TensorShape(13U, 13U, 1024U), TensorShape(1U, 1U, 1024U, 512U), TensorShape(512U), TensorShape(13U, 13U, 512U), PadStrideInfo(1, 1, 0, 0)); - // conv19, conv20 - add_config(TensorShape(13U, 13U, 1024U), TensorShape(3U, 3U, 1024U, 1024U), TensorShape(1024U), TensorShape(13U, 13U, 1024U), PadStrideInfo(1, 1, 1, 1)); - // conv21 - add_config(TensorShape(13U, 13U, 3072U), TensorShape(3U, 3U, 3072U, 1024U), TensorShape(1024U), TensorShape(13U, 13U, 1024U), PadStrideInfo(1, 1, 1, 1)); - // conv22 - add_config(TensorShape(13U, 13U, 1024U), TensorShape(1U, 1U, 1024U, 425U), TensorShape(425U), TensorShape(15U, 15U, 425U), PadStrideInfo(1, 1, 1, 1)); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_YOLOV2_CONVOLUTION_LAYER_DATASET */ diff --git a/tests/datasets_new/system_tests/yolo/v2/YOLOV2PoolingLayerDataset.h b/tests/datasets_new/system_tests/yolo/v2/YOLOV2PoolingLayerDataset.h deleted file mode 100644 index 273409dec6..0000000000 --- a/tests/datasets_new/system_tests/yolo/v2/YOLOV2PoolingLayerDataset.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_YOLOV2_POOLING_LAYER_DATASET -#define ARM_COMPUTE_TEST_YOLOV2_POOLING_LAYER_DATASET - -#include "tests/datasets_new/PoolingLayerDataset.h" - -#include "tests/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class YOLOV2PoolingLayerDataset final : public PoolingLayerDataset -{ -public: - YOLOV2PoolingLayerDataset() - { - // pool1 - add_config(TensorShape(416U, 416U, 32U), TensorShape(208U, 208U, 32U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // pool2 - add_config(TensorShape(208U, 208U, 64U), TensorShape(104U, 104U, 64U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // pool5 - add_config(TensorShape(104U, 104U, 128U), TensorShape(52U, 52U, 128U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // pool8 - add_config(TensorShape(52U, 52U, 256U), TensorShape(26U, 26U, 256U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - // pool13 - add_config(TensorShape(26U, 26U, 512U), TensorShape(13U, 13U, 512U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))); - } -}; -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_YOLOV2_POOLING_LAYER_DATASET */ diff --git a/tests/fixtures_new/ActivationLayerFixture.h b/tests/fixtures_new/ActivationLayerFixture.h deleted file mode 100644 index 5066810c79..0000000000 --- a/tests/fixtures_new/ActivationLayerFixture.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_ACTIVATIONLAYERFIXTURE -#define ARM_COMPUTE_TEST_ACTIVATIONLAYERFIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Fixture.h" -#include "tests/Globals.h" -#include "tests/Utils.h" - -namespace arm_compute -{ -namespace test -{ -/** Fixture that can be used for NEON and CL */ -template -class ActivationLayerFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, ActivationLayerInfo info, DataType data_type, int batches) - { - // Set batched in source and destination shapes - shape.set(shape.num_dimensions(), batches); - - // Create tensors - const int fixed_point_position = 4; - src = create_tensor(shape, data_type, 1, fixed_point_position); - dst = create_tensor(shape, data_type, 1, fixed_point_position); - - // Create and configure function - act_layer.configure(&src, &dst, info); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - } - - void run() - { - act_layer.run(); - } - - void teardown() - { - src.allocator()->free(); - dst.allocator()->free(); - } - -private: - TensorType src{}; - TensorType dst{}; - Function act_layer{}; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ACTIVATIONLAYERFIXTURE */ diff --git a/tests/fixtures_new/AlexNetFixture.h b/tests/fixtures_new/AlexNetFixture.h deleted file mode 100644 index 0fbc1b77e3..0000000000 --- a/tests/fixtures_new/AlexNetFixture.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_ALEXNETFIXTURE -#define ARM_COMPUTE_TEST_ALEXNETFIXTURE - -#include "framework/Fixture.h" -#include "networks_new/AlexNetNetwork.h" -#include "tests/AssetsLibrary.h" -#include "tests/Utils.h" - -namespace arm_compute -{ -namespace test -{ -template - -class AlexNetFixture : public framework::Fixture -{ -public: - template - void setup(DataType data_type, int batches) - { - constexpr bool weights_reshaped = true; - constexpr int fixed_point_position = 4; - - network.init(data_type, fixed_point_position, batches, weights_reshaped); - network.build(); - network.allocate(); - network.fill_random(); - } - - void run() - { - network.run(); - } - - void teardown() - { - network.clear(); - } - -private: - networks::AlexNetNetwork - network{}; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ALEXNETFIXTURE */ diff --git a/tests/fixtures_new/BatchNormalizationLayerFixture.h b/tests/fixtures_new/BatchNormalizationLayerFixture.h deleted file mode 100644 index 39c80e5405..0000000000 --- a/tests/fixtures_new/BatchNormalizationLayerFixture.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_BATCHNORMALIZATIONLAYERFIXTURE -#define ARM_COMPUTE_TEST_BATCHNORMALIZATIONLAYERFIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Fixture.h" -#include "tests/Globals.h" -#include "tests/Utils.h" - -namespace arm_compute -{ -namespace test -{ -/** Fixture that can be used for NEON and CL */ -template -class BatchNormalizationLayerFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape tensor_shape, TensorShape param_shape, float epsilon, DataType data_type, int batches) - { - // Set batched in source and destination shapes - const unsigned int fixed_point_position = 4; - tensor_shape.set(tensor_shape.num_dimensions(), batches); - - // Create tensors - src = create_tensor(tensor_shape, data_type, 1, fixed_point_position); - dst = create_tensor(tensor_shape, data_type, 1, fixed_point_position); - mean = create_tensor(param_shape, data_type, 1, fixed_point_position); - variance = create_tensor(param_shape, data_type, 1, fixed_point_position); - beta = create_tensor(param_shape, data_type, 1, fixed_point_position); - gamma = create_tensor(param_shape, data_type, 1, fixed_point_position); - - // Create and configure function - batch_norm_layer.configure(&src, &dst, &mean, &variance, &beta, &gamma, epsilon); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - mean.allocator()->allocate(); - variance.allocator()->allocate(); - beta.allocator()->allocate(); - gamma.allocator()->allocate(); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - library->fill_tensor_uniform(Accessor(mean), 1); - library->fill_tensor_uniform(Accessor(variance), 2); - library->fill_tensor_uniform(Accessor(beta), 3); - library->fill_tensor_uniform(Accessor(gamma), 4); - } - - void run() - { - batch_norm_layer.run(); - } - - void teardown() - { - src.allocator()->free(); - dst.allocator()->free(); - mean.allocator()->free(); - variance.allocator()->free(); - beta.allocator()->free(); - gamma.allocator()->free(); - } - -private: - TensorType src{}; - TensorType dst{}; - TensorType mean{}; - TensorType variance{}; - TensorType beta{}; - TensorType gamma{}; - Function batch_norm_layer{}; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_BATCHNORMALIZATIONLAYERFIXTURE */ diff --git a/tests/fixtures_new/ConvolutionLayerFixture.h b/tests/fixtures_new/ConvolutionLayerFixture.h deleted file mode 100644 index f41cd1d25e..0000000000 --- a/tests/fixtures_new/ConvolutionLayerFixture.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_CONVOLUTIONLAYERFIXTURE -#define ARM_COMPUTE_TEST_CONVOLUTIONLAYERFIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Fixture.h" -#include "tests/Globals.h" -#include "tests/Utils.h" - -namespace arm_compute -{ -namespace test -{ -/** Fixture that can be used for NEON and CL */ -template -class ConvolutionLayerFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape src_shape, TensorShape weights_shape, TensorShape biases_shape, TensorShape dst_shape, PadStrideInfo info, DataType data_type, int batches) - { - // Set batched in source and destination shapes - const unsigned int fixed_point_position = 4; - src_shape.set(3 /* batch */, batches); - dst_shape.set(3 /* batch */, batches); - - // Create tensors - src = create_tensor(src_shape, data_type, 1, fixed_point_position); - weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); - biases = create_tensor(biases_shape, data_type, 1, fixed_point_position); - dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); - - // Create and configure function - conv_layer.configure(&src, &weights, &biases, &dst, info); - - // Allocate tensors - src.allocator()->allocate(); - weights.allocator()->allocate(); - biases.allocator()->allocate(); - dst.allocator()->allocate(); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - library->fill_tensor_uniform(Accessor(weights), 1); - library->fill_tensor_uniform(Accessor(biases), 2); - } - - void run() - { - conv_layer.run(); - } - - void teardown() - { - src.allocator()->free(); - weights.allocator()->free(); - biases.allocator()->free(); - dst.allocator()->free(); - } - -private: - TensorType src{}; - TensorType weights{}; - TensorType biases{}; - TensorType dst{}; - Function conv_layer{}; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_CONVOLUTIONLAYERFIXTURE */ diff --git a/tests/fixtures_new/DepthwiseConvolutionFixture.h b/tests/fixtures_new/DepthwiseConvolutionFixture.h deleted file mode 100644 index 8223c210d4..0000000000 --- a/tests/fixtures_new/DepthwiseConvolutionFixture.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DEPTHWISECONVOLUTIONFIXTURE -#define ARM_COMPUTE_TEST_DEPTHWISECONVOLUTIONFIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Fixture.h" -#include "tests/Globals.h" -#include "tests/Utils.h" - -namespace arm_compute -{ -namespace test -{ -/** Fixture that can be used for NEON and CL */ -template -class DepthwiseConvolutionFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape src_shape, TensorShape weights_shape, TensorShape dst_shape, PadStrideInfo info, DataType data_type, int batches) - { - // Set batched in source and destination shapes - const unsigned int fixed_point_position = 4; - src_shape.set(3 /* batch */, batches); - dst_shape.set(3 /* batch */, batches); - - // Create tensors - src = create_tensor(src_shape, data_type, 1, fixed_point_position); - weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); - dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); - - // Create and configure function - depth_conv.configure(&src, &dst, &weights, info); - - // Allocate tensors - src.allocator()->allocate(); - weights.allocator()->allocate(); - dst.allocator()->allocate(); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - library->fill_tensor_uniform(Accessor(weights), 1); - } - - void run() - { - depth_conv.run(); - } - - void teardown() - { - src.allocator()->free(); - weights.allocator()->free(); - dst.allocator()->free(); - } - -private: - TensorType src{}; - TensorType weights{}; - TensorType dst{}; - Function depth_conv{}; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DEPTHWISECONVOLUTIONFIXTURE */ diff --git a/tests/fixtures_new/DepthwiseSeparableConvolutionLayerFixture.h b/tests/fixtures_new/DepthwiseSeparableConvolutionLayerFixture.h deleted file mode 100644 index c4ace2ba1c..0000000000 --- a/tests/fixtures_new/DepthwiseSeparableConvolutionLayerFixture.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DEPTHWISESEPARABLECONVOLUTIONLAYERFIXTURE -#define ARM_COMPUTE_TEST_DEPTHWISESEPARABLECONVOLUTIONLAYERFIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Fixture.h" -#include "tests/Globals.h" -#include "tests/Utils.h" - -namespace arm_compute -{ -namespace test -{ -/** Fixture that can be used for NEON and CL */ -template -class DepthwiseSeparableConvolutionLayerFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape src_shape, TensorShape depthwise_weights_shape, TensorShape depthwise_out_shape, TensorShape pointwise_weights_shape, TensorShape biases_shape, TensorShape dst_shape, - PadStrideInfo pad_stride_depthwise_info, PadStrideInfo pad_stride_pointwise_info, DataType data_type, int batches) - { - // Set batched in source and destination shapes - const unsigned int fixed_point_position = 4; - src_shape.set(3 /* batch */, batches); - depthwise_out_shape.set(3 /* batch */, batches); - dst_shape.set(3 /* batch */, batches); - - src = create_tensor(src_shape, data_type, 1, fixed_point_position); - depthwise_weights = create_tensor(depthwise_weights_shape, data_type, 1, fixed_point_position); - depthwise_out = create_tensor(depthwise_out_shape, data_type, 1, fixed_point_position); - pointwise_weights = create_tensor(pointwise_weights_shape, data_type, 1, fixed_point_position); - biases = create_tensor(biases_shape, data_type, 1, fixed_point_position); - dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); - - // Create and configure function - depth_sep_conv_layer.configure(&src, &depthwise_weights, &depthwise_out, &pointwise_weights, &biases, &dst, pad_stride_depthwise_info, pad_stride_pointwise_info); - - // Allocate tensors - src.allocator()->allocate(); - depthwise_weights.allocator()->allocate(); - depthwise_out.allocator()->allocate(); - pointwise_weights.allocator()->allocate(); - biases.allocator()->allocate(); - dst.allocator()->allocate(); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - library->fill_tensor_uniform(Accessor(depthwise_weights), 1); - library->fill_tensor_uniform(Accessor(pointwise_weights), 2); - library->fill_tensor_uniform(Accessor(biases), 3); - } - - void run() - { - depth_sep_conv_layer.run(); - } - - void teardown() - { - src.allocator()->free(); - depthwise_weights.allocator()->free(); - depthwise_out.allocator()->free(); - pointwise_weights.allocator()->free(); - biases.allocator()->free(); - dst.allocator()->free(); - } - -private: - TensorType src{}; - TensorType depthwise_weights{}; - TensorType depthwise_out{}; - TensorType pointwise_weights{}; - TensorType biases{}; - TensorType dst{}; - Function depth_sep_conv_layer{}; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DEPTHWISESEPARABLECONVOLUTIONLAYERFIXTURE */ diff --git a/tests/fixtures_new/FloorFixture.h b/tests/fixtures_new/FloorFixture.h deleted file mode 100644 index 145b623bdb..0000000000 --- a/tests/fixtures_new/FloorFixture.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_FLOORFIXTURE -#define ARM_COMPUTE_TEST_FLOORFIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Fixture.h" -#include "tests/Globals.h" -#include "tests/Utils.h" - -namespace arm_compute -{ -namespace test -{ -/** Fixture that can be used for NEON and CL */ -template -class FloorFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - // Create tensors - src = create_tensor(shape, data_type); - dst = create_tensor(shape, data_type); - - // Create and configure function - floor_func.configure(&src, &dst); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - } - - void run() - { - floor_func.run(); - } - - void teardown() - { - src.allocator()->free(); - dst.allocator()->free(); - } - -private: - TensorType src{}; - TensorType dst{}; - Function floor_func{}; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_FLOORFIXTURE */ diff --git a/tests/fixtures_new/FullyConnectedLayerFixture.h b/tests/fixtures_new/FullyConnectedLayerFixture.h deleted file mode 100644 index 82ecb39b9c..0000000000 --- a/tests/fixtures_new/FullyConnectedLayerFixture.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_FULLYCONNECTEDLAYERFIXTURE -#define ARM_COMPUTE_TEST_FULLYCONNECTEDLAYERFIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Fixture.h" -#include "tests/Globals.h" -#include "tests/Utils.h" - -namespace arm_compute -{ -namespace test -{ -/** Fixture that can be used for NEON and CL */ -template -class FullyConnectedLayerFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape src_shape, TensorShape weights_shape, TensorShape biases_shape, TensorShape dst_shape, DataType data_type, int batches) - { - // Set batched in source and destination shapes - const unsigned int fixed_point_position = 4; - src_shape.set(src_shape.num_dimensions() /* batch */, batches); - dst_shape.set(dst_shape.num_dimensions() /* batch */, batches); - - // Create tensors - src = create_tensor(src_shape, data_type, 1, fixed_point_position); - weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); - biases = create_tensor(biases_shape, data_type, 1, fixed_point_position); - dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); - - // Create and configure function - fc_layer.configure(&src, &weights, &biases, &dst); - - // Allocate tensors - src.allocator()->allocate(); - weights.allocator()->allocate(); - biases.allocator()->allocate(); - dst.allocator()->allocate(); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - library->fill_tensor_uniform(Accessor(weights), 1); - library->fill_tensor_uniform(Accessor(biases), 2); - } - - void run() - { - fc_layer.run(); - } - - void teardown() - { - src.allocator()->free(); - weights.allocator()->free(); - biases.allocator()->free(); - dst.allocator()->free(); - } - -private: - TensorType src{}; - TensorType weights{}; - TensorType biases{}; - TensorType dst{}; - Function fc_layer{}; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_FULLYCONNECTEDLAYERFIXTURE */ diff --git a/tests/fixtures_new/GEMMFixture.h b/tests/fixtures_new/GEMMFixture.h deleted file mode 100644 index 669a91f0cb..0000000000 --- a/tests/fixtures_new/GEMMFixture.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GEMMFIXTURE -#define ARM_COMPUTE_TEST_GEMMFIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Fixture.h" -#include "tests/Globals.h" -#include "tests/Utils.h" - -namespace arm_compute -{ -namespace test -{ -/** Fixture that can be used for NEON and CL */ -template -class GEMMFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape_a, TensorShape shape_b, TensorShape shape_c, TensorShape shape_dst, float alpha, float beta, DataType data_type) - { - constexpr int fixed_point_position = 4; - - // Create tensors - a = create_tensor(shape_a, data_type, 1, fixed_point_position); - b = create_tensor(shape_b, data_type, 1, fixed_point_position); - c = create_tensor(shape_c, data_type, 1, fixed_point_position); - dst = create_tensor(shape_dst, data_type, 1, fixed_point_position); - - // Create and configure function - gemm.configure(&a, &b, &c, &dst, alpha, beta); - - // Allocate tensors - a.allocator()->allocate(); - b.allocator()->allocate(); - c.allocator()->allocate(); - dst.allocator()->allocate(); - - library->fill_tensor_uniform(Accessor(a), 0); - library->fill_tensor_uniform(Accessor(b), 1); - library->fill_tensor_uniform(Accessor(c), 2); - } - - void run() - { - gemm.run(); - } - - void teardown() - { - a.allocator()->free(); - b.allocator()->free(); - c.allocator()->free(); - dst.allocator()->free(); - } - -private: - TensorType a{}; - TensorType b{}; - TensorType c{}; - TensorType dst{}; - Function gemm{}; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GEMMFIXTURE */ diff --git a/tests/fixtures_new/LeNet5Fixture.h b/tests/fixtures_new/LeNet5Fixture.h deleted file mode 100644 index 9a2590b39b..0000000000 --- a/tests/fixtures_new/LeNet5Fixture.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_LENET5FIXTURE -#define ARM_COMPUTE_TEST_LENET5FIXTURE - -#include "framework/Fixture.h" -#include "networks_new/LeNet5Network.h" -#include "tests/AssetsLibrary.h" -#include "tests/Utils.h" - -namespace arm_compute -{ -namespace test -{ -template -class LeNet5Fixture : public framework::Fixture -{ -public: - template - void setup(int batches) - { - network.init(batches); - network.build(); - network.allocate(); - network.fill_random(); - } - - void run() - { - network.run(); - } - - void teardown() - { - network.clear(); - } - -private: - networks::LeNet5Network - network{}; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_LENET5FIXTURE */ diff --git a/tests/fixtures_new/NormalizationLayerFixture.h b/tests/fixtures_new/NormalizationLayerFixture.h deleted file mode 100644 index 999eed6cff..0000000000 --- a/tests/fixtures_new/NormalizationLayerFixture.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_NORMALIZATIONLAYERFIXTURE -#define ARM_COMPUTE_TEST_NORMALIZATIONLAYERFIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Fixture.h" -#include "tests/Globals.h" -#include "tests/Utils.h" - -namespace arm_compute -{ -namespace test -{ -/** Fixture that can be used for NEON and CL */ -template -class NormalizationLayerFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, NormalizationLayerInfo info, DataType data_type, int batches) - { - // Set batched in source and destination shapes - const unsigned int fixed_point_position = 4; - shape.set(shape.num_dimensions(), batches); - - // Create tensors - src = create_tensor(shape, data_type, 1, fixed_point_position); - dst = create_tensor(shape, data_type, 1, fixed_point_position); - - // Create and configure function - norm_layer.configure(&src, &dst, info); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - } - - void run() - { - norm_layer.run(); - } - - void teardown() - { - src.allocator()->free(); - dst.allocator()->free(); - } - -private: - TensorType src{}; - TensorType dst{}; - Function norm_layer{}; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_NORMALIZATIONLAYERFIXTURE */ diff --git a/tests/fixtures_new/PoolingLayerFixture.h b/tests/fixtures_new/PoolingLayerFixture.h deleted file mode 100644 index fc9c90ae3c..0000000000 --- a/tests/fixtures_new/PoolingLayerFixture.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_POOLINGLAYERFIXTURE -#define ARM_COMPUTE_TEST_POOLINGLAYERFIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Fixture.h" -#include "tests/Globals.h" -#include "tests/Utils.h" - -namespace arm_compute -{ -namespace test -{ -/** Fixture that can be used for NEON and CL */ -template -class PoolingLayerFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape src_shape, TensorShape dst_shape, PoolingLayerInfo info, DataType data_type, int batches) - { - // Set batched in source and destination shapes - const unsigned int fixed_point_position = 4; - src_shape.set(src_shape.num_dimensions(), batches); - dst_shape.set(dst_shape.num_dimensions(), batches); - - // Create tensors - src = create_tensor(src_shape, data_type, 1, fixed_point_position); - dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); - - // Create and configure function - pool_layer.configure(&src, &dst, info); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - } - - void run() - { - pool_layer.run(); - } - - void teardown() - { - src.allocator()->free(); - dst.allocator()->free(); - } - -private: - TensorType src{}; - TensorType dst{}; - Function pool_layer{}; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_POOLINGLAYERFIXTURE */ diff --git a/tests/fixtures_new/ROIPoolingLayerFixture.h b/tests/fixtures_new/ROIPoolingLayerFixture.h deleted file mode 100644 index 54dac51ee4..0000000000 --- a/tests/fixtures_new/ROIPoolingLayerFixture.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_ROIPOOLINGLAYERFIXTURE -#define ARM_COMPUTE_TEST_ROIPOOLINGLAYERFIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Fixture.h" -#include "tests/Globals.h" -#include "tests/Utils.h" - -#include - -namespace arm_compute -{ -namespace test -{ -/** Fixture that can be used for NEON and CL */ -template -class ROIPoolingLayerFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, const ROIPoolingLayerInfo pool_info, unsigned int num_rois, DataType data_type, int batches) - { - // Set batched in source and destination shapes - const unsigned int fixed_point_position = 4; - TensorShape shape_dst; - shape.set(shape.num_dimensions(), batches); - shape_dst.set(0, pool_info.pooled_width()); - shape_dst.set(1, pool_info.pooled_height()); - shape_dst.set(2, shape.z()); - shape_dst.set(3, num_rois); - - // Create tensors - src = create_tensor(shape, data_type, 1, fixed_point_position); - dst = create_tensor(shape_dst, data_type, 1, fixed_point_position); - - // Create random ROIs - std::vector rois = generate_random_rois(shape, pool_info, num_rois, 0U); - rois_array = arm_compute::support::cpp14::make_unique(num_rois); - fill_array(ArrayAccessor(*rois_array), rois); - - // Create and configure function - roi_pool.configure(&src, rois_array.get(), &dst, pool_info); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - } - - void run() - { - roi_pool.run(); - } - - void teardown() - { - src.allocator()->free(); - dst.allocator()->free(); - } - -private: - TensorType src{}; - TensorType dst{}; - std::unique_ptr rois_array{}; - Function roi_pool{}; -}; -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ROIPOOLINGLAYERFIXTURE */ diff --git a/tests/framework/Asserts.h b/tests/framework/Asserts.h new file mode 100644 index 0000000000..b545a9ebba --- /dev/null +++ b/tests/framework/Asserts.h @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_FRAMEWORK_ASSERTS +#define ARM_COMPUTE_TEST_FRAMEWORK_ASSERTS + +#include "Exceptions.h" +#include "Framework.h" + +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +// Cast char values to int so that their numeric value are printed. +inline int make_printable(int8_t value) +{ + return value; +} + +inline unsigned int make_printable(uint8_t value) +{ + return value; +} + +// Everything else can be printed as its own type. +template +inline T make_printable(T &&value) +{ + return value; +} + +#define ARM_COMPUTE_TEST_INFO(INFO) \ + { \ + std::stringstream info; \ + info << INFO; \ + arm_compute::test::framework::Framework::get().add_test_info(info.str()); \ + } + +namespace detail +{ +#define ARM_COMPUTE_TEST_COMP_FACTORY(SEVERITY, SEVERITY_NAME, COMP, COMP_NAME, ERROR_CALL) \ + template \ + void ARM_COMPUTE_##SEVERITY##_##COMP_NAME##_IMPL(T &&x, U &&y, const std::string &x_str, const std::string &y_str, LogLevel level) \ + { \ + if(!(x COMP y)) \ + { \ + std::stringstream msg; \ + msg << #SEVERITY_NAME " '" << x_str << " " #COMP " " << y_str << "' failed. [" \ + << std::boolalpha << arm_compute::test::framework::make_printable(x) \ + << " " #COMP " " \ + << std::boolalpha << arm_compute::test::framework::make_printable(y) \ + << "]\n"; \ + arm_compute::test::framework::Framework::get().print_test_info(msg); \ + ERROR_CALL \ + } \ + arm_compute::test::framework::Framework::get().clear_test_info(); \ + } + +ARM_COMPUTE_TEST_COMP_FACTORY(EXPECT, Expectation, ==, EQUAL, arm_compute::test::framework::Framework::get().log_failed_expectation(arm_compute::test::framework::TestError(msg.str(), level));) +ARM_COMPUTE_TEST_COMP_FACTORY(EXPECT, Expectation, !=, NOT_EQUAL, arm_compute::test::framework::Framework::get().log_failed_expectation(arm_compute::test::framework::TestError(msg.str(), level));) +ARM_COMPUTE_TEST_COMP_FACTORY(ASSERT, Assertion, ==, EQUAL, throw arm_compute::test::framework::TestError(msg.str(), level);) +ARM_COMPUTE_TEST_COMP_FACTORY(ASSERT, Assertion, !=, NOT_EQUAL, throw arm_compute::test::framework::TestError(msg.str(), level);) +} // namespace detail + +#define ARM_COMPUTE_ASSERT_NOT_EQUAL(X, Y) \ + arm_compute::test::framework::detail::ARM_COMPUTE_ASSERT_NOT_EQUAL_IMPL(X, Y, #X, #Y, LogLevel::ERRORS) + +#define ARM_COMPUTE_ASSERT_EQUAL(X, Y) \ + arm_compute::test::framework::detail::ARM_COMPUTE_ASSERT_EQUAL_IMPL(X, Y, #X, #Y, LogLevel::ERRORS) + +#define ARM_COMPUTE_EXPECT_EQUAL(X, Y, LEVEL) \ + arm_compute::test::framework::detail::ARM_COMPUTE_EXPECT_EQUAL_IMPL(X, Y, #X, #Y, LEVEL) + +#define ARM_COMPUTE_EXPECT_NOT_EQUAL(X, Y, LEVEL) \ + arm_compute::test::framework::detail::ARM_COMPUTE_EXPECT_NOT_EQUAL_IMPL(X, Y, #X, #Y, LEVEL) + +#define ARM_COMPUTE_ASSERT(X) \ + do \ + { \ + const auto &x = X; \ + if(!x) \ + { \ + std::stringstream msg; \ + msg << "Assertion '" #X "' failed.\n"; \ + arm_compute::test::framework::Framework::get().print_test_info(msg); \ + throw arm_compute::test::framework::TestError(msg.str(), arm_compute::test::framework::LogLevel::ERRORS); \ + } \ + arm_compute::test::framework::Framework::get().clear_test_info(); \ + } while(false) + +#define ARM_COMPUTE_EXPECT(X, LEVEL) \ + do \ + { \ + const auto &x = X; \ + if(!x) \ + { \ + std::stringstream msg; \ + msg << "Expectation '" #X "' failed.\n"; \ + arm_compute::test::framework::Framework::get().print_test_info(msg); \ + arm_compute::test::framework::Framework::get().log_failed_expectation(arm_compute::test::framework::TestError(msg.str(), LEVEL)); \ + } \ + arm_compute::test::framework::Framework::get().clear_test_info(); \ + } while(false) +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_FRAMEWORK_ASSERTS */ diff --git a/tests/framework/DatasetModes.cpp b/tests/framework/DatasetModes.cpp new file mode 100644 index 0000000000..3f747df747 --- /dev/null +++ b/tests/framework/DatasetModes.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "DatasetModes.h" + +#include "Utils.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +DatasetMode dataset_mode_from_name(const std::string &name) +{ + static const std::map modes = + { + { "all", DatasetMode::ALL }, + { "precommit", DatasetMode::PRECOMMIT }, + { "nightly", DatasetMode::NIGHTLY }, + }; + + try + { + return modes.at(tolower(name)); + } + catch(const std::out_of_range &) + { + throw std::invalid_argument(name); + } +} +} // namespace framework +} // namespace test +} // namespace arm_compute diff --git a/tests/framework/DatasetModes.h b/tests/framework/DatasetModes.h new file mode 100644 index 0000000000..27638b0504 --- /dev/null +++ b/tests/framework/DatasetModes.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DATASET_MODES +#define ARM_COMPUTE_TEST_DATASET_MODES + +#include +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Possible dataset modes. */ +enum class DatasetMode : unsigned int +{ + ALL = ~0U, + DISABLED = 0, + PRECOMMIT = 1, + NIGHTLY = 2 +}; + +inline DatasetMode operator&(DatasetMode t1, DatasetMode t2) +{ + using type = std::underlying_type::type; + return static_cast(static_cast(t1) & static_cast(t2)); +} + +inline DatasetMode operator|(DatasetMode t1, DatasetMode t2) +{ + using type = std::underlying_type::type; + return static_cast(static_cast(t1) | static_cast(t2)); +} + +inline DatasetMode &operator|=(DatasetMode &t1, DatasetMode t2) +{ + using type = std::underlying_type::type; + t1 = static_cast(static_cast(t1) | static_cast(t2)); + return t1; +} + +DatasetMode dataset_mode_from_name(const std::string &name); + +inline ::std::istream &operator>>(::std::istream &stream, DatasetMode &mode) +{ + std::string value; + stream >> value; + mode = dataset_mode_from_name(value); + return stream; +} + +inline ::std::ostream &operator<<(::std::ostream &stream, DatasetMode mode) +{ + switch(mode) + { + case DatasetMode::PRECOMMIT: + stream << "PRECOMMIT"; + break; + case DatasetMode::NIGHTLY: + stream << "NIGHTLY"; + break; + case DatasetMode::ALL: + stream << "ALL"; + break; + default: + throw std::invalid_argument("Unsupported dataset mode"); + } + + return stream; +} + +inline std::string to_string(DatasetMode mode) +{ + std::stringstream stream; + stream << mode; + return stream.str(); +} +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DATASET_MODES */ diff --git a/tests/framework/Exceptions.cpp b/tests/framework/Exceptions.cpp new file mode 100644 index 0000000000..3d6c65c181 --- /dev/null +++ b/tests/framework/Exceptions.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "Exceptions.h" + +#include "Utils.h" + +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +LogLevel log_level_from_name(const std::string &name) +{ + static const std::map levels = + { + { "none", LogLevel::NONE }, + { "config", LogLevel::CONFIG }, + { "tests", LogLevel::TESTS }, + { "errors", LogLevel::ERRORS }, + { "debug", LogLevel::DEBUG }, + { "measurements", LogLevel::MEASUREMENTS }, + { "all", LogLevel::ALL }, + }; + + try + { + return levels.at(tolower(name)); + } + catch(const std::out_of_range &) + { + throw std::invalid_argument(name); + } +} + +::std::istream &operator>>(::std::istream &stream, LogLevel &level) +{ + std::string value; + stream >> value; + level = log_level_from_name(value); + return stream; +} + +::std::ostream &operator<<(::std::ostream &stream, LogLevel level) +{ + switch(level) + { + case LogLevel::NONE: + stream << "NONE"; + break; + case LogLevel::CONFIG: + stream << "CONFIG"; + break; + case LogLevel::TESTS: + stream << "TESTS"; + break; + case LogLevel::ERRORS: + stream << "ERRORS"; + break; + case LogLevel::DEBUG: + stream << "DEBUG"; + break; + case LogLevel::MEASUREMENTS: + stream << "MEASUREMENTS"; + break; + case LogLevel::ALL: + stream << "ALL"; + break; + default: + throw std::invalid_argument("Unsupported log level"); + } + + return stream; +} + +std::string to_string(LogLevel level) +{ + std::stringstream stream; + stream << level; + return stream.str(); +} + +TestError::TestError(const std::string &msg, LogLevel level, std::string context) + : std::runtime_error{ msg }, _level{ level }, _msg{ msg }, _context{ std::move(context) }, _combined{ "ERROR: " + msg } +{ + if(!_context.empty()) + { + _combined += "\nCONTEXT:\n" + _context; + } +} + +LogLevel TestError::level() const +{ + return _level; +} + +const char *TestError::what() const noexcept +{ + return _combined.c_str(); +} + +} // namespace framework +} // namespace test +} // namespace arm_compute diff --git a/tests/framework/Exceptions.h b/tests/framework/Exceptions.h new file mode 100644 index 0000000000..edb0ed92c9 --- /dev/null +++ b/tests/framework/Exceptions.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_EXCEPTIONS +#define ARM_COMPUTE_TEST_EXCEPTIONS + +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Severity of the information. + * + * Each category includes the ones above it. + * + * NONE == Only for filtering. Not used to tag information. + * CONFIG == Configuration info. + * TESTS == Information about the tests. + * ERRORS == Violated assertions/expectations. + * DEBUG == More violated assertions/expectations. + * MEASUREMENTS == Information about measurements. + * ALL == Only for filtering. Not used to tag information. + */ +enum class LogLevel +{ + NONE, + CONFIG, + TESTS, + ERRORS, + DEBUG, + MEASUREMENTS, + ALL, +}; + +LogLevel log_level_from_name(const std::string &name); +::std::istream &operator>>(::std::istream &stream, LogLevel &level); +::std::ostream &operator<<(::std::ostream &stream, LogLevel level); +std::string to_string(LogLevel level); + +/** Error class for failures during test execution. */ +class TestError : public std::runtime_error +{ +public: + using std::runtime_error::runtime_error; + + /** Construct error with severity. + * + * @param[in] msg Error message. + * @param[in] level Severity level. + * @param[in] context Context. + */ + TestError(const std::string &msg, LogLevel level, std::string context = ""); + + /** Severity of the error. + * + * @return Severity. + */ + LogLevel level() const; + + const char *what() const noexcept override; + +private: + LogLevel _level{ LogLevel::ERRORS }; + std::string _msg{}; + std::string _context{}; + std::string _combined{}; +}; +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_EXCEPTIONS */ diff --git a/tests/framework/Fixture.h b/tests/framework/Fixture.h new file mode 100644 index 0000000000..916dcc7fef --- /dev/null +++ b/tests/framework/Fixture.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_FIXTURE +#define ARM_COMPUTE_TEST_FIXTURE + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Abstract fixture class. + * + * All custom fixtures have to inherit from this class. + */ +class Fixture +{ +public: + /** Setup function. + * + * This function is only invoked by non-data fixture test cases. Fixture + * data test cases implement a setup function with arguments matching the + * dataset. + * + * The function is called before the test case is executed. + */ + void setup() {}; + + /** Teardown function. + * + * The function is called after the test case finished. + */ + void teardown() {}; + +protected: + Fixture() = default; + virtual ~Fixture() = default; +}; +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_FIXTURE */ diff --git a/tests/framework/Framework.cpp b/tests/framework/Framework.cpp new file mode 100644 index 0000000000..315f8ebea7 --- /dev/null +++ b/tests/framework/Framework.cpp @@ -0,0 +1,494 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "Framework.h" + +#include "support/ToolchainSupport.h" + +#ifdef ARM_COMPUTE_CL +#include "arm_compute/core/CL/OpenCL.h" +#include "arm_compute/runtime/CL/CLScheduler.h" +#endif /* ARM_COMPUTE_CL */ + +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +Framework::Framework() +{ + _available_instruments.emplace(InstrumentType::WALL_CLOCK_TIMER, Instrument::make_instrument); +#ifdef PMU_ENABLED + _available_instruments.emplace(InstrumentType::PMU_CYCLE_COUNTER, Instrument::make_instrument); + _available_instruments.emplace(InstrumentType::PMU_INSTRUCTION_COUNTER, Instrument::make_instrument); +#endif /* PMU_ENABLED */ +} + +std::set Framework::available_instruments() const +{ + std::set types; + + for(const auto &instrument : _available_instruments) + { + types.emplace(instrument.first); + } + + return types; +} + +std::map Framework::count_test_results() const +{ + std::map counts; + + for(const auto &test : _test_results) + { + ++counts[test.second.status]; + } + + return counts; +} + +Framework &Framework::get() +{ + static Framework instance; + return instance; +} + +void Framework::init(const std::vector &instruments, int num_iterations, DatasetMode mode, const std::string &name_filter, const std::string &id_filter, LogLevel log_level) +{ + _test_filter = TestFilter(mode, name_filter, id_filter); + _num_iterations = num_iterations; + _log_level = log_level; + + _instruments = InstrumentType::NONE; + + for(const auto &instrument : instruments) + { + _instruments |= instrument; + } +} + +std::string Framework::current_suite_name() const +{ + return join(_test_suite_name.cbegin(), _test_suite_name.cend(), "/"); +} + +void Framework::push_suite(std::string name) +{ + _test_suite_name.emplace_back(std::move(name)); +} + +void Framework::pop_suite() +{ + _test_suite_name.pop_back(); +} + +void Framework::add_test_info(std::string info) +{ + _test_info.emplace_back(std::move(info)); +} + +void Framework::clear_test_info() +{ + _test_info.clear(); +} + +bool Framework::has_test_info() const +{ + return !_test_info.empty(); +} + +void Framework::print_test_info(std::ostream &os) const +{ + if(!_test_info.empty()) + { + os << "CONTEXT:\n"; + + for(const auto &str : _test_info) + { + os << " " << str << "\n"; + } + } +} + +void Framework::log_test_start(const TestInfo &info) +{ + if(_printer != nullptr && _log_level >= LogLevel::TESTS) + { + _printer->print_test_header(info); + } +} + +void Framework::log_test_skipped(const TestInfo &info) +{ + static_cast(info); +} + +void Framework::log_test_end(const TestInfo &info) +{ + if(_printer != nullptr) + { + if(_log_level >= LogLevel::MEASUREMENTS) + { + _printer->print_measurements(_test_results.at(info).measurements); + } + + if(_log_level >= LogLevel::TESTS) + { + _printer->print_test_footer(); + } + } +} + +void Framework::log_failed_expectation(const TestError &error) +{ + if(_log_level >= error.level() && _printer != nullptr) + { + _printer->print_error(error); + } + + if(_current_test_result != nullptr) + { + _current_test_result->status = TestResult::Status::FAILED; + } +} + +int Framework::num_iterations() const +{ + return _num_iterations; +} + +void Framework::set_num_iterations(int num_iterations) +{ + _num_iterations = num_iterations; +} + +void Framework::set_throw_errors(bool throw_errors) +{ + _throw_errors = throw_errors; +} + +bool Framework::throw_errors() const +{ + return _throw_errors; +} + +void Framework::set_stop_on_error(bool stop_on_error) +{ + _stop_on_error = stop_on_error; +} + +bool Framework::stop_on_error() const +{ + return _stop_on_error; +} + +void Framework::run_test(const TestInfo &info, TestCaseFactory &test_factory) +{ + if(test_factory.status() == TestCaseFactory::Status::DISABLED) + { + log_test_skipped(info); + set_test_result(info, TestResult(TestResult::Status::DISABLED)); + return; + } + + log_test_start(info); + + Profiler profiler = get_profiler(); + TestResult result(TestResult::Status::NOT_RUN); + + _current_test_result = &result; + + if(_log_level >= LogLevel::ERRORS && _printer != nullptr) + { + _printer->print_errors_header(); + } + + try + { + std::unique_ptr test_case = test_factory.make(); + + try + { + test_case->do_setup(); + + for(int i = 0; i < _num_iterations; ++i) + { + profiler.start(); + test_case->do_run(); +#ifdef ARM_COMPUTE_CL + if(opencl_is_available()) + { + CLScheduler::get().sync(); + } +#endif /* ARM_COMPUTE_CL */ + profiler.stop(); + } + + test_case->do_teardown(); + + // Change status to success if no error has happend + if(result.status == TestResult::Status::NOT_RUN) + { + result.status = TestResult::Status::SUCCESS; + } + } + catch(const TestError &error) + { + if(_log_level >= error.level() && _printer != nullptr) + { + _printer->print_error(error); + } + + result.status = TestResult::Status::FAILED; + + if(_throw_errors) + { + throw; + } + } +#ifdef ARM_COMPUTE_CL + catch(const ::cl::Error &error) + { + if(_log_level >= LogLevel::ERRORS && _printer != nullptr) + { + std::stringstream stream; + stream << "Error code: " << error.err(); + _printer->print_error(TestError(error.what(), LogLevel::ERRORS, stream.str())); + } + + result.status = TestResult::Status::FAILED; + + if(_throw_errors) + { + throw; + } + } +#endif /* ARM_COMPUTE_CL */ + catch(const std::exception &error) + { + if(_log_level >= LogLevel::ERRORS && _printer != nullptr) + { + _printer->print_error(error); + } + + result.status = TestResult::Status::CRASHED; + + if(_throw_errors) + { + throw; + } + } + catch(...) + { + if(_log_level >= LogLevel::ERRORS && _printer != nullptr) + { + _printer->print_error(TestError("Received unknown exception")); + } + + result.status = TestResult::Status::CRASHED; + + if(_throw_errors) + { + throw; + } + } + } + catch(const std::exception &error) + { + if(_log_level >= LogLevel::ERRORS && _printer != nullptr) + { + _printer->print_error(error); + } + + result.status = TestResult::Status::CRASHED; + + if(_throw_errors) + { + throw; + } + } + catch(...) + { + if(_log_level >= LogLevel::ERRORS && _printer != nullptr) + { + _printer->print_error(TestError("Received unknown exception")); + } + + result.status = TestResult::Status::CRASHED; + + if(_throw_errors) + { + throw; + } + } + + if(_log_level >= LogLevel::ERRORS && _printer != nullptr) + { + _printer->print_errors_footer(); + } + + _current_test_result = nullptr; + + if(result.status == TestResult::Status::FAILED) + { + if(info.status == TestCaseFactory::Status::EXPECTED_FAILURE) + { + result.status = TestResult::Status::EXPECTED_FAILURE; + } + } + + if(result.status == TestResult::Status::FAILED || result.status == TestResult::Status::CRASHED) + { + if(_stop_on_error) + { + throw std::runtime_error("Abort on first error."); + } + } + + result.measurements = profiler.measurements(); + + set_test_result(info, result); + log_test_end(info); +} + +bool Framework::run() +{ + // Clear old test results + _test_results.clear(); + + if(_printer != nullptr && _log_level >= LogLevel::TESTS) + { + _printer->print_run_header(); + } + + const std::chrono::time_point start = std::chrono::high_resolution_clock::now(); + + int id = 0; + + for(auto &test_factory : _test_factories) + { + const std::string test_case_name = test_factory->name(); + const TestInfo test_info{ id, test_case_name, test_factory->mode(), test_factory->status() }; + + if(_test_filter.is_selected(test_info)) + { + run_test(test_info, *test_factory); + } + + ++id; + } + + const std::chrono::time_point end = std::chrono::high_resolution_clock::now(); + + if(_printer != nullptr && _log_level >= LogLevel::TESTS) + { + _printer->print_run_footer(); + } + + auto runtime = std::chrono::duration_cast(end - start); + std::map results = count_test_results(); + + if(_log_level > LogLevel::NONE) + { + std::cout << "Executed " << _test_results.size() << " test(s) (" + << results[TestResult::Status::SUCCESS] << " passed, " + << results[TestResult::Status::EXPECTED_FAILURE] << " expected failures, " + << results[TestResult::Status::FAILED] << " failed, " + << results[TestResult::Status::CRASHED] << " crashed, " + << results[TestResult::Status::DISABLED] << " disabled) in " << runtime.count() << " second(s)\n"; + } + + int num_successful_tests = results[TestResult::Status::SUCCESS] + results[TestResult::Status::EXPECTED_FAILURE]; + + return (static_cast(num_successful_tests) == _test_results.size()); +} + +void Framework::set_test_result(TestInfo info, TestResult result) +{ + _test_results.emplace(std::move(info), std::move(result)); +} + +void Framework::print_test_results(Printer &printer) const +{ + printer.print_run_header(); + + for(const auto &test : _test_results) + { + printer.print_test_header(test.first); + printer.print_measurements(test.second.measurements); + printer.print_test_footer(); + } + + printer.print_run_footer(); +} + +Profiler Framework::get_profiler() const +{ + Profiler profiler; + + for(const auto &instrument : _available_instruments) + { + if((instrument.first & _instruments) != InstrumentType::NONE) + { + profiler.add(instrument.second()); + } + } + + return profiler; +} + +void Framework::set_printer(Printer *printer) +{ + _printer = printer; +} + +std::vector Framework::test_infos() const +{ + std::vector ids; + + int id = 0; + + for(const auto &factory : _test_factories) + { + TestInfo test_info{ id, factory->name(), factory->mode(), factory->status() }; + + if(_test_filter.is_selected(test_info)) + { + ids.emplace_back(std::move(test_info)); + } + + ++id; + } + + return ids; +} +} // namespace framework +} // namespace test +} // namespace arm_compute diff --git a/tests/framework/Framework.h b/tests/framework/Framework.h new file mode 100644 index 0000000000..055392cdae --- /dev/null +++ b/tests/framework/Framework.h @@ -0,0 +1,330 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_FRAMEWORK +#define ARM_COMPUTE_TEST_FRAMEWORK + +#include "DatasetModes.h" +#include "Exceptions.h" +#include "Profiler.h" +#include "TestCase.h" +#include "TestCaseFactory.h" +#include "TestFilter.h" +#include "TestResult.h" +#include "Utils.h" +#include "instruments/Instruments.h" +#include "printers/Printer.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Information about a test case. + * + * A test can be identified either via its id or via its name. Additionally + * each test is tagged with the data set mode in which it will be used and + * its status. + * + * @note The mapping between test id and test name is not guaranteed to be + * stable. It is subject to change as new test are added. + */ +struct TestInfo +{ + int id; + std::string name; + DatasetMode mode; + TestCaseFactory::Status status; +}; + +inline bool operator<(const TestInfo &lhs, const TestInfo &rhs) +{ + return lhs.id < rhs.id; +} + +/** Main framework class. + * + * Keeps track of the global state, owns all test cases and collects results. + */ +class Framework final +{ +public: + /** Access to the singleton. + * + * @return Unique instance of the framework class. + */ + static Framework &get(); + + /** Supported instrument types for benchmarking. + * + * @return Set of all available instrument types. + */ + std::set available_instruments() const; + + /** Init the framework. + * + * @see TestFilter::TestFilter for the format of the string to filter ids. + * + * @param[in] instruments Instrument types that will be used for benchmarking. + * @param[in] num_iterations Number of iterations per test. + * @param[in] mode Dataset mode. + * @param[in] name_filter Regular expression to filter tests by name. Only matching tests will be executed. + * @param[in] id_filter String to match selected test ids. Only matching tests will be executed. + * @param[in] log_level Verbosity of the output. + */ + void init(const std::vector &instruments, int num_iterations, DatasetMode mode, const std::string &name_filter, const std::string &id_filter, LogLevel log_level); + + /** Add a new test suite. + * + * @warning Cannot be used at execution time. It can only be used for + * registering test cases. + * + * @param[in] name Name of the added test suite. + * + * @return Name of the current test suite. + */ + void push_suite(std::string name); + + /** Remove innermost test suite. + * + * @warning Cannot be used at execution time. It can only be used for + * registering test cases. + */ + void pop_suite(); + + /** Add a test case to the framework. + * + * @param[in] test_name Name of the new test case. + * @param[in] mode Mode in which to include the test. + * @param[in] status Status of the test case. + */ + template + void add_test_case(std::string test_name, DatasetMode mode, TestCaseFactory::Status status); + + /** Add a data test case to the framework. + * + * @param[in] test_name Name of the new test case. + * @param[in] mode Mode in which to include the test. + * @param[in] status Status of the test case. + * @param[in] description Description of @p data. + * @param[in] data Data that will be used as input to the test. + */ + template + void add_data_test_case(std::string test_name, DatasetMode mode, TestCaseFactory::Status status, std::string description, D &&data); + + /** Add info string for the next expectation/assertion. + * + * @param[in] info Info string. + */ + void add_test_info(std::string info); + + /** Clear the collected test info. */ + void clear_test_info(); + + /** Check if any info has been registered. + * + * @return True if there is test info. + */ + bool has_test_info() const; + + /** Print test info. + * + * @param[out] os Output stream. + */ + void print_test_info(std::ostream &os) const; + + /** Tell the framework that execution of a test starts. + * + * @param[in] info Test info. + */ + void log_test_start(const TestInfo &info); + + /** Tell the framework that a test case is skipped. + * + * @param[in] info Test info. + */ + void log_test_skipped(const TestInfo &info); + + /** Tell the framework that a test case finished. + * + * @param[in] info Test info. + */ + void log_test_end(const TestInfo &info); + + /** Tell the framework that the currently running test case failed a non-fatal expectation. + * + * @param[in] error Description of the error. + */ + void log_failed_expectation(const TestError &error); + + /** Number of iterations per test case. + * + * @return Number of iterations per test case. + */ + int num_iterations() const; + + /** Set number of iterations per test case. + * + * @param[in] num_iterations Number of iterations per test case. + */ + void set_num_iterations(int num_iterations); + + /** Should errors be caught or thrown by the framework. + * + * @return True if errors are thrown. + */ + bool throw_errors() const; + + /** Set whether errors are caught or thrown by the framework. + * + * @param[in] throw_errors True if errors should be thrown. + */ + void set_throw_errors(bool throw_errors); + + /** Indicates if test execution is stopped after the first failed test. + * + * @return True if the execution is going to be aborted after the first failed test. + */ + bool stop_on_error() const; + + /** Set whether to abort execution after the first failed test. + * + * @param[in] stop_on_error True if execution is going to be aborted after first failed test. + */ + void set_stop_on_error(bool stop_on_error); + + /** Run all enabled test cases. + * + * @return True if all test cases executed successful. + */ + bool run(); + + /** Set the result for an executed test case. + * + * @param[in] info Test info. + * @param[in] result Execution result. + */ + void set_test_result(TestInfo info, TestResult result); + + /** Use the specified printer to output test results from the last run. + * + * This method can be used if the test results need to be obtained using a + * different printer than the one managed by the framework. + * + * @param[in] printer Printer used to output results. + */ + void print_test_results(Printer &printer) const; + + /** Factory method to obtain a configured profiler. + * + * The profiler enables all instruments that have been passed to the @ref + * init method. + * + * @return Configured profiler to collect benchmark results. + */ + Profiler get_profiler() const; + + /** Set the printer used for the output of test results. + * + * @param[in] printer Pointer to a printer. + */ + void set_printer(Printer *printer); + + /** List of @ref TestInfo's. + * + * @return Vector with all test ids. + */ + std::vector test_infos() const; + +private: + Framework(); + ~Framework() = default; + + Framework(const Framework &) = delete; + Framework &operator=(const Framework &) = delete; + + void run_test(const TestInfo &info, TestCaseFactory &test_factory); + std::map count_test_results() const; + + /** Returns the current test suite name. + * + * @warning Cannot be used at execution time to get the test suite of the + * currently executed test case. It can only be used for registering test + * cases. + * + * @return Name of the current test suite. + */ + std::string current_suite_name() const; + + std::vector _test_suite_name{}; + std::vector> _test_factories{}; + std::map _test_results{}; + int _num_iterations{ 1 }; + bool _throw_errors{ false }; + bool _stop_on_error{ false }; + Printer *_printer{ nullptr }; + + using create_function = std::unique_ptr(); + std::map _available_instruments{}; + + InstrumentType _instruments{ InstrumentType::NONE }; + TestFilter _test_filter{}; + LogLevel _log_level{ LogLevel::ALL }; + TestResult *_current_test_result{ nullptr }; + std::vector _test_info{}; +}; + +template +inline void Framework::add_test_case(std::string test_name, DatasetMode mode, TestCaseFactory::Status status) +{ + _test_factories.emplace_back(support::cpp14::make_unique>(current_suite_name(), std::move(test_name), mode, status)); +} + +template +inline void Framework::add_data_test_case(std::string test_name, DatasetMode mode, TestCaseFactory::Status status, std::string description, D &&data) +{ + // WORKAROUND for GCC 4.9 + // The function should get *it which is tuple but that seems to trigger a + // bug in the compiler. + auto tmp = std::unique_ptr())>>(new DataTestCaseFactory())>(current_suite_name(), std::move(test_name), mode, status, + std::move(description), *data)); + _test_factories.emplace_back(std::move(tmp)); +} +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_FRAMEWORK */ diff --git a/tests/framework/Macros.h b/tests/framework/Macros.h new file mode 100644 index 0000000000..7aabb75cfc --- /dev/null +++ b/tests/framework/Macros.h @@ -0,0 +1,260 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_FRAMEWORK_MACROS +#define ARM_COMPUTE_TEST_FRAMEWORK_MACROS + +#include "Framework.h" +#include "Registrars.h" +#include "TestCase.h" + +// +// TEST SUITE MACROS +// +#define TEST_SUITE(SUITE_NAME) \ + namespace SUITE_NAME##Suite \ + { \ + static arm_compute::test::framework::detail::TestSuiteRegistrar SUITE_NAME##Suite_reg{ #SUITE_NAME }; + +#define TEST_SUITE_END() \ + static arm_compute::test::framework::detail::TestSuiteRegistrar Suite_end; \ + } +// +// TEST SUITE MACROS END +// + +// +// HELPER MACROS +// + +#define CONCAT(ARG0, ARG1) ARG0##ARG1 + +#define VARIADIC_SIZE_IMPL(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, size, ...) size +#define VARIADIC_SIZE(...) VARIADIC_SIZE_IMPL(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) + +#define JOIN_PARAM1(OP, param) OP(0, param) +#define JOIN_PARAM2(OP, param, ...) \ + OP(1, param) \ + , JOIN_PARAM1(OP, __VA_ARGS__) +#define JOIN_PARAM3(OP, param, ...) \ + OP(2, param) \ + , JOIN_PARAM2(OP, __VA_ARGS__) +#define JOIN_PARAM4(OP, param, ...) \ + OP(3, param) \ + , JOIN_PARAM3(OP, __VA_ARGS__) +#define JOIN_PARAM5(OP, param, ...) \ + OP(4, param) \ + , JOIN_PARAM4(OP, __VA_ARGS__) +#define JOIN_PARAM6(OP, param, ...) \ + OP(5, param) \ + , JOIN_PARAM5(OP, __VA_ARGS__) +#define JOIN_PARAM7(OP, param, ...) \ + OP(6, param) \ + , JOIN_PARAM6(OP, __VA_ARGS__) +#define JOIN_PARAM8(OP, param, ...) \ + OP(7, param) \ + , JOIN_PARAM7(OP, __VA_ARGS__) +#define JOIN_PARAM9(OP, param, ...) \ + OP(8, param) \ + , JOIN_PARAM8(OP, __VA_ARGS__) +#define JOIN_PARAM10(OP, param, ...) \ + OP(9, param) \ + , JOIN_PARAM9(OP, __VA_ARGS__) +#define JOIN_PARAM(OP, NUM, ...) \ + CONCAT(JOIN_PARAM, NUM) \ + (OP, __VA_ARGS__) + +#define MAKE_TYPE_PARAM(i, name) typename T##i +#define MAKE_ARG_PARAM(i, name) const T##i &name +#define MAKE_TYPE_PARAMS(...) JOIN_PARAM(MAKE_TYPE_PARAM, VARIADIC_SIZE(__VA_ARGS__), __VA_ARGS__) +#define MAKE_ARG_PARAMS(...) JOIN_PARAM(MAKE_ARG_PARAM, VARIADIC_SIZE(__VA_ARGS__), __VA_ARGS__) + +// +// TEST CASE MACROS +// +#define TEST_CASE_CONSTRUCTOR(TEST_NAME) \ + TEST_NAME() = default; +#define DATA_TEST_CASE_CONSTRUCTOR(TEST_NAME, DATASET) \ + template \ + explicit TEST_NAME(D &&data) : DataTestCase{ std::forward(data) } \ + { \ + } +#define FIXTURE_SETUP(FIXTURE) \ + void do_setup() override \ + { \ + FIXTURE::setup(); \ + } +#define FIXTURE_DATA_SETUP(FIXTURE) \ + void do_setup() override \ + { \ + apply(this, &FIXTURE::setup, _data); \ + } +#define FIXTURE_RUN(FIXTURE) \ + void do_run() override \ + { \ + FIXTURE::run(); \ + } +#define FIXTURE_TEARDOWN(FIXTURE) \ + void do_teardown() override \ + { \ + FIXTURE::teardown(); \ + } +#define TEST_REGISTRAR(TEST_NAME, MODE, STATUS) \ + static arm_compute::test::framework::detail::TestCaseRegistrar TEST_NAME##_reg \ + { \ + #TEST_NAME, MODE, STATUS \ + } +#define DATA_TEST_REGISTRAR(TEST_NAME, MODE, STATUS, DATASET) \ + static arm_compute::test::framework::detail::TestCaseRegistrar> TEST_NAME##_reg \ + { \ + #TEST_NAME, MODE, STATUS, DATASET \ + } + +#define TEST_CASE_IMPL(TEST_NAME, MODE, STATUS) \ + class TEST_NAME : public arm_compute::test::framework::TestCase \ + { \ + public: \ + TEST_CASE_CONSTRUCTOR(TEST_NAME) \ + void do_run() override; \ + }; \ + TEST_REGISTRAR(TEST_NAME, MODE, STATUS); \ + void TEST_NAME::do_run() + +#define TEST_CASE(TEST_NAME, MODE) \ + TEST_CASE_IMPL(TEST_NAME, MODE, arm_compute::test::framework::TestCaseFactory::Status::ACTIVE) +#define EXPECTED_FAILURE_TEST_CASE(TEST_NAME, MODE) \ + TEST_CASE_IMPL(TEST_NAME, MODE, arm_compute::test::framework::TestCaseFactory::Status::EXPECTED_FAILURE) +#define DISABLED_TEST_CASE(TEST_NAME, MODE) \ + TEST_CASE_IMPL(TEST_NAME, MODE, arm_compute::test::framework::TestCaseFactory::Status::DISABLED) + +#define DATA_TEST_CASE_IMPL(TEST_NAME, MODE, STATUS, DATASET, ...) \ + template \ + class TEST_NAME; \ + template \ + class TEST_NAME> : public arm_compute::test::framework::DataTestCase \ + { \ + public: \ + DATA_TEST_CASE_CONSTRUCTOR(TEST_NAME, DATASET) \ + void do_run() override \ + { \ + arm_compute::test::framework::apply(this, &TEST_NAME::run, _data); \ + } \ + template \ + void run(MAKE_ARG_PARAMS(__VA_ARGS__)); \ + }; \ + DATA_TEST_REGISTRAR(TEST_NAME, MODE, STATUS, DATASET); \ + template \ + template \ + void TEST_NAME>::run(MAKE_ARG_PARAMS(__VA_ARGS__)) + +#define DATA_TEST_CASE(TEST_NAME, MODE, DATASET, ...) \ + DATA_TEST_CASE_IMPL(TEST_NAME, MODE, arm_compute::test::framework::TestCaseFactory::Status::ACTIVE, DATASET, __VA_ARGS__) +#define EXPECTED_FAILURE_DATA_TEST_CASE(TEST_NAME, MODE, DATASET, ...) \ + DATA_TEST_CASE_IMPL(TEST_NAME, MODE, arm_compute::test::framework::TestCaseFactory::Status::EXPECTED_FAILURE, DATASET, __VA_ARGS__) +#define DISABLED_DATA_TEST_CASE(TEST_NAME, MODE, DATASET, ...) \ + DATA_TEST_CASE_IMPL(TEST_NAME, MODE, arm_compute::test::framework::TestCaseFactory::Status::DISABLED, DATASET, __VA_ARGS__) + +#define FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, STATUS) \ + class TEST_NAME : public arm_compute::test::framework::TestCase, public FIXTURE \ + { \ + public: \ + TEST_CASE_CONSTRUCTOR(TEST_NAME) \ + FIXTURE_SETUP(FIXTURE) \ + void do_run() override; \ + FIXTURE_TEARDOWN(FIXTURE) \ + }; \ + TEST_REGISTRAR(TEST_NAME, MODE, STATUS); \ + void TEST_NAME::do_run() + +#define FIXTURE_TEST_CASE(TEST_NAME, FIXTURE, MODE) \ + FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::ACTIVE) +#define EXPECTED_FAILURE_FIXTURE_TEST_CASE(TEST_NAME, FIXTURE, MODE) \ + FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::EXPECTED_FAILURE) +#define DISABLED_FIXTURE_TEST_CASE(TEST_NAME, FIXTURE, MODE) \ + FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::DISABLED) + +#define FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, STATUS, DATASET) \ + template \ + class TEST_NAME; \ + template \ + class TEST_NAME> : public arm_compute::test::framework::DataTestCase, public FIXTURE \ + { \ + public: \ + DATA_TEST_CASE_CONSTRUCTOR(TEST_NAME, DATASET) \ + FIXTURE_DATA_SETUP(FIXTURE) \ + void do_run() override; \ + FIXTURE_TEARDOWN(FIXTURE) \ + }; \ + DATA_TEST_REGISTRAR(TEST_NAME, MODE, STATUS, DATASET); \ + template \ + void TEST_NAME>::do_run() + +#define FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, DATASET) \ + FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::ACTIVE, DATASET) +#define EXPECTED_FAILURE_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, DATASET) \ + FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::EXPECTED_FAILURE, DATASET) +#define DISABLED_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, DATASET) \ + FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::DISABLED, DATASET) + +#define REGISTER_FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, STATUS) \ + class TEST_NAME : public arm_compute::test::framework::TestCase, public FIXTURE \ + { \ + public: \ + TEST_CASE_CONSTRUCTOR(TEST_NAME) \ + FIXTURE_SETUP(FIXTURE) \ + FIXTURE_RUN(FIXTURE) \ + FIXTURE_TEARDOWN(FIXTURE) \ + }; \ + TEST_REGISTRAR(TEST_NAME, MODE, STATUS) + +#define REGISTER_FIXTURE_TEST_CASE(TEST_NAME, FIXTURE, MODE) \ + REGISTER_FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::ACTIVE) +#define EXPECTED_FAILURE_REGISTER_FIXTURE_TEST_CASE(TEST_NAME, FIXTURE, MODE) \ + REGISTER_FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::EXPECTED_FAILURE) +#define DISABLED_REGISTER_FIXTURE_TEST_CASE(TEST_NAME, FIXTURE, MODE) \ + REGISTER_FIXTURE_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::DISABLED) + +#define REGISTER_FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, STATUS, DATASET) \ + template \ + class TEST_NAME; \ + template \ + class TEST_NAME> : public arm_compute::test::framework::DataTestCase, public FIXTURE \ + { \ + public: \ + DATA_TEST_CASE_CONSTRUCTOR(TEST_NAME, DATASET) \ + FIXTURE_DATA_SETUP(FIXTURE) \ + FIXTURE_RUN(FIXTURE) \ + FIXTURE_TEARDOWN(FIXTURE) \ + }; \ + DATA_TEST_REGISTRAR(TEST_NAME, MODE, STATUS, DATASET) + +#define REGISTER_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, DATASET) \ + REGISTER_FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::ACTIVE, DATASET) +#define EXPECTED_FAILURE_REGISTER_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, DATASET) \ + REGISTER_FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::EXPECTED_FAILURE, DATASET) +#define DISABLED_REGISTER_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, DATASET) \ + REGISTER_FIXTURE_DATA_TEST_CASE_IMPL(TEST_NAME, FIXTURE, MODE, arm_compute::test::framework::TestCaseFactory::Status::DISABLED, DATASET) +// +// TEST CASE MACROS END +// +#endif /* ARM_COMPUTE_TEST_FRAMEWORK_MACROS */ diff --git a/tests/framework/Profiler.cpp b/tests/framework/Profiler.cpp new file mode 100644 index 0000000000..76de9a818f --- /dev/null +++ b/tests/framework/Profiler.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "Profiler.h" + +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +void Profiler::add(std::unique_ptr instrument) +{ + _instruments.emplace_back(std::move(instrument)); +} + +void Profiler::start() +{ + for(auto &instrument : _instruments) + { + instrument->start(); + } +} + +void Profiler::stop() +{ + for(auto &instrument : _instruments) + { + instrument->stop(); + } + + for(const auto &instrument : _instruments) + { + _measurements[instrument->id()].push_back(instrument->measurement()); + } +} + +const Profiler::MeasurementsMap &Profiler::measurements() const +{ + return _measurements; +} +} // namespace framework +} // namespace test +} // namespace arm_compute diff --git a/tests/framework/Profiler.h b/tests/framework/Profiler.h new file mode 100644 index 0000000000..1454c0f875 --- /dev/null +++ b/tests/framework/Profiler.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_PROFILER +#define ARM_COMPUTE_TEST_PROFILER + +#include "instruments/Instrument.h" + +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Profiler class to collect benchmark numbers. + * + * A profiler manages multiple instruments that can collect different types of benchmarking numbers. + */ +class Profiler +{ +public: + /** Mapping from instrument ids to their measurements. */ + using MeasurementsMap = std::map>; + + /** Add @p instrument to the performance monitor. + * + * All added instruments will be used when @ref start or @ref stop are + * called to make measurements. + * + * @param[in] instrument Instrument to be used to measure performance. + */ + void add(std::unique_ptr instrument); + + /** Start all added instruments to measure performance. */ + void start(); + + /** Stop all added instruments. */ + void stop(); + + /** Return measurements for all instruments. */ + const MeasurementsMap &measurements() const; + +private: + std::vector> _instruments{}; + MeasurementsMap _measurements{}; +}; +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_PROFILER */ diff --git a/tests/framework/Registrars.h b/tests/framework/Registrars.h new file mode 100644 index 0000000000..ca23edf0de --- /dev/null +++ b/tests/framework/Registrars.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_FRAMEWORK_REGISTRARS +#define ARM_COMPUTE_TEST_FRAMEWORK_REGISTRARS + +#include "DatasetModes.h" +#include "Framework.h" + +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +namespace detail +{ +/** Helper class to statically register a test case. */ +template +class TestCaseRegistrar final +{ +public: + /** Add a new test case with the given name to the framework. + * + * @param[in] test_name Name of the test case. + * @param[in] mode Mode in which the test should be activated. + * @param[in] status Status of the test case. + */ + TestCaseRegistrar(std::string test_name, DatasetMode mode, TestCaseFactory::Status status); + + /** Add a new data test case with the given name to the framework. + * + * @param[in] test_name Name of the test case. + * @param[in] mode Mode in which the test should be activated. + * @param[in] status Status of the test case. + * @param[in] dataset Dataset used as input for the test case. + */ + template + TestCaseRegistrar(std::string test_name, DatasetMode mode, TestCaseFactory::Status status, D &&dataset); +}; + +/** Helper class to statically begin and end a test suite. */ +class TestSuiteRegistrar final +{ +public: + /** Remove the last added test suite from the framework. */ + TestSuiteRegistrar(); + + /** Add a new test suite with the given name to the framework. + * + * @param[in] name Name of the test suite. + */ + TestSuiteRegistrar(std::string name); +}; + +template +inline TestCaseRegistrar::TestCaseRegistrar(std::string test_name, DatasetMode mode, TestCaseFactory::Status status) +{ + Framework::get().add_test_case(std::move(test_name), mode, status); +} + +template +template +inline TestCaseRegistrar::TestCaseRegistrar(std::string test_name, DatasetMode mode, TestCaseFactory::Status status, D &&dataset) +{ + auto it = dataset.begin(); + + for(int i = 0; i < dataset.size(); ++i, ++it) + { + // WORKAROUND for GCC 4.9 + // The last argument should be *it to pass just the data and not the + // iterator. + Framework::get().add_data_test_case(test_name, mode, status, it.description(), it); + } +} + +inline TestSuiteRegistrar::TestSuiteRegistrar() +{ + Framework::get().pop_suite(); +} + +inline TestSuiteRegistrar::TestSuiteRegistrar(std::string name) +{ + Framework::get().push_suite(std::move(name)); +} +} // namespace detail +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_FRAMEWORK_REGISTRARS */ diff --git a/tests/framework/SConscript b/tests/framework/SConscript new file mode 100644 index 0000000000..36632515a3 --- /dev/null +++ b/tests/framework/SConscript @@ -0,0 +1,71 @@ +# Copyright (c) 2017 ARM Limited. +# +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +import SCons +import os.path + +Import('env') +Import('vars') + +# vars is imported from arm_compute: +variables = [ + BoolVariable("pmu", "Enable PMU counters", False) +] + +# We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice) +new_options = Variables('scons') + +for v in variables: + new_options.Add(v) + vars.Add(v) + +# Clone the environment to make sure we're not polluting the arm_compute one: +framework_env = env.Clone() +vars.Update(framework_env) + +Help(new_options.GenerateHelpText(framework_env)) + +if env['os'] == 'android' and framework_env['pmu']: + print("pmu=1 is not supported for os=android") + Exit(1) + +if(env['opencl']): + framework_env.Append(CPPDEFINES=['ARM_COMPUTE_CL']) + +framework_env.Append(CPPPATH = ["."]) +framework_env.Append(CPPFLAGS=['-Wno-overloaded-virtual']) + +files = Glob('*.cpp') +files += Glob('command_line/*.cpp') +files += Glob('printers/*.cpp') +files += Glob('datasets/*.cpp') +files += Glob('instruments/*.cpp') + +if not framework_env['pmu']: + # Remove PMU files + files = [f for f in files if "PMU" not in os.path.basename(str(f))] +else: + framework_env.Append(CPPDEFINES = ['PMU_ENABLED']) + +arm_compute_test_framework = framework_env.StaticLibrary('arm_compute_test_framework', files) + +Default(arm_compute_test_framework) +Export('arm_compute_test_framework') diff --git a/tests/framework/TestCase.h b/tests/framework/TestCase.h new file mode 100644 index 0000000000..dbb9312dee --- /dev/null +++ b/tests/framework/TestCase.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_TESTCASE +#define ARM_COMPUTE_TEST_TESTCASE + +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Abstract test case class. + * + * All test cases have to inherit from this class. + */ +class TestCase +{ +public: + virtual void do_setup() {}; + virtual void do_run() {}; + virtual void do_teardown() {}; + + /** Default destructor. */ + virtual ~TestCase() = default; + +protected: + TestCase() = default; + + friend class TestCaseFactory; +}; + +template +class DataTestCase : public TestCase +{ +protected: + explicit DataTestCase(T data) + : _data{ std::move(data) } + { + } + + T _data; +}; +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_TESTCASE */ diff --git a/tests/framework/TestCaseFactory.h b/tests/framework/TestCaseFactory.h new file mode 100644 index 0000000000..b8c8cdbeb0 --- /dev/null +++ b/tests/framework/TestCaseFactory.h @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_TEST_CASE_FACTORY +#define ARM_COMPUTE_TEST_TEST_CASE_FACTORY + +#include "DatasetModes.h" +#include "TestCase.h" +#include "support/ToolchainSupport.h" + +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Abstract factory class to create test cases. */ +class TestCaseFactory +{ +public: + /** Test case status. + * + * ACTIVE == Test is run and result is validated. Failure on failed validation. + * EXPECTED_FAILURE == Test is run and result is validated. Failure on successful validation. + * DISABLED == Test is not run. + */ + enum class Status + { + ACTIVE, + EXPECTED_FAILURE, + DISABLED + }; + + /** Constructor. + * + * @param[in] suite_name Name of the test suite to which the test case has been added. + * @param[in] name Name of the test case. + * @param[in] mode Datset mode of the test case. + * @param[in] status Status of the test case. + * @param[in] description Description of data arguments. + */ + TestCaseFactory(std::string suite_name, std::string name, DatasetMode mode, Status status, std::string description = ""); + + /** Default destructor. */ + virtual ~TestCaseFactory() = default; + + /** Name of the test case. + * + * @return Name of the test case. + */ + std::string name() const; + + /** Get the mode for which test case will be enabled. + * + * @return Dataset mode of the test case. + */ + DatasetMode mode() const; + + /** Get the status of the test case. + * + * @return Status of the test case. + */ + Status status() const; + + /** Factory function to create the test case + * + * @return Unique pointer to a newly created test case. + */ + virtual std::unique_ptr make() const = 0; + +private: + const std::string _suite_name; + const std::string _test_name; + const std::string _data_description; + const DatasetMode _mode{ DatasetMode::ALL }; + const Status _status{ Status::ACTIVE }; +}; + +/** Implementation of a test case factory to create non-data test cases. */ +template +class SimpleTestCaseFactory final : public TestCaseFactory +{ +public: + /** Default constructor. */ + using TestCaseFactory::TestCaseFactory; + + std::unique_ptr make() const override; +}; + +template +class DataTestCaseFactory final : public TestCaseFactory +{ +public: + /** Constructor. + * + * @param[in] suite_name Name of the test suite to which the test case has been added. + * @param[in] test_name Name of the test case. + * @param[in] mode Mode in which the test case is enabled. + * @param[in] status Status of the test case. + * @param[in] description Description of data arguments. + * @param[in] data Input data for the test case. + */ + DataTestCaseFactory(std::string suite_name, std::string test_name, DatasetMode mode, Status status, std::string description, const D &data); + + std::unique_ptr make() const override; + +private: + D _data; +}; + +inline TestCaseFactory::TestCaseFactory(std::string suite_name, std::string test_name, DatasetMode mode, Status status, std::string description) + : _suite_name{ std::move(suite_name) }, _test_name{ std::move(test_name) }, _data_description{ std::move(description) }, _mode{ mode }, _status{ status } + +{ +} + +inline std::string TestCaseFactory::name() const +{ + std::string name = _suite_name + "/" + _test_name; + + if(!_data_description.empty()) + { + name += "@" + _data_description; + } + + return name; +} + +inline DatasetMode TestCaseFactory::mode() const +{ + return _mode; +} + +inline TestCaseFactory::Status TestCaseFactory::status() const +{ + return _status; +} + +inline ::std::ostream &operator<<(::std::ostream &stream, TestCaseFactory::Status status) +{ + switch(status) + { + case TestCaseFactory::Status::ACTIVE: + stream << "ACTIVE"; + break; + case TestCaseFactory::Status::EXPECTED_FAILURE: + stream << "EXPECTED_FAILURE"; + break; + case TestCaseFactory::Status::DISABLED: + stream << "DISABLED"; + break; + default: + throw std::invalid_argument("Unsupported test case factory status"); + } + + return stream; +} + +template +inline std::unique_ptr SimpleTestCaseFactory::make() const +{ + return support::cpp14::make_unique(); +} + +template +inline DataTestCaseFactory::DataTestCaseFactory(std::string suite_name, std::string test_name, DatasetMode mode, Status status, std::string description, const D &data) + : TestCaseFactory{ std::move(suite_name), std::move(test_name), mode, status, std::move(description) }, _data{ data } +{ +} + +template +inline std::unique_ptr DataTestCaseFactory::make() const +{ + return support::cpp14::make_unique(_data); +} +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_TEST_CASE_FACTORY */ diff --git a/tests/framework/TestFilter.cpp b/tests/framework/TestFilter.cpp new file mode 100644 index 0000000000..0af40c1717 --- /dev/null +++ b/tests/framework/TestFilter.cpp @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "TestFilter.h" + +#include "Framework.h" +#include "support/ToolchainSupport.h" + +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +TestFilter::TestFilter(DatasetMode mode, const std::string &name_filter, const std::string &id_filter) + : _dataset_mode{ mode }, _name_filter{ name_filter }, _id_filter{ parse_id_filter(id_filter) } +{ +} + +bool TestFilter::is_selected(const TestInfo &info) const +{ + if((info.mode & _dataset_mode) == DatasetMode::DISABLED) + { + return false; + } + + if(!std::regex_search(info.name, _name_filter)) + { + return false; + } + + if(!_id_filter.empty()) + { + bool found = false; + + for(const auto range : _id_filter) + { + if(range.first <= info.id && info.id <= range.second) + { + found = true; + break; + } + } + + if(!found) + { + return false; + } + } + + return true; +} + +TestFilter::Ranges TestFilter::parse_id_filter(const std::string &id_filter) const +{ + Ranges ranges; + std::string str; + bool in_range = false; + int value = 0; + int start = 0; + int end = std::numeric_limits::max(); + + std::stringstream stream(id_filter); + + // Get first value + std::getline(stream, str, ','); + + if(stream.fail()) + { + return ranges; + } + + if(str.find("...") != std::string::npos) + { + in_range = true; + } + else + { + start = support::cpp11::stoi(str); + end = start; + } + + while(!stream.eof()) + { + std::getline(stream, str, ','); + + if(stream.fail()) + { + break; + } + + if(str.find("...") != std::string::npos) + { + end = std::numeric_limits::max(); + in_range = true; + } + else + { + value = support::cpp11::stoi(str); + + if(in_range || end == value - 1) + { + end = value; + in_range = false; + } + else + { + ranges.emplace_back(start, end); + start = value; + end = start; + } + } + } + + ranges.emplace_back(start, end); + return ranges; +} +} // namespace framework +} // namespace test +} // namespace arm_compute diff --git a/tests/framework/TestFilter.h b/tests/framework/TestFilter.h new file mode 100644 index 0000000000..f64e73a2ba --- /dev/null +++ b/tests/framework/TestFilter.h @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_TESTFILTER +#define ARM_COMPUTE_TEST_TESTFILTER + +#include "DatasetModes.h" + +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +struct TestInfo; + +/** Test filter class. + * + * Stores information about which test cases are selected for execution. Based + * on test name and test id. + */ +class TestFilter final +{ +public: + /** Default constructor. All tests selected. */ + TestFilter() = default; + + /** Constructor. + * + * The id_filter string has be a comma separated list of test ids. ... can + * be used to include a range of tests. For instance, "..., 15" means all + * test up to and including 15, "3, 6, ..., 10" means tests 3 and 6 to 10, + * and "15, ..." means test 15 and all following. + * + * @param[in] mode Dataset mode. + * @param[in] name_filter Regular expression to filter tests by name. Only matching tests will be executed. + * @param[in] id_filter String to match selected test ids. Only matching tests will be executed. + */ + TestFilter(DatasetMode mode, const std::string &name_filter, const std::string &id_filter); + + /** Check if a test case is selected to be executed. + * + * @param[in] info Test case info. + * + * @return True if the test case is selected to be executed. + */ + bool is_selected(const TestInfo &info) const; + +private: + using Ranges = std::vector>; + Ranges parse_id_filter(const std::string &id_filter) const; + + DatasetMode _dataset_mode{ DatasetMode::ALL }; + std::regex _name_filter{ ".*" }; + Ranges _id_filter{}; +}; +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_TESTFILTER */ diff --git a/tests/framework/TestResult.h b/tests/framework/TestResult.h new file mode 100644 index 0000000000..e71ef95112 --- /dev/null +++ b/tests/framework/TestResult.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_TESTRESULT +#define ARM_COMPUTE_TEST_TESTRESULT + +#include "Profiler.h" + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Class to store results of a test. + * + * Currently the execution status and profiling information are stored. + */ +struct TestResult +{ + /** Execution status of a test. */ + enum class Status + { + NOT_RUN, + SUCCESS, + EXPECTED_FAILURE, + FAILED, + CRASHED, + DISABLED + }; + + /** Default constructor. */ + TestResult() = default; + + /** Initialise the result with a status. + * + * @param[in] status Execution status. + */ + TestResult(Status status) + : status{ status } + { + } + + /** Initialise the result with a status and profiling information. + * + * @param[in] status Execution status. + * @param[in] measurements Profiling information. + */ + TestResult(Status status, const Profiler::MeasurementsMap &measurements) + : status{ status }, measurements{ measurements } + { + } + + Status status{ Status::NOT_RUN }; //< Execution status + Profiler::MeasurementsMap measurements{}; //< Profiling information +}; +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_TESTRESULT */ diff --git a/tests/framework/Utils.h b/tests/framework/Utils.h new file mode 100644 index 0000000000..a9fe0dcaa3 --- /dev/null +++ b/tests/framework/Utils.h @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_UTILS +#define ARM_COMPUTE_TEST_UTILS + +#include "support/ToolchainSupport.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** @cond */ +namespace detail +{ +template +struct sequence +{ +}; + +template +struct sequence_generator; + +template +struct sequence_generator<0, Ns...> +{ + using type = sequence; +}; + +template +struct sequence_generator : sequence_generator < N - 1, N - 1, Ns... > +{ +}; + +template +using sequence_t = typename sequence_generator::type; +/** @endcond */ + +template +void apply_impl(O *obj, F &&func, const std::tuple &args, detail::sequence) +{ + (obj->*func)(std::get(args)...); +} +} // namespace + +template +void apply(O *obj, F &&func, const std::tuple &args) +{ + detail::apply_impl(obj, std::forward(func), args, detail::sequence_t()); +} + +/** Helper function to concatenate multiple strings. + * + * @param[in] first Iterator pointing to the first element to be concatenated. + * @param[in] last Iterator pointing behind the last element to be concatenated. + * @param[in] separator String used to join the elements. + * + * @return String containing all elements joined by @p separator. + */ +template ::value, int>::type = 0> +std::string join(T first, T last, const std::string &separator) +{ + return std::accumulate(std::next(first), last, *first, [&separator](const std::string & base, const std::string & suffix) + { + return base + separator + suffix; + }); +} + +/** Helper function to concatenate multiple values. + * + * All values are converted to std::string using the provided operation before + * being joined. + * + * The signature of op has to be equivalent to + * std::string op(const T::value_type &val). + * + * @param[in] first Iterator pointing to the first element to be concatenated. + * @param[in] last Iterator pointing behind the last element to be concatenated. + * @param[in] separator String used to join the elements. + * @param[in] op Conversion function. + * + * @return String containing all elements joined by @p separator. + */ +template +std::string join(T &&first, T &&last, const std::string &separator, UnaryOp &&op) +{ + return std::accumulate(std::next(first), last, op(*first), [&separator, &op](const std::string & base, const typename T::value_type & suffix) + { + return base + separator + op(suffix); + }); +} + +/** Helper function to concatenate multiple values. + * + * All values are converted to std::string using std::to_string before being joined. + * + * @param[in] first Iterator pointing to the first element to be concatenated. + * @param[in] last Iterator pointing behind the last element to be concatenated. + * @param[in] separator String used to join the elements. + * + * @return String containing all elements joined by @p separator. + */ +template ::value, int>::type = 0> +std::string join(T && first, T && last, const std::string &separator) +{ + return join(std::forward(first), std::forward(last), separator, support::cpp11::to_string); +} + +/** Convert string to lower case. + * + * @param[in] string To be converted string. + * + * @return Lower case string. + */ +inline std::string tolower(std::string string) +{ + std::transform(string.begin(), string.end(), string.begin(), [](unsigned char c) + { + return std::tolower(c); + }); + return string; +} +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_UTILS */ diff --git a/tests/framework/command_line/CommandLineOptions.h b/tests/framework/command_line/CommandLineOptions.h new file mode 100644 index 0000000000..cb4b794a3e --- /dev/null +++ b/tests/framework/command_line/CommandLineOptions.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_COMMANDLINEOPTIONS +#define ARM_COMPUTE_TEST_COMMANDLINEOPTIONS + +#include "EnumListOption.h" +#include "EnumOption.h" +#include "ListOption.h" +#include "Option.h" +#include "ToggleOption.h" + +#endif /* ARM_COMPUTE_TEST_COMMANDLINEOPTIONS */ diff --git a/tests/framework/command_line/CommandLineParser.cpp b/tests/framework/command_line/CommandLineParser.cpp new file mode 100644 index 0000000000..228b18d842 --- /dev/null +++ b/tests/framework/command_line/CommandLineParser.cpp @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CommandLineParser.h" + +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +void CommandLineParser::parse(int argc, char **argv) +{ + const std::regex option_regex{ "--((?:no-)?)([^=]+)(?:=(.*))?" }; + + const auto set_option = [&](const std::string & option, const std::string & name, const std::string & value) + { + if(_options.find(name) == _options.end()) + { + _unknown_options.push_back(option); + return; + } + + const bool success = _options[name]->parse(value); + + if(!success) + { + _invalid_options.push_back(option); + } + }; + + unsigned int positional_index = 0; + + for(int i = 1; i < argc; ++i) + { + const std::string option{ argv[i] }; + std::smatch option_matches; + + if(std::regex_match(option, option_matches, option_regex)) + { + // Boolean option + if(option_matches.str(3).empty()) + { + set_option(option, option_matches.str(2), option_matches.str(1).empty() ? "true" : "false"); + } + else + { + // Can't have "no-" and a value + if(!option_matches.str(1).empty()) + { + _invalid_options.emplace_back(option); + } + else + { + set_option(option, option_matches.str(2), option_matches.str(3)); + } + } + } + else + { + if(positional_index >= _positional_options.size()) + { + _invalid_options.push_back(option); + } + else + { + _positional_options[positional_index]->parse(option); + ++positional_index; + } + } + } +} + +bool CommandLineParser::validate() const +{ + bool is_valid = true; + + for(const auto &option : _options) + { + if(option.second->is_required() && !option.second->is_set()) + { + is_valid = false; + std::cerr << "ERROR: Option '" << option.second->name() << "' is required but not given!\n"; + } + } + + for(const auto &option : _positional_options) + { + if(option->is_required() && !option->is_set()) + { + is_valid = false; + std::cerr << "ERROR: Option '" << option->name() << "' is required but not given!\n"; + } + } + + for(const auto &option : _unknown_options) + { + std::cerr << "WARNING: Skipping unknown option '" << option << "'!\n"; + } + + for(const auto &option : _invalid_options) + { + std::cerr << "WARNING: Skipping invalid option '" << option << "'!\n"; + } + + return is_valid; +} + +void CommandLineParser::print_help(const std::string &program_name) const +{ + std::cout << "usage: " << program_name << " \n"; + + for(const auto &option : _options) + { + std::cout << option.second->help() << "\n"; + } + + for(const auto &option : _positional_options) + { + //FIXME: Print help string as well + std::cout << option->name() << "\n"; + } +} +} // namespace framework +} // namespace test +} // namespace arm_compute diff --git a/tests/framework/command_line/CommandLineParser.h b/tests/framework/command_line/CommandLineParser.h new file mode 100644 index 0000000000..adb5214e2f --- /dev/null +++ b/tests/framework/command_line/CommandLineParser.h @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_COMMANDLINEPARSER +#define ARM_COMPUTE_TEST_COMMANDLINEPARSER + +#include "../Utils.h" +#include "Option.h" + +#include +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Class to parse command line arguments. */ +class CommandLineParser final +{ +public: + /** Default constructor. */ + CommandLineParser() = default; + + /** Function to add a new option to the parser. + * + * @param[in] name Name of the option. Will be available under --name=VALUE. + * @param[in] args Option specific configuration arguments. + * + * @return Pointer to the option. The option is owned by the parser. + */ + template + T *add_option(const std::string &name, As &&... args); + + /** Function to add a new positional argument to the parser. + * + * @param[in] args Option specific configuration arguments. + * + * @return Pointer to the option. The option is owned by the parser. + */ + template + T *add_positional_option(As &&... args); + + /** Parses the command line arguments and updates the options accordingly. + * + * @param[in] argc Number of arguments. + * @param[in] argv Arguments. + */ + void parse(int argc, char **argv); + + /** Validates the previously parsed command line arguments. + * + * Validation fails if not all required options are provided. Additionally + * warnings are generated for options that have illegal values or unknown + * options. + * + * @return True if all required options have been provided. + */ + bool validate() const; + + /** Prints a help message for all configured options. + * + * @param[in] program_name Name of the program to be used in the help message. + */ + void print_help(const std::string &program_name) const; + +private: + using OptionsMap = std::map>; + using PositionalOptionsVector = std::vector>; + + OptionsMap _options{}; + PositionalOptionsVector _positional_options{}; + std::vector _unknown_options{}; + std::vector _invalid_options{}; +}; + +template +inline T *CommandLineParser::add_option(const std::string &name, As &&... args) +{ + auto result = _options.emplace(name, support::cpp14::make_unique(name, std::forward(args)...)); + return static_cast(result.first->second.get()); +} + +template +inline T *CommandLineParser::add_positional_option(As &&... args) +{ + _positional_options.emplace_back(support::cpp14::make_unique(std::forward(args)...)); + return static_cast(_positional_options.back().get()); +} +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_COMMANDLINEPARSER */ diff --git a/tests/framework/command_line/EnumListOption.h b/tests/framework/command_line/EnumListOption.h new file mode 100644 index 0000000000..d19bfbdc0f --- /dev/null +++ b/tests/framework/command_line/EnumListOption.h @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_ENUMLISTOPTION +#define ARM_COMPUTE_TEST_ENUMLISTOPTION + +#include "Option.h" + +#include +#include +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Implementation of an option that accepts any number of values from a fixed set. */ +template +class EnumListOption : public Option +{ +public: + /** Construct option with allowed values. + * + * @param[in] name Name of the option. + * @param[in] allowed_values Set of allowed values for the option. + */ + EnumListOption(std::string name, std::set allowed_values); + + /** Construct option with allowed values, a fixed number of accepted values and default values for the option. + * + * @param[in] name Name of the option. + * @param[in] allowed_values Set of allowed values for the option. + * @param[in] default_values Default values. + */ + EnumListOption(std::string name, std::set allowed_values, std::initializer_list &&default_values); + + bool parse(std::string value) override; + std::string help() const override; + const std::vector &value() const; + +private: + std::vector _values{}; + std::set _allowed_values{}; +}; + +template +inline EnumListOption::EnumListOption(std::string name, std::set allowed_values) + : Option{ std::move(name) }, _allowed_values{ std::move(allowed_values) } +{ +} + +template +inline EnumListOption::EnumListOption(std::string name, std::set allowed_values, std::initializer_list &&default_values) + : Option{ std::move(name), false, true }, _values{ std::forward>(default_values) }, _allowed_values{ std::move(allowed_values) } +{ +} + +template +bool EnumListOption::parse(std::string value) +{ + // Remove default values + _values.clear(); + _is_set = true; + + try + { + std::stringstream stream{ value }; + std::string item; + + while(!std::getline(stream, item, ',').fail()) + { + std::stringstream item_stream(item); + T typed_value{}; + + item_stream >> typed_value; + + if(!item_stream.fail()) + { + if(_allowed_values.count(typed_value) == 0) + { + _values.clear(); + return false; + } + + _values.emplace_back(typed_value); + } + + _is_set = _is_set && !item_stream.fail(); + } + + return _is_set; + } + catch(const std::invalid_argument &) + { + return false; + } +} + +template +std::string EnumListOption::help() const +{ + std::stringstream msg; + msg << "--" + name() + "={"; + + for(const auto &value : _allowed_values) + { + msg << value << ","; + } + + msg << "}[,{...}[,...]] - " << _help; + + return msg.str(); +} + +template +inline const std::vector &EnumListOption::value() const +{ + return _values; +} +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ENUMLISTOPTION */ diff --git a/tests/framework/command_line/EnumOption.h b/tests/framework/command_line/EnumOption.h new file mode 100644 index 0000000000..1abba77b4b --- /dev/null +++ b/tests/framework/command_line/EnumOption.h @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_ENUMOPTION +#define ARM_COMPUTE_TEST_ENUMOPTION + +#include "SimpleOption.h" + +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Implementation of a simple option that accepts a value from a fixed set. */ +template +class EnumOption : public SimpleOption +{ +public: + /** Construct option with allowed values. + * + * @param[in] name Name of the option. + * @param[in] allowed_values Set of allowed values for the option. + */ + EnumOption(std::string name, std::set allowed_values); + + /** Construct option with allowed values, a fixed number of accepted values and default values for the option. + * + * @param[in] name Name of the option. + * @param[in] allowed_values Set of allowed values for the option. + * @param[in] default_value Default value. + */ + EnumOption(std::string name, std::set allowed_values, T default_value); + + bool parse(std::string value) override; + std::string help() const override; + const T &value() const; + +private: + std::set _allowed_values{}; +}; + +template +inline EnumOption::EnumOption(std::string name, std::set allowed_values) + : SimpleOption{ std::move(name) }, _allowed_values{ std::move(allowed_values) } +{ +} + +template +inline EnumOption::EnumOption(std::string name, std::set allowed_values, T default_value) + : SimpleOption{ std::move(name), std::move(default_value) }, _allowed_values{ std::move(allowed_values) } +{ +} + +template +bool EnumOption::parse(std::string value) +{ + try + { + std::stringstream stream{ value }; + T typed_value{}; + + stream >> typed_value; + + if(!stream.fail()) + { + if(_allowed_values.count(typed_value) == 0) + { + return false; + } + + this->_value = std::move(typed_value); + this->_is_set = true; + return true; + } + + return false; + } + catch(const std::invalid_argument &) + { + return false; + } +} + +template +std::string EnumOption::help() const +{ + std::stringstream msg; + msg << "--" + this->name() + "={"; + + for(const auto &value : _allowed_values) + { + msg << value << ","; + } + + msg << "} - " << this->_help; + + return msg.str(); +} + +template +inline const T &EnumOption::value() const +{ + return this->_value; +} +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ENUMOPTION */ diff --git a/tests/framework/command_line/ListOption.h b/tests/framework/command_line/ListOption.h new file mode 100644 index 0000000000..8b1bb3d05a --- /dev/null +++ b/tests/framework/command_line/ListOption.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_LISTOPTION +#define ARM_COMPUTE_TEST_LISTOPTION + +#include "Option.h" + +#include +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Implementation of an option that accepts any number of values. */ +template +class ListOption : public Option +{ +public: + using Option::Option; + + /** Construct the option with the given default values. + * + * @param[in] name Name of the option. + * @param[in] default_values Default values. + */ + ListOption(std::string name, std::initializer_list &&default_values); + + bool parse(std::string value) override; + std::string help() const override; + const std::vector &value() const; + +private: + std::vector _values{}; +}; + +template +inline ListOption::ListOption(std::string name, std::initializer_list &&default_values) + : Option{ std::move(name), false, true }, _values{ std::forward>(default_values) } +{ +} + +template +bool ListOption::parse(std::string value) +{ + _is_set = true; + + try + { + std::stringstream stream{ value }; + std::string item; + + while(!std::getline(stream, item, ',').fail()) + { + std::stringstream item_stream(item); + T typed_value{}; + + item_stream >> typed_value; + + if(!item_stream.fail()) + { + _values.emplace_back(typed_value); + } + + _is_set = _is_set && !item_stream.fail(); + } + + return _is_set; + } + catch(const std::invalid_argument &) + { + return false; + } +} + +template +inline std::string ListOption::help() const +{ + return "--" + name() + "=VALUE[,VALUE[,...]] - " + _help; +} + +template +inline const std::vector &ListOption::value() const +{ + return _values; +} +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_LISTOPTION */ diff --git a/tests/framework/command_line/Option.cpp b/tests/framework/command_line/Option.cpp new file mode 100644 index 0000000000..d60c35a698 --- /dev/null +++ b/tests/framework/command_line/Option.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "Option.h" + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +Option::Option(std::string name) + : _name{ std::move(name) } +{ +} + +Option::Option(std::string name, bool is_required, bool is_set) + : _name{ std::move(name) }, _is_required{ is_required }, _is_set{ is_set } +{ +} + +std::string Option::name() const +{ + return _name; +} + +void Option::set_required(bool is_required) +{ + _is_required = is_required; +} + +void Option::set_help(std::string help) +{ + _help = std::move(help); +} + +bool Option::is_required() const +{ + return _is_required; +} + +bool Option::is_set() const +{ + return _is_set; +} +} // namespace framework +} // namespace test +} // namespace arm_compute diff --git a/tests/framework/command_line/Option.h b/tests/framework/command_line/Option.h new file mode 100644 index 0000000000..25cf492b86 --- /dev/null +++ b/tests/framework/command_line/Option.h @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_OPTIONBASE +#define ARM_COMPUTE_TEST_OPTIONBASE + +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Abstract base class for a command line option. */ +class Option +{ +public: + /** Constructor. + * + * @param[in] name Name of the option. + */ + Option(std::string name); + + /** Constructor. + * + * @param[in] name Name of the option. + * @param[in] is_required Is the option required? + * @param[in] is_set Has a value been assigned to the option? + */ + Option(std::string name, bool is_required, bool is_set); + + /** Default destructor. */ + virtual ~Option() = default; + + /** Parses the given string. + * + * @param[in] value String representation as passed on the command line. + * + * @return True if the value could be parsed by the specific subclass. + */ + virtual bool parse(std::string value) = 0; + + /** Help message for the option. + * + * @return String representing the help message for the specific subclass. + */ + virtual std::string help() const = 0; + + /** Name of the option. + * + * @return Name of the option. + */ + std::string name() const; + + /** Set whether the option is required. + * + * @param[in] is_required Pass true if the option is required. + */ + void set_required(bool is_required); + + /** Set the help message for the option. + * + * @param[in] help Option specific help message. + */ + void set_help(std::string help); + + /** Is the option required? + * + * @return True if the option is required. + */ + bool is_required() const; + + /** Has a value been assigned to the option? + * + * @return True if a value has been set. + */ + bool is_set() const; + +protected: + std::string _name; + bool _is_required{ false }; + bool _is_set{ false }; + std::string _help{}; +}; +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_OPTIONBASE */ diff --git a/tests/framework/command_line/SimpleOption.h b/tests/framework/command_line/SimpleOption.h new file mode 100644 index 0000000000..e6e8045840 --- /dev/null +++ b/tests/framework/command_line/SimpleOption.h @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_SIMPLEOPTION +#define ARM_COMPUTE_TEST_SIMPLEOPTION + +#include "Option.h" + +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Implementation of an option that accepts a single value. */ +template +class SimpleOption : public Option +{ +public: + using Option::Option; + + /** Construct the option with the given default value. + * + * @param[in] name Name of the option. + * @param[in] default_value Default value. + */ + SimpleOption(std::string name, T default_value); + + bool parse(std::string value) override; + std::string help() const override; + const T &value() const; + +protected: + T _value{}; +}; + +template +inline SimpleOption::SimpleOption(std::string name, T default_value) + : Option{ std::move(name), false, true }, _value{ std::move(default_value) } +{ +} + +template +bool SimpleOption::parse(std::string value) +{ + try + { + std::stringstream stream{ std::move(value) }; + stream >> _value; + _is_set = !stream.fail(); + return _is_set; + } + catch(const std::invalid_argument &) + { + return false; + } +} + +template <> +inline bool SimpleOption::parse(std::string value) +{ + _value = std::move(value); + _is_set = true; + return true; +} + +template +inline std::string SimpleOption::help() const +{ + return "--" + name() + "=VALUE - " + _help; +} + +template +inline const T &SimpleOption::value() const +{ + return _value; +} +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_SIMPLEOPTION */ diff --git a/tests/framework/command_line/ToggleOption.cpp b/tests/framework/command_line/ToggleOption.cpp new file mode 100644 index 0000000000..df5b1f813b --- /dev/null +++ b/tests/framework/command_line/ToggleOption.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "ToggleOption.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +ToggleOption::ToggleOption(std::string name, bool default_value) + : SimpleOption +{ + std::move(name), default_value +} +{ +} + +bool ToggleOption::parse(std::string value) +{ + if(value == "true") + { + _value = true; + _is_set = true; + } + else if(value == "false") + { + _value = false; + _is_set = true; + } + + return _is_set; +} + +std::string ToggleOption::help() const +{ + return "--" + name() + ", --no-" + name() + " - " + _help; +} +} // namespace framework +} // namespace test +} // namespace arm_compute diff --git a/tests/framework/command_line/ToggleOption.h b/tests/framework/command_line/ToggleOption.h new file mode 100644 index 0000000000..c440c0ee87 --- /dev/null +++ b/tests/framework/command_line/ToggleOption.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_TOGGLEOPTION +#define ARM_COMPUTE_TEST_TOGGLEOPTION + +#include "SimpleOption.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Implementation of an option that can be either true or false. */ +class ToggleOption : public SimpleOption +{ +public: + using SimpleOption::SimpleOption; + + /** Construct the option with the given default value. + * + * @param[in] name Name of the option. + * @param[in] default_value Default value. + */ + ToggleOption(std::string name, bool default_value); + + bool parse(std::string value) override; + std::string help() const override; +}; +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_TOGGLEOPTION */ diff --git a/tests/framework/datasets/CartesianProductDataset.h b/tests/framework/datasets/CartesianProductDataset.h new file mode 100644 index 0000000000..f6e45ddc12 --- /dev/null +++ b/tests/framework/datasets/CartesianProductDataset.h @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DATASET_CARTESIAN_PRODUCT +#define ARM_COMPUTE_TEST_DATASET_CARTESIAN_PRODUCT + +#include "Dataset.h" + +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +namespace dataset +{ +/** Implementation of a dataset representing all combinations of values of the input datasets. + * + * For example, for the inputs {1, 2} and {3, 4} this dataset virtually + * represents the values {(1, 3), (1, 4), (2, 3), (2, 4)}. + */ +template +class CartesianProductDataset : public Dataset +{ +private: + using T_noref = typename std::remove_reference::type; + using U_noref = typename std::remove_reference::type; + using iter1_type = typename T_noref::iterator; + using iter2_type = typename U_noref::iterator; + +public: + /** Construct dataset from the given datasets. + * + * @param[in] dataset1 First dataset. + * @param[in] dataset2 Second dataset. + */ + CartesianProductDataset(T &&dataset1, U &&dataset2) + : _dataset1{ std::forward(dataset1) }, + _dataset2{ std::forward(dataset2) } + { + } + + CartesianProductDataset(CartesianProductDataset &&) = default; + + /** Type of the dataset. */ + using type = decltype(std::tuple_cat(*std::declval(), *std::declval())); + + /** Iterator for the dataset. */ + struct iterator + { + iterator(const T_noref *dataset1, const U_noref *dataset2) + : _iter1{ dataset1->begin() }, + _dataset2{ dataset2 }, + _iter2{ dataset2->begin() } + { + } + + iterator(const iterator &) = default; + iterator &operator=(const iterator &) = default; + iterator(iterator &&) = default; + iterator &operator=(iterator &&) = default; + + ~iterator() = default; + + std::string description() const + { + return _iter1.description() + ":" + _iter2.description(); + } + + CartesianProductDataset::type operator*() const + { + return std::tuple_cat(*_iter1, *_iter2); + } + + iterator &operator++() + { + ++_second_pos; + + if(_second_pos < _dataset2->size()) + { + ++_iter2; + } + else + { + _second_pos = 0; + _iter2 = _dataset2->begin(); + + ++_iter1; + } + + return *this; + } + + private: + iter1_type _iter1; + const U_noref *_dataset2; + iter2_type _iter2; + int _first_pos{ 0 }; + int _second_pos{ 0 }; + }; + + /** Iterator pointing at the begin of the dataset. + * + * @return Iterator for the dataset. + */ + iterator begin() const + { + return iterator(&_dataset1, &_dataset2); + } + + /** Size of the dataset. + * + * @return Number of values in the dataset. + */ + int size() const + { + return _dataset1.size() * _dataset2.size(); + } + +private: + T _dataset1; + U _dataset2; +}; + +/** Helper function to create a @ref CartesianProductDataset. + * + * @param[in] dataset1 First dataset. + * @param[in] dataset2 Second dataset. + * + * @return A grid dataset. + */ +template +CartesianProductDataset combine(T &&dataset1, U &&dataset2) +{ + return CartesianProductDataset(std::forward(dataset1), std::forward(dataset2)); +} +} // namespace dataset +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DATASET_CARTESIAN_PRODUCT */ diff --git a/tests/framework/datasets/ContainerDataset.h b/tests/framework/datasets/ContainerDataset.h new file mode 100644 index 0000000000..bdca97cbac --- /dev/null +++ b/tests/framework/datasets/ContainerDataset.h @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DATASET_CONTAINER +#define ARM_COMPUTE_TEST_DATASET_CONTAINER + +#include "Dataset.h" +#include "support/ToolchainSupport.h" + +#include +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +namespace dataset +{ +/** Base case. Nothing is a container. */ +template +struct is_container : public std::false_type +{ +}; + +/** Vector is considered a container. */ +template +struct is_container> : public std::true_type +{ +}; + +/** Implementation of a dataset created from a container. */ +template +class ContainerDataset : public NamedDataset +{ +private: + using container_value_type = typename T::value_type; + using container_const_iterator = typename T::const_iterator; + +public: + /** Construct dataset with given name and values from the container. + * + * @param[in] name Description of the values. + * @param[in] container Values for the dataset. + */ + ContainerDataset(std::string name, T &&container) + : NamedDataset{ std::move(name) }, _container(std::forward(container)) + { + } + + ContainerDataset(ContainerDataset &&) = default; + + /** Type of the dataset. */ + using type = std::tuple; + + /** Iterator for the dataset. */ + struct iterator + { + iterator(std::string name, container_const_iterator iterator) + : _name{ name }, _iterator{ iterator } + { + } + + std::string description() const + { + using support::cpp11::to_string; + return _name + "=" + to_string(*_iterator); + } + + ContainerDataset::type operator*() const + { + return std::make_tuple(*_iterator); + } + + iterator &operator++() + { + ++_iterator; + return *this; + } + + private: + std::string _name; + container_const_iterator _iterator; + }; + + /** Iterator pointing at the begin of the dataset. + * + * @return Iterator for the dataset. + */ + iterator begin() const + { + return iterator(name(), _container.cbegin()); + } + + /** Size of the dataset. + * + * @return Number of values in the dataset. + */ + int size() const + { + return _container.size(); + } + +private: + T _container; +}; + +/** Helper function to create a @ref ContainerDataset. + * + * @param[in] name Name of the dataset. + * @param[in] values Container. + * + * @return A container dataset. + */ +template +typename std::enable_if::value, ContainerDataset>::type make(std::string name, T &&values) +{ + return ContainerDataset(std::move(name), std::forward(values)); +} +} // namespace dataset +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DATASET_CONTAINER */ diff --git a/tests/framework/datasets/Dataset.h b/tests/framework/datasets/Dataset.h new file mode 100644 index 0000000000..d91673073a --- /dev/null +++ b/tests/framework/datasets/Dataset.h @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DATASET +#define ARM_COMPUTE_TEST_DATASET + +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +namespace dataset +{ +/** Abstract dataset base class. */ +class Dataset +{ +protected: + Dataset() = default; + ~Dataset() = default; + +public: + Dataset(Dataset &&) = default; +}; + +/** Abstract implementation of a named dataset. + * + * The name should describe the values of the dataset. + */ +class NamedDataset : public Dataset +{ +protected: + /** Construct the dataset with the given name. + * + * @param[in] name Description of the values. + */ + explicit NamedDataset(std::string name) + : _name{ std::move(name) } + { + } + + ~NamedDataset() = default; + +public: + NamedDataset(NamedDataset &&) = default; + + /** Return name of the dataset. + * + * @return Description of the values. + */ + std::string name() const + { + return _name; + } + +protected: + const std::string _name; +}; +} // namespace dataset +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DATASET */ diff --git a/tests/framework/datasets/Datasets.h b/tests/framework/datasets/Datasets.h new file mode 100644 index 0000000000..c0e5822e17 --- /dev/null +++ b/tests/framework/datasets/Datasets.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DATASETS +#define ARM_COMPUTE_TEST_DATASETS + +#include "CartesianProductDataset.h" +#include "ContainerDataset.h" +#include "InitializerListDataset.h" +#include "JoinDataset.h" +#include "RangeDataset.h" +#include "SingletonDataset.h" +#include "ZipDataset.h" + +#endif /* ARM_COMPUTE_TEST_DATASETS */ diff --git a/tests/framework/datasets/InitializerListDataset.h b/tests/framework/datasets/InitializerListDataset.h new file mode 100644 index 0000000000..7d32234fab --- /dev/null +++ b/tests/framework/datasets/InitializerListDataset.h @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DATASET_LIST +#define ARM_COMPUTE_TEST_DATASET_LIST + +#include "Dataset.h" +#include "support/ToolchainSupport.h" + +#include +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +namespace dataset +{ +/** Implementation of a dataset created from an initializer list. */ +template +class InitializerListDataset final : public NamedDataset +{ +private: + using data_const_iterator = typename std::vector::const_iterator; + +public: + /** Construct dataset with given name and values from the container. + * + * @param[in] name Description of the values. + * @param[in] list Values for the dataset. + */ + InitializerListDataset(std::string name, std::initializer_list &&list) + : NamedDataset{ std::move(name) }, _data(std::forward>(list)) + { + } + + InitializerListDataset(InitializerListDataset &&) = default; + + /** Type of the dataset. */ + using type = std::tuple; + + /** Iterator for the dataset. */ + struct iterator + { + iterator(std::string name, data_const_iterator iterator) + : _name{ name }, _iterator{ iterator } + { + } + + std::string description() const + { + using support::cpp11::to_string; + return _name + "=" + to_string(*_iterator); + } + + InitializerListDataset::type operator*() const + { + return std::make_tuple(*_iterator); + } + + iterator &operator++() + { + ++_iterator; + return *this; + } + + private: + std::string _name; + data_const_iterator _iterator; + }; + + /** Iterator pointing at the begin of the dataset. + * + * @return Iterator for the dataset. + */ + iterator begin() const + { + return iterator(name(), _data.cbegin()); + } + + /** Size of the dataset. + * + * @return Number of values in the dataset. + */ + int size() const + { + return _data.size(); + } + +private: + std::vector _data; +}; + +/** Helper function to create an @ref InitializerListDataset. + * + * @param[in] name Name of the dataset. + * @param[in] list Initializer list. + * + * @return An initializer list dataset. + */ +template +InitializerListDataset make(std::string name, std::initializer_list &&list) +{ + return InitializerListDataset(std::move(name), std::forward>(list)); +} +} // namespace dataset +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DATASET_LIST */ diff --git a/tests/framework/datasets/JoinDataset.h b/tests/framework/datasets/JoinDataset.h new file mode 100644 index 0000000000..eded6e0259 --- /dev/null +++ b/tests/framework/datasets/JoinDataset.h @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DATASET_JOIN +#define ARM_COMPUTE_TEST_DATASET_JOIN + +#include "Dataset.h" + +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +namespace dataset +{ +/** Implementation of a dataset representing the concatenation of the input datasets. + * + * For example, for the inputs {1, 2} and {3, 4} this dataset virtually + * represents the values {1, 2, 3, 4}. + */ +template +class JoinDataset : public Dataset +{ +private: + using iter1_type = typename T::iterator; + using iter2_type = typename U::iterator; + +public: + /** Construct dataset from the given datasets. + * + * @param[in] dataset1 First dataset. + * @param[in] dataset2 Second dataset. + */ + JoinDataset(T &&dataset1, U &&dataset2) + : _dataset1{ std::forward(dataset1) }, + _dataset2{ std::forward(dataset2) } + { + } + + JoinDataset(JoinDataset &&) = default; + + /** Type of the dataset. */ + using type = typename T::type; + + /** Iterator for the dataset. */ + struct iterator + { + iterator(const T *dataset1, const U *dataset2) + : _iter1{ dataset1->begin() }, _iter2{ dataset2->begin() }, _first_size{ dataset1->size() } + { + } + + std::string description() const + { + return _first_size > 0 ? _iter1.description() : _iter2.description(); + } + + JoinDataset::type operator*() const + { + return _first_size > 0 ? *_iter1 : *_iter2; + } + + iterator &operator++() + { + if(_first_size > 0) + { + --_first_size; + ++_iter1; + } + else + { + ++_iter2; + } + + return *this; + } + + private: + iter1_type _iter1; + iter2_type _iter2; + int _first_size; + }; + + /** Iterator pointing at the begin of the dataset. + * + * @return Iterator for the dataset. + */ + iterator begin() const + { + return iterator(&_dataset1, &_dataset2); + } + + /** Size of the dataset. + * + * @return Number of values in the dataset. + */ + int size() const + { + return _dataset1.size() + _dataset2.size(); + } + +private: + T _dataset1; + U _dataset2; +}; + +/** Helper function to create a @ref JoinDataset. + * + * @param[in] dataset1 First dataset. + * @param[in] dataset2 Second dataset. + * + * @return A join dataset. + */ +template +JoinDataset concat(T &&dataset1, U &&dataset2) +{ + return JoinDataset(std::forward(dataset1), std::forward(dataset2)); +} +} // namespace dataset +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DATASET_JOIN */ diff --git a/tests/framework/datasets/RangeDataset.h b/tests/framework/datasets/RangeDataset.h new file mode 100644 index 0000000000..637abe0a83 --- /dev/null +++ b/tests/framework/datasets/RangeDataset.h @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DATASET_RANGE +#define ARM_COMPUTE_TEST_DATASET_RANGE + +#include "Dataset.h" +#include "support/ToolchainSupport.h" + +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +namespace dataset +{ +/** Implementation of a dataset created from a range of values. + * + * The range is inclusive of the first value but exclusive of the last, i.e. [start, end). + */ +template +class RangeDataset final : public NamedDataset +{ +public: + /** Construct dataset with given name and values in the specified range. + * + * @param[in] name Description of the values. + * @param[in] start Begin of the range. + * @param[in] end End of the range. + * @param[in] step Step size. + */ + RangeDataset(std::string name, T start, T end, T step = 1) + : NamedDataset{ std::move(name) }, _start{ start }, _end{ end }, _step{ step } + { + } + + RangeDataset(RangeDataset &&) = default; + + /** Type of the dataset. */ + using type = std::tuple; + + /** Iterator for the dataset. */ + struct iterator + { + iterator(std::string name, T start, T step) + : _name{ name }, _value{ start }, _step{ step } + { + } + + std::string description() const + { + using support::cpp11::to_string; + return _name + "=" + to_string(_value); + } + + RangeDataset::type operator*() const + { + return std::make_tuple(_value); + } + + iterator &operator++() + { + _value += _step; + return *this; + } + + private: + std::string _name; + T _value; + T _step; + }; + + /** Iterator pointing at the begin of the dataset. + * + * @return Iterator for the dataset. + */ + iterator begin() const + { + return iterator(name(), _start, _step); + } + + /** Size of the dataset. + * + * @return Number of values in the dataset. + */ + int size() const + { + return (_end - _start) / std::abs(_step); + } + +private: + T _start; + T _end; + T _step; +}; + +/** Helper function to create a @ref RangeDataset. + * + * @param[in] name Name of the dataset. + * @param[in] start Begin of the range. + * @param[in] end End of the range. + * @param[in] step Step size. + * + * @return A range dataset. + */ +template +RangeDataset make(std::string name, T start, T end, T step = 1) +{ + return RangeDataset(std::move(name), start, end, step); +} +} // namespace dataset +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DATASET_RANGE */ diff --git a/tests/framework/datasets/SingletonDataset.h b/tests/framework/datasets/SingletonDataset.h new file mode 100644 index 0000000000..1acb5765e5 --- /dev/null +++ b/tests/framework/datasets/SingletonDataset.h @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DATASET_SINGLETON +#define ARM_COMPUTE_TEST_DATASET_SINGLETON + +#include "ContainerDataset.h" +#include "Dataset.h" +#include "support/ToolchainSupport.h" + +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +namespace dataset +{ +/** Implementation of a dataset holding a single value. */ +template +class SingletonDataset : public NamedDataset +{ +public: + /** Construct dataset with given name and value. + * + * @param[in] name Description of the value. + * @param[in] value Value for the dataset. + */ + SingletonDataset(std::string name, T &&value) + : NamedDataset{ std::move(name) }, _value{ std::forward(value) } + { + } + + SingletonDataset(SingletonDataset &&) = default; + + /** Type of the dataset. */ + using type = std::tuple; + + /** Iterator for the dataset. */ + struct iterator + { + iterator(std::string name, const T *value) + : _name{ name }, _value{ value } + { + } + + ~iterator() = default; + + iterator(const iterator &) = default; + iterator &operator=(const iterator &) = default; + iterator(iterator &&) = default; + iterator &operator=(iterator &&) = default; + + std::string description() const + { + using support::cpp11::to_string; + return _name + "=" + to_string(*_value); + } + + SingletonDataset::type operator*() const + { + return std::make_tuple(*_value); + } + + iterator &operator++() + { + return *this; + } + + private: + std::string _name; + const T *_value; + }; + + /** Iterator pointing at the begin of the dataset. + * + * @return Iterator for the dataset. + */ + iterator begin() const + { + return iterator(name(), &_value); + } + + /** Size of the dataset. + * + * @return Number of values in the dataset. + */ + int size() const + { + return 1; + } + +private: + T _value; +}; + +/** Helper function to create a @ref SingletonDataset. + * + * @param[in] name Name of the dataset. + * @param[in] value Value. + * + * @return A singleton dataset. + */ +template +typename std::enable_if < !is_container::value, SingletonDataset>::type make(std::string name, T &&value) +{ + return SingletonDataset(std::move(name), std::forward(value)); +} +} // namespace dataset +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DATASET_SINGLETON */ diff --git a/tests/framework/datasets/ZipDataset.h b/tests/framework/datasets/ZipDataset.h new file mode 100644 index 0000000000..b95b7209a7 --- /dev/null +++ b/tests/framework/datasets/ZipDataset.h @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DATASET_ZIP +#define ARM_COMPUTE_TEST_DATASET_ZIP + +#include "Dataset.h" + +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +namespace dataset +{ +/** Implementation of a dataset representing pairs of values of the input datasets. + * + * For example, for the inputs {1, 2} and {3, 4} this dataset virtually + * represents the values {(1, 3), (1, 4)}. + */ +template +class ZipDataset : public Dataset +{ +private: + using iter1_type = typename T::iterator; + using iter2_type = typename U::iterator; + +public: + /** Construct dataset from the given datasets. + * + * @param[in] dataset1 First dataset. + * @param[in] dataset2 Second dataset. + */ + ZipDataset(T &&dataset1, U &&dataset2) + : _dataset1{ std::forward(dataset1) }, + _dataset2{ std::forward(dataset2) } + { + } + + ZipDataset(ZipDataset &&) = default; + + /** Type of the dataset. */ + using type = decltype(std::tuple_cat(*std::declval(), *std::declval())); + + /** Iterator for the dataset. */ + struct iterator + { + iterator(iter1_type iter1, iter2_type iter2) + : _iter1{ std::move(iter1) }, _iter2{ std::move(iter2) } + { + } + + std::string description() const + { + return _iter1.description() + ":" + _iter2.description(); + } + + ZipDataset::type operator*() const + { + return std::tuple_cat(*_iter1, *_iter2); + } + + iterator &operator++() + { + ++_iter1; + ++_iter2; + return *this; + } + + private: + iter1_type _iter1; + iter2_type _iter2; + }; + + /** Iterator pointing at the begin of the dataset. + * + * @return Iterator for the dataset. + */ + iterator begin() const + { + return iterator(_dataset1.begin(), _dataset2.begin()); + } + + /** Size of the dataset. + * + * @return Number of values in the dataset. + */ + int size() const + { + return std::min(_dataset1.size(), _dataset2.size()); + } + +private: + T _dataset1; + U _dataset2; +}; + +/** Helper function to create a @ref ZipDataset. + * + * @param[in] dataset1 First dataset. + * @param[in] dataset2 Second dataset. + * + * @return A zip dataset. + */ +template +ZipDataset zip(T &&dataset1, U &&dataset2) +{ + return ZipDataset(std::forward(dataset1), std::forward(dataset2)); +} +} // namespace dataset +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DATASET_ZIP */ diff --git a/tests/framework/instruments/Instrument.h b/tests/framework/instruments/Instrument.h new file mode 100644 index 0000000000..895a64738c --- /dev/null +++ b/tests/framework/instruments/Instrument.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_INSTRUMENT +#define ARM_COMPUTE_TEST_INSTRUMENT + +#include "../Utils.h" + +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Interface for classes that can be used to measure performance. */ +class Instrument +{ +public: + /** Helper function to create an instrument of the given type. + * + * @return Instance of an instrument of the given type. + */ + template + static std::unique_ptr make_instrument(); + + /** Struct representing measurement consisting of value and unit. */ + struct Measurement final + { + Measurement(double value, std::string unit) + : value{ value }, unit{ std::move(unit) } + { + } + + friend std::ostream &operator<<(std::ostream &os, const Measurement &measurement); + + double value; + std::string unit; + }; + + Instrument() = default; + Instrument(const Instrument &) = default; + Instrument(Instrument &&) = default; + Instrument &operator=(const Instrument &) = default; + Instrument &operator=(Instrument &&) = default; + virtual ~Instrument() = default; + + /** Identifier for the instrument */ + virtual std::string id() const = 0; + + /** Start measuring. */ + virtual void start() = 0; + + /** Stop measuring. */ + virtual void stop() = 0; + + /** Return the latest measurement. */ + virtual Measurement measurement() const = 0; +}; + +inline std::ostream &operator<<(std::ostream &os, const Instrument::Measurement &measurement) +{ + os << measurement.value << measurement.unit; + return os; +} + +template +inline std::unique_ptr Instrument::make_instrument() +{ + return support::cpp14::make_unique(); +} +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_INSTRUMENT */ diff --git a/tests/framework/instruments/Instruments.cpp b/tests/framework/instruments/Instruments.cpp new file mode 100644 index 0000000000..797a7242ae --- /dev/null +++ b/tests/framework/instruments/Instruments.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "Instruments.h" + +#include "../Utils.h" + +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +InstrumentType instrument_type_from_name(const std::string &name) +{ + static const std::map types = + { + { "all", InstrumentType::ALL }, + { "none", InstrumentType::NONE }, + { "wall_clock", InstrumentType::WALL_CLOCK_TIMER }, + { "cycles", InstrumentType::PMU_CYCLE_COUNTER }, + { "instructions", InstrumentType::PMU_INSTRUCTION_COUNTER }, + }; + + try + { + return types.at(tolower(name)); + } + catch(const std::out_of_range &) + { + throw std::invalid_argument(name); + } +} +} // namespace framework +} // namespace test +} // namespace arm_compute diff --git a/tests/framework/instruments/Instruments.h b/tests/framework/instruments/Instruments.h new file mode 100644 index 0000000000..034fa168f5 --- /dev/null +++ b/tests/framework/instruments/Instruments.h @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_INSTRUMENTS +#define ARM_COMPUTE_TEST_INSTRUMENTS + +#include "PMUCounter.h" +#include "WallClockTimer.h" + +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +enum class InstrumentType : unsigned int +{ + ALL = ~0U, + NONE = 0, + WALL_CLOCK_TIMER = 1, + PMU_CYCLE_COUNTER = 2, + PMU_INSTRUCTION_COUNTER = 4 +}; + +InstrumentType instrument_type_from_name(const std::string &name); + +inline InstrumentType operator&(InstrumentType t1, InstrumentType t2) +{ + using type = std::underlying_type::type; + return static_cast(static_cast(t1) & static_cast(t2)); +} + +inline InstrumentType operator|(InstrumentType t1, InstrumentType t2) +{ + using type = std::underlying_type::type; + return static_cast(static_cast(t1) | static_cast(t2)); +} + +inline InstrumentType &operator|=(InstrumentType &t1, InstrumentType t2) +{ + using type = std::underlying_type::type; + t1 = static_cast(static_cast(t1) | static_cast(t2)); + return t1; +} + +inline ::std::stringstream &operator>>(::std::stringstream &stream, InstrumentType &instrument) +{ + std::string value; + stream >> value; + instrument = instrument_type_from_name(value); + return stream; +} + +inline ::std::stringstream &operator<<(::std::stringstream &stream, InstrumentType instrument) +{ + switch(instrument) + { + case InstrumentType::WALL_CLOCK_TIMER: + stream << "WALL_CLOCK_TIMER"; + break; + case InstrumentType::PMU_CYCLE_COUNTER: + stream << "PMU_CYCLE_COUNTER"; + break; + case InstrumentType::PMU_INSTRUCTION_COUNTER: + stream << "PMU_INSTRUCTION_COUNTER"; + break; + case InstrumentType::ALL: + stream << "ALL"; + break; + case InstrumentType::NONE: + stream << "NONE"; + break; + default: + throw std::invalid_argument("Unsupported instrument type"); + } + + return stream; +} +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_INSTRUMENTS */ diff --git a/tests/framework/instruments/PMUCounter.cpp b/tests/framework/instruments/PMUCounter.cpp new file mode 100644 index 0000000000..7994a15862 --- /dev/null +++ b/tests/framework/instruments/PMUCounter.cpp @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "PMUCounter.h" + +#define _GNU_SOURCE 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#undef _GNU_SOURCE + +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +CycleCounter::CycleCounter() +{ + const pid_t pid = getpid(); + + struct perf_event_attr perf_config; //NOLINT + memset(&perf_config, 0, sizeof(struct perf_event_attr)); + + perf_config.config = PERF_COUNT_HW_CPU_CYCLES; + perf_config.size = sizeof(struct perf_event_attr); + perf_config.type = PERF_TYPE_HARDWARE; + // The inherit bit specifies that this counter should count events of child + // tasks as well as the task specified + perf_config.inherit = 1; + // Enables saving of event counts on context switch for inherited tasks + perf_config.inherit_stat = 1; + + _fd = syscall(__NR_perf_event_open, &perf_config, pid, -1, -1, 0); + + if(_fd < 0) + { + throw std::runtime_error("perf_event_open for cycles failed"); + } +} + +std::string CycleCounter::id() const +{ + return "Cycle Counter"; +} + +void CycleCounter::start() +{ + ioctl(_fd, PERF_EVENT_IOC_RESET, 0); + ioctl(_fd, PERF_EVENT_IOC_ENABLE, 0); +} + +void CycleCounter::stop() +{ + ioctl(_fd, PERF_EVENT_IOC_DISABLE, 0); + read(_fd, &_cycles, sizeof(_cycles)); +} + +Instrument::Measurement CycleCounter::measurement() const +{ + return Measurement(_cycles, "cycles"); +} + +InstructionCounter::InstructionCounter() +{ + const pid_t pid = getpid(); + + struct perf_event_attr perf_config; //NOLINT + memset(&perf_config, 0, sizeof(struct perf_event_attr)); + + perf_config.config = PERF_COUNT_HW_INSTRUCTIONS; + perf_config.size = sizeof(struct perf_event_attr); + perf_config.type = PERF_TYPE_HARDWARE; + // The inherit bit specifies that this counter should count events of child + // tasks as well as the task specified + perf_config.inherit = 1; + // Enables saving of event counts on context switch for inherited tasks + perf_config.inherit_stat = 1; + + _fd = syscall(__NR_perf_event_open, &perf_config, pid, -1, -1, 0); + + if(_fd < 0) + { + throw std::runtime_error("perf_event_open for instructions failed"); + } +} + +std::string InstructionCounter::id() const +{ + return "Instruction Counter"; +} + +void InstructionCounter::start() +{ + ioctl(_fd, PERF_EVENT_IOC_RESET, 0); + ioctl(_fd, PERF_EVENT_IOC_ENABLE, 0); +} + +void InstructionCounter::stop() +{ + ioctl(_fd, PERF_EVENT_IOC_DISABLE, 0); + read(_fd, &_instructions, sizeof(_instructions)); +} + +Instrument::Measurement InstructionCounter::measurement() const +{ + return Measurement(_instructions, "instructions"); +} +} // namespace framework +} // namespace test +} // namespace arm_compute diff --git a/tests/framework/instruments/PMUCounter.h b/tests/framework/instruments/PMUCounter.h new file mode 100644 index 0000000000..f407be602f --- /dev/null +++ b/tests/framework/instruments/PMUCounter.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_PMU_COUNTER +#define ARM_COMPUTE_TEST_PMU_COUNTER + +#include "Instrument.h" + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Implementation of an instrument to count CPU cycles. */ +class CycleCounter : public Instrument +{ +public: + /** Initialise the cycle counter. */ + CycleCounter(); + + std::string id() const override; + void start() override; + void stop() override; + Measurement measurement() const override; + +private: + long _fd{ -1 }; + long long _cycles{ 0 }; +}; + +/** Implementation of an instrument to count executed CPU instructions. */ +class InstructionCounter : public Instrument +{ +public: + /** Initialise the instruction counter. */ + InstructionCounter(); + + std::string id() const override; + void start() override; + void stop() override; + Measurement measurement() const override; + +private: + long _fd{ -1 }; + long long _instructions{ 0 }; +}; +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_PMU_COUNTER */ diff --git a/tests/framework/instruments/WallClockTimer.cpp b/tests/framework/instruments/WallClockTimer.cpp new file mode 100644 index 0000000000..37db0c7f05 --- /dev/null +++ b/tests/framework/instruments/WallClockTimer.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "WallClockTimer.h" + +#include "../Framework.h" +#include "../Utils.h" + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +std::string WallClockTimer::id() const +{ + return "Wall clock"; +} + +void WallClockTimer::start() +{ + _start = std::chrono::high_resolution_clock::now(); +} + +void WallClockTimer::stop() +{ + _stop = std::chrono::high_resolution_clock::now(); +} + +Instrument::Measurement WallClockTimer::measurement() const +{ + const auto delta = std::chrono::duration_cast(_stop - _start); + return Instrument::Measurement(delta.count(), "us"); +} +} // namespace framework +} // namespace test +} // namespace arm_compute diff --git a/tests/framework/instruments/WallClockTimer.h b/tests/framework/instruments/WallClockTimer.h new file mode 100644 index 0000000000..b7c390f691 --- /dev/null +++ b/tests/framework/instruments/WallClockTimer.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_WALL_CLOCK_TIMER +#define ARM_COMPUTE_TEST_WALL_CLOCK_TIMER + +#include "Instrument.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Implementation of an instrument to measure elapsed wall-clock time in milliseconds. */ +class WallClockTimer : public Instrument +{ +public: + std::string id() const override; + void start() override; + void stop() override; + Measurement measurement() const override; + +private: + std::chrono::high_resolution_clock::time_point _start{}; + std::chrono::high_resolution_clock::time_point _stop{}; +}; +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_WALL_CLOCK_TIMER */ diff --git a/tests/framework/printers/JSONPrinter.cpp b/tests/framework/printers/JSONPrinter.cpp new file mode 100644 index 0000000000..5b30389eca --- /dev/null +++ b/tests/framework/printers/JSONPrinter.cpp @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "JSONPrinter.h" + +#include "tests/framework/Framework.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +void JSONPrinter::print_separator(bool &flag) +{ + if(flag) + { + flag = false; + } + else + { + *_stream << ","; + } +} + +void JSONPrinter::print_entry(const std::string &name, const std::string &value) +{ + print_separator(_first_entry); + + *_stream << R"(")" << name << R"(" : ")" << value << R"(")"; +} + +void JSONPrinter::print_global_header() +{ + *_stream << "{"; +} + +void JSONPrinter::print_global_footer() +{ + *_stream << "}\n"; +} + +void JSONPrinter::print_run_header() +{ + print_separator(_first_entry); + + *_stream << R"("tests" : {)"; +} + +void JSONPrinter::print_run_footer() +{ + *_stream << "}"; +} + +void JSONPrinter::print_test_header(const TestInfo &info) +{ + print_separator(_first_test); + + _first_test_entry = true; + *_stream << R"(")" << info.name << R"(" : {)"; +} + +void JSONPrinter::print_test_footer() +{ + *_stream << "}"; +} + +void JSONPrinter::print_errors_header() +{ + print_separator(_first_test_entry); + + _first_error = true; + *_stream << R"("errors" : [)"; +} + +void JSONPrinter::print_errors_footer() +{ + *_stream << "]"; +} + +void JSONPrinter::print_error(const std::exception &error) +{ + std::stringstream error_log; + error_log.str(error.what()); + + for(std::string line; !std::getline(error_log, line).fail();) + { + print_separator(_first_error); + + *_stream << R"(")" << line << R"(")"; + } +} + +void JSONPrinter::print_measurements(const Profiler::MeasurementsMap &measurements) +{ + print_separator(_first_test_entry); + + *_stream << R"("measurements" : {)"; + + for(auto i_it = measurements.cbegin(), i_end = measurements.cend(); i_it != i_end;) + { + *_stream << R"(")" << i_it->first << R"(" : {)"; + + auto add_measurements = [](double a, const Instrument::Measurement & b) + { + return a + b.value; + }; + + auto cmp_measurements = [](const Instrument::Measurement & a, const Instrument::Measurement & b) + { + return a.value < b.value; + }; + + double sum_values = std::accumulate(i_it->second.cbegin(), i_it->second.cend(), 0., add_measurements); + int num_values = i_it->second.size(); + const auto minmax_values = std::minmax_element(i_it->second.begin(), i_it->second.end(), cmp_measurements); + + if(num_values > 2) + { + sum_values -= minmax_values.first->value + minmax_values.second->value; + num_values -= 2; + } + + auto measurement_to_string = [](const Instrument::Measurement & measurement) + { + return support::cpp11::to_string(measurement.value); + }; + + *_stream << R"("avg" : )" << (sum_values / num_values) << ","; + *_stream << R"("min" : )" << minmax_values.first->value << ","; + *_stream << R"("max" : )" << minmax_values.second->value << ","; + *_stream << R"("raw" : [)" << join(i_it->second.begin(), i_it->second.end(), ",", measurement_to_string) << "],"; + *_stream << R"("unit" : ")" << minmax_values.first->unit << R"(")"; + *_stream << "}"; + + if(++i_it != i_end) + { + *_stream << ","; + } + } + + *_stream << "}"; +} +} // namespace framework +} // namespace test +} // namespace arm_compute diff --git a/tests/framework/printers/JSONPrinter.h b/tests/framework/printers/JSONPrinter.h new file mode 100644 index 0000000000..14c8b35cb9 --- /dev/null +++ b/tests/framework/printers/JSONPrinter.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_JSONPRINTER +#define ARM_COMPUTE_TEST_JSONPRINTER + +#include "Printer.h" + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Implementation of a @ref Printer that produces JSON output. */ +class JSONPrinter : public Printer +{ +public: + using Printer::Printer; + + void print_entry(const std::string &name, const std::string &value) override; + void print_global_header() override; + void print_global_footer() override; + void print_run_header() override; + void print_run_footer() override; + void print_test_header(const TestInfo &info) override; + void print_test_footer() override; + void print_errors_header() override; + void print_errors_footer() override; + void print_error(const std::exception &error) override; + void print_measurements(const Profiler::MeasurementsMap &measurements) override; + +private: + void print_separator(bool &flag); + + bool _first_entry{ true }; + bool _first_test{ true }; + bool _first_test_entry{ true }; + bool _first_error{ true }; +}; +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_JSONPRINTER */ diff --git a/tests/framework/printers/PrettyPrinter.cpp b/tests/framework/printers/PrettyPrinter.cpp new file mode 100644 index 0000000000..ec32e5296e --- /dev/null +++ b/tests/framework/printers/PrettyPrinter.cpp @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "PrettyPrinter.h" + +#include "tests/framework/Framework.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +std::string PrettyPrinter::begin_color(const std::string &color) const +{ + if(!_color_output) + { + return ""; + } + + return "\033[0;3" + color + "m"; +} + +std::string PrettyPrinter::end_color() const +{ + if(!_color_output) + { + return ""; + } + + return "\033[m"; +} + +void PrettyPrinter::set_color_output(bool color_output) +{ + _color_output = color_output; +} + +void PrettyPrinter::print_entry(const std::string &name, const std::string &value) +{ + *_stream << begin_color("4") << name << " = " << value << end_color() << "\n"; +} + +void PrettyPrinter::print_global_header() +{ +} + +void PrettyPrinter::print_global_footer() +{ +} + +void PrettyPrinter::print_run_header() +{ +} + +void PrettyPrinter::print_run_footer() +{ +} + +void PrettyPrinter::print_test_header(const TestInfo &info) +{ + *_stream << begin_color("2") << "Running [" << info.id << "] '" << info.name << "'" << end_color() << "\n"; +} + +void PrettyPrinter::print_test_footer() +{ +} + +void PrettyPrinter::print_errors_header() +{ +} + +void PrettyPrinter::print_errors_footer() +{ +} + +void PrettyPrinter::print_error(const std::exception &error) +{ + *_stream << begin_color("1") << "ERROR: " << error.what() << end_color() << "\n"; +} + +void PrettyPrinter::print_measurements(const Profiler::MeasurementsMap &measurements) +{ + for(const auto &instrument : measurements) + { + *_stream << begin_color("3") << " " << instrument.first << ":"; + + auto add_measurements = [](double a, const Instrument::Measurement & b) + { + return a + b.value; + }; + + auto cmp_measurements = [](const Instrument::Measurement & a, const Instrument::Measurement & b) + { + return a.value < b.value; + }; + + double sum_values = std::accumulate(instrument.second.begin(), instrument.second.end(), 0., add_measurements); + int num_values = instrument.second.size(); + const auto minmax_values = std::minmax_element(instrument.second.begin(), instrument.second.end(), cmp_measurements); + + if(num_values > 2) + { + sum_values -= minmax_values.first->value + minmax_values.second->value; + num_values -= 2; + } + + Instrument::Measurement avg{ sum_values / num_values, minmax_values.first->unit }; + + *_stream << " "; + *_stream << "AVG=" << avg << ", "; + *_stream << "MIN=" << *minmax_values.first << ", "; + *_stream << "MAX=" << *minmax_values.second << end_color() << "\n"; + } +} +} // namespace framework +} // namespace test +} // namespace arm_compute diff --git a/tests/framework/printers/PrettyPrinter.h b/tests/framework/printers/PrettyPrinter.h new file mode 100644 index 0000000000..fa7b7b2c59 --- /dev/null +++ b/tests/framework/printers/PrettyPrinter.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_PRETTYPRINTER +#define ARM_COMPUTE_TEST_PRETTYPRINTER + +#include "Printer.h" + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +/** Implementation of a @ref Printer that produces human readable output. */ +class PrettyPrinter : public Printer +{ +public: + using Printer::Printer; + + /** Set if the output is colored. + * + * @param[in] color_output True if the output is colored. + */ + void set_color_output(bool color_output); + + void print_entry(const std::string &name, const std::string &value) override; + void print_global_header() override; + void print_global_footer() override; + void print_run_header() override; + void print_run_footer() override; + void print_test_header(const TestInfo &info) override; + void print_test_footer() override; + void print_errors_header() override; + void print_errors_footer() override; + void print_error(const std::exception &error) override; + void print_measurements(const Profiler::MeasurementsMap &measurements) override; + +private: + std::string begin_color(const std::string &color) const; + std::string end_color() const; + + bool _color_output{ true }; +}; +} // namespace framework +} // namespace test +} // namespace arm_compute + +#endif /* ARM_COMPUTE_TEST_PRETTYPRINTER */ diff --git a/tests/framework/printers/Printer.cpp b/tests/framework/printers/Printer.cpp new file mode 100644 index 0000000000..e034c2ed43 --- /dev/null +++ b/tests/framework/printers/Printer.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "Printer.h" + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +Printer::Printer(std::ostream &stream) + : _stream{ &stream } +{ +} + +void Printer::print(const std::string &str) +{ + *_stream << str; +} + +void Printer::set_stream(std::ostream &stream) +{ + _stream = &stream; +} +} // namespace framework +} // namespace test +} // namespace arm_compute diff --git a/tests/framework/printers/Printer.h b/tests/framework/printers/Printer.h new file mode 100644 index 0000000000..198d84d466 --- /dev/null +++ b/tests/framework/printers/Printer.h @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_PRINTER +#define ARM_COMPUTE_TEST_PRINTER + +#include "tests/framework/Profiler.h" + +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +struct TestInfo; + +/** Abstract printer class used by the @ref Framework to present output. */ +class Printer +{ +public: + /** Default constructor. + * + * Prints values to std::cout. + * */ + Printer() = default; + + /** Construct printer with given output stream. + * + * @param[out] stream Output stream. + */ + Printer(std::ostream &stream); + + Printer(const Printer &) = delete; + Printer &operator=(const Printer &) = delete; + Printer(Printer &&) = default; + Printer &operator=(Printer &&) = default; + + virtual ~Printer() = default; + + /** Print given string. + * + * @param[in] str String. + */ + void print(const std::string &str); + + /** Print an entry consisting of a (name, value) pair. + * + * @param[in] name Description of the value. + * @param[in] value Value. + */ + virtual void print_entry(const std::string &name, const std::string &value) = 0; + + /** Print global header. */ + virtual void print_global_header() = 0; + + /** Print global footer. */ + virtual void print_global_footer() = 0; + + /** Print header before running all tests. */ + virtual void print_run_header() = 0; + + /** Print footer after running all tests. */ + virtual void print_run_footer() = 0; + + /** Print header before a test. + * + * @param[in] info Test info. + */ + virtual void print_test_header(const TestInfo &info) = 0; + + /** Print footer after a test. */ + virtual void print_test_footer() = 0; + + /** Print header before errors. */ + virtual void print_errors_header() = 0; + + /** Print footer after errors. */ + virtual void print_errors_footer() = 0; + + /** Print test error. + * + * @param[in] error Description of the error. + */ + virtual void print_error(const std::exception &error) = 0; + + /** Print measurements for a test. + * + * @param[in] measurements Measurements as collected by a @ref Profiler. + */ + virtual void print_measurements(const Profiler::MeasurementsMap &measurements) = 0; + + /** Set the output stream. + * + * @param[out] stream Output stream. + */ + void set_stream(std::ostream &stream); + +protected: + std::ostream *_stream{ &std::cout }; +}; +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_PRINTER */ diff --git a/tests/framework/printers/Printers.cpp b/tests/framework/printers/Printers.cpp new file mode 100644 index 0000000000..6e11b63a9a --- /dev/null +++ b/tests/framework/printers/Printers.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "Printers.h" + +#include "../Utils.h" + +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +LogFormat log_format_from_name(const std::string &name) +{ + static const std::map formats = + { + { "pretty", LogFormat::PRETTY }, + { "none", LogFormat::NONE }, + { "json", LogFormat::JSON }, + }; + + try + { + return formats.at(tolower(name)); + } + catch(const std::out_of_range &) + { + throw std::invalid_argument(name); + } +} +} // namespace framework +} // namespace test +} // namespace arm_compute diff --git a/tests/framework/printers/Printers.h b/tests/framework/printers/Printers.h new file mode 100644 index 0000000000..53867e2dff --- /dev/null +++ b/tests/framework/printers/Printers.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_PRINTERS +#define ARM_COMPUTE_TEST_PRINTERS + +#include "JSONPrinter.h" +#include "PrettyPrinter.h" + +namespace arm_compute +{ +namespace test +{ +namespace framework +{ +enum class LogFormat +{ + NONE, + JSON, + PRETTY +}; + +LogFormat log_format_from_name(const std::string &name); + +inline ::std::stringstream &operator>>(::std::stringstream &stream, LogFormat &format) +{ + std::string value; + stream >> value; + format = log_format_from_name(value); + return stream; +} + +inline ::std::stringstream &operator<<(::std::stringstream &stream, LogFormat format) +{ + switch(format) + { + case LogFormat::PRETTY: + stream << "PRETTY"; + break; + case LogFormat::NONE: + stream << "NONE"; + break; + case LogFormat::JSON: + stream << "JSON"; + break; + default: + throw std::invalid_argument("Unsupported log format"); + } + + return stream; +} +} // namespace framework +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_PRINTERS */ diff --git a/tests/main.cpp b/tests/main.cpp index 0b01185fc9..9cd2895e1b 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -21,16 +21,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "framework/DatasetModes.h" -#include "framework/Exceptions.h" -#include "framework/Framework.h" -#include "framework/Macros.h" -#include "framework/command_line/CommandLineOptions.h" -#include "framework/command_line/CommandLineParser.h" -#include "framework/instruments/Instruments.h" -#include "framework/printers/Printers.h" #include "support/ToolchainSupport.h" #include "tests/AssetsLibrary.h" +#include "tests/framework/DatasetModes.h" +#include "tests/framework/Exceptions.h" +#include "tests/framework/Framework.h" +#include "tests/framework/Macros.h" +#include "tests/framework/command_line/CommandLineOptions.h" +#include "tests/framework/command_line/CommandLineParser.h" +#include "tests/framework/instruments/Instruments.h" +#include "tests/framework/printers/Printers.h" #ifdef ARM_COMPUTE_CL #include "arm_compute/runtime/CL/CLScheduler.h" diff --git a/tests/model_objects/AlexNet.h b/tests/model_objects/AlexNet.h deleted file mode 100644 index 45622e2118..0000000000 --- a/tests/model_objects/AlexNet.h +++ /dev/null @@ -1,585 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_MODEL_OBJECTS_ALEXNET_H__ -#define __ARM_COMPUTE_TEST_MODEL_OBJECTS_ALEXNET_H__ - -#include "arm_compute/runtime/Tensor.h" - -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/Utils.h" - -#include - -using namespace arm_compute; -using namespace arm_compute::test; - -namespace arm_compute -{ -namespace test -{ -namespace model_objects -{ -/** AlexNet model object */ -template -class AlexNet -{ -public: - AlexNet() - : _batches(1), _reshaped_weights(false) - { - } - - void init_weights(unsigned int batches, bool reshaped_weights = false) - { - _batches = batches; - _reshaped_weights = reshaped_weights; - - // Initialize weights and biases - if(!_reshaped_weights) - { - for(auto &wi : w) - { - wi = std::unique_ptr(new TensorType()); - } - for(auto &bi : b) - { - bi = std::unique_ptr(new TensorType()); - } - w[0]->allocator()->init(TensorInfo(TensorShape(11U, 11U, 3U, 96U), 1, dt, fixed_point_position)); - b[0]->allocator()->init(TensorInfo(TensorShape(96U), 1, dt, fixed_point_position)); - w[1]->allocator()->init(TensorInfo(TensorShape(5U, 5U, 48U, 256U), 1, dt, fixed_point_position)); - b[1]->allocator()->init(TensorInfo(TensorShape(256U), 1, dt, fixed_point_position)); - w[2]->allocator()->init(TensorInfo(TensorShape(3U, 3U, 256U, 384U), 1, dt, fixed_point_position)); - b[2]->allocator()->init(TensorInfo(TensorShape(384U), 1, dt, fixed_point_position)); - w[3]->allocator()->init(TensorInfo(TensorShape(3U, 3U, 192U, 384U), 1, dt, fixed_point_position)); - b[3]->allocator()->init(TensorInfo(TensorShape(384U), 1, dt, fixed_point_position)); - w[4]->allocator()->init(TensorInfo(TensorShape(3U, 3U, 192U, 256U), 1, dt, fixed_point_position)); - b[4]->allocator()->init(TensorInfo(TensorShape(256U), 1, dt, fixed_point_position)); - w[5]->allocator()->init(TensorInfo(TensorShape(9216U, 4096U), 1, dt, fixed_point_position)); - b[5]->allocator()->init(TensorInfo(TensorShape(4096U), 1, dt, fixed_point_position)); - w[6]->allocator()->init(TensorInfo(TensorShape(4096U, 4096U), 1, dt, fixed_point_position)); - b[6]->allocator()->init(TensorInfo(TensorShape(4096U), 1, dt, fixed_point_position)); - w[7]->allocator()->init(TensorInfo(TensorShape(4096U, 1000U), 1, dt, fixed_point_position)); - b[7]->allocator()->init(TensorInfo(TensorShape(1000U), 1, dt, fixed_point_position)); - - w21 = std::unique_ptr(new SubTensorType(w[1].get(), TensorShape(5U, 5U, 48U, 128U), Coordinates())); - w22 = std::unique_ptr(new SubTensorType(w[1].get(), TensorShape(5U, 5U, 48U, 128U), Coordinates(0, 0, 0, 128))); - b21 = std::unique_ptr(new SubTensorType(b[1].get(), TensorShape(128U), Coordinates())); - b22 = std::unique_ptr(new SubTensorType(b[1].get(), TensorShape(128U), Coordinates(128))); - - w41 = std::unique_ptr(new SubTensorType(w[3].get(), TensorShape(3U, 3U, 192U, 192U), Coordinates())); - w42 = std::unique_ptr(new SubTensorType(w[3].get(), TensorShape(3U, 3U, 192U, 192U), Coordinates(0, 0, 0, 192))); - b41 = std::unique_ptr(new SubTensorType(b[3].get(), TensorShape(192U), Coordinates())); - b42 = std::unique_ptr(new SubTensorType(b[3].get(), TensorShape(192U), Coordinates(192))); - - w51 = std::unique_ptr(new SubTensorType(w[4].get(), TensorShape(3U, 3U, 192U, 128U), Coordinates())); - w52 = std::unique_ptr(new SubTensorType(w[4].get(), TensorShape(3U, 3U, 192U, 128U), Coordinates(0, 0, 0, 128))); - b51 = std::unique_ptr(new SubTensorType(b[4].get(), TensorShape(128U), Coordinates())); - b52 = std::unique_ptr(new SubTensorType(b[4].get(), TensorShape(128U), Coordinates(128))); - } - else - { - const unsigned int dt_size = 16 / arm_compute::data_size_from_type(dt); - - // Create tensor for the reshaped weights - w[0] = std::unique_ptr(new TensorType()); - auto w21_tensor = std::unique_ptr(new TensorType()); - auto w22_tensor = std::unique_ptr(new TensorType()); - w[2] = std::unique_ptr(new TensorType()); - auto w41_tensor = std::unique_ptr(new TensorType()); - auto w42_tensor = std::unique_ptr(new TensorType()); - auto w51_tensor = std::unique_ptr(new TensorType()); - auto w52_tensor = std::unique_ptr(new TensorType()); - - w[0]->allocator()->init(TensorInfo(TensorShape(366U * dt_size, 96U / dt_size), 1, dt, fixed_point_position)); - w21_tensor->allocator()->init(TensorInfo(TensorShape(1248U * dt_size, 128U / dt_size), 1, dt, fixed_point_position)); - w22_tensor->allocator()->init(TensorInfo(TensorShape(1248U * dt_size, 128U / dt_size), 1, dt, fixed_point_position)); - w[2]->allocator()->init(TensorInfo(TensorShape(2560U * dt_size, 384U / dt_size), 1, dt, fixed_point_position)); - w41_tensor->allocator()->init(TensorInfo(TensorShape(1920U * dt_size, 192U / dt_size), 1, dt, fixed_point_position)); - w42_tensor->allocator()->init(TensorInfo(TensorShape(1920U * dt_size, 192U / dt_size), 1, dt, fixed_point_position)); - w51_tensor->allocator()->init(TensorInfo(TensorShape(1920U * dt_size, 128U / dt_size), 1, dt, fixed_point_position)); - w52_tensor->allocator()->init(TensorInfo(TensorShape(1920U * dt_size, 128U / dt_size), 1, dt, fixed_point_position)); - - w21 = std::move(w21_tensor); - w22 = std::move(w22_tensor); - w41 = std::move(w41_tensor); - w42 = std::move(w42_tensor); - w51 = std::move(w51_tensor); - w52 = std::move(w52_tensor); - - w[5] = std::unique_ptr(new TensorType()); - w[6] = std::unique_ptr(new TensorType()); - w[7] = std::unique_ptr(new TensorType()); - b[5] = std::unique_ptr(new TensorType()); - b[6] = std::unique_ptr(new TensorType()); - b[7] = std::unique_ptr(new TensorType()); - - b[5]->allocator()->init(TensorInfo(TensorShape(4096U), 1, dt, fixed_point_position)); - b[6]->allocator()->init(TensorInfo(TensorShape(4096U), 1, dt, fixed_point_position)); - b[7]->allocator()->init(TensorInfo(TensorShape(1000U), 1, dt, fixed_point_position)); - - if(_batches > 1 && std::is_same::value) - { - w[5]->allocator()->init(TensorInfo(TensorShape(9216U * dt_size, 4096U / dt_size), 1, dt, fixed_point_position)); - w[6]->allocator()->init(TensorInfo(TensorShape(4096U * dt_size, 4096U / dt_size), 1, dt, fixed_point_position)); - w[7]->allocator()->init(TensorInfo(TensorShape(4096U * dt_size, 1000U / dt_size), 1, dt, fixed_point_position)); - } - else - { - w[5]->allocator()->init(TensorInfo(TensorShape(4096U, 9216U), 1, dt, fixed_point_position)); - w[6]->allocator()->init(TensorInfo(TensorShape(4096U, 4096U), 1, dt, fixed_point_position)); - w[7]->allocator()->init(TensorInfo(TensorShape(1000U, 4096U), 1, dt, fixed_point_position)); - } - } - } - - void build() - { - input.allocator()->init(TensorInfo(TensorShape(227U, 227U, 3U, _batches), 1, dt, fixed_point_position)); - output.allocator()->init(TensorInfo(TensorShape(1000U, _batches), 1, dt, fixed_point_position)); - - // Initialize intermediate tensors - // Layer 1 - conv1_out.allocator()->init(TensorInfo(TensorShape(55U, 55U, 96U, _batches), 1, dt, fixed_point_position)); - act1_out.allocator()->init(TensorInfo(TensorShape(55U, 55U, 96U, _batches), 1, dt, fixed_point_position)); - norm1_out.allocator()->init(TensorInfo(TensorShape(55U, 55U, 96U, _batches), 1, dt, fixed_point_position)); - pool1_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 96U, _batches), 1, dt, fixed_point_position)); - pool11_out = std::unique_ptr(new SubTensorType(&pool1_out, TensorShape(27U, 27U, 48U, _batches), Coordinates())); - pool12_out = std::unique_ptr(new SubTensorType(&pool1_out, TensorShape(27U, 27U, 48U, _batches), Coordinates(0, 0, 48))); - // Layer 2 - conv2_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 256U, _batches), 1, dt, fixed_point_position)); - conv21_out = std::unique_ptr(new SubTensorType(&conv2_out, TensorShape(27U, 27U, 128U, _batches), Coordinates())); - conv22_out = std::unique_ptr(new SubTensorType(&conv2_out, TensorShape(27U, 27U, 128U, _batches), Coordinates(0, 0, 128))); - act2_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 256U, _batches), 1, dt, fixed_point_position)); - norm2_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 256U, _batches), 1, dt, fixed_point_position)); - pool2_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 256U, _batches), 1, dt, fixed_point_position)); - // Layer 3 - conv3_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, dt, fixed_point_position)); - act3_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, dt, fixed_point_position)); - act31_out = std::unique_ptr(new SubTensorType(&act3_out, TensorShape(13U, 13U, 192U, _batches), Coordinates())); - act32_out = std::unique_ptr(new SubTensorType(&act3_out, TensorShape(13U, 13U, 192U, _batches), Coordinates(0, 0, 192))); - // Layer 4 - conv4_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, dt, fixed_point_position)); - conv41_out = std::unique_ptr(new SubTensorType(&conv4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates())); - conv42_out = std::unique_ptr(new SubTensorType(&conv4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates(0, 0, 192))); - act4_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, dt, fixed_point_position)); - act41_out = std::unique_ptr(new SubTensorType(&act4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates())); - act42_out = std::unique_ptr(new SubTensorType(&act4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates(0, 0, 192))); - // Layer 5 - conv5_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 256U, _batches), 1, dt, fixed_point_position)); - conv51_out = std::unique_ptr(new SubTensorType(&conv5_out, TensorShape(13U, 13U, 128U, _batches), Coordinates())); - conv52_out = std::unique_ptr(new SubTensorType(&conv5_out, TensorShape(13U, 13U, 128U, _batches), Coordinates(0, 0, 128))); - act5_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 256U, _batches), 1, dt, fixed_point_position)); - pool5_out.allocator()->init(TensorInfo(TensorShape(6U, 6U, 256U, _batches), 1, dt, fixed_point_position)); - // Layer 6 - fc6_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, dt, fixed_point_position)); - act6_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, dt, fixed_point_position)); - // Layer 7 - fc7_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, dt, fixed_point_position)); - act7_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, dt, fixed_point_position)); - // Layer 8 - fc8_out.allocator()->init(TensorInfo(TensorShape(1000U, _batches), 1, dt, fixed_point_position)); - - // Allocate layers - { - // Layer 1 - conv1 = std::unique_ptr(new ConvolutionLayerFunction()); - act1 = std::unique_ptr(new ActivationLayerFunction()); - norm1 = std::unique_ptr(new NormalizationLayerFunction()); - pool1 = std::unique_ptr(new PoolingLayerFunction()); - // Layer 2 - conv21 = std::unique_ptr(new ConvolutionLayerFunction()); - conv22 = std::unique_ptr(new ConvolutionLayerFunction()); - act2 = std::unique_ptr(new ActivationLayerFunction()); - norm2 = std::unique_ptr(new NormalizationLayerFunction()); - pool2 = std::unique_ptr(new PoolingLayerFunction()); - // Layer 3 - conv3 = std::unique_ptr(new ConvolutionLayerFunction()); - act3 = std::unique_ptr(new ActivationLayerFunction()); - // Layer 4 - conv41 = std::unique_ptr(new ConvolutionLayerFunction()); - conv42 = std::unique_ptr(new ConvolutionLayerFunction()); - act4 = std::unique_ptr(new ActivationLayerFunction()); - // Layer 5 - conv51 = std::unique_ptr(new ConvolutionLayerFunction()); - conv52 = std::unique_ptr(new ConvolutionLayerFunction()); - act5 = std::unique_ptr(new ActivationLayerFunction()); - pool5 = std::unique_ptr(new PoolingLayerFunction()); - // Layer 6 - fc6 = std::unique_ptr(new FullyConnectedLayerFunction()); - act6 = std::unique_ptr(new ActivationLayerFunction()); - // Layer 7 - fc7 = std::unique_ptr(new FullyConnectedLayerFunction()); - act7 = std::unique_ptr(new ActivationLayerFunction()); - // Layer 8 - fc8 = std::unique_ptr(new FullyConnectedLayerFunction()); - // Softmax - smx = std::unique_ptr(new SoftmaxLayerFunction()); - } - - // Configure Layers - { - // Layer 1 - conv1->configure(&input, w[0].get(), b[0].get(), &conv1_out, PadStrideInfo(4, 4, 0, 0), WeightsInfo(_reshaped_weights, 11U, 11U, 96U)); - act1->configure(&conv1_out, &act1_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); - norm1->configure(&act1_out, &norm1_out, NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)); - pool1->configure(&norm1_out, &pool1_out, PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); - // Layer 2 - conv21->configure(pool11_out.get(), w21.get(), b21.get(), conv21_out.get(), PadStrideInfo(1, 1, 2, 2), WeightsInfo(_reshaped_weights, 5U, 5U, 128U)); - conv22->configure(pool12_out.get(), w22.get(), b22.get(), conv22_out.get(), PadStrideInfo(1, 1, 2, 2), WeightsInfo(_reshaped_weights, 5U, 5U, 128U)); - act2->configure(&conv2_out, &act2_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); - norm2->configure(&act2_out, &norm2_out, NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)); - pool2->configure(&norm2_out, &pool2_out, PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); - // Layer 3 - conv3->configure(&pool2_out, w[2].get(), b[2].get(), &conv3_out, PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 384U)); - act3->configure(&conv3_out, &act3_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); - // Layer 4 - conv41->configure(act31_out.get(), w41.get(), b41.get(), conv41_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 192U)); - conv42->configure(act32_out.get(), w42.get(), b42.get(), conv42_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 192U)); - act4->configure(&conv4_out, &act4_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); - // Layer 5 - conv51->configure(act41_out.get(), w51.get(), b51.get(), conv51_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 128U)); - conv52->configure(act42_out.get(), w52.get(), b52.get(), conv52_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 128U)); - act5->configure(&conv5_out, &act5_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); - pool5->configure(&act5_out, &pool5_out, PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); - // Layer 6 - fc6->configure(&pool5_out, w[5].get(), b[5].get(), &fc6_out, true, _reshaped_weights); - act6->configure(&fc6_out, &act6_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); - // Layer 7 - fc7->configure(&act6_out, w[6].get(), b[6].get(), &fc7_out, true, _reshaped_weights); - act7->configure(&fc7_out, &act7_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); - // Layer 8 - fc8->configure(&act7_out, w[7].get(), b[7].get(), &fc8_out, true, _reshaped_weights); - // Softmax - smx->configure(&fc8_out, &output); - } - } - - void allocate() - { - input.allocator()->allocate(); - output.allocator()->allocate(); - for(auto &wi : w) - { - if(wi.get()) - { - wi->allocator()->allocate(); - } - } - for(auto &bi : b) - { - if(bi.get()) - { - bi->allocator()->allocate(); - } - } - if(_reshaped_weights) - { - dynamic_cast(w21.get())->allocator()->allocate(); - dynamic_cast(w22.get())->allocator()->allocate(); - dynamic_cast(w41.get())->allocator()->allocate(); - dynamic_cast(w42.get())->allocator()->allocate(); - dynamic_cast(w51.get())->allocator()->allocate(); - dynamic_cast(w52.get())->allocator()->allocate(); - } - conv1_out.allocator()->allocate(); - act1_out.allocator()->allocate(); - norm1_out.allocator()->allocate(); - pool1_out.allocator()->allocate(); - conv2_out.allocator()->allocate(); - act2_out.allocator()->allocate(); - norm2_out.allocator()->allocate(); - pool2_out.allocator()->allocate(); - conv3_out.allocator()->allocate(); - act3_out.allocator()->allocate(); - conv4_out.allocator()->allocate(); - act4_out.allocator()->allocate(); - conv5_out.allocator()->allocate(); - act5_out.allocator()->allocate(); - pool5_out.allocator()->allocate(); - fc6_out.allocator()->allocate(); - act6_out.allocator()->allocate(); - fc7_out.allocator()->allocate(); - act7_out.allocator()->allocate(); - fc8_out.allocator()->allocate(); - } - - /** Fills the trainable parameters and input with random data. */ - void fill_random() - { - library->fill_tensor_uniform(Accessor(input), 0); - if(!_reshaped_weights) - { - for(unsigned int i = 0; i < w.size(); ++i) - { - library->fill_tensor_uniform(Accessor(*w[i]), i + 1); - library->fill_tensor_uniform(Accessor(*b[i]), i + 10); - } - } - else - { - library->fill_tensor_uniform(Accessor(*w[0]), 1); - library->fill_tensor_uniform(Accessor(*w[2]), 2); - - library->fill_tensor_uniform(Accessor(*w[5]), 3); - library->fill_tensor_uniform(Accessor(*b[5]), 4); - library->fill_tensor_uniform(Accessor(*w[6]), 5); - library->fill_tensor_uniform(Accessor(*b[6]), 6); - library->fill_tensor_uniform(Accessor(*w[7]), 7); - library->fill_tensor_uniform(Accessor(*b[7]), 8); - - library->fill_tensor_uniform(Accessor(*dynamic_cast(w21.get())), 9); - library->fill_tensor_uniform(Accessor(*dynamic_cast(w22.get())), 10); - library->fill_tensor_uniform(Accessor(*dynamic_cast(w41.get())), 11); - library->fill_tensor_uniform(Accessor(*dynamic_cast(w42.get())), 12); - library->fill_tensor_uniform(Accessor(*dynamic_cast(w51.get())), 13); - library->fill_tensor_uniform(Accessor(*dynamic_cast(w52.get())), 14); - } - } - -#ifdef INTERNAL_ONLY - /** Fills the trainable parameters from binary files - * - * @param weights Files names containing the weights data - * @param biases Files names containing the bias data - */ - void fill(std::vector weights, std::vector biases) - { - ARM_COMPUTE_ERROR_ON(weights.size() != w.size()); - ARM_COMPUTE_ERROR_ON(biases.size() != b.size()); - ARM_COMPUTE_ERROR_ON(_reshaped_weights); - - for(unsigned int i = 0; i < weights.size(); ++i) - { - library->fill_layer_data(Accessor(*w[i]), weights[i]); - library->fill_layer_data(Accessor(*b[i]), biases[i]); - } - } - - /** Feed input to network from file. - * - * @param name File name of containing the input data. - */ - void feed(std::string name) - { - library->fill_layer_data(Accessor(input), name); - } -#endif /* INTERNAL_ONLY */ - - /** Get the classification results. - * - * @return Vector containing the classified labels - */ - std::vector get_classifications() - { - std::vector classified_labels; - Accessor output_accessor(output); - - Window window; - window.set(Window::DimX, Window::Dimension(0, 1, 1)); - for(unsigned int d = 1; d < output_accessor.shape().num_dimensions(); ++d) - { - window.set(d, Window::Dimension(0, output_accessor.shape()[d], 1)); - } - - execute_window_loop(window, [&](const Coordinates & id) - { - int max_idx = 0; - float val = 0; - const void *const out_ptr = output_accessor(id); - for(unsigned int l = 0; l < output_accessor.shape().x(); ++l) - { - float curr_val = reinterpret_cast(out_ptr)[l]; - if(curr_val > val) - { - max_idx = l; - val = curr_val; - } - } - classified_labels.push_back(max_idx); - }); - return classified_labels; - } - - /** Clear all allocated memory from the tensor objects */ - void clear() - { - conv1.reset(); - act1.reset(); - norm1.reset(); - pool1.reset(); - conv21.reset(); - conv22.reset(); - act2.reset(); - norm2.reset(); - pool2.reset(); - conv3.reset(); - act3.reset(); - conv41.reset(); - conv42.reset(); - act4.reset(); - conv51.reset(); - conv52.reset(); - act5.reset(); - pool5.reset(); - fc6.reset(); - act6.reset(); - fc7.reset(); - act7.reset(); - fc8.reset(); - smx.reset(); - - // Free allocations - input.allocator()->free(); - output.allocator()->free(); - for(auto &wi : w) - { - wi.reset(); - } - for(auto &bi : b) - { - bi.reset(); - } - - w21.reset(); - w22.reset(); - b21.reset(); - b21.reset(); - w41.reset(); - w42.reset(); - b41.reset(); - b42.reset(); - w51.reset(); - w52.reset(); - b51.reset(); - b52.reset(); - - conv1_out.allocator()->free(); - act1_out.allocator()->free(); - norm1_out.allocator()->free(); - pool1_out.allocator()->free(); - conv2_out.allocator()->free(); - act2_out.allocator()->free(); - norm2_out.allocator()->free(); - pool2_out.allocator()->free(); - conv3_out.allocator()->free(); - act3_out.allocator()->free(); - conv4_out.allocator()->free(); - act4_out.allocator()->free(); - conv5_out.allocator()->free(); - act5_out.allocator()->free(); - pool5_out.allocator()->free(); - fc6_out.allocator()->free(); - act6_out.allocator()->free(); - fc7_out.allocator()->free(); - act7_out.allocator()->free(); - fc8_out.allocator()->free(); - } - - /** Runs the model */ - void run() - { - // Layer 1 - conv1->run(); - act1->run(); - norm1->run(); - pool1->run(); - // Layer 2 - conv21->run(); - conv22->run(); - act2->run(); - norm2->run(); - pool2->run(); - // Layer 3 - conv3->run(); - act3->run(); - // Layer 4 - conv41->run(); - conv42->run(); - act4->run(); - // Layer 5 - conv51->run(); - conv52->run(); - act5->run(); - pool5->run(); - // Layer 6 - fc6->run(); - act6->run(); - // Layer 7 - fc7->run(); - act7->run(); - // Layer 8 - fc8->run(); - // Softmax - smx->run(); - } - -private: - unsigned int _batches; - bool _reshaped_weights; - - std::unique_ptr act1{ nullptr }, act2{ nullptr }, act3{ nullptr }, act4{ nullptr }, act5{ nullptr }, act6{ nullptr }, act7{ nullptr }; - std::unique_ptr conv1{ nullptr }, conv21{ nullptr }, conv22{ nullptr }, conv3{ nullptr }, conv41{ nullptr }, conv42{ nullptr }, conv51{ nullptr }, conv52{ nullptr }; - std::unique_ptr fc6{ nullptr }, fc7{ nullptr }, fc8{}; - std::unique_ptr norm1{ nullptr }, norm2{ nullptr }; - std::unique_ptr pool1{ nullptr }, pool2{ nullptr }, pool5{ nullptr }; - std::unique_ptr smx{ nullptr }; - - TensorType input{}, output{}; - std::array, 8> w{}, b{}; - std::unique_ptr w21{ nullptr }, w22{ nullptr }, b21{ nullptr }, b22{ nullptr }; - std::unique_ptr w41{ nullptr }, w42{ nullptr }, b41{ nullptr }, b42{ nullptr }; - std::unique_ptr w51{ nullptr }, w52{ nullptr }, b51{ nullptr }, b52{ nullptr }; - - TensorType conv1_out{}, act1_out{}, norm1_out{}, pool1_out{}; - TensorType conv2_out{}, act2_out{}, pool2_out{}, norm2_out{}; - TensorType conv3_out{}, act3_out{}; - TensorType conv4_out{}, act4_out{}; - TensorType conv5_out{}, act5_out{}, pool5_out{}; - TensorType fc6_out{}, act6_out{}; - TensorType fc7_out{}, act7_out{}; - TensorType fc8_out{}; - - std::unique_ptr pool11_out{ nullptr }, pool12_out{ nullptr }; - std::unique_ptr conv21_out{ nullptr }, conv22_out{ nullptr }; - std::unique_ptr act31_out{ nullptr }, act32_out{ nullptr }; - std::unique_ptr conv41_out{ nullptr }, conv42_out{ nullptr }, act41_out{ nullptr }, act42_out{ nullptr }; - std::unique_ptr conv51_out{ nullptr }, conv52_out{ nullptr }; -}; -} // namespace model_objects -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_MODEL_OBJECTS_ALEXNET_H__ diff --git a/tests/model_objects/LeNet5.h b/tests/model_objects/LeNet5.h deleted file mode 100644 index d3e72b0010..0000000000 --- a/tests/model_objects/LeNet5.h +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_MODEL_OBJECTS_LENET5_H__ -#define __ARM_COMPUTE_TEST_MODEL_OBJECTS_LENET5_H__ - -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/Utils.h" - -#include - -using namespace arm_compute; -using namespace arm_compute::test; - -namespace arm_compute -{ -namespace test -{ -namespace model_objects -{ -/** Lenet5 model object */ -template -class LeNet5 -{ -public: - /** Initialize and build the model. - * - * @param batches Number of batches should handle - */ - void build(unsigned int batches) - { - // Initialize input, output, weights and biases - input.allocator()->init(TensorInfo(TensorShape(28U, 28U, 1U, batches), 1, DataType::F32)); - output.allocator()->init(TensorInfo(TensorShape(10U, batches), 1, DataType::F32)); - w[0].allocator()->init(TensorInfo(TensorShape(5U, 5U, 1U, 20U), 1, DataType::F32)); - b[0].allocator()->init(TensorInfo(TensorShape(20U), 1, DataType::F32)); - w[1].allocator()->init(TensorInfo(TensorShape(5U, 5U, 20U, 50U), 1, DataType::F32)); - b[1].allocator()->init(TensorInfo(TensorShape(50U), 1, DataType::F32)); - w[2].allocator()->init(TensorInfo(TensorShape(800U, 500U), 1, DataType::F32)); - b[2].allocator()->init(TensorInfo(TensorShape(500U), 1, DataType::F32)); - w[3].allocator()->init(TensorInfo(TensorShape(500U, 10U), 1, DataType::F32)); - b[3].allocator()->init(TensorInfo(TensorShape(10U), 1, DataType::F32)); - - // Initialize intermediate tensors - // Layer 1 - conv1_out.allocator()->init(TensorInfo(TensorShape(24U, 24U, 20U, batches), 1, DataType::F32)); - pool1_out.allocator()->init(TensorInfo(TensorShape(12U, 12U, 20U, batches), 1, DataType::F32)); - // Layer 2 - conv2_out.allocator()->init(TensorInfo(TensorShape(8U, 8U, 50U, batches), 1, DataType::F32)); - pool2_out.allocator()->init(TensorInfo(TensorShape(4U, 4U, 50U, batches), 1, DataType::F32)); - // Layer 3 - fc1_out.allocator()->init(TensorInfo(TensorShape(500U, batches), 1, DataType::F32)); - act1_out.allocator()->init(TensorInfo(TensorShape(500U, batches), 1, DataType::F32)); - // Layer 6 - fc2_out.allocator()->init(TensorInfo(TensorShape(10U, batches), 1, DataType::F32)); - - // Allocate layers - { - // Layer 1 - conv1 = std::unique_ptr(new ConvolutionLayerFunction()); - pool1 = std::unique_ptr(new PoolingLayerFunction()); - // Layer 2 - conv2 = std::unique_ptr(new ConvolutionLayerFunction()); - pool2 = std::unique_ptr(new PoolingLayerFunction()); - // Layer 3 - fc1 = std::unique_ptr(new FullyConnectedLayerFunction()); - act1 = std::unique_ptr(new ActivationLayerFunction()); - // Layer 4 - fc2 = std::unique_ptr(new FullyConnectedLayerFunction()); - // Softmax - smx = std::unique_ptr(new SoftmaxLayerFunction()); - } - - // Configure Layers - { - conv1->configure(&input, &w[0], &b[0], &conv1_out, PadStrideInfo(1, 1, 0, 0)); - pool1->configure(&conv1_out, &pool1_out, PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0))); - conv2->configure(&pool1_out, &w[1], &b[1], &conv2_out, PadStrideInfo(1, 1, 0, 0)); - pool2->configure(&conv2_out, &pool2_out, PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0))); - fc1->configure(&pool2_out, &w[2], &b[2], &fc1_out); - act1->configure(&fc1_out, &act1_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); - fc2->configure(&act1_out, &w[3], &b[3], &fc2_out); - smx->configure(&fc2_out, &output); - } - - // Allocate tensors - { - input.allocator()->allocate(); - output.allocator()->allocate(); - for(auto &wi : w) - { - wi.allocator()->allocate(); - } - for(auto &bi : b) - { - bi.allocator()->allocate(); - } - conv1_out.allocator()->allocate(); - pool1_out.allocator()->allocate(); - conv2_out.allocator()->allocate(); - pool2_out.allocator()->allocate(); - fc1_out.allocator()->allocate(); - act1_out.allocator()->allocate(); - fc2_out.allocator()->allocate(); - } - } - - /** Fills the trainable parameters and input with random data. */ - void fill_random() - { - std::uniform_real_distribution<> distribution(-1, 1); - library->fill(Accessor(input), distribution, 0); - for(unsigned int i = 0; i < w.size(); ++i) - { - library->fill(Accessor(w[i]), distribution, i + 1); - library->fill(Accessor(b[i]), distribution, i + 10); - } - } - -#ifdef INTERNAL_ONLY - /** Fills the trainable parameters from binary files - * - * @param weights Files names containing the weights data - * @param biases Files names containing the bias data - */ - void fill(std::vector weights, std::vector biases) - { - ARM_COMPUTE_ERROR_ON(weights.size() != w.size()); - ARM_COMPUTE_ERROR_ON(biases.size() != b.size()); - - for(unsigned int i = 0; i < weights.size(); ++i) - { - library->fill_layer_data(Accessor(w[i]), weights[i]); - library->fill_layer_data(Accessor(b[i]), biases[i]); - } - } - - /** Feed input to network from file. - * - * @param name File name of containing the input data. - */ - void feed(std::string name) - { - library->fill_layer_data(Accessor(input), name); - } -#endif /* INTERNAL_ONLY */ - - /** Get the classification results. - * - * @return Vector containing the classified labels - */ - std::vector get_classifications() - { - std::vector classified_labels; - Accessor output_accessor(output); - - Window window; - window.set(Window::DimX, Window::Dimension(0, 1, 1)); - for(unsigned int d = 1; d < output_accessor.shape().num_dimensions(); ++d) - { - window.set(d, Window::Dimension(0, output_accessor.shape()[d], 1)); - } - - execute_window_loop(window, [&](const Coordinates & id) - { - int max_idx = 0; - float val = 0; - const void *const out_ptr = output_accessor(id); - for(unsigned int l = 0; l < output_accessor.shape().x(); ++l) - { - float curr_val = reinterpret_cast(out_ptr)[l]; - if(curr_val > val) - { - max_idx = l; - val = curr_val; - } - } - classified_labels.push_back(max_idx); - }); - return classified_labels; - } - - /** Clear all allocated memory from the tensor objects */ - void clear() - { - conv1.reset(); - pool1.reset(); - conv2.reset(); - pool2.reset(); - fc1.reset(); - act1.reset(); - fc2.reset(); - smx.reset(); - - input.allocator()->free(); - output.allocator()->free(); - for(auto &wi : w) - { - wi.allocator()->free(); - } - for(auto &bi : b) - { - bi.allocator()->free(); - } - - conv1_out.allocator()->free(); - pool1_out.allocator()->free(); - conv2_out.allocator()->free(); - pool2_out.allocator()->free(); - fc1_out.allocator()->free(); - act1_out.allocator()->free(); - fc2_out.allocator()->free(); - } - - /** Runs the model */ - void run() - { - // Layer 1 - conv1->run(); - pool1->run(); - // Layer 2 - conv2->run(); - pool2->run(); - // Layer 3 - fc1->run(); - act1->run(); - // Layer 4 - fc2->run(); - // Softmax - smx->run(); - } - -private: - std::unique_ptr act1{ nullptr }; - std::unique_ptr conv1{ nullptr }, conv2{ nullptr }; - std::unique_ptr fc1{ nullptr }, fc2{ nullptr }; - std::unique_ptr pool1{ nullptr }, pool2{ nullptr }; - std::unique_ptr smx{ nullptr }; - - TensorType input{}, output{}; - std::array w{}, b{}; - - TensorType conv1_out{}, pool1_out{}; - TensorType conv2_out{}, pool2_out{}; - TensorType fc1_out{}, act1_out{}; - TensorType fc2_out{}; -}; -} // namespace model_objects -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_MODEL_OBJECTS_LENET5_H__ diff --git a/tests/networks/AlexNetNetwork.h b/tests/networks/AlexNetNetwork.h new file mode 100644 index 0000000000..d41e1b676c --- /dev/null +++ b/tests/networks/AlexNetNetwork.h @@ -0,0 +1,622 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_MODEL_OBJECTS_ALEXNET_H__ +#define __ARM_COMPUTE_TEST_MODEL_OBJECTS_ALEXNET_H__ + +#include "arm_compute/runtime/Tensor.h" + +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/Utils.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace networks +{ +/** AlexNet model object */ +template +class AlexNetNetwork +{ +public: + void init(DataType data_type, int fixed_point_position, int batches, bool reshaped_weights = false) + { + _data_type = data_type; + _fixed_point_position = fixed_point_position; + _batches = batches; + _reshaped_weights = reshaped_weights; + + // Initialize weights and biases + if(!_reshaped_weights) + { + w[0].allocator()->init(TensorInfo(TensorShape(11U, 11U, 3U, 96U), 1, _data_type, _fixed_point_position)); + b[0].allocator()->init(TensorInfo(TensorShape(96U), 1, _data_type, _fixed_point_position)); + w[1].allocator()->init(TensorInfo(TensorShape(5U, 5U, 48U, 256U), 1, _data_type, _fixed_point_position)); + b[1].allocator()->init(TensorInfo(TensorShape(256U), 1, _data_type, _fixed_point_position)); + w[2].allocator()->init(TensorInfo(TensorShape(3U, 3U, 256U, 384U), 1, _data_type, _fixed_point_position)); + b[2].allocator()->init(TensorInfo(TensorShape(384U), 1, _data_type, _fixed_point_position)); + w[3].allocator()->init(TensorInfo(TensorShape(3U, 3U, 192U, 384U), 1, _data_type, _fixed_point_position)); + b[3].allocator()->init(TensorInfo(TensorShape(384U), 1, _data_type, _fixed_point_position)); + w[4].allocator()->init(TensorInfo(TensorShape(3U, 3U, 192U, 256U), 1, _data_type, _fixed_point_position)); + b[4].allocator()->init(TensorInfo(TensorShape(256U), 1, _data_type, _fixed_point_position)); + w[5].allocator()->init(TensorInfo(TensorShape(9216U, 4096U), 1, _data_type, _fixed_point_position)); + b[5].allocator()->init(TensorInfo(TensorShape(4096U), 1, _data_type, _fixed_point_position)); + w[6].allocator()->init(TensorInfo(TensorShape(4096U, 4096U), 1, _data_type, _fixed_point_position)); + b[6].allocator()->init(TensorInfo(TensorShape(4096U), 1, _data_type, _fixed_point_position)); + w[7].allocator()->init(TensorInfo(TensorShape(4096U, 1000U), 1, _data_type, _fixed_point_position)); + b[7].allocator()->init(TensorInfo(TensorShape(1000U), 1, _data_type, _fixed_point_position)); + + w21 = std::unique_ptr(new SubTensorType(&w[1], TensorShape(5U, 5U, 48U, 128U), Coordinates())); + w22 = std::unique_ptr(new SubTensorType(&w[1], TensorShape(5U, 5U, 48U, 128U), Coordinates(0, 0, 0, 128))); + b21 = std::unique_ptr(new SubTensorType(&b[1], TensorShape(128U), Coordinates())); + b22 = std::unique_ptr(new SubTensorType(&b[1], TensorShape(128U), Coordinates(128))); + + w41 = std::unique_ptr(new SubTensorType(&w[3], TensorShape(3U, 3U, 192U, 192U), Coordinates())); + w42 = std::unique_ptr(new SubTensorType(&w[3], TensorShape(3U, 3U, 192U, 192U), Coordinates(0, 0, 0, 192))); + b41 = std::unique_ptr(new SubTensorType(&b[3], TensorShape(192U), Coordinates())); + b42 = std::unique_ptr(new SubTensorType(&b[3], TensorShape(192U), Coordinates(192))); + + w51 = std::unique_ptr(new SubTensorType(&w[4], TensorShape(3U, 3U, 192U, 128U), Coordinates())); + w52 = std::unique_ptr(new SubTensorType(&w[4], TensorShape(3U, 3U, 192U, 128U), Coordinates(0, 0, 0, 128))); + b51 = std::unique_ptr(new SubTensorType(&b[4], TensorShape(128U), Coordinates())); + b52 = std::unique_ptr(new SubTensorType(&b[4], TensorShape(128U), Coordinates(128))); + } + else + { + auto reshape = [&](unsigned int width, unsigned int height) -> TensorShape + { + const int interleave_width = 16 / arm_compute::data_size_from_type(_data_type); + + return TensorShape{ width * interleave_width, static_cast(std::ceil(static_cast(height) / interleave_width)) }; + }; + + // Create tensor for the reshaped weights + w[0].allocator()->init(TensorInfo(reshape(366U, 96U), 1, _data_type, _fixed_point_position)); + + // Configure the direct convolution's weights. Direct convolution doesn't need reshape weights + if(!_is_direct_conv) + { + auto w21_tensor = std::unique_ptr(new TensorType()); + auto w22_tensor = std::unique_ptr(new TensorType()); + auto w41_tensor = std::unique_ptr(new TensorType()); + auto w42_tensor = std::unique_ptr(new TensorType()); + auto w51_tensor = std::unique_ptr(new TensorType()); + auto w52_tensor = std::unique_ptr(new TensorType()); + w21_tensor->allocator()->init(TensorInfo(reshape(1248U, 128U), 1, _data_type, _fixed_point_position)); + w22_tensor->allocator()->init(TensorInfo(reshape(1248U, 128U), 1, _data_type, _fixed_point_position)); + w41_tensor->allocator()->init(TensorInfo(reshape(1920U, 192U), 1, _data_type, _fixed_point_position)); + w42_tensor->allocator()->init(TensorInfo(reshape(1920U, 192U), 1, _data_type, _fixed_point_position)); + w51_tensor->allocator()->init(TensorInfo(reshape(1920U, 128U), 1, _data_type, _fixed_point_position)); + w52_tensor->allocator()->init(TensorInfo(reshape(1920U, 128U), 1, _data_type, _fixed_point_position)); + w[2].allocator()->init(TensorInfo(reshape(2560U, 384U), 1, _data_type, _fixed_point_position)); + w21 = std::move(w21_tensor); + w22 = std::move(w22_tensor); + w41 = std::move(w41_tensor); + w42 = std::move(w42_tensor); + w51 = std::move(w51_tensor); + w52 = std::move(w52_tensor); + } + else + { + w[1].allocator()->init(TensorInfo(TensorShape(5U, 5U, 48U, 256U), 1, _data_type, _fixed_point_position)); + b[1].allocator()->init(TensorInfo(TensorShape(256U), 1, _data_type, _fixed_point_position)); + w[2].allocator()->init(TensorInfo(TensorShape(3U, 3U, 256U, 384U), 1, _data_type, _fixed_point_position)); + b[2].allocator()->init(TensorInfo(TensorShape(384U), 1, _data_type, _fixed_point_position)); + w[3].allocator()->init(TensorInfo(TensorShape(3U, 3U, 192U, 384U), 1, _data_type, _fixed_point_position)); + b[3].allocator()->init(TensorInfo(TensorShape(384U), 1, _data_type, _fixed_point_position)); + w[4].allocator()->init(TensorInfo(TensorShape(3U, 3U, 192U, 256U), 1, _data_type, _fixed_point_position)); + b[4].allocator()->init(TensorInfo(TensorShape(256U), 1, _data_type, _fixed_point_position)); + w21 = std::unique_ptr(new SubTensorType(&w[1], TensorShape(5U, 5U, 48U, 128U), Coordinates())); + w22 = std::unique_ptr(new SubTensorType(&w[1], TensorShape(5U, 5U, 48U, 128U), Coordinates(0, 0, 0, 128))); + b21 = std::unique_ptr(new SubTensorType(&b[1], TensorShape(128U), Coordinates())); + b22 = std::unique_ptr(new SubTensorType(&b[1], TensorShape(128U), Coordinates(128))); + + w41 = std::unique_ptr(new SubTensorType(&w[3], TensorShape(3U, 3U, 192U, 192U), Coordinates())); + w42 = std::unique_ptr(new SubTensorType(&w[3], TensorShape(3U, 3U, 192U, 192U), Coordinates(0, 0, 0, 192))); + b41 = std::unique_ptr(new SubTensorType(&b[3], TensorShape(192U), Coordinates())); + b42 = std::unique_ptr(new SubTensorType(&b[3], TensorShape(192U), Coordinates(192))); + + w51 = std::unique_ptr(new SubTensorType(&w[4], TensorShape(3U, 3U, 192U, 128U), Coordinates())); + w52 = std::unique_ptr(new SubTensorType(&w[4], TensorShape(3U, 3U, 192U, 128U), Coordinates(0, 0, 0, 128))); + b51 = std::unique_ptr(new SubTensorType(&b[4], TensorShape(128U), Coordinates())); + b52 = std::unique_ptr(new SubTensorType(&b[4], TensorShape(128U), Coordinates(128))); + } + + b[5].allocator()->init(TensorInfo(TensorShape(4096U), 1, _data_type, _fixed_point_position)); + b[6].allocator()->init(TensorInfo(TensorShape(4096U), 1, _data_type, _fixed_point_position)); + b[7].allocator()->init(TensorInfo(TensorShape(1000U), 1, _data_type, _fixed_point_position)); + + if(_batches > 1 && std::is_same::value) + { + w[5].allocator()->init(TensorInfo(reshape(9216U, 4096U), 1, _data_type, _fixed_point_position)); + w[6].allocator()->init(TensorInfo(reshape(4096U, 4096U), 1, _data_type, _fixed_point_position)); + w[7].allocator()->init(TensorInfo(reshape(4096U, 1000U), 1, _data_type, _fixed_point_position)); + } + else + { + w[5].allocator()->init(TensorInfo(TensorShape(4096U, 9216U), 1, _data_type, _fixed_point_position)); + w[6].allocator()->init(TensorInfo(TensorShape(4096U, 4096U), 1, _data_type, _fixed_point_position)); + w[7].allocator()->init(TensorInfo(TensorShape(1000U, 4096U), 1, _data_type, _fixed_point_position)); + } + } + } + + void build() + { + input.allocator()->init(TensorInfo(TensorShape(227U, 227U, 3U, _batches), 1, _data_type, _fixed_point_position)); + output.allocator()->init(TensorInfo(TensorShape(1000U, _batches), 1, _data_type, _fixed_point_position)); + + // Initialize intermediate tensors + // Layer 1 + conv1_out.allocator()->init(TensorInfo(TensorShape(55U, 55U, 96U, _batches), 1, _data_type, _fixed_point_position)); + act1_out.allocator()->init(TensorInfo(TensorShape(55U, 55U, 96U, _batches), 1, _data_type, _fixed_point_position)); + norm1_out.allocator()->init(TensorInfo(TensorShape(55U, 55U, 96U, _batches), 1, _data_type, _fixed_point_position)); + pool1_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 96U, _batches), 1, _data_type, _fixed_point_position)); + pool11_out = std::unique_ptr(new SubTensorType(&pool1_out, TensorShape(27U, 27U, 48U, _batches), Coordinates())); + pool12_out = std::unique_ptr(new SubTensorType(&pool1_out, TensorShape(27U, 27U, 48U, _batches), Coordinates(0, 0, 48))); + // Layer 2 + conv2_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 256U, _batches), 1, _data_type, _fixed_point_position)); + conv21_out = std::unique_ptr(new SubTensorType(&conv2_out, TensorShape(27U, 27U, 128U, _batches), Coordinates())); + conv22_out = std::unique_ptr(new SubTensorType(&conv2_out, TensorShape(27U, 27U, 128U, _batches), Coordinates(0, 0, 128))); + act2_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 256U, _batches), 1, _data_type, _fixed_point_position)); + norm2_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 256U, _batches), 1, _data_type, _fixed_point_position)); + pool2_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 256U, _batches), 1, _data_type, _fixed_point_position)); + // Layer 3 + conv3_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, _data_type, _fixed_point_position)); + act3_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, _data_type, _fixed_point_position)); + act31_out = std::unique_ptr(new SubTensorType(&act3_out, TensorShape(13U, 13U, 192U, _batches), Coordinates())); + act32_out = std::unique_ptr(new SubTensorType(&act3_out, TensorShape(13U, 13U, 192U, _batches), Coordinates(0, 0, 192))); + // Layer 4 + conv4_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, _data_type, _fixed_point_position)); + conv41_out = std::unique_ptr(new SubTensorType(&conv4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates())); + conv42_out = std::unique_ptr(new SubTensorType(&conv4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates(0, 0, 192))); + act4_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, _data_type, _fixed_point_position)); + act41_out = std::unique_ptr(new SubTensorType(&act4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates())); + act42_out = std::unique_ptr(new SubTensorType(&act4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates(0, 0, 192))); + // Layer 5 + conv5_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 256U, _batches), 1, _data_type, _fixed_point_position)); + conv51_out = std::unique_ptr(new SubTensorType(&conv5_out, TensorShape(13U, 13U, 128U, _batches), Coordinates())); + conv52_out = std::unique_ptr(new SubTensorType(&conv5_out, TensorShape(13U, 13U, 128U, _batches), Coordinates(0, 0, 128))); + act5_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 256U, _batches), 1, _data_type, _fixed_point_position)); + pool5_out.allocator()->init(TensorInfo(TensorShape(6U, 6U, 256U, _batches), 1, _data_type, _fixed_point_position)); + // Layer 6 + fc6_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, _data_type, _fixed_point_position)); + act6_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, _data_type, _fixed_point_position)); + // Layer 7 + fc7_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, _data_type, _fixed_point_position)); + act7_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, _data_type, _fixed_point_position)); + // Layer 8 + fc8_out.allocator()->init(TensorInfo(TensorShape(1000U, _batches), 1, _data_type, _fixed_point_position)); + + // Configure Layers + // Layer 1 + TensorType *b0 = _reshaped_weights ? nullptr : &b[0]; + conv1.configure(&input, &w[0], b0, &conv1_out, PadStrideInfo(4, 4, 0, 0), WeightsInfo(_reshaped_weights, 11U, 11U, 96U)); + act1.configure(&conv1_out, &act1_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + norm1.configure(&act1_out, &norm1_out, NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)); + pool1.configure(&norm1_out, &pool1_out, PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); + // Layer 2 + conv21.configure(pool11_out.get(), w21.get(), b21.get(), conv21_out.get(), PadStrideInfo(1, 1, 2, 2), WeightsInfo(_reshaped_weights, 5U, 5U, 128U)); + conv22.configure(pool12_out.get(), w22.get(), b22.get(), conv22_out.get(), PadStrideInfo(1, 1, 2, 2), WeightsInfo(_reshaped_weights, 5U, 5U, 128U)); + act2.configure(&conv2_out, &act2_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + norm2.configure(&act2_out, &norm2_out, NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)); + pool2.configure(&norm2_out, &pool2_out, PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); + // Layer 3 + TensorType *b2 = (_reshaped_weights && !_is_direct_conv) ? nullptr : &b[2]; + conv3.configure(&pool2_out, &w[2], b2, &conv3_out, PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 384U)); + act3.configure(&conv3_out, &act3_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + // Layer 4 + conv41.configure(act31_out.get(), w41.get(), b41.get(), conv41_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 192U)); + conv42.configure(act32_out.get(), w42.get(), b42.get(), conv42_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 192U)); + act4.configure(&conv4_out, &act4_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + // Layer 5 + conv51.configure(act41_out.get(), w51.get(), b51.get(), conv51_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 128U)); + conv52.configure(act42_out.get(), w52.get(), b52.get(), conv52_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 128U)); + act5.configure(&conv5_out, &act5_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + pool5.configure(&act5_out, &pool5_out, PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); + // Layer 6 + fc6.configure(&pool5_out, &w[5], &b[5], &fc6_out, true, _reshaped_weights); + act6.configure(&fc6_out, &act6_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + // Layer 7 + fc7.configure(&act6_out, &w[6], &b[6], &fc7_out, true, _reshaped_weights); + act7.configure(&fc7_out, &act7_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + // Layer 8 + fc8.configure(&act7_out, &w[7], &b[7], &fc8_out, true, _reshaped_weights); + // Softmax + smx.configure(&fc8_out, &output); + } + + void allocate() + { + input.allocator()->allocate(); + output.allocator()->allocate(); + + if(!_reshaped_weights) + { + for(auto &wi : w) + { + wi.allocator()->allocate(); + } + + for(auto &bi : b) + { + bi.allocator()->allocate(); + } + } + else + { + w[0].allocator()->allocate(); + w[2].allocator()->allocate(); + w[5].allocator()->allocate(); + w[6].allocator()->allocate(); + w[7].allocator()->allocate(); + + b[5].allocator()->allocate(); + b[6].allocator()->allocate(); + b[7].allocator()->allocate(); + + if(!_is_direct_conv) + { + dynamic_cast(w21.get())->allocator()->allocate(); + dynamic_cast(w22.get())->allocator()->allocate(); + dynamic_cast(w41.get())->allocator()->allocate(); + dynamic_cast(w42.get())->allocator()->allocate(); + dynamic_cast(w51.get())->allocator()->allocate(); + dynamic_cast(w52.get())->allocator()->allocate(); + } + else + { + b[1].allocator()->allocate(); + b[2].allocator()->allocate(); + b[3].allocator()->allocate(); + b[4].allocator()->allocate(); + w[1].allocator()->allocate(); + w[3].allocator()->allocate(); + w[4].allocator()->allocate(); + } + } + + conv1_out.allocator()->allocate(); + act1_out.allocator()->allocate(); + norm1_out.allocator()->allocate(); + pool1_out.allocator()->allocate(); + conv2_out.allocator()->allocate(); + act2_out.allocator()->allocate(); + norm2_out.allocator()->allocate(); + pool2_out.allocator()->allocate(); + conv3_out.allocator()->allocate(); + act3_out.allocator()->allocate(); + conv4_out.allocator()->allocate(); + act4_out.allocator()->allocate(); + conv5_out.allocator()->allocate(); + act5_out.allocator()->allocate(); + pool5_out.allocator()->allocate(); + fc6_out.allocator()->allocate(); + act6_out.allocator()->allocate(); + fc7_out.allocator()->allocate(); + act7_out.allocator()->allocate(); + fc8_out.allocator()->allocate(); + } + + /** Fills the trainable parameters and input with random data. */ + void fill_random() + { + library->fill_tensor_uniform(Accessor(input), 0); + + if(!_reshaped_weights) + { + for(unsigned int i = 0; i < w.size(); ++i) + { + library->fill_tensor_uniform(Accessor(w[i]), i + 1); + library->fill_tensor_uniform(Accessor(b[i]), i + 10); + } + } + else + { + library->fill_tensor_uniform(Accessor(w[0]), 1); + library->fill_tensor_uniform(Accessor(w[2]), 2); + + library->fill_tensor_uniform(Accessor(w[5]), 3); + library->fill_tensor_uniform(Accessor(b[5]), 4); + library->fill_tensor_uniform(Accessor(w[6]), 5); + library->fill_tensor_uniform(Accessor(b[6]), 6); + library->fill_tensor_uniform(Accessor(w[7]), 7); + library->fill_tensor_uniform(Accessor(b[7]), 8); + + if(!_is_direct_conv) + { + library->fill_tensor_uniform(Accessor(*dynamic_cast(w21.get())), 9); + library->fill_tensor_uniform(Accessor(*dynamic_cast(w22.get())), 10); + library->fill_tensor_uniform(Accessor(*dynamic_cast(w41.get())), 11); + library->fill_tensor_uniform(Accessor(*dynamic_cast(w42.get())), 12); + library->fill_tensor_uniform(Accessor(*dynamic_cast(w51.get())), 13); + library->fill_tensor_uniform(Accessor(*dynamic_cast(w52.get())), 14); + } + else + { + library->fill_tensor_uniform(Accessor(w[1]), 9); + library->fill_tensor_uniform(Accessor(b[1]), 10); + library->fill_tensor_uniform(Accessor(w[3]), 11); + library->fill_tensor_uniform(Accessor(b[3]), 12); + library->fill_tensor_uniform(Accessor(w[4]), 13); + library->fill_tensor_uniform(Accessor(b[4]), 14); + } + } + } + +#ifdef INTERNAL_ONLY + /** Fills the trainable parameters from binary files + * + * @param weights Files names containing the weights data + * @param biases Files names containing the bias data + */ + void fill(std::vector weights, std::vector biases) + { + ARM_COMPUTE_ERROR_ON(weights.size() != w.size()); + ARM_COMPUTE_ERROR_ON(biases.size() != b.size()); + ARM_COMPUTE_ERROR_ON(_reshaped_weights); + + for(unsigned int i = 0; i < weights.size(); ++i) + { + library->fill_layer_data(Accessor(w[i]), weights[i]); + library->fill_layer_data(Accessor(b[i]), biases[i]); + } + } + + /** Feed input to network from file. + * + * @param name File name of containing the input data. + */ + void feed(std::string name) + { + library->fill_layer_data(Accessor(input), name); + } +#endif /* INTERNAL_ONLY */ + + /** Get the classification results. + * + * @return Vector containing the classified labels + */ + std::vector get_classifications() + { + std::vector classified_labels; + Accessor output_accessor(output); + + Window window; + window.set(Window::DimX, Window::Dimension(0, 1, 1)); + for(unsigned int d = 1; d < output_accessor.shape().num_dimensions(); ++d) + { + window.set(d, Window::Dimension(0, output_accessor.shape()[d], 1)); + } + + execute_window_loop(window, [&](const Coordinates & id) + { + int max_idx = 0; + float val = 0; + const void *const out_ptr = output_accessor(id); + for(unsigned int l = 0; l < output_accessor.shape().x(); ++l) + { + float curr_val = reinterpret_cast(out_ptr)[l]; + if(curr_val > val) + { + max_idx = l; + val = curr_val; + } + } + classified_labels.push_back(max_idx); + }); + return classified_labels; + } + + /** Clear all allocated memory from the tensor objects */ + void clear() + { + // Free allocations + input.allocator()->free(); + output.allocator()->free(); + + if(!_reshaped_weights) + { + for(auto &wi : w) + { + wi.allocator()->free(); + } + + for(auto &bi : b) + { + bi.allocator()->free(); + } + } + else + { + w[0].allocator()->free(); + w[2].allocator()->free(); + w[5].allocator()->free(); + w[6].allocator()->free(); + w[7].allocator()->free(); + + b[5].allocator()->free(); + b[6].allocator()->free(); + b[7].allocator()->free(); + + if(_is_direct_conv) + { + w[3].allocator()->free(); + w[4].allocator()->free(); + b[2].allocator()->free(); + b[3].allocator()->free(); + b[4].allocator()->free(); + } + } + + w21.reset(); + w22.reset(); + b21.reset(); + b21.reset(); + w41.reset(); + w42.reset(); + b41.reset(); + b42.reset(); + w51.reset(); + w52.reset(); + b51.reset(); + b52.reset(); + + conv1_out.allocator()->free(); + act1_out.allocator()->free(); + norm1_out.allocator()->free(); + pool1_out.allocator()->free(); + conv2_out.allocator()->free(); + act2_out.allocator()->free(); + norm2_out.allocator()->free(); + pool2_out.allocator()->free(); + conv3_out.allocator()->free(); + act3_out.allocator()->free(); + conv4_out.allocator()->free(); + act4_out.allocator()->free(); + conv5_out.allocator()->free(); + act5_out.allocator()->free(); + pool5_out.allocator()->free(); + fc6_out.allocator()->free(); + act6_out.allocator()->free(); + fc7_out.allocator()->free(); + act7_out.allocator()->free(); + fc8_out.allocator()->free(); + } + + /** Runs the model */ + void run() + { + // Layer 1 + conv1.run(); + act1.run(); + norm1.run(); + pool1.run(); + // Layer 2 + conv21.run(); + conv22.run(); + act2.run(); + norm2.run(); + pool2.run(); + // Layer 3 + conv3.run(); + act3.run(); + // Layer 4 + conv41.run(); + conv42.run(); + act4.run(); + // Layer 5 + conv51.run(); + conv52.run(); + act5.run(); + pool5.run(); + // Layer 6 + fc6.run(); + act6.run(); + // Layer 7 + fc7.run(); + act7.run(); + // Layer 8 + fc8.run(); + // Softmax + smx.run(); + } + +private: + struct DirectConv + { + template + typename std::enable_if < !std::is_same::value, void >::type + configure(ITensorType *input, const ITensorType *weights, const ITensorType *biases, ITensorType *output, const PadStrideInfo &conv_info, const WeightsInfo &weights_info = WeightsInfo()) + { + _func.configure(input, weights, biases, output, conv_info); + } + + template + typename std::enable_if::value, void>::type + configure(ITensorType *input, const ITensorType *weights, const ITensorType *biases, ITensorType *output, const PadStrideInfo &conv_info, const WeightsInfo &weights_info = WeightsInfo()) + { + _func.configure(input, weights, biases, output, conv_info, weights_info); + } + + void run() + { + _func.run(); + } + + DirectConvolutionLayerFunction _func{}; + }; + + DataType _data_type{ DataType::UNKNOWN }; + int _fixed_point_position{ 0 }; + unsigned int _batches{ 0 }; + bool _reshaped_weights{ false }; + bool _is_direct_conv{ !std::is_same::value }; + + ActivationLayerFunction act1{}, act2{}, act3{}, act4{}, act5{}, act6{}, act7{}; + ConvolutionLayerFunction conv1{}; + DirectConv conv21{}, conv22{}, conv3{}, conv41{}, conv42{}, conv51{}, conv52{}; + FullyConnectedLayerFunction fc6{}, fc7{}, fc8{}; + NormalizationLayerFunction norm1{}, norm2{}; + PoolingLayerFunction pool1{}, pool2{}, pool5{}; + SoftmaxLayerFunction smx{}; + + TensorType input{}, output{}; + std::array w{ {} }, b{ {} }; + std::unique_ptr w21{ nullptr }, w22{ nullptr }, b21{ nullptr }, b22{ nullptr }; + std::unique_ptr w41{ nullptr }, w42{ nullptr }, b41{ nullptr }, b42{ nullptr }; + std::unique_ptr w51{ nullptr }, w52{ nullptr }, b51{ nullptr }, b52{ nullptr }; + + TensorType conv1_out{}, act1_out{}, norm1_out{}, pool1_out{}; + TensorType conv2_out{}, act2_out{}, pool2_out{}, norm2_out{}; + TensorType conv3_out{}, act3_out{}; + TensorType conv4_out{}, act4_out{}; + TensorType conv5_out{}, act5_out{}, pool5_out{}; + TensorType fc6_out{}, act6_out{}; + TensorType fc7_out{}, act7_out{}; + TensorType fc8_out{}; + + std::unique_ptr pool11_out{}, pool12_out{}; + std::unique_ptr conv21_out{}, conv22_out{}; + std::unique_ptr act31_out{}, act32_out{}; + std::unique_ptr conv41_out{}, conv42_out{}, act41_out{}, act42_out{}; + std::unique_ptr conv51_out{}, conv52_out{}; +}; +} // namespace networks +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_MODEL_OBJECTS_ALEXNET_H__ diff --git a/tests/networks/LeNet5Network.h b/tests/networks/LeNet5Network.h new file mode 100644 index 0000000000..ed7ac18f40 --- /dev/null +++ b/tests/networks/LeNet5Network.h @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_MODEL_OBJECTS_LENET5_H__ +#define __ARM_COMPUTE_TEST_MODEL_OBJECTS_LENET5_H__ + +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/Utils.h" + +#include + +using namespace arm_compute; +using namespace arm_compute::test; + +namespace arm_compute +{ +namespace test +{ +namespace networks +{ +/** Lenet5 model object */ +template +class LeNet5Network +{ +public: + void init(int batches) + { + _batches = batches; + + // Initialize input, output, weights and biases + input.allocator()->init(TensorInfo(TensorShape(28U, 28U, 1U, _batches), 1, DataType::F32)); + output.allocator()->init(TensorInfo(TensorShape(10U, _batches), 1, DataType::F32)); + w[0].allocator()->init(TensorInfo(TensorShape(5U, 5U, 1U, 20U), 1, DataType::F32)); + b[0].allocator()->init(TensorInfo(TensorShape(20U), 1, DataType::F32)); + w[1].allocator()->init(TensorInfo(TensorShape(5U, 5U, 20U, 50U), 1, DataType::F32)); + b[1].allocator()->init(TensorInfo(TensorShape(50U), 1, DataType::F32)); + w[2].allocator()->init(TensorInfo(TensorShape(800U, 500U), 1, DataType::F32)); + b[2].allocator()->init(TensorInfo(TensorShape(500U), 1, DataType::F32)); + w[3].allocator()->init(TensorInfo(TensorShape(500U, 10U), 1, DataType::F32)); + b[3].allocator()->init(TensorInfo(TensorShape(10U), 1, DataType::F32)); + } + + /** Build the model. */ + void build() + { + // Initialize intermediate tensors + // Layer 1 + conv1_out.allocator()->init(TensorInfo(TensorShape(24U, 24U, 20U, _batches), 1, DataType::F32)); + pool1_out.allocator()->init(TensorInfo(TensorShape(12U, 12U, 20U, _batches), 1, DataType::F32)); + // Layer 2 + conv2_out.allocator()->init(TensorInfo(TensorShape(8U, 8U, 50U, _batches), 1, DataType::F32)); + pool2_out.allocator()->init(TensorInfo(TensorShape(4U, 4U, 50U, _batches), 1, DataType::F32)); + // Layer 3 + fc1_out.allocator()->init(TensorInfo(TensorShape(500U, _batches), 1, DataType::F32)); + act1_out.allocator()->init(TensorInfo(TensorShape(500U, _batches), 1, DataType::F32)); + // Layer 6 + fc2_out.allocator()->init(TensorInfo(TensorShape(10U, _batches), 1, DataType::F32)); + + // Configure Layers + conv1.configure(&input, &w[0], &b[0], &conv1_out, PadStrideInfo(1, 1, 0, 0)); + pool1.configure(&conv1_out, &pool1_out, PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0))); + conv2.configure(&pool1_out, &w[1], &b[1], &conv2_out, PadStrideInfo(1, 1, 0, 0)); + pool2.configure(&conv2_out, &pool2_out, PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0))); + fc1.configure(&pool2_out, &w[2], &b[2], &fc1_out); + act1.configure(&fc1_out, &act1_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + fc2.configure(&act1_out, &w[3], &b[3], &fc2_out); + smx.configure(&fc2_out, &output); + } + + void allocate() + { + // Allocate tensors + input.allocator()->allocate(); + output.allocator()->allocate(); + for(auto &wi : w) + { + wi.allocator()->allocate(); + } + for(auto &bi : b) + { + bi.allocator()->allocate(); + } + conv1_out.allocator()->allocate(); + pool1_out.allocator()->allocate(); + conv2_out.allocator()->allocate(); + pool2_out.allocator()->allocate(); + fc1_out.allocator()->allocate(); + act1_out.allocator()->allocate(); + fc2_out.allocator()->allocate(); + } + + /** Fills the trainable parameters and input with random data. */ + void fill_random() + { + std::uniform_real_distribution<> distribution(-1, 1); + library->fill(Accessor(input), distribution, 0); + for(unsigned int i = 0; i < w.size(); ++i) + { + library->fill(Accessor(w[i]), distribution, i + 1); + library->fill(Accessor(b[i]), distribution, i + 10); + } + } + +#ifdef INTERNAL_ONLY + /** Fills the trainable parameters from binary files + * + * @param weights Files names containing the weights data + * @param biases Files names containing the bias data + */ + void fill(std::vector weights, std::vector biases) + { + ARM_COMPUTE_ERROR_ON(weights.size() != w.size()); + ARM_COMPUTE_ERROR_ON(biases.size() != b.size()); + + for(unsigned int i = 0; i < weights.size(); ++i) + { + library->fill_layer_data(Accessor(w[i]), weights[i]); + library->fill_layer_data(Accessor(b[i]), biases[i]); + } + } + + /** Feed input to network from file. + * + * @param name File name of containing the input data. + */ + void feed(std::string name) + { + library->fill_layer_data(Accessor(input), name); + } +#endif /* INTERNAL_ONLY */ + + /** Get the classification results. + * + * @return Vector containing the classified labels + */ + std::vector get_classifications() + { + std::vector classified_labels; + Accessor output_accessor(output); + + Window window; + window.set(Window::DimX, Window::Dimension(0, 1, 1)); + for(unsigned int d = 1; d < output_accessor.shape().num_dimensions(); ++d) + { + window.set(d, Window::Dimension(0, output_accessor.shape()[d], 1)); + } + + execute_window_loop(window, [&](const Coordinates & id) + { + int max_idx = 0; + float val = 0; + const void *const out_ptr = output_accessor(id); + for(unsigned int l = 0; l < output_accessor.shape().x(); ++l) + { + float curr_val = reinterpret_cast(out_ptr)[l]; + if(curr_val > val) + { + max_idx = l; + val = curr_val; + } + } + classified_labels.push_back(max_idx); + }); + return classified_labels; + } + + /** Clear all allocated memory from the tensor objects */ + void clear() + { + input.allocator()->free(); + output.allocator()->free(); + for(auto &wi : w) + { + wi.allocator()->free(); + } + for(auto &bi : b) + { + bi.allocator()->free(); + } + + conv1_out.allocator()->free(); + pool1_out.allocator()->free(); + conv2_out.allocator()->free(); + pool2_out.allocator()->free(); + fc1_out.allocator()->free(); + act1_out.allocator()->free(); + fc2_out.allocator()->free(); + } + + /** Runs the model */ + void run() + { + // Layer 1 + conv1.run(); + pool1.run(); + // Layer 2 + conv2.run(); + pool2.run(); + // Layer 3 + fc1.run(); + act1.run(); + // Layer 4 + fc2.run(); + // Softmax + smx.run(); + } + +private: + unsigned int _batches{ 0 }; + + ActivationLayerFunction act1{}; + ConvolutionLayerFunction conv1{}, conv2{}; + FullyConnectedLayerFunction fc1{}, fc2{}; + PoolingLayerFunction pool1{}, pool2{}; + SoftmaxLayerFunction smx{}; + + TensorType input{}, output{}; + std::array w{ {} }, b{ {} }; + + TensorType conv1_out{}, pool1_out{}; + TensorType conv2_out{}, pool2_out{}; + TensorType fc1_out{}, act1_out{}; + TensorType fc2_out{}; +}; +} // namespace networks +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_MODEL_OBJECTS_LENET5_H__ diff --git a/tests/networks_new/AlexNetNetwork.h b/tests/networks_new/AlexNetNetwork.h deleted file mode 100644 index 11171d6ec2..0000000000 --- a/tests/networks_new/AlexNetNetwork.h +++ /dev/null @@ -1,622 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_MODEL_OBJECTS_ALEXNET_H__ -#define __ARM_COMPUTE_TEST_MODEL_OBJECTS_ALEXNET_H__ - -#include "arm_compute/runtime/Tensor.h" - -#include "AssetsLibrary.h" -#include "Globals.h" -#include "Utils.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace networks -{ -/** AlexNet model object */ -template -class AlexNetNetwork -{ -public: - void init(DataType data_type, int fixed_point_position, int batches, bool reshaped_weights = false) - { - _data_type = data_type; - _fixed_point_position = fixed_point_position; - _batches = batches; - _reshaped_weights = reshaped_weights; - - // Initialize weights and biases - if(!_reshaped_weights) - { - w[0].allocator()->init(TensorInfo(TensorShape(11U, 11U, 3U, 96U), 1, _data_type, _fixed_point_position)); - b[0].allocator()->init(TensorInfo(TensorShape(96U), 1, _data_type, _fixed_point_position)); - w[1].allocator()->init(TensorInfo(TensorShape(5U, 5U, 48U, 256U), 1, _data_type, _fixed_point_position)); - b[1].allocator()->init(TensorInfo(TensorShape(256U), 1, _data_type, _fixed_point_position)); - w[2].allocator()->init(TensorInfo(TensorShape(3U, 3U, 256U, 384U), 1, _data_type, _fixed_point_position)); - b[2].allocator()->init(TensorInfo(TensorShape(384U), 1, _data_type, _fixed_point_position)); - w[3].allocator()->init(TensorInfo(TensorShape(3U, 3U, 192U, 384U), 1, _data_type, _fixed_point_position)); - b[3].allocator()->init(TensorInfo(TensorShape(384U), 1, _data_type, _fixed_point_position)); - w[4].allocator()->init(TensorInfo(TensorShape(3U, 3U, 192U, 256U), 1, _data_type, _fixed_point_position)); - b[4].allocator()->init(TensorInfo(TensorShape(256U), 1, _data_type, _fixed_point_position)); - w[5].allocator()->init(TensorInfo(TensorShape(9216U, 4096U), 1, _data_type, _fixed_point_position)); - b[5].allocator()->init(TensorInfo(TensorShape(4096U), 1, _data_type, _fixed_point_position)); - w[6].allocator()->init(TensorInfo(TensorShape(4096U, 4096U), 1, _data_type, _fixed_point_position)); - b[6].allocator()->init(TensorInfo(TensorShape(4096U), 1, _data_type, _fixed_point_position)); - w[7].allocator()->init(TensorInfo(TensorShape(4096U, 1000U), 1, _data_type, _fixed_point_position)); - b[7].allocator()->init(TensorInfo(TensorShape(1000U), 1, _data_type, _fixed_point_position)); - - w21 = std::unique_ptr(new SubTensorType(&w[1], TensorShape(5U, 5U, 48U, 128U), Coordinates())); - w22 = std::unique_ptr(new SubTensorType(&w[1], TensorShape(5U, 5U, 48U, 128U), Coordinates(0, 0, 0, 128))); - b21 = std::unique_ptr(new SubTensorType(&b[1], TensorShape(128U), Coordinates())); - b22 = std::unique_ptr(new SubTensorType(&b[1], TensorShape(128U), Coordinates(128))); - - w41 = std::unique_ptr(new SubTensorType(&w[3], TensorShape(3U, 3U, 192U, 192U), Coordinates())); - w42 = std::unique_ptr(new SubTensorType(&w[3], TensorShape(3U, 3U, 192U, 192U), Coordinates(0, 0, 0, 192))); - b41 = std::unique_ptr(new SubTensorType(&b[3], TensorShape(192U), Coordinates())); - b42 = std::unique_ptr(new SubTensorType(&b[3], TensorShape(192U), Coordinates(192))); - - w51 = std::unique_ptr(new SubTensorType(&w[4], TensorShape(3U, 3U, 192U, 128U), Coordinates())); - w52 = std::unique_ptr(new SubTensorType(&w[4], TensorShape(3U, 3U, 192U, 128U), Coordinates(0, 0, 0, 128))); - b51 = std::unique_ptr(new SubTensorType(&b[4], TensorShape(128U), Coordinates())); - b52 = std::unique_ptr(new SubTensorType(&b[4], TensorShape(128U), Coordinates(128))); - } - else - { - auto reshape = [&](unsigned int width, unsigned int height) -> TensorShape - { - const int interleave_width = 16 / arm_compute::data_size_from_type(_data_type); - - return TensorShape{ width * interleave_width, static_cast(std::ceil(static_cast(height) / interleave_width)) }; - }; - - // Create tensor for the reshaped weights - w[0].allocator()->init(TensorInfo(reshape(366U, 96U), 1, _data_type, _fixed_point_position)); - - // Configure the direct convolution's weights. Direct convolution doesn't need reshape weights - if(!_is_direct_conv) - { - auto w21_tensor = std::unique_ptr(new TensorType()); - auto w22_tensor = std::unique_ptr(new TensorType()); - auto w41_tensor = std::unique_ptr(new TensorType()); - auto w42_tensor = std::unique_ptr(new TensorType()); - auto w51_tensor = std::unique_ptr(new TensorType()); - auto w52_tensor = std::unique_ptr(new TensorType()); - w21_tensor->allocator()->init(TensorInfo(reshape(1248U, 128U), 1, _data_type, _fixed_point_position)); - w22_tensor->allocator()->init(TensorInfo(reshape(1248U, 128U), 1, _data_type, _fixed_point_position)); - w41_tensor->allocator()->init(TensorInfo(reshape(1920U, 192U), 1, _data_type, _fixed_point_position)); - w42_tensor->allocator()->init(TensorInfo(reshape(1920U, 192U), 1, _data_type, _fixed_point_position)); - w51_tensor->allocator()->init(TensorInfo(reshape(1920U, 128U), 1, _data_type, _fixed_point_position)); - w52_tensor->allocator()->init(TensorInfo(reshape(1920U, 128U), 1, _data_type, _fixed_point_position)); - w[2].allocator()->init(TensorInfo(reshape(2560U, 384U), 1, _data_type, _fixed_point_position)); - w21 = std::move(w21_tensor); - w22 = std::move(w22_tensor); - w41 = std::move(w41_tensor); - w42 = std::move(w42_tensor); - w51 = std::move(w51_tensor); - w52 = std::move(w52_tensor); - } - else - { - w[1].allocator()->init(TensorInfo(TensorShape(5U, 5U, 48U, 256U), 1, _data_type, _fixed_point_position)); - b[1].allocator()->init(TensorInfo(TensorShape(256U), 1, _data_type, _fixed_point_position)); - w[2].allocator()->init(TensorInfo(TensorShape(3U, 3U, 256U, 384U), 1, _data_type, _fixed_point_position)); - b[2].allocator()->init(TensorInfo(TensorShape(384U), 1, _data_type, _fixed_point_position)); - w[3].allocator()->init(TensorInfo(TensorShape(3U, 3U, 192U, 384U), 1, _data_type, _fixed_point_position)); - b[3].allocator()->init(TensorInfo(TensorShape(384U), 1, _data_type, _fixed_point_position)); - w[4].allocator()->init(TensorInfo(TensorShape(3U, 3U, 192U, 256U), 1, _data_type, _fixed_point_position)); - b[4].allocator()->init(TensorInfo(TensorShape(256U), 1, _data_type, _fixed_point_position)); - w21 = std::unique_ptr(new SubTensorType(&w[1], TensorShape(5U, 5U, 48U, 128U), Coordinates())); - w22 = std::unique_ptr(new SubTensorType(&w[1], TensorShape(5U, 5U, 48U, 128U), Coordinates(0, 0, 0, 128))); - b21 = std::unique_ptr(new SubTensorType(&b[1], TensorShape(128U), Coordinates())); - b22 = std::unique_ptr(new SubTensorType(&b[1], TensorShape(128U), Coordinates(128))); - - w41 = std::unique_ptr(new SubTensorType(&w[3], TensorShape(3U, 3U, 192U, 192U), Coordinates())); - w42 = std::unique_ptr(new SubTensorType(&w[3], TensorShape(3U, 3U, 192U, 192U), Coordinates(0, 0, 0, 192))); - b41 = std::unique_ptr(new SubTensorType(&b[3], TensorShape(192U), Coordinates())); - b42 = std::unique_ptr(new SubTensorType(&b[3], TensorShape(192U), Coordinates(192))); - - w51 = std::unique_ptr(new SubTensorType(&w[4], TensorShape(3U, 3U, 192U, 128U), Coordinates())); - w52 = std::unique_ptr(new SubTensorType(&w[4], TensorShape(3U, 3U, 192U, 128U), Coordinates(0, 0, 0, 128))); - b51 = std::unique_ptr(new SubTensorType(&b[4], TensorShape(128U), Coordinates())); - b52 = std::unique_ptr(new SubTensorType(&b[4], TensorShape(128U), Coordinates(128))); - } - - b[5].allocator()->init(TensorInfo(TensorShape(4096U), 1, _data_type, _fixed_point_position)); - b[6].allocator()->init(TensorInfo(TensorShape(4096U), 1, _data_type, _fixed_point_position)); - b[7].allocator()->init(TensorInfo(TensorShape(1000U), 1, _data_type, _fixed_point_position)); - - if(_batches > 1 && std::is_same::value) - { - w[5].allocator()->init(TensorInfo(reshape(9216U, 4096U), 1, _data_type, _fixed_point_position)); - w[6].allocator()->init(TensorInfo(reshape(4096U, 4096U), 1, _data_type, _fixed_point_position)); - w[7].allocator()->init(TensorInfo(reshape(4096U, 1000U), 1, _data_type, _fixed_point_position)); - } - else - { - w[5].allocator()->init(TensorInfo(TensorShape(4096U, 9216U), 1, _data_type, _fixed_point_position)); - w[6].allocator()->init(TensorInfo(TensorShape(4096U, 4096U), 1, _data_type, _fixed_point_position)); - w[7].allocator()->init(TensorInfo(TensorShape(1000U, 4096U), 1, _data_type, _fixed_point_position)); - } - } - } - - void build() - { - input.allocator()->init(TensorInfo(TensorShape(227U, 227U, 3U, _batches), 1, _data_type, _fixed_point_position)); - output.allocator()->init(TensorInfo(TensorShape(1000U, _batches), 1, _data_type, _fixed_point_position)); - - // Initialize intermediate tensors - // Layer 1 - conv1_out.allocator()->init(TensorInfo(TensorShape(55U, 55U, 96U, _batches), 1, _data_type, _fixed_point_position)); - act1_out.allocator()->init(TensorInfo(TensorShape(55U, 55U, 96U, _batches), 1, _data_type, _fixed_point_position)); - norm1_out.allocator()->init(TensorInfo(TensorShape(55U, 55U, 96U, _batches), 1, _data_type, _fixed_point_position)); - pool1_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 96U, _batches), 1, _data_type, _fixed_point_position)); - pool11_out = std::unique_ptr(new SubTensorType(&pool1_out, TensorShape(27U, 27U, 48U, _batches), Coordinates())); - pool12_out = std::unique_ptr(new SubTensorType(&pool1_out, TensorShape(27U, 27U, 48U, _batches), Coordinates(0, 0, 48))); - // Layer 2 - conv2_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 256U, _batches), 1, _data_type, _fixed_point_position)); - conv21_out = std::unique_ptr(new SubTensorType(&conv2_out, TensorShape(27U, 27U, 128U, _batches), Coordinates())); - conv22_out = std::unique_ptr(new SubTensorType(&conv2_out, TensorShape(27U, 27U, 128U, _batches), Coordinates(0, 0, 128))); - act2_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 256U, _batches), 1, _data_type, _fixed_point_position)); - norm2_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 256U, _batches), 1, _data_type, _fixed_point_position)); - pool2_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 256U, _batches), 1, _data_type, _fixed_point_position)); - // Layer 3 - conv3_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, _data_type, _fixed_point_position)); - act3_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, _data_type, _fixed_point_position)); - act31_out = std::unique_ptr(new SubTensorType(&act3_out, TensorShape(13U, 13U, 192U, _batches), Coordinates())); - act32_out = std::unique_ptr(new SubTensorType(&act3_out, TensorShape(13U, 13U, 192U, _batches), Coordinates(0, 0, 192))); - // Layer 4 - conv4_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, _data_type, _fixed_point_position)); - conv41_out = std::unique_ptr(new SubTensorType(&conv4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates())); - conv42_out = std::unique_ptr(new SubTensorType(&conv4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates(0, 0, 192))); - act4_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, _data_type, _fixed_point_position)); - act41_out = std::unique_ptr(new SubTensorType(&act4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates())); - act42_out = std::unique_ptr(new SubTensorType(&act4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates(0, 0, 192))); - // Layer 5 - conv5_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 256U, _batches), 1, _data_type, _fixed_point_position)); - conv51_out = std::unique_ptr(new SubTensorType(&conv5_out, TensorShape(13U, 13U, 128U, _batches), Coordinates())); - conv52_out = std::unique_ptr(new SubTensorType(&conv5_out, TensorShape(13U, 13U, 128U, _batches), Coordinates(0, 0, 128))); - act5_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 256U, _batches), 1, _data_type, _fixed_point_position)); - pool5_out.allocator()->init(TensorInfo(TensorShape(6U, 6U, 256U, _batches), 1, _data_type, _fixed_point_position)); - // Layer 6 - fc6_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, _data_type, _fixed_point_position)); - act6_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, _data_type, _fixed_point_position)); - // Layer 7 - fc7_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, _data_type, _fixed_point_position)); - act7_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, _data_type, _fixed_point_position)); - // Layer 8 - fc8_out.allocator()->init(TensorInfo(TensorShape(1000U, _batches), 1, _data_type, _fixed_point_position)); - - // Configure Layers - // Layer 1 - TensorType *b0 = _reshaped_weights ? nullptr : &b[0]; - conv1.configure(&input, &w[0], b0, &conv1_out, PadStrideInfo(4, 4, 0, 0), WeightsInfo(_reshaped_weights, 11U, 11U, 96U)); - act1.configure(&conv1_out, &act1_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); - norm1.configure(&act1_out, &norm1_out, NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)); - pool1.configure(&norm1_out, &pool1_out, PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); - // Layer 2 - conv21.configure(pool11_out.get(), w21.get(), b21.get(), conv21_out.get(), PadStrideInfo(1, 1, 2, 2), WeightsInfo(_reshaped_weights, 5U, 5U, 128U)); - conv22.configure(pool12_out.get(), w22.get(), b22.get(), conv22_out.get(), PadStrideInfo(1, 1, 2, 2), WeightsInfo(_reshaped_weights, 5U, 5U, 128U)); - act2.configure(&conv2_out, &act2_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); - norm2.configure(&act2_out, &norm2_out, NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)); - pool2.configure(&norm2_out, &pool2_out, PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); - // Layer 3 - TensorType *b2 = (_reshaped_weights && !_is_direct_conv) ? nullptr : &b[2]; - conv3.configure(&pool2_out, &w[2], b2, &conv3_out, PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 384U)); - act3.configure(&conv3_out, &act3_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); - // Layer 4 - conv41.configure(act31_out.get(), w41.get(), b41.get(), conv41_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 192U)); - conv42.configure(act32_out.get(), w42.get(), b42.get(), conv42_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 192U)); - act4.configure(&conv4_out, &act4_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); - // Layer 5 - conv51.configure(act41_out.get(), w51.get(), b51.get(), conv51_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 128U)); - conv52.configure(act42_out.get(), w52.get(), b52.get(), conv52_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 128U)); - act5.configure(&conv5_out, &act5_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); - pool5.configure(&act5_out, &pool5_out, PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); - // Layer 6 - fc6.configure(&pool5_out, &w[5], &b[5], &fc6_out, true, _reshaped_weights); - act6.configure(&fc6_out, &act6_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); - // Layer 7 - fc7.configure(&act6_out, &w[6], &b[6], &fc7_out, true, _reshaped_weights); - act7.configure(&fc7_out, &act7_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); - // Layer 8 - fc8.configure(&act7_out, &w[7], &b[7], &fc8_out, true, _reshaped_weights); - // Softmax - smx.configure(&fc8_out, &output); - } - - void allocate() - { - input.allocator()->allocate(); - output.allocator()->allocate(); - - if(!_reshaped_weights) - { - for(auto &wi : w) - { - wi.allocator()->allocate(); - } - - for(auto &bi : b) - { - bi.allocator()->allocate(); - } - } - else - { - w[0].allocator()->allocate(); - w[2].allocator()->allocate(); - w[5].allocator()->allocate(); - w[6].allocator()->allocate(); - w[7].allocator()->allocate(); - - b[5].allocator()->allocate(); - b[6].allocator()->allocate(); - b[7].allocator()->allocate(); - - if(!_is_direct_conv) - { - dynamic_cast(w21.get())->allocator()->allocate(); - dynamic_cast(w22.get())->allocator()->allocate(); - dynamic_cast(w41.get())->allocator()->allocate(); - dynamic_cast(w42.get())->allocator()->allocate(); - dynamic_cast(w51.get())->allocator()->allocate(); - dynamic_cast(w52.get())->allocator()->allocate(); - } - else - { - b[1].allocator()->allocate(); - b[2].allocator()->allocate(); - b[3].allocator()->allocate(); - b[4].allocator()->allocate(); - w[1].allocator()->allocate(); - w[3].allocator()->allocate(); - w[4].allocator()->allocate(); - } - } - - conv1_out.allocator()->allocate(); - act1_out.allocator()->allocate(); - norm1_out.allocator()->allocate(); - pool1_out.allocator()->allocate(); - conv2_out.allocator()->allocate(); - act2_out.allocator()->allocate(); - norm2_out.allocator()->allocate(); - pool2_out.allocator()->allocate(); - conv3_out.allocator()->allocate(); - act3_out.allocator()->allocate(); - conv4_out.allocator()->allocate(); - act4_out.allocator()->allocate(); - conv5_out.allocator()->allocate(); - act5_out.allocator()->allocate(); - pool5_out.allocator()->allocate(); - fc6_out.allocator()->allocate(); - act6_out.allocator()->allocate(); - fc7_out.allocator()->allocate(); - act7_out.allocator()->allocate(); - fc8_out.allocator()->allocate(); - } - - /** Fills the trainable parameters and input with random data. */ - void fill_random() - { - library->fill_tensor_uniform(Accessor(input), 0); - - if(!_reshaped_weights) - { - for(unsigned int i = 0; i < w.size(); ++i) - { - library->fill_tensor_uniform(Accessor(w[i]), i + 1); - library->fill_tensor_uniform(Accessor(b[i]), i + 10); - } - } - else - { - library->fill_tensor_uniform(Accessor(w[0]), 1); - library->fill_tensor_uniform(Accessor(w[2]), 2); - - library->fill_tensor_uniform(Accessor(w[5]), 3); - library->fill_tensor_uniform(Accessor(b[5]), 4); - library->fill_tensor_uniform(Accessor(w[6]), 5); - library->fill_tensor_uniform(Accessor(b[6]), 6); - library->fill_tensor_uniform(Accessor(w[7]), 7); - library->fill_tensor_uniform(Accessor(b[7]), 8); - - if(!_is_direct_conv) - { - library->fill_tensor_uniform(Accessor(*dynamic_cast(w21.get())), 9); - library->fill_tensor_uniform(Accessor(*dynamic_cast(w22.get())), 10); - library->fill_tensor_uniform(Accessor(*dynamic_cast(w41.get())), 11); - library->fill_tensor_uniform(Accessor(*dynamic_cast(w42.get())), 12); - library->fill_tensor_uniform(Accessor(*dynamic_cast(w51.get())), 13); - library->fill_tensor_uniform(Accessor(*dynamic_cast(w52.get())), 14); - } - else - { - library->fill_tensor_uniform(Accessor(w[1]), 9); - library->fill_tensor_uniform(Accessor(b[1]), 10); - library->fill_tensor_uniform(Accessor(w[3]), 11); - library->fill_tensor_uniform(Accessor(b[3]), 12); - library->fill_tensor_uniform(Accessor(w[4]), 13); - library->fill_tensor_uniform(Accessor(b[4]), 14); - } - } - } - -#ifdef INTERNAL_ONLY - /** Fills the trainable parameters from binary files - * - * @param weights Files names containing the weights data - * @param biases Files names containing the bias data - */ - void fill(std::vector weights, std::vector biases) - { - ARM_COMPUTE_ERROR_ON(weights.size() != w.size()); - ARM_COMPUTE_ERROR_ON(biases.size() != b.size()); - ARM_COMPUTE_ERROR_ON(_reshaped_weights); - - for(unsigned int i = 0; i < weights.size(); ++i) - { - library->fill_layer_data(Accessor(w[i]), weights[i]); - library->fill_layer_data(Accessor(b[i]), biases[i]); - } - } - - /** Feed input to network from file. - * - * @param name File name of containing the input data. - */ - void feed(std::string name) - { - library->fill_layer_data(Accessor(input), name); - } -#endif /* INTERNAL_ONLY */ - - /** Get the classification results. - * - * @return Vector containing the classified labels - */ - std::vector get_classifications() - { - std::vector classified_labels; - Accessor output_accessor(output); - - Window window; - window.set(Window::DimX, Window::Dimension(0, 1, 1)); - for(unsigned int d = 1; d < output_accessor.shape().num_dimensions(); ++d) - { - window.set(d, Window::Dimension(0, output_accessor.shape()[d], 1)); - } - - execute_window_loop(window, [&](const Coordinates & id) - { - int max_idx = 0; - float val = 0; - const void *const out_ptr = output_accessor(id); - for(unsigned int l = 0; l < output_accessor.shape().x(); ++l) - { - float curr_val = reinterpret_cast(out_ptr)[l]; - if(curr_val > val) - { - max_idx = l; - val = curr_val; - } - } - classified_labels.push_back(max_idx); - }); - return classified_labels; - } - - /** Clear all allocated memory from the tensor objects */ - void clear() - { - // Free allocations - input.allocator()->free(); - output.allocator()->free(); - - if(!_reshaped_weights) - { - for(auto &wi : w) - { - wi.allocator()->free(); - } - - for(auto &bi : b) - { - bi.allocator()->free(); - } - } - else - { - w[0].allocator()->free(); - w[2].allocator()->free(); - w[5].allocator()->free(); - w[6].allocator()->free(); - w[7].allocator()->free(); - - b[5].allocator()->free(); - b[6].allocator()->free(); - b[7].allocator()->free(); - - if(_is_direct_conv) - { - w[3].allocator()->free(); - w[4].allocator()->free(); - b[2].allocator()->free(); - b[3].allocator()->free(); - b[4].allocator()->free(); - } - } - - w21.reset(); - w22.reset(); - b21.reset(); - b21.reset(); - w41.reset(); - w42.reset(); - b41.reset(); - b42.reset(); - w51.reset(); - w52.reset(); - b51.reset(); - b52.reset(); - - conv1_out.allocator()->free(); - act1_out.allocator()->free(); - norm1_out.allocator()->free(); - pool1_out.allocator()->free(); - conv2_out.allocator()->free(); - act2_out.allocator()->free(); - norm2_out.allocator()->free(); - pool2_out.allocator()->free(); - conv3_out.allocator()->free(); - act3_out.allocator()->free(); - conv4_out.allocator()->free(); - act4_out.allocator()->free(); - conv5_out.allocator()->free(); - act5_out.allocator()->free(); - pool5_out.allocator()->free(); - fc6_out.allocator()->free(); - act6_out.allocator()->free(); - fc7_out.allocator()->free(); - act7_out.allocator()->free(); - fc8_out.allocator()->free(); - } - - /** Runs the model */ - void run() - { - // Layer 1 - conv1.run(); - act1.run(); - norm1.run(); - pool1.run(); - // Layer 2 - conv21.run(); - conv22.run(); - act2.run(); - norm2.run(); - pool2.run(); - // Layer 3 - conv3.run(); - act3.run(); - // Layer 4 - conv41.run(); - conv42.run(); - act4.run(); - // Layer 5 - conv51.run(); - conv52.run(); - act5.run(); - pool5.run(); - // Layer 6 - fc6.run(); - act6.run(); - // Layer 7 - fc7.run(); - act7.run(); - // Layer 8 - fc8.run(); - // Softmax - smx.run(); - } - -private: - struct DirectConv - { - template - typename std::enable_if < !std::is_same::value, void >::type - configure(ITensorType *input, const ITensorType *weights, const ITensorType *biases, ITensorType *output, const PadStrideInfo &conv_info, const WeightsInfo &weights_info = WeightsInfo()) - { - _func.configure(input, weights, biases, output, conv_info); - } - - template - typename std::enable_if::value, void>::type - configure(ITensorType *input, const ITensorType *weights, const ITensorType *biases, ITensorType *output, const PadStrideInfo &conv_info, const WeightsInfo &weights_info = WeightsInfo()) - { - _func.configure(input, weights, biases, output, conv_info, weights_info); - } - - void run() - { - _func.run(); - } - - DirectConvolutionLayerFunction _func{}; - }; - - DataType _data_type{ DataType::UNKNOWN }; - int _fixed_point_position{ 0 }; - unsigned int _batches{ 0 }; - bool _reshaped_weights{ false }; - bool _is_direct_conv{ !std::is_same::value }; - - ActivationLayerFunction act1{}, act2{}, act3{}, act4{}, act5{}, act6{}, act7{}; - ConvolutionLayerFunction conv1{}; - DirectConv conv21{}, conv22{}, conv3{}, conv41{}, conv42{}, conv51{}, conv52{}; - FullyConnectedLayerFunction fc6{}, fc7{}, fc8{}; - NormalizationLayerFunction norm1{}, norm2{}; - PoolingLayerFunction pool1{}, pool2{}, pool5{}; - SoftmaxLayerFunction smx{}; - - TensorType input{}, output{}; - std::array w{ {} }, b{ {} }; - std::unique_ptr w21{ nullptr }, w22{ nullptr }, b21{ nullptr }, b22{ nullptr }; - std::unique_ptr w41{ nullptr }, w42{ nullptr }, b41{ nullptr }, b42{ nullptr }; - std::unique_ptr w51{ nullptr }, w52{ nullptr }, b51{ nullptr }, b52{ nullptr }; - - TensorType conv1_out{}, act1_out{}, norm1_out{}, pool1_out{}; - TensorType conv2_out{}, act2_out{}, pool2_out{}, norm2_out{}; - TensorType conv3_out{}, act3_out{}; - TensorType conv4_out{}, act4_out{}; - TensorType conv5_out{}, act5_out{}, pool5_out{}; - TensorType fc6_out{}, act6_out{}; - TensorType fc7_out{}, act7_out{}; - TensorType fc8_out{}; - - std::unique_ptr pool11_out{}, pool12_out{}; - std::unique_ptr conv21_out{}, conv22_out{}; - std::unique_ptr act31_out{}, act32_out{}; - std::unique_ptr conv41_out{}, conv42_out{}, act41_out{}, act42_out{}; - std::unique_ptr conv51_out{}, conv52_out{}; -}; -} // namespace networks -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_MODEL_OBJECTS_ALEXNET_H__ diff --git a/tests/networks_new/LeNet5Network.h b/tests/networks_new/LeNet5Network.h deleted file mode 100644 index 33cb59bbd2..0000000000 --- a/tests/networks_new/LeNet5Network.h +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_MODEL_OBJECTS_LENET5_H__ -#define __ARM_COMPUTE_TEST_MODEL_OBJECTS_LENET5_H__ - -#include "AssetsLibrary.h" -#include "Globals.h" -#include "Utils.h" - -#include - -using namespace arm_compute; -using namespace arm_compute::test; - -namespace arm_compute -{ -namespace test -{ -namespace networks -{ -/** Lenet5 model object */ -template -class LeNet5Network -{ -public: - void init(int batches) - { - _batches = batches; - - // Initialize input, output, weights and biases - input.allocator()->init(TensorInfo(TensorShape(28U, 28U, 1U, _batches), 1, DataType::F32)); - output.allocator()->init(TensorInfo(TensorShape(10U, _batches), 1, DataType::F32)); - w[0].allocator()->init(TensorInfo(TensorShape(5U, 5U, 1U, 20U), 1, DataType::F32)); - b[0].allocator()->init(TensorInfo(TensorShape(20U), 1, DataType::F32)); - w[1].allocator()->init(TensorInfo(TensorShape(5U, 5U, 20U, 50U), 1, DataType::F32)); - b[1].allocator()->init(TensorInfo(TensorShape(50U), 1, DataType::F32)); - w[2].allocator()->init(TensorInfo(TensorShape(800U, 500U), 1, DataType::F32)); - b[2].allocator()->init(TensorInfo(TensorShape(500U), 1, DataType::F32)); - w[3].allocator()->init(TensorInfo(TensorShape(500U, 10U), 1, DataType::F32)); - b[3].allocator()->init(TensorInfo(TensorShape(10U), 1, DataType::F32)); - } - - /** Build the model. */ - void build() - { - // Initialize intermediate tensors - // Layer 1 - conv1_out.allocator()->init(TensorInfo(TensorShape(24U, 24U, 20U, _batches), 1, DataType::F32)); - pool1_out.allocator()->init(TensorInfo(TensorShape(12U, 12U, 20U, _batches), 1, DataType::F32)); - // Layer 2 - conv2_out.allocator()->init(TensorInfo(TensorShape(8U, 8U, 50U, _batches), 1, DataType::F32)); - pool2_out.allocator()->init(TensorInfo(TensorShape(4U, 4U, 50U, _batches), 1, DataType::F32)); - // Layer 3 - fc1_out.allocator()->init(TensorInfo(TensorShape(500U, _batches), 1, DataType::F32)); - act1_out.allocator()->init(TensorInfo(TensorShape(500U, _batches), 1, DataType::F32)); - // Layer 6 - fc2_out.allocator()->init(TensorInfo(TensorShape(10U, _batches), 1, DataType::F32)); - - // Configure Layers - conv1.configure(&input, &w[0], &b[0], &conv1_out, PadStrideInfo(1, 1, 0, 0)); - pool1.configure(&conv1_out, &pool1_out, PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0))); - conv2.configure(&pool1_out, &w[1], &b[1], &conv2_out, PadStrideInfo(1, 1, 0, 0)); - pool2.configure(&conv2_out, &pool2_out, PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0))); - fc1.configure(&pool2_out, &w[2], &b[2], &fc1_out); - act1.configure(&fc1_out, &act1_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); - fc2.configure(&act1_out, &w[3], &b[3], &fc2_out); - smx.configure(&fc2_out, &output); - } - - void allocate() - { - // Allocate tensors - input.allocator()->allocate(); - output.allocator()->allocate(); - for(auto &wi : w) - { - wi.allocator()->allocate(); - } - for(auto &bi : b) - { - bi.allocator()->allocate(); - } - conv1_out.allocator()->allocate(); - pool1_out.allocator()->allocate(); - conv2_out.allocator()->allocate(); - pool2_out.allocator()->allocate(); - fc1_out.allocator()->allocate(); - act1_out.allocator()->allocate(); - fc2_out.allocator()->allocate(); - } - - /** Fills the trainable parameters and input with random data. */ - void fill_random() - { - std::uniform_real_distribution<> distribution(-1, 1); - library->fill(Accessor(input), distribution, 0); - for(unsigned int i = 0; i < w.size(); ++i) - { - library->fill(Accessor(w[i]), distribution, i + 1); - library->fill(Accessor(b[i]), distribution, i + 10); - } - } - -#ifdef INTERNAL_ONLY - /** Fills the trainable parameters from binary files - * - * @param weights Files names containing the weights data - * @param biases Files names containing the bias data - */ - void fill(std::vector weights, std::vector biases) - { - ARM_COMPUTE_ERROR_ON(weights.size() != w.size()); - ARM_COMPUTE_ERROR_ON(biases.size() != b.size()); - - for(unsigned int i = 0; i < weights.size(); ++i) - { - library->fill_layer_data(Accessor(w[i]), weights[i]); - library->fill_layer_data(Accessor(b[i]), biases[i]); - } - } - - /** Feed input to network from file. - * - * @param name File name of containing the input data. - */ - void feed(std::string name) - { - library->fill_layer_data(Accessor(input), name); - } -#endif /* INTERNAL_ONLY */ - - /** Get the classification results. - * - * @return Vector containing the classified labels - */ - std::vector get_classifications() - { - std::vector classified_labels; - Accessor output_accessor(output); - - Window window; - window.set(Window::DimX, Window::Dimension(0, 1, 1)); - for(unsigned int d = 1; d < output_accessor.shape().num_dimensions(); ++d) - { - window.set(d, Window::Dimension(0, output_accessor.shape()[d], 1)); - } - - execute_window_loop(window, [&](const Coordinates & id) - { - int max_idx = 0; - float val = 0; - const void *const out_ptr = output_accessor(id); - for(unsigned int l = 0; l < output_accessor.shape().x(); ++l) - { - float curr_val = reinterpret_cast(out_ptr)[l]; - if(curr_val > val) - { - max_idx = l; - val = curr_val; - } - } - classified_labels.push_back(max_idx); - }); - return classified_labels; - } - - /** Clear all allocated memory from the tensor objects */ - void clear() - { - input.allocator()->free(); - output.allocator()->free(); - for(auto &wi : w) - { - wi.allocator()->free(); - } - for(auto &bi : b) - { - bi.allocator()->free(); - } - - conv1_out.allocator()->free(); - pool1_out.allocator()->free(); - conv2_out.allocator()->free(); - pool2_out.allocator()->free(); - fc1_out.allocator()->free(); - act1_out.allocator()->free(); - fc2_out.allocator()->free(); - } - - /** Runs the model */ - void run() - { - // Layer 1 - conv1.run(); - pool1.run(); - // Layer 2 - conv2.run(); - pool2.run(); - // Layer 3 - fc1.run(); - act1.run(); - // Layer 4 - fc2.run(); - // Softmax - smx.run(); - } - -private: - unsigned int _batches{ 0 }; - - ActivationLayerFunction act1{}; - ConvolutionLayerFunction conv1{}, conv2{}; - FullyConnectedLayerFunction fc1{}, fc2{}; - PoolingLayerFunction pool1{}, pool2{}; - SoftmaxLayerFunction smx{}; - - TensorType input{}, output{}; - std::array w{ {} }, b{ {} }; - - TensorType conv1_out{}, pool1_out{}; - TensorType conv2_out{}, pool2_out{}; - TensorType fc1_out{}, act1_out{}; - TensorType fc2_out{}; -}; -} // namespace networks -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_MODEL_OBJECTS_LENET5_H__ diff --git a/tests/validation/CL/ActivationLayer.cpp b/tests/validation/CL/ActivationLayer.cpp new file mode 100644 index 0000000000..097fb638f9 --- /dev/null +++ b/tests/validation/CL/ActivationLayer.cpp @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLActivationLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ActivationFunctionsDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/ActivationLayerFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Define tolerance of the activation layer. + * + * @param[in] activation The activation function used. + * @param[in] data_type Data type. + * + * @return Tolerance depending on the activation function. + */ +AbsoluteTolerance tolerance(ActivationLayerInfo::ActivationFunction activation, DataType data_type) +{ + constexpr float epsilon = 1e-6f; + + switch(activation) + { + case ActivationLayerInfo::ActivationFunction::LINEAR: + return AbsoluteTolerance(data_type == DataType::F16 ? 0.2f : epsilon); + case ActivationLayerInfo::ActivationFunction::SQUARE: + return AbsoluteTolerance(data_type == DataType::F16 ? 0.1f : epsilon); + case ActivationLayerInfo::ActivationFunction::LOGISTIC: + if(is_data_type_fixed_point(data_type)) + { + return AbsoluteTolerance(5.f); + } + else + { + return AbsoluteTolerance(data_type == DataType::F16 ? 0.001f : epsilon); + } + case ActivationLayerInfo::ActivationFunction::LEAKY_RELU: + return AbsoluteTolerance(data_type == DataType::F16 ? 0.00001f : epsilon); + case ActivationLayerInfo::ActivationFunction::SOFT_RELU: + case ActivationLayerInfo::ActivationFunction::SQRT: + if(is_data_type_fixed_point(data_type)) + { + return AbsoluteTolerance(5.f); + } + else + { + return AbsoluteTolerance(data_type == DataType::F16 ? 0.01f : 0.00001f); + } + case ActivationLayerInfo::ActivationFunction::TANH: + if(is_data_type_fixed_point(data_type)) + { + return AbsoluteTolerance(5.f); + } + else + { + return AbsoluteTolerance(data_type == DataType::F16 ? 0.001f : 0.00001f); + } + default: + return AbsoluteTolerance(epsilon); + } +} + +/** CNN data types */ +const auto CNNDataTypes = framework::dataset::make("DataType", +{ + DataType::F16, + DataType::F32, + DataType::QS8, + DataType::QS16, +}); + +/** Input data sets. */ +const auto ActivationDataset = combine(combine(framework::dataset::make("InPlace", { false, true }), datasets::ActivationFunctions()), framework::dataset::make("AlphaBeta", { 0.5f, 1.f })); +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(ActivationLayer) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), CNNDataTypes), framework::dataset::make("InPlace", { false, true })), + shape, data_type, in_place) +{ + // Set fixed point position data type allowed + const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; + + // Create tensors + CLTensor src = create_tensor(shape, data_type, 1, fixed_point_position); + CLTensor dst = create_tensor(shape, data_type, 1, fixed_point_position); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + CLActivationLayer act_layer; + + if(in_place) + { + act_layer.configure(&src, nullptr, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS)); + } + else + { + act_layer.configure(&src, &dst, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS)); + } + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + + if(!in_place) + { + validate(dst.info()->valid_region(), valid_region); + } + + // Validate padding + const int step = 16 / arm_compute::data_size_from_type(data_type); + const PaddingSize padding = PaddingCalculator(shape.x(), step).required_padding(); + validate(src.info()->padding(), padding); + + if(!in_place) + { + validate(dst.info()->padding(), padding); + } +} + +template +using CLActivationLayerFixture = ActivationValidationFixture; + +TEST_SUITE(Float) +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ActivationDataset), + framework::dataset::make("DataType", + DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ActivationDataset), + framework::dataset::make("DataType", + DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); +} +TEST_SUITE_END() + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ActivationDataset), framework::dataset::make("DataType", + DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ActivationDataset), framework::dataset::make("DataType", + DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); +} +TEST_SUITE_END() +TEST_SUITE_END() + +template +using CLActivationLayerFixedPointFixture = ActivationValidationFixedPointFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +// We test for fixed point precision [3,5] because [1,2] and [6,7] ranges cause +// overflowing issues in most of the transcendentals functions. +FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), ActivationDataset), + framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 3, 6))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLActivationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), ActivationDataset), + framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 3, 6))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 +FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), ActivationDataset), + framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLActivationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), ActivationDataset), + framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/ArithmeticAddition.cpp b/tests/validation/CL/ArithmeticAddition.cpp deleted file mode 100644 index fc1bf5905d..0000000000 --- a/tests/validation/CL/ArithmeticAddition.cpp +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "tests/Globals.h" -#include "tests/Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLArithmeticAddition.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon arithmetic addition function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] policy Overflow policy of the operation. - * @param[in] fixed_point_position (Optional) Fixed point position that expresses the number of bits for the fractional part of the number when the tensor's data type is QS8 or QS16 (default = 0). - * - * @return Computed output tensor. - */ -CLTensor compute_arithmetic_addition(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy policy, int fixed_point_position = 0) -{ - // Create tensors - CLTensor src1 = create_tensor(shape, dt_in0, 1, fixed_point_position); - CLTensor src2 = create_tensor(shape, dt_in1, 1, fixed_point_position); - CLTensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); - - // Create and configure function - CLArithmeticAddition add; - add.configure(&src1, &src2, &dst, policy); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src1.info()->is_resizable()); - BOOST_TEST(!src2.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src1), 0); - library->fill_tensor_uniform(CLAccessor(src2), 1); - - // Compute function - add.run(); - - return dst; -} - -void validate_configuration(const CLTensor &src1, const CLTensor &src2, CLTensor &dst, TensorShape shape, ConvertPolicy policy) -{ - BOOST_TEST(src1.info()->is_resizable()); - BOOST_TEST(src2.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - CLArithmeticAddition add; - add.configure(&src1, &src2, &dst, policy); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(ArithmeticAddition) - -BOOST_AUTO_TEST_SUITE(U8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, policy) -{ - // Create tensors - CLTensor src1 = create_tensor(shape, DataType::U8); - CLTensor src2 = create_tensor(shape, DataType::U8); - CLTensor dst = create_tensor(shape, DataType::U8); - - validate_configuration(src1, src2, dst, shape, policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, policy) -{ - // Compute function - CLTensor dst = compute_arithmetic_addition(shape, DataType::U8, DataType::U8, DataType::U8, policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::U8, DataType::U8, DataType::U8, policy); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(S16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, dt, policy) -{ - // Create tensors - CLTensor src1 = create_tensor(shape, dt); - CLTensor src2 = create_tensor(shape, DataType::S16); - CLTensor dst = create_tensor(shape, DataType::S16); - - validate_configuration(src1, src2, dst, shape, policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, dt, policy) -{ - // Compute function - CLTensor dst = compute_arithmetic_addition(shape, dt, DataType::S16, DataType::S16, policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, dt, DataType::S16, DataType::S16, policy); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, dt, policy) -{ - // Compute function - CLTensor dst = compute_arithmetic_addition(shape, dt, DataType::S16, DataType::S16, policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, dt, DataType::S16, DataType::S16, policy); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Quantized) -BOOST_AUTO_TEST_SUITE(QS8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 7), - shape, policy, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_arithmetic_addition(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 7), - shape, policy, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_arithmetic_addition(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(QS16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 15), - shape, policy, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_arithmetic_addition(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 15), - shape, policy, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_arithmetic_addition(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(F16) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) -{ - // Compute function - CLTensor dst = compute_arithmetic_addition(shape, DataType::F16, DataType::F16, DataType::F16, ConvertPolicy::WRAP); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::F16, DataType::F16, DataType::F16, ConvertPolicy::WRAP); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(F32) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, policy) -{ - // Create tensors - CLTensor src1 = create_tensor(shape, DataType::F32); - CLTensor src2 = create_tensor(shape, DataType::F32); - CLTensor dst = create_tensor(shape, DataType::F32); - - validate_configuration(src1, src2, dst, shape, policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) -{ - // Compute function - CLTensor dst = compute_arithmetic_addition(shape, DataType::F32, DataType::F32, DataType::F32, ConvertPolicy::WRAP); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::F32, DataType::F32, DataType::F32, ConvertPolicy::WRAP); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, policy) -{ - // Compute function - CLTensor dst = compute_arithmetic_addition(shape, DataType::F32, DataType::F32, DataType::F32, policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::F32, DataType::F32, DataType::F32, policy); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/ArithmeticSubtraction.cpp b/tests/validation/CL/ArithmeticSubtraction.cpp deleted file mode 100644 index 086281cdda..0000000000 --- a/tests/validation/CL/ArithmeticSubtraction.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "tests/Globals.h" -#include "tests/Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLArithmeticSubtraction.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon arithmetic subtraction function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] policy Overflow policy of the operation. - * @param[in] fixed_point_position (Optional) Fixed point position that expresses the number of bits for the fractional part of the number when the tensor's data type is QS8 or QS16 (default = 0). - * - * @return Computed output tensor. - */ -CLTensor compute_arithmetic_subtraction(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy policy, int fixed_point_position = 0) -{ - // Create tensors - CLTensor src1 = create_tensor(shape, dt_in0, 1, fixed_point_position); - CLTensor src2 = create_tensor(shape, dt_in1, 1, fixed_point_position); - CLTensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); - - // Create and configure function - CLArithmeticSubtraction sub; - sub.configure(&src1, &src2, &dst, policy); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src1.info()->is_resizable()); - BOOST_TEST(!src2.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src1), 0); - library->fill_tensor_uniform(CLAccessor(src2), 1); - - // Compute function - sub.run(); - - return dst; -} - -void validate_configuration(const CLTensor &src1, const CLTensor &src2, CLTensor &dst, TensorShape shape, ConvertPolicy policy) -{ - BOOST_TEST(src1.info()->is_resizable()); - BOOST_TEST(src2.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - CLArithmeticSubtraction sub; - sub.configure(&src1, &src2, &dst, policy); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(ArithmeticSubtraction) - -BOOST_AUTO_TEST_SUITE(U8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, policy) -{ - // Create tensors - CLTensor src1 = create_tensor(shape, DataType::U8); - CLTensor src2 = create_tensor(shape, DataType::U8); - CLTensor dst = create_tensor(shape, DataType::U8); - - validate_configuration(src1, src2, dst, shape, policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, policy) -{ - // Compute function - CLTensor dst = compute_arithmetic_subtraction(shape, DataType::U8, DataType::U8, DataType::U8, policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::U8, DataType::U8, DataType::U8, policy); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(S16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, dt, policy) -{ - // Create tensors - CLTensor src1 = create_tensor(shape, dt); - CLTensor src2 = create_tensor(shape, DataType::S16); - CLTensor dst = create_tensor(shape, DataType::S16); - - validate_configuration(src1, src2, dst, shape, policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, dt, policy) -{ - // Compute function - CLTensor dst = compute_arithmetic_subtraction(shape, dt, DataType::S16, DataType::S16, policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, dt, DataType::S16, DataType::S16, policy); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, dt, policy) -{ - // Compute function - CLTensor dst = compute_arithmetic_subtraction(shape, dt, DataType::S16, DataType::S16, policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, dt, DataType::S16, DataType::S16, policy); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Quantized) -BOOST_AUTO_TEST_SUITE(QS8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 7), - shape, policy, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_arithmetic_subtraction(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 7), - shape, policy, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_arithmetic_subtraction(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(QS16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 15), - shape, policy, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_arithmetic_subtraction(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 15), - shape, policy, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_arithmetic_subtraction(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Float) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, policy) -{ - // Create tensors - CLTensor src1 = create_tensor(shape, DataType::F32); - CLTensor src2 = create_tensor(shape, DataType::F32); - CLTensor dst = create_tensor(shape, DataType::F32); - - validate_configuration(src1, src2, dst, shape, policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) -{ - // Compute function - CLTensor dst = compute_arithmetic_subtraction(shape, DataType::F32, DataType::F32, DataType::F32, ConvertPolicy::WRAP); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::F32, DataType::F32, DataType::F32, ConvertPolicy::WRAP); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, policy) -{ - // Compute function - CLTensor dst = compute_arithmetic_subtraction(shape, DataType::F32, DataType::F32, DataType::F32, policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::F32, DataType::F32, DataType::F32, policy); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/BatchNormalizationLayer.cpp b/tests/validation/CL/BatchNormalizationLayer.cpp deleted file mode 100644 index abcc619cb8..0000000000 --- a/tests/validation/CL/BatchNormalizationLayer.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "dataset/BatchNormalizationLayerDataset.h" -#include "tests/validation/Helpers.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLBatchNormalizationLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -const float tolerance_f = 1e-05; /**< Tolerance value for comparing reference's output against floating point implementation's output */ -const float tolerance_qs8 = 3; /**< Tolerance value for comparing reference's output against quantized implementation's output */ -const float tolerance_qs16 = 6; /**< Tolerance value for comparing reference's output against quantized implementation's output */ - -/** Compute Neon batch normalization function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt Data type of input and output tensors. - * @param[in] norm_info Normalization Layer information. - * - * @return Computed output tensor. - */ -CLTensor compute_reference_batch_normalization_layer(const TensorShape &shape0, const TensorShape &shape1, DataType dt, float epsilon, int fixed_point_position = 0) -{ - // Create tensors - CLTensor src = create_tensor(shape0, dt, 1, fixed_point_position); - CLTensor dst = create_tensor(shape0, dt, 1, fixed_point_position); - CLTensor mean = create_tensor(shape1, dt, 1, fixed_point_position); - CLTensor var = create_tensor(shape1, dt, 1, fixed_point_position); - CLTensor beta = create_tensor(shape1, dt, 1, fixed_point_position); - CLTensor gamma = create_tensor(shape1, dt, 1, fixed_point_position); - - // Create and configure function - CLBatchNormalizationLayer norm; - norm.configure(&src, &dst, &mean, &var, &beta, &gamma, epsilon); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - mean.allocator()->allocate(); - var.allocator()->allocate(); - beta.allocator()->allocate(); - gamma.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - BOOST_TEST(!mean.info()->is_resizable()); - BOOST_TEST(!var.info()->is_resizable()); - BOOST_TEST(!beta.info()->is_resizable()); - BOOST_TEST(!gamma.info()->is_resizable()); - - // Fill tensors - if(dt == DataType::F32) - { - float min_bound = 0.f; - float max_bound = 0.f; - std::tie(min_bound, max_bound) = get_batchnormalization_layer_test_bounds(); - std::uniform_real_distribution<> distribution(min_bound, max_bound); - std::uniform_real_distribution<> distribution_var(0, max_bound); - library->fill(CLAccessor(src), distribution, 0); - library->fill(CLAccessor(mean), distribution, 1); - library->fill(CLAccessor(var), distribution_var, 0); - library->fill(CLAccessor(beta), distribution, 3); - library->fill(CLAccessor(gamma), distribution, 4); - } - else - { - int min_bound = 0; - int max_bound = 0; - if(dt == DataType::QS8) - { - std::tie(min_bound, max_bound) = get_batchnormalization_layer_test_bounds(fixed_point_position); - } - else - { - std::tie(min_bound, max_bound) = get_batchnormalization_layer_test_bounds(fixed_point_position); - } - std::uniform_int_distribution<> distribution(min_bound, max_bound); - std::uniform_int_distribution<> distribution_var(0, max_bound); - library->fill(CLAccessor(src), distribution, 0); - library->fill(CLAccessor(mean), distribution, 1); - library->fill(CLAccessor(var), distribution_var, 0); - library->fill(CLAccessor(beta), distribution, 3); - library->fill(CLAccessor(gamma), distribution, 4); - } - - // Compute function - norm.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(BatchNormalizationLayer) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make({ DataType::QS8, DataType::QS16, DataType::F32 }), obj, dt) -{ - // Set fixed point position data type allowed - int fixed_point_position = (arm_compute::is_data_type_fixed_point(dt)) ? 3 : 0; - - // Create tensors - CLTensor src = create_tensor(obj.shape0, dt, 1, fixed_point_position); - CLTensor dst = create_tensor(obj.shape0, dt, 1, fixed_point_position); - CLTensor mean = create_tensor(obj.shape1, dt, 1, fixed_point_position); - CLTensor var = create_tensor(obj.shape1, dt, 1, fixed_point_position); - CLTensor beta = create_tensor(obj.shape1, dt, 1, fixed_point_position); - CLTensor gamma = create_tensor(obj.shape1, dt, 1, fixed_point_position); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - BOOST_TEST(mean.info()->is_resizable()); - BOOST_TEST(var.info()->is_resizable()); - BOOST_TEST(beta.info()->is_resizable()); - BOOST_TEST(gamma.info()->is_resizable()); - - // Create and configure function - CLBatchNormalizationLayer norm; - norm.configure(&src, &dst, &mean, &var, &beta, &gamma, obj.epsilon); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(obj.shape0); - const ValidRegion valid_region_vec = shape_to_valid_region(obj.shape1); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - validate(mean.info()->valid_region(), valid_region_vec); - validate(var.info()->valid_region(), valid_region_vec); - validate(beta.info()->valid_region(), valid_region_vec); - validate(gamma.info()->valid_region(), valid_region_vec); -} - -BOOST_AUTO_TEST_SUITE(Float) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(Random, - RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::F32), - obj, dt) -{ - // Compute function - CLTensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon); - - // Validate output - validate(CLAccessor(dst), ref_dst, tolerance_f, 0); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Quantized) - -BOOST_AUTO_TEST_SUITE(QS8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(Random, - RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::QS8) * boost::unit_test::data::xrange(1, 6), - obj, dt, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst, tolerance_qs8, 0); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(QS16) -BOOST_DATA_TEST_CASE(Random, - RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::QS16) * boost::unit_test::data::xrange(1, 14), - obj, dt, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst, tolerance_qs16, 0); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/BitwiseAnd.cpp b/tests/validation/CL/BitwiseAnd.cpp new file mode 100644 index 0000000000..3e458a4c9b --- /dev/null +++ b/tests/validation/CL/BitwiseAnd.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/functions/CLBitwiseAnd.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/BitwiseAndFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(CL) +TEST_SUITE(BitwiseAnd) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) +{ + // Create tensors + CLTensor src1 = create_tensor(shape, data_type); + CLTensor src2 = create_tensor(shape, data_type); + CLTensor dst = create_tensor(shape, data_type); + + ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + CLBitwiseAnd bitwise_and; + bitwise_and.configure(&src1, &src2, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src1.info()->valid_region(), valid_region); + validate(src2.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src1.info()->padding(), padding); + validate(src2.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using CLBitwiseAndFixture = BitwiseAndValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, CLBitwiseAndFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLBitwiseAndFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/BitwiseNot.cpp b/tests/validation/CL/BitwiseNot.cpp new file mode 100644 index 0000000000..376bde9c78 --- /dev/null +++ b/tests/validation/CL/BitwiseNot.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/functions/CLBitwiseNot.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/BitwiseNotFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(CL) +TEST_SUITE(BitwiseNot) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) +{ + // Create tensors + CLTensor src = create_tensor(shape, data_type); + CLTensor dst = create_tensor(shape, data_type); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + CLBitwiseNot bitwise_not; + bitwise_not.configure(&src, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using CLBitwiseNotFixture = BitwiseNotValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, CLBitwiseNotFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLBitwiseNotFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/BitwiseOr.cpp b/tests/validation/CL/BitwiseOr.cpp new file mode 100644 index 0000000000..ecff0be6c0 --- /dev/null +++ b/tests/validation/CL/BitwiseOr.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/functions/CLBitwiseOr.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/BitwiseOrFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(CL) +TEST_SUITE(BitwiseOr) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) +{ + // Create tensors + CLTensor src1 = create_tensor(shape, data_type); + CLTensor src2 = create_tensor(shape, data_type); + CLTensor dst = create_tensor(shape, data_type); + + ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + CLBitwiseOr bitwise_or; + bitwise_or.configure(&src1, &src2, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src1.info()->valid_region(), valid_region); + validate(src2.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src1.info()->padding(), padding); + validate(src2.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using CLBitwiseOrFixture = BitwiseOrValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, CLBitwiseOrFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLBitwiseOrFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/BitwiseXor.cpp b/tests/validation/CL/BitwiseXor.cpp new file mode 100644 index 0000000000..3104894c29 --- /dev/null +++ b/tests/validation/CL/BitwiseXor.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/functions/CLBitwiseXor.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/BitwiseXorFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(CL) +TEST_SUITE(BitwiseXor) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) +{ + // Create tensors + CLTensor src1 = create_tensor(shape, data_type); + CLTensor src2 = create_tensor(shape, data_type); + CLTensor dst = create_tensor(shape, data_type); + + ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + CLBitwiseXor bitwise_xor; + bitwise_xor.configure(&src1, &src2, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src1.info()->valid_region(), valid_region); + validate(src2.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src1.info()->padding(), padding); + validate(src2.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using CLBitwiseXorFixture = BitwiseXorValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, CLBitwiseXorFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLBitwiseXorFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/Box3x3.cpp b/tests/validation/CL/Box3x3.cpp deleted file mode 100644 index f2df5e6511..0000000000 --- a/tests/validation/CL/Box3x3.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLBox3x3.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -constexpr unsigned int filter_size = 3; /** Size of the kernel/filter in number of elements. */ -constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ - -/** Compute CL box3x3 filter. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor. - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. - * - * @return Computed output tensor. - */ -CLTensor compute_box3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst = create_tensor(shape, DataType::U8); - - // Create and configure function - CLBox3x3 box3x3; - box3x3.configure(&src, &dst, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src), 0); - - // Compute function - box3x3.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(Box3x3) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst = create_tensor(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - CLBox3x3 box3x3; - box3x3.configure(&src, &dst, border_mode); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(shape); - const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - validate(src.info()->valid_region(), src_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 8); - calculator.set_border_size(1); - calculator.set_border_mode(border_mode); - - const PaddingSize dst_padding = calculator.required_padding(); - - calculator.set_accessed_elements(16); - calculator.set_access_offset(-1); - - const PaddingSize src_padding = calculator.required_padding(); - - validate(src.info()->padding(), src_padding); - validate(dst.info()->padding(), dst_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - CLTensor dst = compute_box3x3(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_box3x3(shape, border_mode, border_value); - - // Validate output - validate(CLAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - CLTensor dst = compute_box3x3(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_box3x3(shape, border_mode, border_value); - - // Validate output - validate(CLAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/CLFixture.cpp b/tests/validation/CL/CLFixture.cpp deleted file mode 100644 index 38e52c31f6..0000000000 --- a/tests/validation/CL/CLFixture.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "validation/CL/CLFixture.h" - -#include "boost_wrapper.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -BOOST_GLOBAL_FIXTURE(CLFixture); diff --git a/tests/validation/CL/CLFixture.h b/tests/validation/CL/CLFixture.h deleted file mode 100644 index 77538be8f4..0000000000 --- a/tests/validation/CL/CLFixture.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_VALIDATION_CL_CLFIXTURE_H__ -#define __ARM_COMPUTE_TEST_VALIDATION_CL_CLFIXTURE_H__ - -#include "arm_compute/runtime/CL/CLScheduler.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -struct CLFixture -{ - CLFixture() - { - CLScheduler::get().default_init(); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_VALIDATION_CL_CLFIXTURE_H__ */ diff --git a/tests/validation/CL/CMakeLists.txt b/tests/validation/CL/CMakeLists.txt deleted file mode 100644 index f4477f621f..0000000000 --- a/tests/validation/CL/CMakeLists.txt +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright (c) 2017 ARM Limited. -# -# SPDX-License-Identifier: MIT -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -cmake_minimum_required (VERSION 3.1) - -include_directories(${CMAKE_SOURCE_DIR}/../include) - -set(arm_compute_test_validation_OPENCL_SOURCE_FILES - ${CMAKE_SOURCE_DIR}/CL/CLAccessor.h - ${CMAKE_CURRENT_SOURCE_DIR}/CLFixture.h - ${CMAKE_CURRENT_SOURCE_DIR}/CLFixture.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ActivationLayer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/BitwiseAnd.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Box3x3.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ConvolutionLayer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/DepthConvert.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FillBorder.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FixedPoint/FixedPoint_QS8.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FullyConnectedLayer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Gaussian3x3.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Gaussian5x5.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/GEMM.cpp -` ${CMAKE_CURRENT_SOURCE_DIR}/IntegralImage.cpp -` ${CMAKE_CURRENT_SOURCE_DIR}/NonLinearFilter.cpp -` ${CMAKE_CURRENT_SOURCE_DIR}/PoolingLayer.cpp -` ${CMAKE_CURRENT_SOURCE_DIR}/ROIPoolingLayer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Sobel3x3.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Sobel5x5.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/SoftmaxLayer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Threshold.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/DirectConvolutionLayer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/MeanStdDev.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/HarrisCorners.cpp -) - -add_library(arm_compute_test_validation_OPENCL OBJECT - ${arm_compute_test_validation_OPENCL_SOURCE_FILES} -) - -set(arm_compute_test_validation_TARGET_OBJECTS - ${arm_compute_test_validation_TARGET_OBJECTS} - $ - PARENT_SCOPE -) - -set(arm_compute_test_validation_TARGET_LIBRARIES - ${arm_compute_test_validation_TARGET_LIBRARIES} - OpenCL - PARENT_SCOPE -) diff --git a/tests/validation/CL/ConvolutionLayer.cpp b/tests/validation/CL/ConvolutionLayer.cpp new file mode 100644 index 0000000000..d7123842e9 --- /dev/null +++ b/tests/validation/CL/ConvolutionLayer.cpp @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/LargeConvolutionLayerDataset.h" +#include "tests/datasets/SmallConvolutionLayerDataset.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/ConvolutionLayerFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ +constexpr AbsoluteTolerance tolerance_f16(0.1f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F16 */ +constexpr AbsoluteTolerance tolerance_q(1.0f); /**< Tolerance value for comparing reference's output against implementation's output for fixed point data types */ + +/** CNN data types */ +const auto CNNDataTypes = framework::dataset::make("DataType", +{ + DataType::F16, + DataType::F32, + DataType::QS8, + DataType::QS16, +}); +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(ConvolutionLayer) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallConvolutionLayerDataset(), datasets::LargeConvolutionLayerDataset()), CNNDataTypes), + input_shape, weights_shape, bias_shape, output_shape, info, data_type) +{ + // Set fixed point position data type allowed + int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; + + // Create tensors + CLTensor src = create_tensor(input_shape, data_type, 1, fixed_point_position); + CLTensor weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); + CLTensor bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); + CLTensor dst = create_tensor(output_shape, data_type, 1, fixed_point_position); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + CLConvolutionLayer conv; + conv.configure(&src, &weights, &bias, &dst, info); + + // Validate valid region + const ValidRegion src_valid_region = shape_to_valid_region(input_shape); + const ValidRegion weights_valid_region = shape_to_valid_region(weights_shape); + const ValidRegion bias_valid_region = shape_to_valid_region(bias_shape); + const ValidRegion dst_valid_region = shape_to_valid_region(output_shape); + + validate(src.info()->valid_region(), src_valid_region); + validate(weights.info()->valid_region(), weights_valid_region); + validate(bias.info()->valid_region(), bias_valid_region); + validate(dst.info()->valid_region(), dst_valid_region); + + // Validate padding + //TODO(COMPMID-415) Need to validate padding? +} + +template +using CLConvolutionLayerFixture = ConvolutionValidationFixture; + +TEST_SUITE(Float) +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallConvolutionLayerDataset(), + framework::dataset::make("DataType", + DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeConvolutionLayerDataset(), + framework::dataset::make("DataType", + DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f16); +} +TEST_SUITE_END() + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallConvolutionLayerDataset(), framework::dataset::make("DataType", + DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeConvolutionLayerDataset(), framework::dataset::make("DataType", + DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() +TEST_SUITE_END() + +template +using CLConvolutionLayerFixedPointFixture = ConvolutionValidationFixedPointFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +// We test for fixed point precision [4,6] +FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallConvolutionLayerDataset(), + framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 4, 7))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_q); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeConvolutionLayerDataset(), + framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 4, 7))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_q); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +// Testing for fixed point position [1,14) +FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallConvolutionLayerDataset(), + framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_q); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeConvolutionLayerDataset(), + framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_q); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/DepthConcatenateLayer.cpp b/tests/validation/CL/DepthConcatenateLayer.cpp new file mode 100644 index 0000000000..a8ef1c37c7 --- /dev/null +++ b/tests/validation/CL/DepthConcatenateLayer.cpp @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLDepthConcatenate.h" +#include "tests/CL/CLAccessor.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/DepthConcatenateLayerFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(CL) +TEST_SUITE(DepthConcatenateLayer) + +//TODO(COMPMID-415): Add configuration test? + +template +using CLDepthConcatenateLayerFixture = DepthConcatenateValidationFixture; + +TEST_SUITE(Float) +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", + DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", + DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +TEST_SUITE_END() + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", + DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", + DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), + framework::dataset::make("DataType", + DataType::QS8))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), + framework::dataset::make("DataType", + DataType::QS8))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), + framework::dataset::make("DataType", + DataType::QS16))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), + framework::dataset::make("DataType", + DataType::QS16))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/DepthConvert.cpp b/tests/validation/CL/DepthConvert.cpp deleted file mode 100644 index 57a21e89c7..0000000000 --- a/tests/validation/CL/DepthConvert.cpp +++ /dev/null @@ -1,495 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLDepthConvert.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute CL depth convert function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in Data type of input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] policy Conversion policy. - * @param[in] shift Value for down/up conversions. Must be 0 <= shift < 8. - * - * @return Computed output CLtensor. - */ -CLTensor compute_depth_convert(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, uint32_t shift, uint32_t fixed_point_position = 0) -{ - // Create tensors - CLTensor src = create_tensor(shape, dt_in, 1, fixed_point_position); - CLTensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); - - // Create and configure function - CLDepthConvert depth_convert; - depth_convert.configure(&src, &dst, policy, shift); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src), 0); - - // Compute function - depth_convert.run(); - - return dst; -} -/** Configure and validate region/padding function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in Data type of input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] policy Conversion policy. - * @param[in] shift Value for down/up conversions. Must be 0 <= shift < 8. - * @param[in] fixed_point_position Fixed point position. - * - */ -void compute_configure_validate(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, uint32_t shift, uint32_t fixed_point_position = 0) -{ - // Create tensors - CLTensor src = create_tensor(shape, dt_in, 1, fixed_point_position); - CLTensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - CLDepthConvert depth_convert; - depth_convert.configure(&src, &dst, policy, shift); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(DepthConvert) - -BOOST_AUTO_TEST_SUITE(U8_to_U16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::U8, DataType::U16, policy, shift); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, DataType::U8, DataType::U16, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::U16, policy, shift, 0); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, DataType::U8, DataType::U16, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::U16, policy, shift, 0); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(U8_to_S16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::U8, DataType::S16, policy, shift); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, DataType::U8, DataType::S16, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S16, policy, shift, 0); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, DataType::U8, DataType::S16, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S16, policy, shift, 0); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(U8_to_S32) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::U8, DataType::S32, policy, shift); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, DataType::U8, DataType::S32, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S32, policy, shift, 0); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, DataType::U8, DataType::S32, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S32, policy, shift, 0); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(U16_to_U8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::U16, DataType::U8, policy, shift); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, DataType::U16, DataType::U8, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U8, policy, shift, 0); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, DataType::U16, DataType::U8, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U8, policy, shift, 0); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(U16_to_U32) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::U16, DataType::U32, policy, shift); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, DataType::U16, DataType::U32, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U32, policy, shift, 0); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, DataType::U16, DataType::U32, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U32, policy, shift, 0); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(S16_to_U8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::S16, DataType::U8, policy, shift); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, DataType::S16, DataType::U8, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::U8, policy, shift, 0); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, DataType::S16, DataType::U8, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::U8, policy, shift, 0); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(S16_to_S32) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::S16, DataType::S32, policy, shift); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, DataType::S16, DataType::S32, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::S32, policy, shift, 0); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, DataType::S16, DataType::S32, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::S32, policy, shift, 0); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Quantized_to_F32) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::QS8, DataType::QS16 }) - * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) * boost::unit_test::data::xrange(1, 7, 1), - shape, dt, policy, fixed_point_position) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, dt, DataType::F32, policy, 0, fixed_point_position); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * boost::unit_test::data::make({ DataType::QS8, DataType::QS16 }) * boost::unit_test::data::xrange(1, 7, 1), - shape, policy, dt, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, dt, DataType::F32, policy, 0, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, dt, DataType::F32, policy, 0, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::QS8, DataType::QS16 }) - * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) * boost::unit_test::data::xrange(1, 7, 1), - shape, dt, policy, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, dt, DataType::F32, policy, 0, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, dt, DataType::F32, policy, 0, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(F32_to_Quantized) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::QS8, DataType::QS16 }) - * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) * boost::unit_test::data::xrange(1, 7, 1), - shape, dt, policy, fixed_point_position) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::F32, dt, policy, 0, fixed_point_position); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::QS8, DataType::QS16 }) - * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) * boost::unit_test::data::xrange(1, 7, 1), - shape, dt, policy, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, DataType::F32, dt, policy, 0, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::F32, dt, policy, 0, fixed_point_position, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::QS8, DataType::QS16 }) - * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) * boost::unit_test::data::xrange(1, 7, 1), - shape, dt, policy, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_depth_convert(shape, DataType::F32, dt, policy, 0, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::F32, dt, policy, 0, fixed_point_position, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/DepthwiseConvolution.cpp b/tests/validation/CL/DepthwiseConvolution.cpp new file mode 100644 index 0000000000..ccee9607d3 --- /dev/null +++ b/tests/validation/CL/DepthwiseConvolution.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLDepthwiseConvolution.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/LargeDepthwiseConvolutionDataset.h" +#include "tests/datasets/SmallDepthwiseConvolutionDataset.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/DepthwiseConvolutionFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(DepthwiseConvolution) + +template +using CLDepthwiseConvolutionFixture = DepthwiseConvolutionValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionFixture, framework::DatasetMode::PRECOMMIT, datasets::SmallDepthwiseConvolutionDataset()) +{ + validate(CLAccessor(_target), _reference, tolerance_f32); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionFixture, framework::DatasetMode::NIGHTLY, datasets::LargeDepthwiseConvolutionDataset()) +{ + validate(CLAccessor(_target), _reference, tolerance_f32); +} + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/DepthwiseSeparableConvolutionLayer.cpp b/tests/validation/CL/DepthwiseSeparableConvolutionLayer.cpp new file mode 100644 index 0000000000..4fac9b2d0d --- /dev/null +++ b/tests/validation/CL/DepthwiseSeparableConvolutionLayer.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLDepthwiseSeparableConvolutionLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/MobileNetDepthwiseSeparableConvolutionLayerDataset.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/DepthwiseSeparableConvolutionLayerFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(DepthwiseSeparableConvolutionLayer) + +// Configuration test to do + +template +using CLDepthwiseSeparableConvolutionLayerFixture = DepthwiseSeparableConvolutionValidationFixture; +FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseSeparableConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, datasets::MobileNetDepthwiseSeparableConvolutionLayerDataset()) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/DirectConvolutionLayer.cpp b/tests/validation/CL/DirectConvolutionLayer.cpp new file mode 100644 index 0000000000..d2d2cd1419 --- /dev/null +++ b/tests/validation/CL/DirectConvolutionLayer.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLDirectConvolutionLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/DirectConvolutionLayerFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +constexpr AbsoluteTolerance tolerance_fp16(0.1f); /**< Tolerance for floating point tests */ +constexpr AbsoluteTolerance tolerance_fp32(0.001f); /**< Tolerance for floating point tests */ + +constexpr AbsoluteTolerance tolerance_qs8(0); /**< Tolerance for fixed point tests */ +constexpr AbsoluteTolerance tolerance_qs16(0); /**< Tolerance for fixed point tests */ + +/** Direct convolution data set. */ +const auto data_quantized = combine(datasets::SmallDirectConvolutionShapes(), + combine(framework::dataset::make("StrideX", 1, 3), + combine(framework::dataset::make("StrideY", 1, 3), + combine(concat(combine(framework::dataset::make("PadX", 0), + combine(framework::dataset::make("PadY", 0), + framework::dataset::make("KernelSize", 1))), + combine(framework::dataset::make("PadX", 0, 2), + combine(framework::dataset::make("PadY", 0, 2), + framework::dataset::make("KernelSize", { 3 })))), + framework::dataset::make("NumKernels", { 1, 4, 8, 16 }))))); + +const auto data = combine(datasets::SmallDirectConvolutionShapes(), + combine(framework::dataset::make("StrideX", 1, 3), + combine(framework::dataset::make("StrideY", 1, 3), + combine(concat(combine(framework::dataset::make("PadX", 0), + combine(framework::dataset::make("PadY", 0), + framework::dataset::make("KernelSize", 1))), + combine(framework::dataset::make("PadX", 0, 2), + combine(framework::dataset::make("PadY", 0, 2), + framework::dataset::make("KernelSize", { 3, 5 })))), + framework::dataset::make("NumKernels", { 1, 4, 8, 16 }))))); +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(DirectConvolutionLayer) + +//TODO(COMPMID-415): Configuration tests? + +template +using CLDirectConvolutionLayerFixture = DirectConvolutionValidationFixture; + +TEST_SUITE(Float) +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionLayerFixture, framework::DatasetMode::ALL, combine(data, framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_fp16); +} +TEST_SUITE_END() + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionLayerFixture, framework::DatasetMode::ALL, combine(data, framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_fp32); +} +TEST_SUITE_END() +TEST_SUITE_END() + +template +using CLDirectConvolutionLayerFixedPointFixture = DirectConvolutionValidationFixedPointFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(data_quantized, framework::dataset::make("DataType", DataType::QS8)), + framework::dataset::make("FractionalBits", 2, 7))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_qs8); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(data_quantized, framework::dataset::make("DataType", DataType::QS16)), + framework::dataset::make("FractionalBits", 2, 15))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_qs16); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/FillBorder.cpp b/tests/validation/CL/FillBorder.cpp deleted file mode 100644 index dc522c5c3b..0000000000 --- a/tests/validation/CL/FillBorder.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Validation.h" - -#include "arm_compute/core/CL/kernels/CLFillBorderKernel.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(FillBorder, BorderModes() * boost::unit_test::data::make({ PaddingSize{ 0 }, PaddingSize{ 1, 0, 1, 2 }, PaddingSize{ 10 } }), border_mode, padding) -{ - constexpr uint8_t border_value = 42U; - constexpr uint8_t tensor_value = 89U; - BorderSize border_size{ 5 }; - - // Create tensors - CLTensor src = create_tensor(TensorShape{ 10U, 10U, 2U }, DataType::U8); - - src.info()->extend_padding(padding); - - // Allocate tensor - src.allocator()->allocate(); - - // Check padding is as required - validate(src.info()->padding(), padding); - - // Fill tensor with constant value - std::uniform_int_distribution distribution{ tensor_value, tensor_value }; - library->fill(CLAccessor(src), distribution, 0); - - // Create and configure kernel - CLFillBorderKernel fill_border; - fill_border.configure(&src, border_size, border_mode, border_value); - - // Run kernel - fill_border.run(fill_border.window(), CLScheduler::get().queue()); - - // Validate border - border_size.limit(padding); - validate(CLAccessor(src), border_size, border_mode, &border_value); - - // Validate tensor - validate(CLAccessor(src), &tensor_value); -} - -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/FixedPoint/FixedPoint_QS8.cpp b/tests/validation/CL/FixedPoint/FixedPoint_QS8.cpp deleted file mode 100644 index d4ccc2ba2b..0000000000 --- a/tests/validation/CL/FixedPoint/FixedPoint_QS8.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/CL/CLKernelLibrary.h" -#include "arm_compute/core/CL/ICLKernel.h" -#include "arm_compute/core/CL/OpenCL.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/core/Window.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/CL/CLSubTensor.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" - -#include "arm_compute/core/CL/ICLTensor.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -const float tolerance_exp = 1.0f; /**< Tolerance value for comparing reference's output against implementation's output (exponential)*/ -const float tolerance_invsqrt = 4.0f; /**< Tolerance value for comparing reference's output against implementation's output (inverse square-root) */ -const float tolerance_log = 5.0f; /**< Tolerance value for comparing reference's output against implementation's output (logarithm) */ - -/** Compute Neon fixed point operation for signed 8bit fixed point. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -CLTensor compute_fixed_point_op(const TensorShape &shape, int fixed_point_position, FixedPointOp op) -{ - std::string fixed_point_operation_kernel; -#ifndef EMBEDDED_KERNELS - fixed_point_operation_kernel += "#include \"fixed_point.h\"\n"; -#endif /* EMBEDDED_KERNELS */ - fixed_point_operation_kernel += - "__kernel void fixed_point_operation_qs8( \n" - " __global char* src, \n" - " __global char* dst) \n" - "{ \n" - " char16 in = vload16(0, src + get_global_id(0) * 16); \n" - " if(FIXED_POINT_OP == 0) \n" - " { \n" - " vstore16(EXP_OP_EXPAND(in, DATA_TYPE, 16, FIXED_POINT_POS), 0, dst + get_global_id(0) * 16); \n" - " } \n" - " else if(FIXED_POINT_OP == 1) \n" - " { \n" - " vstore16(INVSQRT_OP_EXPAND(in, DATA_TYPE, 16, FIXED_POINT_POS), 0, dst + get_global_id(0) * 16); \n" - " } \n" - " else \n" - " { \n" - " vstore16(LOG_OP_EXPAND(in, DATA_TYPE, 16, FIXED_POINT_POS), 0, dst + get_global_id(0) * 16); \n" - " } \n" - "} \n" - "\n"; - - // Create tensors - CLTensor src = create_tensor(shape, DataType::QS8, 1, fixed_point_position); - CLTensor dst = create_tensor(shape, DataType::QS8, 1, fixed_point_position); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Set build options - std::string build_opts = "-DFIXED_POINT_POS=" + support::cpp11::to_string(fixed_point_position); - build_opts += " -DDATA_TYPE=qs8"; - - // Fill tensors. - int min = 0; - int max = 0; - switch(op) - { - case FixedPointOp::EXP: - min = -(1 << (fixed_point_position - 1)); - max = (1 << (fixed_point_position - 1)); - build_opts += " -DFIXED_POINT_OP=0"; - break; - case FixedPointOp::INV_SQRT: - min = 1; - max = 0x7F; - build_opts += " -DFIXED_POINT_OP=1"; - break; - case FixedPointOp::LOG: - min = (1 << (fixed_point_position - 1)); - max = 0x3F; - build_opts += " -DFIXED_POINT_OP=2"; - break; - default: - ARM_COMPUTE_ERROR("Operation not supported"); - } - - std::uniform_int_distribution<> distribution(min, max); - library->fill(CLAccessor(src), distribution, 0); - - std::vector sources; - -#ifndef EMBEDDED_KERNELS - build_opts += " -I" + CLKernelLibrary::get().get_kernel_path(); -#else /* EMBEDDED_KERNELS */ - sources.push_back(CLKernelLibrary::get().get_program_source("fixed_point.h")); -#endif /* EMBEDDED_KERNELS */ - - sources.push_back(fixed_point_operation_kernel); - - // Create program - ::cl::Program program(sources); - - // Build program - program.build(build_opts.c_str()); - - ::cl::Kernel kernel(program, "fixed_point_operation_qs8", nullptr); - - unsigned int idx = 0; - kernel.setArg(idx++, src.cl_buffer()); - kernel.setArg(idx++, dst.cl_buffer()); - - ::cl::NDRange gws(shape[0] / 16, 1, 1); - CLScheduler::get().queue().enqueueNDRangeKernel(kernel, 0, gws); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(FixedPoint) -BOOST_AUTO_TEST_SUITE(QS8) - -BOOST_AUTO_TEST_SUITE(Exp) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(1, 6), shape, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_fixed_point_op(shape, fixed_point_position, FixedPointOp::EXP); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS8, DataType::QS8, FixedPointOp::EXP, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst, tolerance_exp); -} - -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Log) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(3, 6), shape, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_fixed_point_op(shape, fixed_point_position, FixedPointOp::LOG); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS8, DataType::QS8, FixedPointOp::LOG, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst, tolerance_log); -} - -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Invsqrt) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(1, 6), shape, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_fixed_point_op(shape, fixed_point_position, FixedPointOp::INV_SQRT); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS8, DataType::QS8, FixedPointOp::INV_SQRT, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst, tolerance_invsqrt); -} - -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/Floor.cpp b/tests/validation/CL/Floor.cpp new file mode 100644 index 0000000000..81495e8337 --- /dev/null +++ b/tests/validation/CL/Floor.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLFloor.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/FloorFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(CL) +TEST_SUITE(Floor) + +template +using CLFloorFixture = FloorValidationFixture; + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, CLFloorFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLFloorFixture, framework::DatasetMode::NIGHTLY, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference); +} +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/FullyConnectedLayer.cpp b/tests/validation/CL/FullyConnectedLayer.cpp new file mode 100644 index 0000000000..7a8734b5a3 --- /dev/null +++ b/tests/validation/CL/FullyConnectedLayer.cpp @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/FullyConnectedLayerDataset.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/FullyConnectedLayerFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Tolerance for float operations */ +constexpr AbsoluteTolerance tolerance_f32(0.001f); +constexpr AbsoluteTolerance tolerance_f16(0.4f); +/** Tolerance for fixed point operations */ +constexpr AbsoluteTolerance tolerance_fixed_point(1.f); + +/** CNN data types */ +const auto CNNDataTypes = framework::dataset::make("DataType", +{ + DataType::F16, + DataType::F32, + DataType::QS8, + DataType::QS16, +}); + +const auto FullyConnectedParameters = combine(framework::dataset::make("TransposeWeights", { false, true }), framework::dataset::make("ReshapeWeights", { false, true })); +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(FullyConnectedLayer) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(framework::dataset::concat(datasets::SmallFullyConnectedLayerDataset(), datasets::LargeFullyConnectedLayerDataset()), + FullyConnectedParameters), + CNNDataTypes), + src_shape, weights_shape, bias_shape, dst_shape, transpose_weights, reshape_weights, data_type) +{ + // Set fixed point position data type allowed + int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; + + TensorShape ws(weights_shape); + + // Transpose weights if not done in the function + if(!reshape_weights || !transpose_weights) + { + const size_t shape_x = ws.x(); + ws.set(0, ws.y()); + ws.set(1, shape_x); + } + + // Create tensors + CLTensor src = create_tensor(src_shape, data_type, 1, fixed_point_position); + CLTensor weights = create_tensor(ws, data_type, 1, fixed_point_position); + CLTensor bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); + CLTensor dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function. + CLFullyConnectedLayer fc; + fc.configure(&src, &weights, &bias, &dst, transpose_weights, !reshape_weights); + + // Validate valid region + const ValidRegion dst_valid_region = shape_to_valid_region(dst_shape); + validate(dst.info()->valid_region(), dst_valid_region); +} + +template +using CLFullyConnectedLayerFixture = FullyConnectedLayerValidationFixture; + +TEST_SUITE(Float) +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLFullyConnectedLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallFullyConnectedLayerDataset(), + FullyConnectedParameters), + framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeFullyConnectedLayerDataset(), + FullyConnectedParameters), + framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f16); +} +TEST_SUITE_END() + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, CLFullyConnectedLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallFullyConnectedLayerDataset(), FullyConnectedParameters), + framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeFullyConnectedLayerDataset(), FullyConnectedParameters), + framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() +TEST_SUITE_END() + +template +using CLFullyConnectedLayerFixedPointFixture = FullyConnectedLayerValidationFixedPointFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 +FIXTURE_DATA_TEST_CASE(RunSmall, CLFullyConnectedLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallFullyConnectedLayerDataset(), + FullyConnectedParameters), + framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 1, 6))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_fixed_point); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLFullyConnectedLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeFullyConnectedLayerDataset(), + FullyConnectedParameters), + framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 1, 6))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_fixed_point); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 +FIXTURE_DATA_TEST_CASE(RunSmall, CLFullyConnectedLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallFullyConnectedLayerDataset(), + FullyConnectedParameters), + framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_fixed_point); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLFullyConnectedLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeFullyConnectedLayerDataset(), + FullyConnectedParameters), + framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_fixed_point); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/GEMM.cpp b/tests/validation/CL/GEMM.cpp new file mode 100644 index 0000000000..6b2b2b41b1 --- /dev/null +++ b/tests/validation/CL/GEMM.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLGEMM.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/LargeGEMMDataset.h" +#include "tests/datasets/SmallGEMMDataset.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/GEMMFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for floating point data types */ +constexpr AbsoluteTolerance tolerance_f16(0.1f); /**< Tolerance value for comparing reference's output against implementation's output for floating point data types */ +constexpr AbsoluteTolerance tolerance_q(1.0f); /**< Tolerance value for comparing reference's output against implementation's output for fixed point data types */ + +/** CNN data types */ +const auto CNNDataTypes = framework::dataset::make("DataType", +{ + DataType::F16, + DataType::F32, + DataType::QS8, + DataType::QS16, +}); +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(GEMM) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallGEMMDataset(), datasets::LargeGEMMDataset()), CNNDataTypes), + shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type) +{ + // Set fixed point position data type allowed + const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; + + // Create tensors + CLTensor a = create_tensor(shape_a, data_type, 1, fixed_point_position); + CLTensor b = create_tensor(shape_b, data_type, 1, fixed_point_position); + CLTensor c = create_tensor(shape_c, data_type, 1, fixed_point_position); + CLTensor dst = create_tensor(output_shape, data_type, 1, fixed_point_position); + + ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(c.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + CLGEMM gemm; + gemm.configure(&a, &b, &c, &dst, alpha, beta); + + //TODO(COMPMID-415): Validate valid region +} + +template +using CLGEMMFixture = GEMMValidationFixture; + +TEST_SUITE(Float) +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallGEMMDataset(), framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMDataset(), framework::dataset::make("DataType", + DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f16); +} +TEST_SUITE_END() + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallGEMMDataset(), framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMDataset(), framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() +TEST_SUITE_END() + +template +using CLGEMMFixedPointFixture = GEMMValidationFixedPointFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(), + framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 1, 7))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_q); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeGEMMDataset(), + framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 1, 7))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_q); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(), + framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_q); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeGEMMDataset(), + framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_q); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/Gaussian3x3.cpp b/tests/validation/CL/Gaussian3x3.cpp deleted file mode 100644 index 2ef077c005..0000000000 --- a/tests/validation/CL/Gaussian3x3.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLGaussian3x3.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -constexpr unsigned int filter_size = 3; /** Size of the kernel/filter in number of elements. */ -constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ - -/** Compute CL gaussian3x3 filter. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor. - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. - * - * @return Computed output tensor. - */ -CLTensor compute_gaussian3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst = create_tensor(shape, DataType::U8); - - // Create and configure function - CLGaussian3x3 gaussian3x3; - gaussian3x3.configure(&src, &dst, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src), 0); - - // Compute function - gaussian3x3.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(Gaussian3x3) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst = create_tensor(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - CLGaussian3x3 gaussian3x3; - gaussian3x3.configure(&src, &dst, border_mode); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(shape); - const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - validate(src.info()->valid_region(), src_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 8); - calculator.set_border_size(1); - calculator.set_border_mode(border_mode); - - const PaddingSize dst_padding = calculator.required_padding(); - - calculator.set_accessed_elements(16); - calculator.set_access_offset(-1); - - const PaddingSize src_padding = calculator.required_padding(); - - validate(src.info()->padding(), src_padding); - validate(dst.info()->padding(), dst_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - CLTensor dst = compute_gaussian3x3(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gaussian3x3(shape, border_mode, border_value); - - // Validate output - validate(CLAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - CLTensor dst = compute_gaussian3x3(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gaussian3x3(shape, border_mode, border_value); - - // Validate output - validate(CLAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/Gaussian5x5.cpp b/tests/validation/CL/Gaussian5x5.cpp deleted file mode 100644 index fb21ed06af..0000000000 --- a/tests/validation/CL/Gaussian5x5.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLGaussian5x5.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -constexpr unsigned int filter_size = 5; /** Size of the kernel/filter in number of elements. */ -constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ - -/** Compute CL gaussian5x5 filter. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor. - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. - * - * @return Computed output tensor. - */ -CLTensor compute_gaussian5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst = create_tensor(shape, DataType::U8); - - // Create and configure function - CLGaussian5x5 gaussian5x5; - gaussian5x5.configure(&src, &dst, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src), 0); - - // Compute function - gaussian5x5.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(Gaussian5x5) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst = create_tensor(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - CLGaussian5x5 gaussian5x5; - gaussian5x5.configure(&src, &dst, border_mode); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(shape); - const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - validate(src.info()->valid_region(), src_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 8); - calculator.set_border_size(2); - calculator.set_border_mode(border_mode); - - const PaddingSize dst_padding = calculator.required_padding(); - - calculator.set_accessed_elements(16); - calculator.set_access_offset(-2); - - const PaddingSize src_padding = calculator.required_padding(); - - validate(src.info()->padding(), src_padding); - validate(dst.info()->padding(), dst_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - CLTensor dst = compute_gaussian5x5(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gaussian5x5(shape, border_mode, border_value); - - // Validate output - validate(CLAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - CLTensor dst = compute_gaussian5x5(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gaussian5x5(shape, border_mode, border_value); - - // Validate output - validate(CLAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/HarrisCorners.cpp b/tests/validation/CL/HarrisCorners.cpp deleted file mode 100644 index 6370c4d972..0000000000 --- a/tests/validation/CL/HarrisCorners.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLArray.h" -#include "arm_compute/runtime/CL/functions/CLHarrisCorners.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "PaddingCalculator.h" -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute CL Harris corners function. - * - * @param[in] shape Shape of input tensor - * @param[in] threshold Minimum threshold with which to eliminate Harris Corner scores (computed using the normalized Sobel kernel). - * @param[in] min_dist Radial Euclidean distance for the euclidean distance stage - * @param[in] sensitivity Sensitivity threshold k from the Harris-Stephens equation - * @param[in] gradient_size The gradient window size to use on the input. The implementation supports 3, 5, and 7 - * @param[in] block_size The block window size used to compute the Harris Corner score. The implementation supports 3, 5, and 7. - * @param[in] border_mode Border mode to use - * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. - * - * @return Computed corners' keypoints. - */ -void compute_harris_corners(const TensorShape &shape, CLKeyPointArray &corners, float threshold, float min_dist, float sensitivity, - int32_t gradient_size, int32_t block_size, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - src.info()->set_format(Format::U8); - - // Create harris corners configure function - CLHarrisCorners harris_corners; - harris_corners.configure(&src, threshold, min_dist, sensitivity, gradient_size, block_size, &corners, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src), 0); - - // Compute function - harris_corners.run(); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(HarrisCorners) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (Small2DShapes() + Large2DShapes()) * BorderModes() - * boost::unit_test::data::make({ 3, 5, 7 }) * boost::unit_test::data::make({ 3, 5, 7 }), - shape, border_mode, gradient, block) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - src.info()->set_format(Format::U8); - - CLKeyPointArray corners(shape.total_size()); - - uint8_t constant_border_value = 0; - - std::mt19937 gen(user_config.seed.get()); - std::uniform_real_distribution real_dist(0.01, std::numeric_limits::min()); - - const float threshold = real_dist(gen); - const float sensitivity = real_dist(gen); - const float max_euclidean_distance = 30.f; - - real_dist = std::uniform_real_distribution(0.f, max_euclidean_distance); - float min_dist = real_dist(gen); - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::uniform_int_distribution int_dist(0, 255); - constant_border_value = int_dist(gen); - } - - BOOST_TEST(src.info()->is_resizable()); - - // Create harris corners configure function - CLHarrisCorners harris_corners; - harris_corners.configure(&src, threshold, min_dist, sensitivity, gradient, block, &corners, border_mode, constant_border_value); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - - validate(src.info()->valid_region(), valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 8); - - calculator.set_border_mode(border_mode); - calculator.set_border_size(gradient / 2); - calculator.set_access_offset(-gradient / 2); - calculator.set_accessed_elements(16); - - const PaddingSize padding = calculator.required_padding(); - - validate(src.info()->padding(), padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, Small2DShapes() * BorderModes() * boost::unit_test::data::make({ 3, 5, 7 }) * boost::unit_test::data::make({ 3, 5, 7 }), shape, border_mode, gradient, block) -{ - uint8_t constant_border_value = 0; - - std::mt19937 gen(user_config.seed.get()); - std::uniform_real_distribution real_dist(0.01, std::numeric_limits::min()); - - const float threshold = real_dist(gen); - const float sensitivity = real_dist(gen); - const float max_euclidean_distance = 30.f; - - real_dist = std::uniform_real_distribution(0.f, max_euclidean_distance); - const float min_dist = real_dist(gen); - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::uniform_int_distribution int_dist(0, 255); - constant_border_value = int_dist(gen); - } - - // Create array of keypoints - CLKeyPointArray dst(shape.total_size()); - - // Compute function - compute_harris_corners(shape, dst, threshold, min_dist, sensitivity, gradient, block, border_mode, constant_border_value); - - // Compute reference - KeyPointArray ref_dst = Reference::compute_reference_harris_corners(shape, threshold, min_dist, sensitivity, gradient, block, border_mode, constant_border_value); - - // Validate output - dst.map(); - validate(dst, ref_dst, 1); - dst.unmap(); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, Large2DShapes() * BorderModes() * boost::unit_test::data::make({ 3, 5, 7 }) * boost::unit_test::data::make({ 3, 5, 7 }), shape, border_mode, gradient, block) -{ - uint8_t constant_border_value = 0; - - std::mt19937 gen(user_config.seed.get()); - std::uniform_real_distribution real_dist(0.01, std::numeric_limits::min()); - - const float threshold = real_dist(gen); - const float sensitivity = real_dist(gen); - const float max_euclidean_distance = 30.f; - - real_dist = std::uniform_real_distribution(0.f, max_euclidean_distance); - const float min_dist = real_dist(gen); - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::uniform_int_distribution int_dist(0, 255); - constant_border_value = int_dist(gen); - } - - // Create array of keypoints - CLKeyPointArray dst(shape.total_size()); - - // Compute function - compute_harris_corners(shape, dst, threshold, min_dist, sensitivity, gradient, block, border_mode, constant_border_value); - - // Compute reference - KeyPointArray ref_dst = Reference::compute_reference_harris_corners(shape, threshold, min_dist, sensitivity, gradient, block, border_mode, constant_border_value); - - // Validate output - dst.map(); - validate(dst, ref_dst); - dst.unmap(); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/IntegralImage.cpp b/tests/validation/CL/IntegralImage.cpp deleted file mode 100644 index dc325a1f8a..0000000000 --- a/tests/validation/CL/IntegralImage.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLIntegralImage.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute CL integral image function. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -CLTensor compute_integral_image(const TensorShape &shape) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst = create_tensor(shape, DataType::U32); - - // Create integral image configure function - CLIntegralImage integral_image; - integral_image.configure(&src, &dst); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src), 0); - - // Compute function - integral_image.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(IntegralImage) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, SmallShapes() + LargeShapes(), shape) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst = create_tensor(shape, DataType::U32); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create integral image configure function - CLIntegralImage integral_image; - integral_image.configure(&src, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) -{ - // Compute function - CLTensor dst = compute_integral_image(shape); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_integral_image(shape); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes(), shape) -{ - // Compute function - CLTensor dst = compute_integral_image(shape); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_integral_image(shape); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/L2Normalize.cpp b/tests/validation/CL/L2Normalize.cpp new file mode 100644 index 0000000000..bd9bf17322 --- /dev/null +++ b/tests/validation/CL/L2Normalize.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLL2Normalize.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/L2NormalizeFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Tolerance for float operations */ +constexpr AbsoluteTolerance tolerance_f32(0.00001f); + +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(L2Normalize) + +template +using CLL2NormalizeFixture = L2NormalizeValidationFixture; + +TEST_SUITE(Float) +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, CLL2NormalizeFixture, framework::DatasetMode::PRECOMMIT, + combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), framework::dataset::make("Epsilon", { 1e-12 }))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLL2NormalizeFixture, framework::DatasetMode::NIGHTLY, + combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), framework::dataset::make("Epsilon", { 1e-12 }))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/MeanStdDev.cpp b/tests/validation/CL/MeanStdDev.cpp new file mode 100644 index 0000000000..ff8a087c6b --- /dev/null +++ b/tests/validation/CL/MeanStdDev.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/runtime/CL/functions/CLMeanStdDev.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Macros.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/MeanStdDevFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +constexpr RelativeTolerance tolerance_rel_high_error(0.05f); +constexpr RelativeTolerance tolerance_rel_low_error(0.0005f); +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(MeanStdDev) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) +{ + // Create tensors + CLTensor src = create_tensor(shape, data_type); + + // Create output variables + float mean = 0.f; + float std_dev = 0.f; + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create configure function + CLMeanStdDev mean_std_dev_image; + mean_std_dev_image.configure(&src, &mean, &std_dev); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 8).required_padding(); + validate(src.info()->padding(), padding); +} + +template +using CLMeanStdDevFixture = MeanStdDevValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, CLMeanStdDevFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate mean output + validate(_target.first, _reference.first); + + // Validate std_dev output + validate(_target.second, _reference.second, tolerance_rel_high_error); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLMeanStdDevFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate mean output + validate(_target.first, _reference.first, tolerance_rel_low_error); + + // Validate std_dev output + validate(_target.second, _reference.second, tolerance_rel_high_error); +} + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/MinMaxLocation.cpp b/tests/validation/CL/MinMaxLocation.cpp deleted file mode 100644 index 5f8be433cd..0000000000 --- a/tests/validation/CL/MinMaxLocation.cpp +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLMinMaxLocation.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "PaddingCalculator.h" -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute CL MinMaxLocation function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in Data type of first input tensor. - * @param[out] min Minimum value of tensor - * @param[out] max Maximum value of tensor - * @param[out] min_loc Array with locations of minimum values - * @param[out] max_loc Array with locations of maximum values - * @param[out] min_count Number of minimum values found - * @param[out] max_count Number of maximum values found - * - * @return Computed output tensor. - */ -void compute_min_max_location(const TensorShape &shape, DataType dt_in, void *min, void *max, - CLCoordinates2DArray &min_loc, CLCoordinates2DArray &max_loc, uint32_t &min_count, uint32_t &max_count) -{ - // Create tensor - CLTensor src = create_tensor(shape, dt_in); - - // Create and configure min_max_location configure function - CLMinMaxLocation min_max_loc; - min_max_loc.configure(&src, min, max, &min_loc, &max_loc, &min_count, &max_count); - - // Allocate tensors - src.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src), 0); - - // Compute function - min_max_loc.run(); -} - -void validate_configuration(const CLTensor &src, TensorShape shape) -{ - BOOST_TEST(src.info()->is_resizable()); - - // Create output storage - int32_t min; - int32_t max; - CLCoordinates2DArray min_loc(shape.total_size()); - CLCoordinates2DArray max_loc(shape.total_size()); - uint32_t min_count; - uint32_t max_count; - - // Create and configure function - CLMinMaxLocation min_max_loc; - min_max_loc.configure(&src, &min, &max, &min_loc, &max_loc, &min_count, &max_count); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), src.info()->dimension(0)).required_padding(); - validate(src.info()->padding(), padding); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(MinMaxLocation) -BOOST_AUTO_TEST_SUITE(U8) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (Small2DShapes() + Large2DShapes()), - shape) -{ - // Create tensor - CLTensor src = create_tensor(shape, DataType::U8); - src.info()->set_format(Format::U8); - - validate_configuration(src, shape); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, Small2DShapes(), - shape) -{ - // Create output storage - int32_t min; - int32_t max; - CLCoordinates2DArray min_loc(shape.total_size()); - CLCoordinates2DArray max_loc(shape.total_size()); - uint32_t min_count; - uint32_t max_count; - - int32_t ref_min; - int32_t ref_max; - CLCoordinates2DArray ref_min_loc(shape.total_size()); - CLCoordinates2DArray ref_max_loc(shape.total_size()); - uint32_t ref_min_count; - uint32_t ref_max_count; - - // Compute function - compute_min_max_location(shape, DataType::U8, &min, &max, min_loc, max_loc, min_count, max_count); - - // Compute reference - ref_min_loc.map(); - ref_max_loc.map(); - - Reference::compute_reference_min_max_location(shape, DataType::U8, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); - - min_loc.map(); - max_loc.map(); - - // Validate output - validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); - - ref_min_loc.unmap(); - ref_max_loc.unmap(); - min_loc.unmap(); - max_loc.unmap(); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, Large2DShapes(), - shape) -{ - // Create output storage - int32_t min; - int32_t max; - CLCoordinates2DArray min_loc(shape.total_size()); - CLCoordinates2DArray max_loc(shape.total_size()); - uint32_t min_count; - uint32_t max_count; - - int32_t ref_min; - int32_t ref_max; - CLCoordinates2DArray ref_min_loc(shape.total_size()); - CLCoordinates2DArray ref_max_loc(shape.total_size()); - uint32_t ref_min_count; - uint32_t ref_max_count; - - // Compute function - compute_min_max_location(shape, DataType::U8, &min, &max, min_loc, max_loc, min_count, max_count); - - // Compute reference - ref_min_loc.map(); - ref_max_loc.map(); - - Reference::compute_reference_min_max_location(shape, DataType::U8, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); - - min_loc.map(); - max_loc.map(); - - // Validate output - validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); - - ref_min_loc.unmap(); - ref_max_loc.unmap(); - min_loc.unmap(); - max_loc.unmap(); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(S16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (Small2DShapes() + Large2DShapes()), - shape) -{ - // Create tensor - CLTensor src = create_tensor(shape, DataType::S16); - src.info()->set_format(Format::S16); - - validate_configuration(src, shape); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, Small2DShapes(), - shape) -{ - // Create output storage - int32_t min; - int32_t max; - CLCoordinates2DArray min_loc(shape.total_size()); - CLCoordinates2DArray max_loc(shape.total_size()); - uint32_t min_count; - uint32_t max_count; - - int32_t ref_min; - int32_t ref_max; - CLCoordinates2DArray ref_min_loc(shape.total_size()); - CLCoordinates2DArray ref_max_loc(shape.total_size()); - uint32_t ref_min_count; - uint32_t ref_max_count; - - // Compute function - compute_min_max_location(shape, DataType::S16, &min, &max, min_loc, max_loc, min_count, max_count); - - // Compute reference - ref_min_loc.map(); - ref_max_loc.map(); - - Reference::compute_reference_min_max_location(shape, DataType::S16, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); - - min_loc.map(); - max_loc.map(); - - // Validate output - validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); - - ref_min_loc.unmap(); - ref_max_loc.unmap(); - min_loc.unmap(); - max_loc.unmap(); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, Large2DShapes(), - shape) -{ - // Create output storage - int32_t min; - int32_t max; - CLCoordinates2DArray min_loc(shape.total_size()); - CLCoordinates2DArray max_loc(shape.total_size()); - uint32_t min_count; - uint32_t max_count; - - int32_t ref_min; - int32_t ref_max; - CLCoordinates2DArray ref_min_loc(shape.total_size()); - CLCoordinates2DArray ref_max_loc(shape.total_size()); - uint32_t ref_min_count; - uint32_t ref_max_count; - - // Compute function - compute_min_max_location(shape, DataType::S16, &min, &max, min_loc, max_loc, min_count, max_count); - - // Compute reference - ref_min_loc.map(); - ref_max_loc.map(); - - Reference::compute_reference_min_max_location(shape, DataType::S16, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); - - min_loc.map(); - max_loc.map(); - - // Validate output - validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); - - ref_min_loc.unmap(); - ref_max_loc.unmap(); - min_loc.unmap(); - max_loc.unmap(); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Float) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (Small2DShapes() + Large2DShapes()), - shape) -{ - // Create tensor - CLTensor src = create_tensor(shape, DataType::F32); - - validate_configuration(src, shape); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, Small2DShapes(), - shape) -{ - // Create output storage - float min; - float max; - CLCoordinates2DArray min_loc(shape.total_size()); - CLCoordinates2DArray max_loc(shape.total_size()); - uint32_t min_count; - uint32_t max_count; - - float ref_min; - float ref_max; - CLCoordinates2DArray ref_min_loc(shape.total_size()); - CLCoordinates2DArray ref_max_loc(shape.total_size()); - uint32_t ref_min_count; - uint32_t ref_max_count; - - // Compute function - compute_min_max_location(shape, DataType::F32, &min, &max, min_loc, max_loc, min_count, max_count); - - // Compute reference - ref_min_loc.map(); - ref_max_loc.map(); - - Reference::compute_reference_min_max_location(shape, DataType::F32, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); - - min_loc.map(); - max_loc.map(); - - // Validate output - validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); - - ref_min_loc.unmap(); - ref_max_loc.unmap(); - min_loc.unmap(); - max_loc.unmap(); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, Large2DShapes(), - shape) -{ - // Create output storage - float min; - float max; - CLCoordinates2DArray min_loc(shape.total_size()); - CLCoordinates2DArray max_loc(shape.total_size()); - uint32_t min_count; - uint32_t max_count; - - float ref_min; - float ref_max; - CLCoordinates2DArray ref_min_loc(shape.total_size()); - CLCoordinates2DArray ref_max_loc(shape.total_size()); - uint32_t ref_min_count; - uint32_t ref_max_count; - - // Compute function - compute_min_max_location(shape, DataType::F32, &min, &max, min_loc, max_loc, min_count, max_count); - - // Compute reference - ref_min_loc.map(); - ref_max_loc.map(); - - Reference::compute_reference_min_max_location(shape, DataType::F32, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); - - min_loc.map(); - max_loc.map(); - - // Validate output - validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); - - ref_min_loc.unmap(); - ref_max_loc.unmap(); - min_loc.unmap(); - max_loc.unmap(); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/NonLinearFilter.cpp b/tests/validation/CL/NonLinearFilter.cpp deleted file mode 100644 index f453f27e8a..0000000000 --- a/tests/validation/CL/NonLinearFilter.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Helpers.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLNonLinearFilter.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute NonLinearFilter function. - * - * @param[in] input Shape of the input and output tensors. - * @param[in] function Non linear function to perform - * @param[in] mask_size Mask size. Supported sizes: 3, 5 - * @param[in] pattern Mask pattern - * @param[in] mask The given mask. Will be used only if pattern is specified to PATTERN_OTHER - * @param[in] border_mode Strategy to use for borders. - * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT. - * - * @return Computed output CL tensor. - */ -CLTensor compute_non_linear_filter(const TensorShape &shape, NonLinearFilterFunction function, unsigned int mask_size, - MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, - uint8_t constant_border_value) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst = create_tensor(shape, DataType::U8); - - // Create and configure function - CLNonLinearFilter filter; - filter.configure(&src, &dst, function, mask_size, pattern, mask, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src), 0); - - // Compute function - filter.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(NonLinearFilter) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) - * NonLinearFilterFunctions() * boost::unit_test::data::make({ 3U, 5U }) - * boost::unit_test::data::make({ MatrixPattern::BOX, MatrixPattern::CROSS, MatrixPattern::DISK }) * BorderModes(), - shape, function, mask_size, pattern, border_mode) -{ - std::mt19937 generator(user_config.seed.get()); - std::uniform_int_distribution distribution_u8(0, 255); - const uint8_t constant_border_value = distribution_u8(generator); - - // Create the mask - uint8_t mask[mask_size * mask_size]; - fill_mask_from_pattern(mask, mask_size, mask_size, pattern); - const auto half_mask_size = static_cast(mask_size / 2); - - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst = create_tensor(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - CLNonLinearFilter filter; - filter.configure(&src, &dst, function, mask_size, pattern, mask, border_mode, constant_border_value); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(shape); - const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, BorderSize(half_mask_size)); - - validate(src.info()->valid_region(), src_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), ((MatrixPattern::OTHER == pattern) ? 1 : 8)); - calculator.set_border_mode(border_mode); - calculator.set_border_size(half_mask_size); - - const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER); - - calculator.set_accessed_elements(16); - calculator.set_access_offset(-half_mask_size); - - const PaddingSize read_padding = calculator.required_padding(PaddingCalculator::Option::INCLUDE_BORDER); - - validate(src.info()->padding(), read_padding); - validate(dst.info()->padding(), write_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() - * NonLinearFilterFunctions() * boost::unit_test::data::make({ 3U, 5U }) - * boost::unit_test::data::make({ MatrixPattern::BOX, MatrixPattern::CROSS, MatrixPattern::DISK }) * BorderModes(), - shape, function, mask_size, pattern, border_mode) -{ - std::mt19937 generator(user_config.seed.get()); - std::uniform_int_distribution distribution_u8(0, 255); - const uint8_t constant_border_value = distribution_u8(generator); - - // Create the mask - uint8_t mask[mask_size * mask_size]; - fill_mask_from_pattern(mask, mask_size, mask_size, pattern); - - // Compute function - CLTensor dst = compute_non_linear_filter(shape, function, mask_size, pattern, mask, border_mode, constant_border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_non_linear_filter(shape, function, mask_size, pattern, mask, border_mode, constant_border_value); - - // Calculate valid region - const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, BorderSize(static_cast(mask_size / 2))); - - // Validate output - validate(CLAccessor(dst), ref_dst, valid_region); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() - * NonLinearFilterFunctions() * boost::unit_test::data::make({ 3U, 5U }) - * boost::unit_test::data::make({ MatrixPattern::BOX, MatrixPattern::CROSS, MatrixPattern::DISK }) * BorderModes(), - shape, function, mask_size, pattern, border_mode) -{ - std::mt19937 generator(user_config.seed.get()); - std::uniform_int_distribution distribution_u8(0, 255); - const uint8_t constant_border_value = distribution_u8(generator); - - // Create the mask - uint8_t mask[mask_size * mask_size]; - fill_mask_from_pattern(mask, mask_size, mask_size, pattern); - - // Compute function - CLTensor dst = compute_non_linear_filter(shape, function, mask_size, pattern, mask, border_mode, constant_border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_non_linear_filter(shape, function, mask_size, pattern, mask, border_mode, constant_border_value); - - // Calculate valid region - const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, BorderSize(static_cast(mask_size / 2))); - - // Validate output - validate(CLAccessor(dst), ref_dst, valid_region); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/NormalizationLayer.cpp b/tests/validation/CL/NormalizationLayer.cpp new file mode 100644 index 0000000000..4d14649a91 --- /dev/null +++ b/tests/validation/CL/NormalizationLayer.cpp @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLNormalizationLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/NormalizationTypesDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/NormalizationLayerFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Tolerance for float operations */ +constexpr AbsoluteTolerance tolerance_f16(0.01f); +constexpr AbsoluteTolerance tolerance_f32(0.00001f); +/** Tolerance for fixed point operations */ +constexpr AbsoluteTolerance tolerance_qs8(2); +constexpr AbsoluteTolerance tolerance_qs16(2); + +/** Input data set. */ +const auto NormalizationDataset = combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("NormType", { NormType::IN_MAP_1D, NormType::CROSS_MAP })), + framework::dataset::make("NormalizationSize", 3, 9, 2)), + framework::dataset::make("Beta", { 0.5f, 1.f, 2.f })); +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(NormalizationLayer) + +//TODO(COMPMID-415): Missing configuration? + +template +using CLNormalizationLayerFixture = NormalizationValidationFixture; + +TEST_SUITE(Float) +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLNormalizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f16); +} +TEST_SUITE_END() + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, CLNormalizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() +TEST_SUITE_END() + +template +using CLNormalizationLayerFixedPointFixture = NormalizationValidationFixedPointFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 +FIXTURE_DATA_TEST_CASE(RunSmall, CLNormalizationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(NormalizationDataset, framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 1, 6))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_qs8); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLNormalizationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(NormalizationDataset, framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 1, 6))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_qs8); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 5 +FIXTURE_DATA_TEST_CASE(RunSmall, CLNormalizationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(NormalizationDataset, framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_qs16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLNormalizationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(NormalizationDataset, framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_qs16); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/PixelWiseMultiplication.cpp b/tests/validation/CL/PixelWiseMultiplication.cpp deleted file mode 100644 index 375c77dedf..0000000000 --- a/tests/validation/CL/PixelWiseMultiplication.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "CL/CLAccessor.h" -#include "TypePrinter.h" -#include "tests/Globals.h" -#include "tests/Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/runtime/CL/functions/CLPixelWiseMultiplication.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -const float tolerance_f32 = 1.f; /**< Tolerance value for comparing reference's output against implementation's output for float input */ -const float tolerance_f16 = 1.f; /**< Tolerance value for comparing reference's output against implementation's output for float input */ - -/** Compute CL pixel-wise multiplication function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] scale Non-negative scale. - * @param[in] convert_policy Overflow policy of the operation. - * @param[in] rounding_policy Rounding policy of the operation. - * @param[in] fixed_point_position (Optional) Fixed point position that expresses the number of bits for the fractional part of the number. - * - * @return Computed output tensor. - */ -CLTensor compute_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy, - int fixed_point_position = 0) -{ - // Create tensors - CLTensor src1 = create_tensor(shape, dt_in0, 1, fixed_point_position); - CLTensor src2 = create_tensor(shape, dt_in1, 1, fixed_point_position); - CLTensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); - - // Create and configure function - CLPixelWiseMultiplication multiply; - multiply.configure(&src1, &src2, &dst, scale, convert_policy, rounding_policy); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src1.info()->is_resizable()); - BOOST_TEST(!src2.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src1), 0); - library->fill_tensor_uniform(CLAccessor(src2), 1); - - // Compute function - multiply.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(PixelWiseMultiplication) - -BOOST_AUTO_TEST_SUITE(Float16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::F16 *ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP, - shape, dt, convert_policy, rounding_policy) -{ - constexpr float scale = 1.f / 255.f; - - // Compute function - CLTensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy); - - // Validate output - validate(CLAccessor(dst), ref_dst, tolerance_f16); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Float) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::F32 *ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP, - shape, dt, convert_policy, rounding_policy) -{ - constexpr float scale = 1.f / 255.f; - - // Compute function - CLTensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy); - - // Validate output - validate(CLAccessor(dst), ref_dst, tolerance_f32); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Quantized) -BOOST_AUTO_TEST_SUITE(QS8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 7), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(QS16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::QS16 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 15), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - CLTensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif // DOXYGEN_SKIP_THIS diff --git a/tests/validation/CL/PoolingLayer.cpp b/tests/validation/CL/PoolingLayer.cpp new file mode 100644 index 0000000000..24380cb1f0 --- /dev/null +++ b/tests/validation/CL/PoolingLayer.cpp @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLPoolingLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/PoolingTypesDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/PoolingLayerFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Input data set for float data types */ +const auto PoolingLayerDatasetFP = combine(combine(datasets::PoolingTypes(), framework::dataset::make("PoolingSize", { 2, 3, 7 })), + framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) })); + +/** Input data set for quantized data types */ +const auto PoolingLayerDatasetQS = combine(combine(datasets::PoolingTypes(), framework::dataset::make("PoolingSize", { 2, 3 })), + framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) })); + +constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for float types */ +constexpr AbsoluteTolerance tolerance_f16(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for float types */ +constexpr AbsoluteTolerance tolerance_qs8(3); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */ +constexpr AbsoluteTolerance tolerance_qs16(6); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */ +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(PoolingLayer) + +template +using CLPoolingLayerFixture = PoolingLayerValidationFixture; + +TEST_SUITE(Float) +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, CLPoolingLayerFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType", + DataType::F32)))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType", + DataType::F32)))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() + +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLPoolingLayerFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP, + framework::dataset::make("DataType", DataType::F16)))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP, + framework::dataset::make("DataType", DataType::F16)))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f16); +} +TEST_SUITE_END() +TEST_SUITE_END() + +template +using CLPoolingLayerFixedPointFixture = PoolingLayerValidationFixedPointFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +FIXTURE_DATA_TEST_CASE(RunSmall, CLPoolingLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS, + framework::dataset::make("DataType", DataType::QS8))), + framework::dataset::make("FractionalBits", 1, 4))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_qs8); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLPoolingLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS, + framework::dataset::make("DataType", DataType::QS8))), + framework::dataset::make("FractionalBits", 1, 4))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_qs8); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLPoolingLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS, + framework::dataset::make("DataType", DataType::QS16))), + framework::dataset::make("FractionalBits", 1, 12))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_qs16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLPoolingLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS, + framework::dataset::make("DataType", DataType::QS16))), + framework::dataset::make("FractionalBits", 1, 12))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_qs16); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/ROIPoolingLayer.cpp b/tests/validation/CL/ROIPoolingLayer.cpp deleted file mode 100644 index 19d7903128..0000000000 --- a/tests/validation/CL/ROIPoolingLayer.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "CL/CLAccessor.h" -#include "CL/CLArrayAccessor.h" -#include "TypePrinter.h" -#include "arm_compute/runtime/CL/CLArray.h" -#include "arm_compute/runtime/CL/functions/CLROIPoolingLayer.h" -#include "tests/Globals.h" -#include "tests/Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -CLTensor compute_roi_pooling_layer(const TensorShape &shape, DataType dt, const std::vector &rois, ROIPoolingLayerInfo pool_info) -{ - TensorShape shape_dst; - shape_dst.set(0, pool_info.pooled_width()); - shape_dst.set(1, pool_info.pooled_height()); - shape_dst.set(2, shape.z()); - shape_dst.set(3, rois.size()); - - // Create tensors - CLTensor src = create_tensor(shape, dt); - CLTensor dst = create_tensor(shape_dst, dt); - - // Create ROI array - CLArray rois_array(rois.size()); - fill_array(CLArrayAccessor(rois_array), rois); - - // Create and configure function - CLROIPoolingLayer roi_pool; - roi_pool.configure(&src, &rois_array, &dst, pool_info); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - std::uniform_real_distribution<> distribution(-1, 1); - library->fill(CLAccessor(src), distribution, 0); - - // Compute function - roi_pool.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(ROIPoolingLayer) - -BOOST_AUTO_TEST_SUITE(Float) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, boost::unit_test::data::make({ DataType::F16, DataType::F32 }) * boost::unit_test::data::make({ 10, 20, 40 }) * boost::unit_test::data::make({ 7, 9 }) * - boost::unit_test::data::make({ 1.f / 8.f, 1.f / 16.f }), - dt, num_rois, roi_pool_size, roi_scale) -{ - TensorShape shape(50U, 47U, 2U, 3U); - ROIPoolingLayerInfo pool_info(roi_pool_size, roi_pool_size, roi_scale); - - // Construct ROI vector - std::vector rois = generate_random_rois(shape, pool_info, num_rois, user_config.seed); - - // Compute function - CLTensor dst = compute_roi_pooling_layer(shape, dt, rois, pool_info); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_roi_pooling_layer(shape, dt, rois, pool_info); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/ReductionOperation.cpp b/tests/validation/CL/ReductionOperation.cpp new file mode 100644 index 0000000000..5896add68f --- /dev/null +++ b/tests/validation/CL/ReductionOperation.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLReductionOperation.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ReductionOperationDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/ReductionOperationFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Tolerance for float operations */ +constexpr RelativeTolerance tolerance_f32(0.00001f); +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(ReductionOperation) + +template +using CLReductionOperationFixture = ReductionOperationValidationFixture; + +TEST_SUITE(Float) +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, CLReductionOperationFixture, framework::DatasetMode::PRECOMMIT, + combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), datasets::ReductionOperations())) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLReductionOperationFixture, framework::DatasetMode::NIGHTLY, + combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), datasets::ReductionOperations())) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/Scale.cpp b/tests/validation/CL/Scale.cpp new file mode 100644 index 0000000000..d5866fad97 --- /dev/null +++ b/tests/validation/CL/Scale.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/functions/CLScale.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/BorderModeDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Helpers.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/ScaleFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Tolerance */ +constexpr AbsoluteTolerance tolerance(1); +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(Scale) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + shape, data_type, policy, border_mode) +{ + std::mt19937 generator(library->seed()); + std::uniform_real_distribution distribution_float(0.25, 2); + const float scale_x = distribution_float(generator); + const float scale_y = distribution_float(generator); + std::uniform_int_distribution distribution_u8(0, 255); + uint8_t constant_border_value = distribution_u8(generator); + + // Create tensors + CLTensor src = create_tensor(shape, data_type); + TensorShape shape_scaled(shape); + shape_scaled.set(0, shape[0] * scale_x); + shape_scaled.set(1, shape[1] * scale_y); + CLTensor dst = create_tensor(shape_scaled, data_type); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + CLScale clscale; + clscale.configure(&src, &dst, policy, border_mode, constant_border_value); + + // Validate valid region + const ValidRegion dst_valid_region = calculate_valid_region_scale(*(src.info()), shape_scaled, policy, BorderSize(1), (border_mode == BorderMode::UNDEFINED)); + + validate(dst.info()->valid_region(), dst_valid_region); + + // Validate padding + PaddingCalculator calculator(shape_scaled.x(), 4); + calculator.set_border_mode(border_mode); + + const PaddingSize read_padding(1); + const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER); + validate(src.info()->padding(), read_padding); + validate(dst.info()->padding(), write_padding); +} + +template +using CLScaleFixture = ScaleValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::U8)), + framework::dataset::make("InterpolationPolicy", +{ InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), +datasets::BorderModes())) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(CLAccessor(_target), _reference, valid_region, tolerance); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::U8)), + framework::dataset::make("InterpolationPolicy", +{ InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), +datasets::BorderModes())) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(CLAccessor(_target), _reference, valid_region, tolerance); +} +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/Sobel3x3.cpp b/tests/validation/CL/Sobel3x3.cpp deleted file mode 100644 index 9e32a3da66..0000000000 --- a/tests/validation/CL/Sobel3x3.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLSubTensor.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLSobel3x3.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -constexpr unsigned int filter_size = 3; /** Size of the kernel/filter in number of elements. */ -constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ - -/** Compute CL Sobel 3x3 function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT - * - * @return Computed output tensor. - */ -std::pair compute_sobel_3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst_x = create_tensor(shape, DataType::S16); - CLTensor dst_y = create_tensor(shape, DataType::S16); - - src.info()->set_format(Format::U8); - dst_x.info()->set_format(Format::S16); - dst_y.info()->set_format(Format::S16); - - // Create sobel image configure function - CLSobel3x3 sobel_3x3; - sobel_3x3.configure(&src, &dst_x, &dst_y, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst_x.allocator()->allocate(); - dst_y.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst_x.info()->is_resizable()); - BOOST_TEST(!dst_y.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src), 0); - - // Compute function - sobel_3x3.run(); - - return std::make_pair(std::move(dst_x), std::move(dst_y)); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(Sobel3x3) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst_x = create_tensor(shape, DataType::S16); - CLTensor dst_y = create_tensor(shape, DataType::S16); - - src.info()->set_format(Format::U8); - dst_x.info()->set_format(Format::S16); - dst_y.info()->set_format(Format::S16); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst_x.info()->is_resizable()); - BOOST_TEST(dst_y.info()->is_resizable()); - - // Create sobel 3x3 configure function - CLSobel3x3 sobel_3x3; - sobel_3x3.configure(&src, &dst_x, &dst_y, border_mode); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(shape); - const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - - validate(src.info()->valid_region(), src_valid_region); - validate(dst_x.info()->valid_region(), dst_valid_region); - validate(dst_y.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 8); - - calculator.set_border_mode(border_mode); - calculator.set_border_size(1); - - const PaddingSize dst_padding = calculator.required_padding(); - - calculator.set_accessed_elements(16); - calculator.set_access_offset(-1); - - const PaddingSize src_padding = calculator.required_padding(); - - validate(src.info()->padding(), src_padding); - validate(dst_x.info()->padding(), dst_padding); - validate(dst_y.info()->padding(), dst_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) -{ - uint8_t constant_border_value = 0; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - constant_border_value = distribution(gen); - } - - // Compute function - std::pair dst = compute_sobel_3x3(shape, border_mode, constant_border_value); - - // Compute reference - std::pair ref_dst = Reference::compute_reference_sobel_3x3(shape, border_mode, constant_border_value); - - // Calculate valid region - const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - - // Validate output - validate(CLAccessor(dst.first), ref_dst.first, valid_region); - validate(CLAccessor(dst.second), ref_dst.second, valid_region); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) -{ - uint8_t constant_border_value = 0; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - constant_border_value = distribution(gen); - } - - // Compute function - std::pair dst = compute_sobel_3x3(shape, border_mode, constant_border_value); - - // Compute reference - std::pair ref_dst = Reference::compute_reference_sobel_3x3(shape, border_mode, constant_border_value); - - // Calculate valid region - const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - - // Validate output - validate(CLAccessor(dst.first), ref_dst.first, valid_region); - validate(CLAccessor(dst.second), ref_dst.second, valid_region); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/Sobel5x5.cpp b/tests/validation/CL/Sobel5x5.cpp deleted file mode 100644 index a7c971aa3a..0000000000 --- a/tests/validation/CL/Sobel5x5.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLSubTensor.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLSobel5x5.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -constexpr unsigned int filter_size = 5; /** Size of the kernel/filter in number of elements. */ -constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ - -/** Compute CL Sobel 5x5 function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT - * - * @return Computed output tensor. - */ -std::pair compute_sobel_5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst_x = create_tensor(shape, DataType::S16); - CLTensor dst_y = create_tensor(shape, DataType::S16); - - src.info()->set_format(Format::U8); - dst_x.info()->set_format(Format::S16); - dst_y.info()->set_format(Format::S16); - - // Create sobel image configure function - CLSobel5x5 sobel_5x5; - sobel_5x5.configure(&src, &dst_x, &dst_y, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst_x.allocator()->allocate(); - dst_y.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst_x.info()->is_resizable()); - BOOST_TEST(!dst_y.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src), 0); - - // Compute function - sobel_5x5.run(); - - return std::make_pair(std::move(dst_x), std::move(dst_y)); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(Sobel5x5) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst_x = create_tensor(shape, DataType::S16); - CLTensor dst_y = create_tensor(shape, DataType::S16); - - src.info()->set_format(Format::U8); - dst_x.info()->set_format(Format::S16); - dst_y.info()->set_format(Format::S16); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst_x.info()->is_resizable()); - BOOST_TEST(dst_y.info()->is_resizable()); - - // Create sobel 5x5 configure function - CLSobel5x5 sobel_5x5; - sobel_5x5.configure(&src, &dst_x, &dst_y, border_mode); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(shape); - const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - - validate(src.info()->valid_region(), src_valid_region); - validate(dst_x.info()->valid_region(), dst_valid_region); - validate(dst_y.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 8); - calculator.set_border_mode(border_mode); - calculator.set_border_size(2); - - const PaddingSize dst_padding = calculator.required_padding(); - - calculator.set_accessed_elements(16); - calculator.set_access_offset(-2); - - const PaddingSize src_padding = calculator.required_padding(); - - validate(src.info()->padding(), src_padding); - validate(dst_x.info()->padding(), dst_padding); - validate(dst_y.info()->padding(), dst_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) -{ - uint8_t constant_border_value = 0; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - constant_border_value = distribution(gen); - } - - // Compute function - std::pair dst = compute_sobel_5x5(shape, border_mode, constant_border_value); - - // Compute reference - std::pair ref_dst = Reference::compute_reference_sobel_5x5(shape, border_mode, constant_border_value); - - // Calculate valid region - const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - - // Validate output - validate(CLAccessor(dst.first), ref_dst.first, valid_region); - validate(CLAccessor(dst.second), ref_dst.second, valid_region); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) -{ - uint8_t constant_border_value = 0; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - constant_border_value = distribution(gen); - } - - // Compute function - std::pair dst = compute_sobel_5x5(shape, border_mode, constant_border_value); - - // Compute reference - std::pair ref_dst = Reference::compute_reference_sobel_5x5(shape, border_mode, constant_border_value); - - // Calculate valid region - const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - - // Validate output - validate(CLAccessor(dst.first), ref_dst.first, valid_region); - validate(CLAccessor(dst.second), ref_dst.second, valid_region); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/SoftmaxLayer.cpp b/tests/validation/CL/SoftmaxLayer.cpp new file mode 100644 index 0000000000..c4a9970b78 --- /dev/null +++ b/tests/validation/CL/SoftmaxLayer.cpp @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLSoftmaxLayer.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/SoftmaxLayerFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Tolerance for float operations */ +constexpr AbsoluteTolerance tolerance_f16(0.002f); +constexpr AbsoluteTolerance tolerance_f32(0.000001f); +/** Tolerance for fixed point operations */ +constexpr AbsoluteTolerance tolerance_fixed_point(2); + +/** CNN data types */ +const auto CNNDataTypes = framework::dataset::make("DataType", +{ + DataType::F16, + DataType::F32, + DataType::QS8, + DataType::QS16, +}); +} // namespace + +TEST_SUITE(CL) +TEST_SUITE(SoftmaxLayer) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), CNNDataTypes), shape, data_type) +{ + // Set fixed point position data type allowed + const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; + + // Create tensors + CLTensor src = create_tensor(shape, data_type, 1, fixed_point_position); + CLTensor dst = create_tensor(shape, data_type, 1, fixed_point_position); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + CLSoftmaxLayer smx_layer; + smx_layer.configure(&src, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using CLSoftmaxLayerFixture = SoftmaxValidationFixture; + +TEST_SUITE(Float) +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLSoftmaxLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLSoftmaxLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f16); +} +TEST_SUITE_END() + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, CLSoftmaxLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLSoftmaxLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() +TEST_SUITE_END() + +template +using CLSoftmaxLayerFixedPointFixture = SoftmaxValidationFixedPointFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 +FIXTURE_DATA_TEST_CASE(RunSmall, CLSoftmaxLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 1, 6))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_fixed_point); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLSoftmaxLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 1, 6))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_fixed_point); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 +FIXTURE_DATA_TEST_CASE(RunSmall, CLSoftmaxLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_fixed_point); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLSoftmaxLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance_fixed_point); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CL/TableLookup.cpp b/tests/validation/CL/TableLookup.cpp deleted file mode 100644 index 40e847f1cd..0000000000 --- a/tests/validation/CL/TableLookup.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "CL/CLLutAccessor.h" -#include "Globals.h" -#include "PaddingCalculator.h" -#include "RawLutAccessor.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Helpers.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLTableLookup.h" - -#include "boost_wrapper.h" - -#include -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Table Lookup function. - * - * @param[in] shape Shape of the input tensors - * @param[in] data_type Type of the input/output tensor - * @param[in] lut The input LUT. - * - * @return Computed output cl tensor. - */ -CLTensor compute_table_lookup(const TensorShape &shape, DataType data_type, CLLut &lut) -{ - // Create tensors - CLTensor src = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); - - // Create and configure function - CLTableLookup table_lookup; - table_lookup.configure(&src, &lut, &dst); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src), 0); - - // Compute function - table_lookup.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(TableLookup) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, data_type) -{ - //Create Lut - const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; - CLLut cllut(num_elem, data_type); - - if(data_type == DataType::U8) - { - fill_lookuptable(CLLutAccessor(cllut)); - } - else - { - fill_lookuptable(CLLutAccessor(cllut)); - } - - // Create tensors - CLTensor src = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - CLTableLookup table_lookup; - table_lookup.configure(&src, &cllut, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 8).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, - SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, data_type) -{ - //Create Lut - const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; - CLLut cllut(num_elem, data_type); - - if(data_type == DataType::U8) - { - //Create rawLut - std::map rawlut; - - //Fill the Lut - fill_lookuptable(CLLutAccessor(cllut)); - fill_lookuptable(RawLutAccessor(rawlut)); - - // Compute function - CLTensor dst = compute_table_lookup(shape, data_type, cllut); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); - - // Validate output - validate(CLAccessor(dst), ref_dst); - } - else - { - //Create rawLut - std::map rawlut; - - //Fill the Lut - fill_lookuptable(CLLutAccessor(cllut)); - fill_lookuptable(RawLutAccessor(rawlut)); - - // Compute function - CLTensor dst = compute_table_lookup(shape, data_type, cllut); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); - - // Validate output - validate(CLAccessor(dst), ref_dst); - } -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, - LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, data_type) -{ - //Create Lut - const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; - CLLut cllut(num_elem, data_type); - - if(data_type == DataType::U8) - { - //Create rawLut - std::map rawlut; - - //Fill the Lut - fill_lookuptable(CLLutAccessor(cllut)); - fill_lookuptable(RawLutAccessor(rawlut)); - - // Compute function - CLTensor dst = compute_table_lookup(shape, data_type, cllut); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); - - // Validate output - validate(CLAccessor(dst), ref_dst); - } - else - { - //Create rawLut - std::map rawlut; - - //Fill the Lut - fill_lookuptable(CLLutAccessor(cllut)); - fill_lookuptable(RawLutAccessor(rawlut)); - - // Compute function - CLTensor dst = compute_table_lookup(shape, data_type, cllut); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); - - // Validate output - validate(CLAccessor(dst), ref_dst); - } -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/Threshold.cpp b/tests/validation/CL/Threshold.cpp deleted file mode 100644 index a2e7b7b4ba..0000000000 --- a/tests/validation/CL/Threshold.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "dataset/ThresholdDataset.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLThreshold.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Threshold function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] threshold Threshold. When the threshold type is RANGE, this is used as the lower threshold. - * @param[in] false_value value to set when the condition is not respected. - * @param[in] true_value value to set when the condition is respected. - * @param[in] type Thresholding type. Either RANGE or BINARY. - * @param[in] upper Upper threshold. Only used when the thresholding type is RANGE. - * - * @return Computed output tensor. - */ -CLTensor compute_threshold(const TensorShape &shape, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst = create_tensor(shape, DataType::U8); - - // Create and configure function - CLThreshold thrsh; - thrsh.configure(&src, &dst, threshold, false_value, true_value, type, upper); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src), 0); - - // Compute function - thrsh.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(Threshold) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, - (SmallShapes() + LargeShapes()) * ThresholdDataset(), - shape, threshold_conf) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst = create_tensor(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - CLThreshold cl_threshold; - cl_threshold.configure(&src, &dst, threshold_conf.threshold, threshold_conf.false_value, threshold_conf.true_value, threshold_conf.type, threshold_conf.upper); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, - SmallShapes() * ThresholdDataset(), - shape, threshold_conf) -{ - // Compute function - CLTensor dst = compute_threshold(shape, threshold_conf.threshold, threshold_conf.false_value, threshold_conf.true_value, threshold_conf.type, threshold_conf.upper); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_threshold(shape, threshold_conf.threshold, threshold_conf.false_value, threshold_conf.true_value, threshold_conf.type, threshold_conf.upper); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, - LargeShapes() * ThresholdDataset(), - shape, threshold_conf) -{ - // Compute function - CLTensor dst = compute_threshold(shape, threshold_conf.threshold, threshold_conf.false_value, threshold_conf.true_value, threshold_conf.type, threshold_conf.upper); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_threshold(shape, threshold_conf.threshold, threshold_conf.false_value, threshold_conf.true_value, threshold_conf.type, threshold_conf.upper); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CL/WarpPerspective.cpp b/tests/validation/CL/WarpPerspective.cpp deleted file mode 100644 index 260b22be03..0000000000 --- a/tests/validation/CL/WarpPerspective.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "Globals.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Helpers.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLWarpPerspective.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Warp Perspective function. - * - * @param[in] input Shape of the input and output tensors. - * @param[in] matrix The perspective matrix. Must be 3x3 of type float. - * @param[in] policy The interpolation type. - * @param[in] border_mode Strategy to use for borders. - * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. - * - * @return Computed output tensor. - */ -CLTensor compute_warp_perspective(const TensorShape &shape, const float *matrix, InterpolationPolicy policy, - BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst = create_tensor(shape, DataType::U8); - - // Create and configure function - CLWarpPerspective warp_perspective; - warp_perspective.configure(&src, &dst, matrix, policy, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src), 0); - - // Compute function - warp_perspective.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(WarpPerspective) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) - * boost::unit_test::data::make({ InterpolationPolicy::BILINEAR, InterpolationPolicy::NEAREST_NEIGHBOR }) * BorderModes(), - shape, policy, border_mode) -{ - uint8_t constant_border_value = 0; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution_u8(0, 255); - constant_border_value = distribution_u8(gen); - } - - std::array matrix; - fill_warp_matrix<9>(matrix, 3, 3); - - // Create tensors - CLTensor src = create_tensor(shape, DataType::U8); - CLTensor dst = create_tensor(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - CLWarpPerspective warp_perspective; - warp_perspective.configure(&src, &dst, matrix.data(), policy, border_mode, constant_border_value); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 4); - calculator.set_border_mode(border_mode); - - const PaddingSize read_padding(1); - const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER); - - validate(src.info()->padding(), read_padding); - validate(dst.info()->padding(), write_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() - * boost::unit_test::data::make({ InterpolationPolicy::BILINEAR, InterpolationPolicy::NEAREST_NEIGHBOR }) - * BorderModes(), - shape, policy, border_mode) -{ - uint8_t constant_border_value = 0; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution_u8(0, 255); - constant_border_value = distribution_u8(gen); - } - - // Create the valid mask Tensor - RawTensor valid_mask(shape, DataType::U8); - - // Create the matrix - std::array matrix; - fill_warp_matrix<9>(matrix, 3, 3); - - // Compute function - CLTensor dst = compute_warp_perspective(shape, matrix.data(), policy, border_mode, constant_border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_warp_perspective(shape, valid_mask, matrix.data(), policy, border_mode, constant_border_value); - - // Validate output - validate(CLAccessor(dst), ref_dst, valid_mask, 1, 0.2f); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() - * boost::unit_test::data::make({ InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR }) * BorderModes(), - shape, policy, border_mode) -{ - uint8_t constant_border_value = 0; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution_u8(0, 255); - constant_border_value = distribution_u8(gen); - } - - // Create the valid mask Tensor - RawTensor valid_mask(shape, DataType::U8); - - // Create the matrix - std::array matrix; - fill_warp_matrix<9>(matrix, 3, 3); - - // Compute function - CLTensor dst = compute_warp_perspective(shape, matrix.data(), policy, border_mode, constant_border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_warp_perspective(shape, valid_mask, matrix.data(), policy, border_mode, constant_border_value); - - // Validate output - validate(CLAccessor(dst), ref_dst, valid_mask, 1, 0.2f); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/CMakeLists.txt b/tests/validation/CMakeLists.txt deleted file mode 100644 index 3d8f56610b..0000000000 --- a/tests/validation/CMakeLists.txt +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright (c) 2017 ARM Limited. -# -# SPDX-License-Identifier: MIT -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -cmake_minimum_required (VERSION 3.1) - -add_library(openvx SHARED IMPORTED) -set_target_properties(openvx PROPERTIES - IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/../3rdparty/linux/armv7a/libopenvx.so" -) - -add_library(vxu SHARED IMPORTED) -set_target_properties(vxu PROPERTIES - IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/../3rdparty/linux/armv7a/libvxu.so" -) - -add_library(OpenCL SHARED IMPORTED) -set_target_properties(OpenCL PROPERTIES - IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/../build/opencl-1.2-stubs/libOpenCL.so" - IMPORTED_NO_SONAME 1 -) - -add_definitions(-DBOOST) - -set(ARM_COMPUTE_TARGETS_TO_VALIDATE "all" CACHE STRING "Semicolon-separated list of targets to include in validation.") - -set(ARM_COMPUTE_ALL_TARGETS - NEON - CL - UNIT - VX -) - -if(ARM_COMPUTE_TARGETS_TO_VALIDATE STREQUAL "all") - set(ARM_COMPUTE_TARGETS_TO_VALIDATE ${ARM_COMPUTE_ALL_TARGETS}) -endif() - -list(REMOVE_DUPLICATES ARM_COMPUTE_TARGETS_TO_VALIDATE) - -foreach(TARGET ${ARM_COMPUTE_TARGETS_TO_VALIDATE}) - list(FIND ARM_COMPUTE_ALL_TARGETS ${TARGET} idx) - - if(${idx} LESS 0) - message(FATAL_ERROR "The target '${TARGET}' does not exist. It should be one of\n${ARM_COMPUTE_ALL_TARGETS}") - else() - add_subdirectory(${TARGET}) - endif() -endforeach() - -set(arm_compute_test_validation_SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Datasets.h - ${CMAKE_CURRENT_SOURCE_DIR}/Reference.h - ${CMAKE_CURRENT_SOURCE_DIR}/Reference.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ReferenceCPP.h - ${CMAKE_CURRENT_SOURCE_DIR}/ReferenceCPP.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Validation.h - ${CMAKE_CURRENT_SOURCE_DIR}/Validation.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ValidationProgramOptions.h - ${CMAKE_CURRENT_SOURCE_DIR}/ValidationUserConfiguration.h -) - -add_library(arm_compute_test_validation OBJECT - ${arm_compute_test_validation_SOURCE_FILES} -) - -add_executable(arm_compute_validation - $ - ${arm_compute_test_validation_TARGET_OBJECTS} - $ - $ -) - -target_link_libraries(arm_compute_validation - boost_unit_test_framework - boost_program_options - arm_compute - ${arm_compute_test_validation_TARGET_LIBRARIES} -) diff --git a/tests/validation/CPP/ActivationLayer.cpp b/tests/validation/CPP/ActivationLayer.cpp new file mode 100644 index 0000000000..fa393be5e1 --- /dev/null +++ b/tests/validation/CPP/ActivationLayer.cpp @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "ActivationLayer.h" + +#include "tests/validation/FixedPoint.h" +#include "tests/validation/Helpers.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template ::value, int>::type> +SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info) +{ + // Create reference + SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; + + // Compute reference + const T a(info.a()); + const T b(info.b()); + + for(int i = 0; i < src.num_elements(); ++i) + { + T x = src[i]; + + switch(info.activation()) + { + case ActivationLayerInfo::ActivationFunction::ABS: + dst[i] = std::abs(x); + break; + case ActivationLayerInfo::ActivationFunction::LINEAR: + dst[i] = a * x + b; + break; + case ActivationLayerInfo::ActivationFunction::LOGISTIC: + dst[i] = static_cast(1) / (static_cast(1) + std::exp(-x)); + break; + case ActivationLayerInfo::ActivationFunction::RELU: + dst[i] = std::max(static_cast(0), x); + break; + case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU: + dst[i] = std::min(a, std::max(static_cast(0), x)); + break; + case ActivationLayerInfo::ActivationFunction::LEAKY_RELU: + dst[i] = (x > 0) ? x : a * x; + break; + case ActivationLayerInfo::ActivationFunction::SOFT_RELU: + dst[i] = std::log(static_cast(1) + std::exp(x)); + break; + case ActivationLayerInfo::ActivationFunction::SQRT: + dst[i] = std::sqrt(x); + break; + case ActivationLayerInfo::ActivationFunction::SQUARE: + dst[i] = x * x; + break; + case ActivationLayerInfo::ActivationFunction::TANH: + dst[i] = a * std::tanh(b * x); + break; + default: + ARM_COMPUTE_ERROR("Unsupported activation function"); + } + } + + return dst; +} + +template ::value, int>::type> +SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info) +{ + using namespace fixed_point_arithmetic; + + // Create reference + SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; + + // Compute reference + const int fixed_point_position = src.fixed_point_position(); + const fixed_point a(info.a(), fixed_point_position); + const fixed_point b(info.b(), fixed_point_position); + const fixed_point const_0(0, fixed_point_position); + const fixed_point const_1(1, fixed_point_position); + + for(int i = 0; i < src.num_elements(); ++i) + { + fixed_point x(src[i], fixed_point_position, true); + + switch(info.activation()) + { + case ActivationLayerInfo::ActivationFunction::ABS: + dst[i] = abs(x).raw(); + break; + case ActivationLayerInfo::ActivationFunction::LINEAR: + dst[i] = add(b, mul(a, x)).raw(); + break; + case ActivationLayerInfo::ActivationFunction::LOGISTIC: + dst[i] = (const_1 / (const_1 + exp(-x))).raw(); + break; + case ActivationLayerInfo::ActivationFunction::RELU: + dst[i] = max(const_0, x).raw(); + break; + case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU: + dst[i] = min(a, max(const_0, x)).raw(); + break; + case ActivationLayerInfo::ActivationFunction::LEAKY_RELU: + dst[i] = (x > const_0) ? x.raw() : mul(a, x).raw(); + break; + case ActivationLayerInfo::ActivationFunction::SOFT_RELU: + dst[i] = log(const_1 + exp(x)).raw(); + break; + case ActivationLayerInfo::ActivationFunction::SQRT: + dst[i] = (const_1 / inv_sqrt(x)).raw(); + break; + case ActivationLayerInfo::ActivationFunction::SQUARE: + dst[i] = mul(x, x).raw(); + break; + case ActivationLayerInfo::ActivationFunction::TANH: + dst[i] = mul(a, tanh(mul(b, x))).raw(); + break; + default: + ARM_COMPUTE_ERROR("Unsupported activation function"); + } + } + + return dst; +} + +template SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); +template SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); +template SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); +template SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/ActivationLayer.h b/tests/validation/CPP/ActivationLayer.h new file mode 100644 index 0000000000..09f602ffa1 --- /dev/null +++ b/tests/validation/CPP/ActivationLayer.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_ACTIVATION_LAYER_H__ +#define __ARM_COMPUTE_TEST_ACTIVATION_LAYER_H__ + +#include "tests/SimpleTensor.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template ::value, int>::type = 0> +SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); + +template ::value, int>::type = 0> +SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_ACTIVATION_LAYER_H__ */ diff --git a/tests/validation/CPP/BitwiseAnd.cpp b/tests/validation/CPP/BitwiseAnd.cpp new file mode 100644 index 0000000000..6fc46b402b --- /dev/null +++ b/tests/validation/CPP/BitwiseAnd.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "BitwiseAnd.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor bitwise_and(const SimpleTensor &src1, const SimpleTensor &src2) +{ + SimpleTensor dst(src1.shape(), src1.data_type()); + + for(int i = 0; i < src1.num_elements(); ++i) + { + dst[i] = src1[i] & src2[i]; + } + + return dst; +} + +template SimpleTensor bitwise_and(const SimpleTensor &src1, const SimpleTensor &src2); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/BitwiseAnd.h b/tests/validation/CPP/BitwiseAnd.h new file mode 100644 index 0000000000..eba2fd695f --- /dev/null +++ b/tests/validation/CPP/BitwiseAnd.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_BITWISE_AND_H__ +#define __ARM_COMPUTE_TEST_BITWISE_AND_H__ + +#include "tests/SimpleTensor.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor bitwise_and(const SimpleTensor &src1, const SimpleTensor &src2); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_BITWISE_AND_H__ */ diff --git a/tests/validation/CPP/BitwiseNot.cpp b/tests/validation/CPP/BitwiseNot.cpp new file mode 100644 index 0000000000..5a6a13b56c --- /dev/null +++ b/tests/validation/CPP/BitwiseNot.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "BitwiseNot.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor bitwise_not(const SimpleTensor &src) +{ + SimpleTensor dst(src.shape(), src.data_type()); + + for(int i = 0; i < src.num_elements(); ++i) + { + dst[i] = ~src[i]; + } + + return dst; +} + +template SimpleTensor bitwise_not(const SimpleTensor &src); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/BitwiseNot.h b/tests/validation/CPP/BitwiseNot.h new file mode 100644 index 0000000000..b4206f9388 --- /dev/null +++ b/tests/validation/CPP/BitwiseNot.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_BITWISE_NOT_H__ +#define __ARM_COMPUTE_TEST_BITWISE_NOT_H__ + +#include "tests/SimpleTensor.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor bitwise_not(const SimpleTensor &src); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_BITWISE_NOT_H__ */ diff --git a/tests/validation/CPP/BitwiseOr.cpp b/tests/validation/CPP/BitwiseOr.cpp new file mode 100644 index 0000000000..fc258d54f1 --- /dev/null +++ b/tests/validation/CPP/BitwiseOr.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "BitwiseOr.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor bitwise_or(const SimpleTensor &src1, const SimpleTensor &src2) +{ + SimpleTensor dst(src1.shape(), src1.data_type()); + + for(int i = 0; i < src1.num_elements(); ++i) + { + dst[i] = src1[i] | src2[i]; + } + + return dst; +} + +template SimpleTensor bitwise_or(const SimpleTensor &src1, const SimpleTensor &src2); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/BitwiseOr.h b/tests/validation/CPP/BitwiseOr.h new file mode 100644 index 0000000000..39158cb411 --- /dev/null +++ b/tests/validation/CPP/BitwiseOr.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_BITWISE_OR_H__ +#define __ARM_COMPUTE_TEST_BITWISE_OR_H__ + +#include "tests/SimpleTensor.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor bitwise_or(const SimpleTensor &src1, const SimpleTensor &src2); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_BITWISE_OR_H__ */ diff --git a/tests/validation/CPP/BitwiseXor.cpp b/tests/validation/CPP/BitwiseXor.cpp new file mode 100644 index 0000000000..b8d275d8b5 --- /dev/null +++ b/tests/validation/CPP/BitwiseXor.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "BitwiseXor.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor bitwise_xor(const SimpleTensor &src1, const SimpleTensor &src2) +{ + SimpleTensor dst(src1.shape(), src1.data_type()); + + for(int i = 0; i < src1.num_elements(); ++i) + { + dst[i] = src1[i] ^ src2[i]; + } + + return dst; +} + +template SimpleTensor bitwise_xor(const SimpleTensor &src1, const SimpleTensor &src2); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/BitwiseXor.h b/tests/validation/CPP/BitwiseXor.h new file mode 100644 index 0000000000..3e7721e843 --- /dev/null +++ b/tests/validation/CPP/BitwiseXor.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_BITWISE_XOR_H__ +#define __ARM_COMPUTE_TEST_BITWISE_XOR_H__ + +#include "tests/SimpleTensor.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor bitwise_xor(const SimpleTensor &src1, const SimpleTensor &src2); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_BITWISE_XOR_H__ */ diff --git a/tests/validation/CPP/ConvolutionLayer.cpp b/tests/validation/CPP/ConvolutionLayer.cpp new file mode 100644 index 0000000000..1824ada791 --- /dev/null +++ b/tests/validation/CPP/ConvolutionLayer.cpp @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "ConvolutionLayer.h" + +#include "tests/validation/FixedPoint.h" +#include "tests/validation/Helpers.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +namespace +{ +inline bool is_valid_pixel(int i, int min, int max) +{ + return (i >= min && i < max); +} + +// 3D convolution for floating point type +template ::value, int>::type = 0> +void convolution3d(const T *in, const T *weights, const T *bias, T *out, int xi, int yi, int width_in, int height_in, int depth_in, int width_weights, int height_weights, int fixed_point_position) +{ + ARM_COMPUTE_UNUSED(fixed_point_position); + + const int half_width_weights = width_weights / 2; + const int half_height_weights = height_weights / 2; + + // Reset accumulator + T acc(0); + + // Compute a 2D convolution for each IFM and accumulate the result + for(int ifm = 0; ifm < depth_in; ++ifm) + { + // Compute the offset for the input slice + const int offset_slice_in = xi + yi * width_in + ifm * width_in * height_in; + + // Compute 2D convolution + for(int yk = -half_height_weights; yk <= half_height_weights; ++yk) + { + for(int xk = -half_width_weights; xk <= half_width_weights; ++xk) + { + // Check if the pixel is out-of-bound + if(is_valid_pixel(xi + xk, 0, width_in) && is_valid_pixel(yi + yk, 0, height_in)) + { + const int idx = xk + half_width_weights; + const int idy = yk + half_height_weights; + + const T i_value = in[offset_slice_in + xk + yk * width_in]; + const T w_value = weights[idx + idy * width_weights + ifm * width_weights * height_weights]; + + acc += i_value * w_value; + } + } + } + } + + // Accumulate the bias and store the result + *out = acc + (*bias); +} + +// 3D convolution for fixed point type +template ::value, int>::type = 0> +void convolution3d(const T *in, const T *weights, const T *bias, T *out, int xi, int yi, int width_in, int height_in, int depth_in, int width_weights, int height_weights, + int fixed_point_position) +{ + const int half_width_weights = width_weights / 2; + const int half_height_weights = height_weights / 2; + + using namespace fixed_point_arithmetic; + using promoted_type = fixed_point_arithmetic::traits::promote_t; + + // Reset accumulator + fixed_point acc(0, fixed_point_position); + + // Compute a 2D convolution for each IFM and accumulate the result + for(int ifm = 0; ifm < depth_in; ++ifm) + { + // Compute the offset for the input slice + const int offset_slice_in = xi + yi * width_in + ifm * width_in * height_in; + + // Compute 2D convolution + for(int yk = -half_height_weights; yk <= half_height_weights; ++yk) + { + for(int xk = -half_width_weights; xk <= half_width_weights; ++xk) + { + // Check if the pixel is out-of-bound + if(is_valid_pixel(xi + xk, 0, width_in) && is_valid_pixel(yi + yk, 0, height_in)) + { + const int idx = xk + half_width_weights; + const int idy = yk + half_height_weights; + + const fixed_point i_value(in[offset_slice_in + xk + yk * width_in], fixed_point_position, true); + const fixed_point w_value(weights[idx + idy * width_weights + ifm * width_weights * height_weights], fixed_point_position, true); + const fixed_point iw = i_value * w_value; + acc = iw + acc; + } + } + } + } + + // Get the bias + const fixed_point b(*bias, fixed_point_position, true); + + // Accumulate the bias and covert back + acc = acc + b; + fixed_point res(acc); + *out = res.raw(); +} +} // namespace + +template +SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, const PadStrideInfo &info) +{ + // Create reference + SimpleTensor dst{ output_shape, src.data_type(), 1, src.fixed_point_position() }; + + // Compute reference + const int width_in = src.shape().x(); + const int height_in = src.shape().y(); + const int depth_in = src.shape().z(); + const int width_out = dst.shape().x(); + const int height_out = dst.shape().y(); + const int depth_out = dst.shape().z(); + const int width_weights = weights.shape().x(); + const int height_weights = weights.shape().y(); + const int depth_weights = weights.shape().z(); + const int pad_xi = std::min(static_cast(info.pad().first), width_weights / 2); + const int pad_yi = std::min(static_cast(info.pad().second), height_weights / 2); + const int start_xi = width_weights / 2 - pad_xi; + const int start_yi = height_weights / 2 - pad_yi; + const int end_xi = width_in - start_xi; + const int end_yi = height_in - start_yi; + const int stride_xi = info.stride().first; + const int stride_yi = info.stride().second; + const int num_batches = src.shape().total_size() / (width_in * height_in * depth_in); + + for(int r = 0; r < num_batches; ++r) + { + for(int yi = start_yi; yi < end_yi; yi += stride_yi) + { + for(int xi = start_xi; xi < end_xi; xi += stride_xi) + { + for(int ofm = 0; ofm < depth_out; ++ofm) + { + // Compute input and output offsets + const int offset_in = r * width_in * height_in * depth_in; + const int xo = (xi - start_xi) / stride_xi; + const int yo = (yi - start_yi) / stride_yi; + const int offset_out = xo + yo * width_out + ofm * width_out * height_out + r * width_out * height_out * depth_out; + + // Compute 3D convolution + convolution3d(src.data() + offset_in, + weights.data() + ofm * width_weights * height_weights * depth_weights, + bias.data() + ofm, + dst.data() + offset_out, + xi, yi, + width_in, height_in, depth_in, + width_weights, height_weights, + src.fixed_point_position()); + } + } + } + } + + return dst; +} + +template SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, + const PadStrideInfo &info); +template SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, + const TensorShape &output_shape, const PadStrideInfo &info); +template SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, + const PadStrideInfo &info); +template SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, + const PadStrideInfo &info); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/ConvolutionLayer.h b/tests/validation/CPP/ConvolutionLayer.h new file mode 100644 index 0000000000..117e846b1c --- /dev/null +++ b/tests/validation/CPP/ConvolutionLayer.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_CONVOLUTION_LAYER_H__ +#define __ARM_COMPUTE_TEST_CONVOLUTION_LAYER_H__ + +#include "tests/SimpleTensor.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, const PadStrideInfo &info); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_CONVOLUTION_LAYER_H__ */ diff --git a/tests/validation/CPP/DepthConcatenateLayer.cpp b/tests/validation/CPP/DepthConcatenateLayer.cpp new file mode 100644 index 0000000000..139d26f2b6 --- /dev/null +++ b/tests/validation/CPP/DepthConcatenateLayer.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "DepthConcatenateLayer.h" + +#include "tests/validation/FixedPoint.h" +#include "tests/validation/Helpers.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor depthconcatenate_layer(const std::vector> &srcs) +{ + // Create reference + std::vector shapes; + + for(const auto &src : srcs) + { + shapes.emplace_back(src.shape()); + } + + DataType dst_type = srcs.empty() ? DataType::UNKNOWN : srcs[0].data_type(); + TensorShape dst_shape = calculate_depth_concatenate_shape(shapes); + SimpleTensor dst(dst_shape, dst_type); + + // Compute reference + int depth_offset = 0; + const int width_out = dst.shape().x(); + const int height_out = dst.shape().y(); + const int depth_out = dst.shape().z(); + const int out_stride_z = width_out * height_out; + const int batches = dst.shape().total_size_upper(3); + + // Set output tensor to 0 + std::fill_n(dst.data(), dst.num_elements(), 0); + + for(const auto &src : srcs) + { + ARM_COMPUTE_ERROR_ON(depth_offset >= depth_out); + ARM_COMPUTE_ERROR_ON(batches != static_cast(src.shape().total_size_upper(3))); + + const int width = src.shape().x(); + const int height = src.shape().y(); + const int depth = src.shape().z(); + const int x_diff = (width_out - width) / 2; + const int y_diff = (height_out - height) / 2; + + const T *src_ptr = src.data(); + + for(int b = 0; b < batches; ++b) + { + const size_t offset_to_first_element = b * out_stride_z * depth_out + depth_offset * out_stride_z + y_diff * width_out + x_diff; + + for(int d = 0; d < depth; ++d) + { + for(int r = 0; r < height; ++r) + { + std::copy(src_ptr, src_ptr + width, dst.data() + offset_to_first_element + d * out_stride_z + r * width_out); + src_ptr += width; + } + } + } + + depth_offset += depth; + } + + return dst; +} + +template SimpleTensor depthconcatenate_layer(const std::vector> &srcs); +template SimpleTensor depthconcatenate_layer(const std::vector> &srcs); +template SimpleTensor depthconcatenate_layer(const std::vector> &srcs); +template SimpleTensor depthconcatenate_layer(const std::vector> &srcs); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/DepthConcatenateLayer.h b/tests/validation/CPP/DepthConcatenateLayer.h new file mode 100644 index 0000000000..3c486a8015 --- /dev/null +++ b/tests/validation/CPP/DepthConcatenateLayer.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_H__ +#define __ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_H__ + +#include "tests/SimpleTensor.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor depthconcatenate_layer(const std::vector> &srcs); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_H__ */ diff --git a/tests/validation/CPP/DepthwiseConvolution.cpp b/tests/validation/CPP/DepthwiseConvolution.cpp new file mode 100644 index 0000000000..ebca333715 --- /dev/null +++ b/tests/validation/CPP/DepthwiseConvolution.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "DepthwiseConvolution.h" + +#include "ConvolutionLayer.h" +#include "Utils.h" + +#include "tests/validation/Helpers.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +/** Perform a depthwise convolution + * + * - Three dimensions tensors + * - Third dimention is number of channels + * - Depths of input tensor and filter are equals + * - Padding, stride and output shape "match" + * + */ +template +SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const TensorShape &dst_shape, const PadStrideInfo &conv_info) +{ + // Create reference + SimpleTensor dst{ dst_shape, src.data_type(), 1, src.fixed_point_position() }; + + // Compute reference + const size_t filter_width = weights.shape().x(); + const size_t filter_height = weights.shape().y(); + const size_t filter_plane = filter_width * filter_height; + const size_t input_width = src.shape().x(); + const size_t input_height = src.shape().y(); + const size_t input_depth = src.shape().z(); + + const size_t filter_half_size = filter_width / 2; + const size_t pad_x = std::min(filter_half_size, static_cast(conv_info.pad().first)); + const size_t pad_y = std::min(filter_half_size, static_cast(conv_info.pad().second)); + const size_t minimum_x = -pad_x + filter_half_size; + const size_t minimum_y = -pad_y + filter_half_size; + + int out_pos = 0; + for(size_t z = 0; z < input_depth; ++z) + { + for(size_t y = minimum_y; y < input_height + pad_y - filter_half_size; y += conv_info.stride().second) + { + for(size_t x = minimum_x; x < input_width + pad_x - filter_half_size; x += conv_info.stride().first) + { + Coordinates coords(static_cast(x), static_cast(y), static_cast(z)); + size_t filter_offset = filter_plane * z; + + T val = 0; + for(int j = y - filter_half_size; j <= static_cast(y + filter_half_size); ++j) + { + for(int i = x - filter_half_size; i <= static_cast(x + filter_half_size); ++i) + { + coords.set(0, i); + coords.set(1, j); + val += *(weights.data() + filter_offset) * tensor_elem_at(src, coords, BorderMode::CONSTANT, 0.f); + ++filter_offset; + } + } + coords.set(0, x); + coords.set(1, y); + dst[out_pos++] = saturate_cast(val); + } + } + } + + return dst; +} + +template SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const TensorShape &dst_shape, const PadStrideInfo &conv_info); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/DepthwiseConvolution.h b/tests/validation/CPP/DepthwiseConvolution.h new file mode 100644 index 0000000000..6be80fc07f --- /dev/null +++ b/tests/validation/CPP/DepthwiseConvolution.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_H__ +#define __ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_H__ + +#include "tests/SimpleTensor.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const TensorShape &dst_shape, const PadStrideInfo &conv_info); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_H__ */ diff --git a/tests/validation/CPP/DepthwiseSeparableConvolutionLayer.cpp b/tests/validation/CPP/DepthwiseSeparableConvolutionLayer.cpp new file mode 100644 index 0000000000..7020a854cf --- /dev/null +++ b/tests/validation/CPP/DepthwiseSeparableConvolutionLayer.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "DepthwiseConvolution.h" + +#include "DepthwiseSeparableConvolutionLayer.h" + +#include "ConvolutionLayer.h" +#include "Utils.h" + +#include "tests/validation/Helpers.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +// Depthwise separable convolution layer +template +SimpleTensor depthwise_separable_convolution_layer(const SimpleTensor &src, const SimpleTensor &depthwise_weights, const TensorShape &depthwise_out_shape, + const SimpleTensor &pointwise_weights, + const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info) +{ + // Compute reference + SimpleTensor depthwise_out = depthwise_convolution(src, depthwise_weights, depthwise_out_shape, depthwise_conv_info); + SimpleTensor dst = convolution_layer(depthwise_out, pointwise_weights, biases, dst_shape, pointwise_conv_info); + + return dst; +} + +template SimpleTensor depthwise_separable_convolution_layer(const SimpleTensor &in, const SimpleTensor &depthwise_weights, const TensorShape &depthwise_out_shape, + const SimpleTensor &pointwise_weights, const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/DepthwiseSeparableConvolutionLayer.h b/tests/validation/CPP/DepthwiseSeparableConvolutionLayer.h new file mode 100644 index 0000000000..71cd013424 --- /dev/null +++ b/tests/validation/CPP/DepthwiseSeparableConvolutionLayer.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_H__ +#define __ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_H__ + +#include "tests/SimpleTensor.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor depthwise_separable_convolution_layer(const SimpleTensor &src, const SimpleTensor &depthwise_weights, const TensorShape &depthwise_out_shape, + const SimpleTensor &pointwise_weights, + const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_H__ */ diff --git a/tests/validation/CPP/DequantizationLayer.cpp b/tests/validation/CPP/DequantizationLayer.cpp new file mode 100644 index 0000000000..1c7ec25255 --- /dev/null +++ b/tests/validation/CPP/DequantizationLayer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "DequantizationLayer.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template ::value, int>::type> +SimpleTensor dequantization_layer(const SimpleTensor &src, float min, float max) +{ + // Create reference + SimpleTensor dst{ src.shape(), DataType::F32 }; + + const float range = max - min; + const float scaling = range / 255.0f; + + for(int i = 0; i < src.num_elements(); ++i) + { + dst[i] = (static_cast(src[i]) * scaling) + min; + } + + return dst; +} + +template SimpleTensor dequantization_layer(const SimpleTensor &src, float min, float max); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/DequantizationLayer.h b/tests/validation/CPP/DequantizationLayer.h new file mode 100644 index 0000000000..3aae338116 --- /dev/null +++ b/tests/validation/CPP/DequantizationLayer.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_H__ +#define __ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_H__ + +#include "tests/SimpleTensor.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template ::value, int>::type = 0> +SimpleTensor dequantization_layer(const SimpleTensor &src, float min, float max); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_H__ */ diff --git a/tests/validation/CPP/Floor.cpp b/tests/validation/CPP/Floor.cpp new file mode 100644 index 0000000000..1c739448b7 --- /dev/null +++ b/tests/validation/CPP/Floor.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "Floor.h" + +#include "tests/validation/Helpers.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor floor_layer(const SimpleTensor &src) +{ + // Create reference + SimpleTensor dst{ src.shape(), src.data_type() }; + + // Compute reference + for(int i = 0; i < src.num_elements(); ++i) + { + dst[i] = std::floor(src[i]); + } + + return dst; +} + +template SimpleTensor floor_layer(const SimpleTensor &src); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/Floor.h b/tests/validation/CPP/Floor.h new file mode 100644 index 0000000000..d95ee303fc --- /dev/null +++ b/tests/validation/CPP/Floor.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_FLOOR_H__ +#define __ARM_COMPUTE_TEST_FLOOR_H__ + +#include "tests/SimpleTensor.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor floor_layer(const SimpleTensor &src); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_FLOOR_H__ */ diff --git a/tests/validation/CPP/FullyConnectedLayer.cpp b/tests/validation/CPP/FullyConnectedLayer.cpp new file mode 100644 index 0000000000..a146535bd9 --- /dev/null +++ b/tests/validation/CPP/FullyConnectedLayer.cpp @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "FullyConnectedLayer.h" + +#include "tests/validation/FixedPoint.h" +#include "tests/validation/half.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +namespace +{ +// Vector matrix multiply for floating point +template ::value, int>::type = 0> +void vector_matrix_multiply(const T *src, const T *weights, const T *bias, T *dst, int cols_weights, int rows_weights, uint8_t fixed_point_position) +{ + ARM_COMPUTE_UNUSED(fixed_point_position); + + for(int y = 0; y < rows_weights; ++y) + { + dst[y] = std::inner_product(src, src + cols_weights, weights, static_cast(0)) + bias[y]; + weights += cols_weights; + } +} + +// Vector matrix multiply for fixed point type +template ::value, int>::type = 0> +void vector_matrix_multiply(const T *src, const T *weights, const T *bias, T *dst, int cols_weights, int rows_weights, uint8_t fixed_point_position) +{ + using namespace fixed_point_arithmetic; + using promoted_type = fixed_point_arithmetic::traits::promote_t; + + for(int y = 0; y < rows_weights; ++y) + { + // Reset accumulator + fixed_point acc(0, fixed_point_position); + + for(int x = 0; x < cols_weights; ++x) + { + const fixed_point i_value(src[x], fixed_point_position, true); + const fixed_point w_value(weights[x], fixed_point_position, true); + acc = acc + i_value * w_value; + } + + // Get the bias + const fixed_point b(bias[y], fixed_point_position, true); + + // Convert back and accumulate the bias + fixed_point res(acc); + res = res + b; + + // Store the result + dst[y] = res.raw(); + + weights += cols_weights; + } +} +} // namespace + +template +SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &dst_shape) +{ + // Create reference + SimpleTensor dst{ TensorShape{ dst_shape }, src.data_type(), 1, src.fixed_point_position() }; + + // Sanity checks + const int num_batch_dimensions = std::max(0, static_cast(dst_shape.num_dimensions()) - 1); + const int num_input_dimensions = src.shape().num_dimensions() - num_batch_dimensions; + const unsigned int linear_input_size = src.shape().total_size_lower(num_input_dimensions); + + ARM_COMPUTE_UNUSED(num_batch_dimensions); + ARM_COMPUTE_UNUSED(num_input_dimensions); + ARM_COMPUTE_UNUSED(linear_input_size); + ARM_COMPUTE_ERROR_ON(weights.shape().x() != linear_input_size); + ARM_COMPUTE_ERROR_ON(weights.shape().y() != bias.shape().x()); + ARM_COMPUTE_ERROR_ON(weights.shape().y() != dst.shape().x()); + + // Compute reference + const int cols_weights = weights.shape().x(); + const int rows_weights = weights.shape().y(); + const int num_batches = dst_shape.total_size_upper(1); + + for(int k = 0; k < num_batches; ++k) + { + vector_matrix_multiply(src.data() + k * cols_weights, + weights.data(), + bias.data(), + dst.data() + k * rows_weights, + cols_weights, + rows_weights, + src.fixed_point_position()); + } + + return dst; +} + +template SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &dst_shape); +template SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, + const TensorShape &dst_shape); +template SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &dst_shape); +template SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &dst_shape); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/FullyConnectedLayer.h b/tests/validation/CPP/FullyConnectedLayer.h new file mode 100644 index 0000000000..05c570a2c0 --- /dev/null +++ b/tests/validation/CPP/FullyConnectedLayer.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_H__ +#define __ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_H__ + +#include "tests/SimpleTensor.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &dst_shape); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_H__ */ diff --git a/tests/validation/CPP/GEMM.cpp b/tests/validation/CPP/GEMM.cpp new file mode 100644 index 0000000000..9b66597eb8 --- /dev/null +++ b/tests/validation/CPP/GEMM.cpp @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "GEMM.h" + +#include "tests/validation/FixedPoint.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template ::value, int>::type> +SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta) +{ + // Create reference + SimpleTensor dst{ c.shape(), c.data_type(), 1, c.fixed_point_position() }; + + // Compute reference + const int M = dst.shape().y(); + const int N = dst.shape().x(); + const int K = a.shape().x(); + + for(int row = 0; row < M; ++row) + { + for(int col = 0; col < N; ++col) + { + T acc(0); + + for(int k = 0; k < K; ++k) + { + acc += a[row * K + k] * b[k * N + col]; + } + + // Finalize the result: alpha * A * B + beta * C + dst[col + row * N] = alpha * acc + beta * c[col + row * N]; + } + } + + return dst; +} + +template ::value, int>::type> +SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta) +{ + using namespace fixed_point_arithmetic; + + // Create reference + SimpleTensor dst{ c.shape(), c.data_type(), 1, c.fixed_point_position() }; + + // Compute reference + using promoted_type = fixed_point_arithmetic::traits::promote_t; + + const int M = dst.shape().y(); + const int N = dst.shape().x(); + const int K = a.shape().x(); + const int fixed_point_position = a.fixed_point_position(); + + const fixed_point alpha_q(alpha, fixed_point_position); + const fixed_point beta_q(beta, fixed_point_position); + + for(int row = 0; row < M; ++row) + { + for(int col = 0; col < N; ++col) + { + fixed_point acc_q(0, fixed_point_position); + + for(int k = 0; k < K; ++k) + { + const fixed_point a0_q(a[row * K + k], fixed_point_position, true); + const fixed_point b0_q(b[k * N + col], fixed_point_position, true); + + acc_q = acc_q + (a0_q * b0_q); + } + + // Finalize the result: alpha * A * B + beta * C + const fixed_point c0_q(c[col + row * N], fixed_point_position, true); + + fixed_point res_q(acc_q); + res_q = alpha_q * res_q; + res_q = res_q + (beta_q * c0_q); + + // Store the result + dst[col + row * N] = res_q.raw(); + } + } + + return dst; +} + +template SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); +template SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); +template SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); +template SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/GEMM.h b/tests/validation/CPP/GEMM.h new file mode 100644 index 0000000000..cda792bf8b --- /dev/null +++ b/tests/validation/CPP/GEMM.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_GEMM_H__ +#define __ARM_COMPUTE_TEST_GEMM_H__ + +#include "tests/SimpleTensor.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template ::value, int>::type = 0> +SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); + +template ::value, int>::type = 0> +SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_GEMM_H__ */ diff --git a/tests/validation/CPP/L2Normalize.cpp b/tests/validation/CPP/L2Normalize.cpp new file mode 100644 index 0000000000..4fb4d57eb4 --- /dev/null +++ b/tests/validation/CPP/L2Normalize.cpp @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "L2Normalize.h" +#include "ReductionOperation.h" + +#include "tests/validation/Helpers.h" + +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +namespace +{ +TensorShape get_output_shape(TensorShape shape, unsigned int axis) +{ + TensorShape output_shape(shape); + output_shape.set(axis, 1); + return output_shape; +} +} // namespace + +template +SimpleTensor l2_normalize(const SimpleTensor &src, unsigned int axis, float epsilon) +{ + // Create reference + SimpleTensor dst{ src.shape(), src.data_type() }; + + // Reduce across given axis + SimpleTensor sum = reduction_operation(src, get_output_shape(src.shape(), axis), axis, ReductionOperation::SUM_SQUARE); + + // Compute reference + const int elems = src.shape()[axis]; + const int upper_dims = src.shape().total_size_upper(axis + 1); + + for(int du = 0; du < upper_dims; ++du) + { + if(axis == 0) + { + const T *src_row_ptr = src.data() + du * elems; + T *dst_row_ptr = dst.data() + du * elems; + const T normalization_value = std::sqrt(std::max(sum[du], epsilon)); + std::transform(src_row_ptr, src_row_ptr + elems, dst_row_ptr, [normalization_value](T val) + { + return val / normalization_value; + }); + } + else + { + ARM_COMPUTE_ERROR("Unsupported normalization axis"); + } + } + + return dst; +} + +template SimpleTensor l2_normalize(const SimpleTensor &src, unsigned int axis, float epsilon); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/L2Normalize.h b/tests/validation/CPP/L2Normalize.h new file mode 100644 index 0000000000..1db3ae6174 --- /dev/null +++ b/tests/validation/CPP/L2Normalize.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_L2NORMALIZE_H__ +#define __ARM_COMPUTE_TEST_L2NORMALIZE_H__ + +#include "tests/SimpleTensor.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor l2_normalize(const SimpleTensor &src, unsigned int axis, float epsilon); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_L2NORMALIZE_H__ */ diff --git a/tests/validation/CPP/MeanStdDev.cpp b/tests/validation/CPP/MeanStdDev.cpp new file mode 100644 index 0000000000..4a39b13d56 --- /dev/null +++ b/tests/validation/CPP/MeanStdDev.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "MeanStdDev.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +std::pair mean_and_standard_deviation(const SimpleTensor &in) +{ + const int num_elements = in.num_elements(); + + // Calculate mean + float mean = std::accumulate(in.data(), in.data() + num_elements, 0.f) / num_elements; + + // Calculate standard deviation + float std_dev = std::accumulate(in.data(), in.data() + num_elements, 0.f, [&mean](float a, float b) + { + return a + (mean - b) * (mean - b); + }); + + std_dev = std::sqrt(std_dev / num_elements); + + return std::make_pair(mean, std_dev); +} + +template std::pair mean_and_standard_deviation(const SimpleTensor &in); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/MeanStdDev.h b/tests/validation/CPP/MeanStdDev.h new file mode 100644 index 0000000000..6b89ae0656 --- /dev/null +++ b/tests/validation/CPP/MeanStdDev.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_STD_MEAN_DEV_H__ +#define __ARM_COMPUTE_TEST_STD_MEAN_DEV_H__ + +#include "tests/SimpleTensor.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +std::pair mean_and_standard_deviation(const SimpleTensor &in); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_STD_MEAN_DEV_H__ */ diff --git a/tests/validation/CPP/NormalizationLayer.cpp b/tests/validation/CPP/NormalizationLayer.cpp new file mode 100644 index 0000000000..3c6f5e1a54 --- /dev/null +++ b/tests/validation/CPP/NormalizationLayer.cpp @@ -0,0 +1,275 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NormalizationLayer.h" + +#include "tests/validation/FixedPoint.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template ::value, int>::type> +SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info) +{ + // Create reference + SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; + + // Compute reference + const uint32_t norm_size = info.norm_size(); + NormType type = info.type(); + float beta = info.beta(); + uint32_t kappa = info.kappa(); + + const int cols = src.shape()[0]; + const int rows = src.shape()[1]; + const int depth = src.shape()[2]; + int upper_dims = src.shape().total_size() / (cols * rows); + + float coeff = info.scale_coeff(); + int radius_cols = norm_size / 2; + + // IN_MAP_1D and CROSS_MAP normalize over a single axis only + int radius_rows = (NormType::IN_MAP_2D == type) ? norm_size / 2 : 0; + + if(type == NormType::CROSS_MAP) + { + // Remove also depth from upper dimensions since it is the dimension we + // want to use for normalization + upper_dims /= depth; + + for(int r = 0; r < upper_dims; ++r) + { + for(int i = 0; i < rows; ++i) + { + for(int k = 0; k < cols; ++k) + { + for(int l = 0; l < depth; ++l) + { + float accumulated_scale = 0.f; + + for(int j = -radius_cols; j <= radius_cols; ++j) + { + const int z = l + j; + + if(z >= 0 && z < depth) + { + const T value = src[k + i * cols + z * rows * cols + r * cols * rows * depth]; + accumulated_scale += value * value; + } + } + + dst[k + i * cols + l * rows * cols + r * cols * rows * depth] = kappa + accumulated_scale * coeff; + } + } + } + } + } + else + { + for(int r = 0; r < upper_dims; ++r) + { + for(int i = 0; i < rows; ++i) + { + for(int k = 0; k < cols; ++k) + { + float accumulated_scale = 0.f; + + for(int j = -radius_rows; j <= radius_rows; ++j) + { + const int y = i + j; + for(int l = -radius_cols; l <= radius_cols; ++l) + { + const int x = k + l; + + if((x >= 0 && y >= 0) && (x < cols && y < rows)) + { + const T value = src[x + y * cols + r * cols * rows]; + accumulated_scale += value * value; + } + } + } + + dst[k + i * cols + r * cols * rows] = kappa + accumulated_scale * coeff; + } + } + } + } + + if(beta == 1.f) + { + for(int i = 0; i < dst.num_elements(); ++i) + { + dst[i] = src[i] / dst[i]; + } + } + else if(beta == 0.5f) + { + for(int i = 0; i < dst.num_elements(); ++i) + { + dst[i] = src[i] / std::sqrt(dst[i]); + } + } + else + { + for(int i = 0; i < dst.num_elements(); ++i) + { + dst[i] = src[i] * std::exp(std::log(dst[i]) * -beta); + } + } + + return dst; +} + +template ::value, int>::type> +SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info) +{ + using namespace fixed_point_arithmetic; + + // Create reference + SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; + + // Compute reference + const int fixed_point_position = src.fixed_point_position(); + + const uint32_t norm_size = info.norm_size(); + NormType type = info.type(); + fixed_point beta(info.beta(), fixed_point_position); + fixed_point kappa(info.kappa(), fixed_point_position); + + const int cols = src.shape()[0]; + const int rows = src.shape()[1]; + const int depth = src.shape()[2]; + int upper_dims = src.shape().total_size() / (cols * rows); + + fixed_point coeff(info.scale_coeff(), fixed_point_position); + int radius_cols = norm_size / 2; + + // IN_MAP_1D and CROSS_MAP normalize over a single axis only + int radius_rows = (NormType::IN_MAP_2D == type) ? norm_size / 2 : 0; + + if(type == NormType::CROSS_MAP) + { + // Remove also depth from upper dimensions since it is the dimension we + // want to use for normalization + upper_dims /= depth; + + for(int r = 0; r < upper_dims; ++r) + { + for(int i = 0; i < rows; ++i) + { + for(int k = 0; k < cols; ++k) + { + for(int l = 0; l < depth; ++l) + { + fixed_point accumulated_scale(0.f, fixed_point_position); + + for(int j = -radius_cols; j <= radius_cols; ++j) + { + const int z = l + j; + + if(z >= 0 && z < depth) + { + const T value = src[k + i * cols + z * rows * cols + r * cols * rows * depth]; + const fixed_point fp_value(value, fixed_point_position, true); + accumulated_scale = add(accumulated_scale, mul(fp_value, fp_value)); + } + } + + accumulated_scale = add(kappa, mul(accumulated_scale, coeff)); + dst[k + i * cols + l * rows * cols + r * cols * rows * depth] = accumulated_scale.raw(); + } + } + } + } + } + else + { + for(int r = 0; r < upper_dims; ++r) + { + for(int i = 0; i < rows; ++i) + { + for(int k = 0; k < cols; ++k) + { + fixed_point accumulated_scale(0.f, fixed_point_position); + + for(int j = -radius_rows; j <= radius_rows; ++j) + { + const int y = i + j; + + for(int l = -radius_cols; l <= radius_cols; ++l) + { + const int x = k + l; + + if((x >= 0 && y >= 0) && (x < cols && y < rows)) + { + const T value = src[x + y * cols + r * cols * rows]; + const fixed_point fp_value(value, fixed_point_position, true); + accumulated_scale = add(accumulated_scale, mul(fp_value, fp_value)); + } + } + } + + accumulated_scale = add(kappa, mul(accumulated_scale, coeff)); + dst[k + i * cols + r * cols * rows] = accumulated_scale.raw(); + } + } + } + } + + if(info.beta() == 1.f) + { + for(int i = 0; i < dst.num_elements(); ++i) + { + fixed_point res = div(fixed_point(src[i], fixed_point_position, true), fixed_point(dst[i], fixed_point_position, true)); + dst[i] = res.raw(); + } + } + else + { + const fixed_point beta(info.beta(), fixed_point_position); + + for(int i = 0; i < dst.num_elements(); ++i) + { + fixed_point res = pow(fixed_point(dst[i], fixed_point_position, true), beta); + res = div(fixed_point(src[i], fixed_point_position, true), res); + dst[i] = res.raw(); + } + } + + return dst; +} + +template SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); +template SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); +template SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); +template SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/NormalizationLayer.h b/tests/validation/CPP/NormalizationLayer.h new file mode 100644 index 0000000000..3f624ff30a --- /dev/null +++ b/tests/validation/CPP/NormalizationLayer.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_NORMALIZATION_LAYER_H__ +#define __ARM_COMPUTE_TEST_NORMALIZATION_LAYER_H__ + +#include "tests/SimpleTensor.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template ::value, int>::type = 0> +SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); + +template ::value, int>::type = 0> +SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_NORMALIZATION_LAYER_H__ */ diff --git a/tests/validation/CPP/PoolingLayer.cpp b/tests/validation/CPP/PoolingLayer.cpp new file mode 100644 index 0000000000..c4425ca9a1 --- /dev/null +++ b/tests/validation/CPP/PoolingLayer.cpp @@ -0,0 +1,243 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "PoolingLayer.h" + +#include "tests/validation/FixedPoint.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +namespace +{ +TensorShape calculate_output_shape(TensorShape shape, PoolingLayerInfo info) +{ + TensorShape dst_shape = shape; + const std::pair scaled_dims = arm_compute::scaled_dimensions(shape.x(), + shape.y(), + info.pool_size(), + info.pool_size(), + info.pad_stride_info()); + dst_shape.set(0, scaled_dims.first); + dst_shape.set(1, scaled_dims.second); + + return dst_shape; +} +} // namespace + +template ::value, int>::type> +SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info) +{ + const int pool_size = info.pool_size(); + PoolingType type = info.pool_type(); + int pool_stride_x = info.pad_stride_info().stride().first; + int pool_stride_y = info.pad_stride_info().stride().second; + int pad_x = info.pad_stride_info().pad().first; + int pad_y = info.pad_stride_info().pad().second; + + const auto w_src = static_cast(src.shape()[0]); + const auto h_src = static_cast(src.shape()[1]); + const int upper_dims = src.shape().total_size() / (w_src * h_src); + + // Create reference + SimpleTensor dst{ calculate_output_shape(src.shape(), info), src.data_type(), 1, src.fixed_point_position() }; + + const auto w_dst = static_cast(dst.shape()[0]); + const auto h_dst = static_cast(dst.shape()[1]); + + if(type == PoolingType::MAX) + { + for(int r = 0; r < upper_dims; ++r) + { + for(int h = 0; h < h_dst; ++h) + { + for(int w = 0; w < w_dst; ++w) + { + int wstart = w * pool_stride_x - pad_x; + int hstart = h * pool_stride_y - pad_y; + int wend = std::min(wstart + pool_size, w_src); + int hend = std::min(hstart + pool_size, h_src); + wstart = std::max(wstart, 0); + hstart = std::max(hstart, 0); + + T max_val = std::numeric_limits::lowest(); + for(int y = hstart; y < hend; ++y) + { + for(int x = wstart; x < wend; ++x) + { + const T val = src[r * h_src * w_src + y * w_src + x]; + if(val > max_val) + { + max_val = val; + } + } + } + + dst[r * h_dst * w_dst + h * w_dst + w] = max_val; + } + } + } + } + else // Average pooling + { + for(int r = 0; r < upper_dims; ++r) + { + for(int h = 0; h < h_dst; ++h) + { + for(int w = 0; w < w_dst; ++w) + { + T avg_val(0); + int wstart = w * pool_stride_x - pad_x; + int hstart = h * pool_stride_y - pad_y; + int wend = std::min(wstart + pool_size, w_src + pad_x); + int hend = std::min(hstart + pool_size, h_src + pad_y); + int pool = (hend - hstart) * (wend - wstart); + wstart = std::max(wstart, 0); + hstart = std::max(hstart, 0); + wend = std::min(wend, w_src); + hend = std::min(hend, h_src); + + for(int y = hstart; y < hend; ++y) + { + for(int x = wstart; x < wend; ++x) + { + avg_val += src[r * h_src * w_src + y * w_src + x]; + } + } + dst[r * h_dst * w_dst + h * w_dst + w] = avg_val / pool; + } + } + } + } + + return dst; +} + +template ::value, int>::type> +SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info) +{ + const int pool_size = info.pool_size(); + PoolingType type = info.pool_type(); + int pool_stride_x = info.pad_stride_info().stride().first; + int pool_stride_y = info.pad_stride_info().stride().second; + int pad_x = info.pad_stride_info().pad().first; + int pad_y = info.pad_stride_info().pad().second; + + const auto w_src = static_cast(src.shape()[0]); + const auto h_src = static_cast(src.shape()[1]); + const int upper_dims = src.shape().total_size() / (w_src * h_src); + + // Create reference + SimpleTensor dst{ calculate_output_shape(src.shape(), info), src.data_type(), 1, src.fixed_point_position() }; + + const auto w_dst = static_cast(dst.shape()[0]); + const auto h_dst = static_cast(dst.shape()[1]); + + if(type == PoolingType::MAX) + { + for(int r = 0; r < upper_dims; ++r) + { + for(int h = 0; h < h_dst; ++h) + { + for(int w = 0; w < w_dst; ++w) + { + int wstart = w * pool_stride_x - pad_x; + int hstart = h * pool_stride_y - pad_y; + int wend = std::min(wstart + pool_size, w_src); + int hend = std::min(hstart + pool_size, h_src); + wstart = std::max(wstart, 0); + hstart = std::max(hstart, 0); + + T max_val = std::numeric_limits::lowest(); + for(int y = hstart; y < hend; ++y) + { + for(int x = wstart; x < wend; ++x) + { + const T val = src[r * h_src * w_src + y * w_src + x]; + if(val > max_val) + { + max_val = val; + } + } + } + + dst[r * h_dst * w_dst + h * w_dst + w] = max_val; + } + } + } + } + else // Average pooling + { + for(int r = 0; r < upper_dims; ++r) + { + for(int h = 0; h < h_dst; ++h) + { + for(int w = 0; w < w_dst; ++w) + { + int wstart = w * pool_stride_x - pad_x; + int hstart = h * pool_stride_y - pad_y; + int wend = std::min(wstart + pool_size, w_src + pad_x); + int hend = std::min(hstart + pool_size, h_src + pad_y); + int pool = (hend - hstart) * (wend - wstart); + wstart = std::max(wstart, 0); + hstart = std::max(hstart, 0); + wend = std::min(wend, w_src); + hend = std::min(hend, h_src); + + using namespace fixed_point_arithmetic; + + const int fixed_point_position = src.fixed_point_position(); + const fixed_point invpool_fp(1.f / static_cast(pool), fixed_point_position); + fixed_point avg_val(0, fixed_point_position, true); + + for(int y = hstart; y < hend; ++y) + { + for(int x = wstart; x < wend; ++x) + { + const fixed_point in_fp(src[r * h_src * w_src + y * w_src + x], fixed_point_position, true); + avg_val = add(avg_val, in_fp); + } + } + dst[r * h_dst * w_dst + h * w_dst + w] = mul(avg_val, invpool_fp).raw(); + } + } + } + } + + return dst; +} + +template SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); +template SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); +template SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); +template SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/PoolingLayer.h b/tests/validation/CPP/PoolingLayer.h new file mode 100644 index 0000000000..334054a0eb --- /dev/null +++ b/tests/validation/CPP/PoolingLayer.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_POOLING_LAYER_H__ +#define __ARM_COMPUTE_TEST_POOLING_LAYER_H__ + +#include "tests/SimpleTensor.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template ::value, int>::type = 0> +SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); + +template ::value, int>::type = 0> +SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_POOLING_LAYER_H__ */ diff --git a/tests/validation/CPP/QuantizationLayer.cpp b/tests/validation/CPP/QuantizationLayer.cpp new file mode 100644 index 0000000000..d61e75a3a9 --- /dev/null +++ b/tests/validation/CPP/QuantizationLayer.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "QuantizationLayer.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +void compute_min_max(const SimpleTensor &src, float *min, float *max) +{ + // Set min and max to first pixel + float tmp_min = src[0]; + float tmp_max = src[0]; + + // Look for min and max values + for(int i = 1; i < src.num_elements(); ++i) + { + if(src[i] < tmp_min) + { + tmp_min = src[i]; + } + if(src[i] > tmp_max) + { + tmp_max = src[i]; + } + } + + *min = tmp_min; + *max = tmp_max; +} + +template ::value, int>::type> +SimpleTensor quantization_layer(const SimpleTensor &src) +{ + // Create reference + SimpleTensor dst{ src.shape(), DataType::U8 }; + + // Compute min and max of the tensor using Min-Max layer + float min = 0.f; + float max = 0.f; + + compute_min_max(src, &min, &max); + + const float range = max - min; + + for(int i = 0; i < src.num_elements(); ++i) + { + // map values to range [0.0, 1.0] + const float normalized = (src[i] - min) / range; + dst[i] = static_cast(std::min(255.0f, normalized * 256.0f)); + } + + return dst; +} + +template SimpleTensor quantization_layer(const SimpleTensor &src); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/QuantizationLayer.h b/tests/validation/CPP/QuantizationLayer.h new file mode 100644 index 0000000000..7c5572ccf8 --- /dev/null +++ b/tests/validation/CPP/QuantizationLayer.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_QUANTIZATION_LAYER_H__ +#define __ARM_COMPUTE_TEST_QUANTIZATION_LAYER_H__ + +#include "tests/SimpleTensor.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template ::value, int>::type = 0> +SimpleTensor quantization_layer(const SimpleTensor &src); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_QUANTIZATION_LAYER_H__ */ diff --git a/tests/validation/CPP/ReductionOperation.cpp b/tests/validation/CPP/ReductionOperation.cpp new file mode 100644 index 0000000000..acfcc09cea --- /dev/null +++ b/tests/validation/CPP/ReductionOperation.cpp @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "ReductionOperation.h" + +#include "tests/validation/Helpers.h" + +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +namespace +{ +template +struct square +{ + T operator()(const T &lhs, const T &rhs) const + { + return (lhs + rhs * rhs); + } +}; + +template +T reduce_operation(T *ptr, int reduce_elements, ReductionOperation op) +{ + switch(op) + { + case ReductionOperation::SUM_SQUARE: + return std::accumulate(ptr, ptr + reduce_elements, 0.f, square()); + default: + ARM_COMPUTE_ERROR("Unsupported reduction operation"); + } +} +} // namespace + +template +SimpleTensor reduction_operation(const SimpleTensor &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op) +{ + // Create reference + SimpleTensor dst{ dst_shape, src.data_type() }; + + // Compute reference + const int reduce_elems = src.shape()[axis]; + const int upper_dims = src.shape().total_size_upper(axis + 1); + + for(int du = 0; du < upper_dims; ++du) + { + if(axis == 0) + { + const T *src_row_ptr = src.data() + du * reduce_elems; + dst[du] = reduce_operation(src_row_ptr, reduce_elems, op); + } + else + { + ARM_COMPUTE_ERROR("Unsupported reduction axis"); + } + } + + return dst; +} + +template SimpleTensor reduction_operation(const SimpleTensor &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/ReductionOperation.h b/tests/validation/CPP/ReductionOperation.h new file mode 100644 index 0000000000..6da6436686 --- /dev/null +++ b/tests/validation/CPP/ReductionOperation.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_REDUCTION_OPERATION_H__ +#define __ARM_COMPUTE_TEST_REDUCTION_OPERATION_H__ + +#include "tests/SimpleTensor.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor reduction_operation(const SimpleTensor &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_FLOOR_H__ */ diff --git a/tests/validation/CPP/Scale.cpp b/tests/validation/CPP/Scale.cpp new file mode 100644 index 0000000000..a1119f33b9 --- /dev/null +++ b/tests/validation/CPP/Scale.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "arm_compute/core/Helpers.h" + +#include "Scale.h" +#include "Utils.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor scale(const SimpleTensor &in, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) +{ + TensorShape shape_scaled(in.shape()); + shape_scaled.set(0, in.shape()[0] * scale_x); + shape_scaled.set(1, in.shape()[1] * scale_y); + SimpleTensor out(shape_scaled, in.data_type()); + + // Compute the ratio between source width/height and destination width/height + const auto wr = static_cast(in.shape()[0]) / static_cast(out.shape()[0]); + const auto hr = static_cast(in.shape()[1]) / static_cast(out.shape()[1]); + + const auto width = static_cast(in.shape().x()); + const auto height = static_cast(in.shape().y()); + + // Area interpolation behaves as Nearest Neighbour in case of up-sampling + if(policy == InterpolationPolicy::AREA && wr <= 1.f && hr <= 1.f) + { + policy = InterpolationPolicy::NEAREST_NEIGHBOR; + } + + for(int element_idx = 0, count = 0; element_idx < out.num_elements(); ++element_idx, ++count) + { + Coordinates id = index2coord(out.shape(), element_idx); + int idx = id.x(); + int idy = id.y(); + float x_src = (idx + 0.5f) * wr - 0.5f; + float y_src = (idy + 0.5f) * hr - 0.5f; + + switch(policy) + { + case InterpolationPolicy::NEAREST_NEIGHBOR: + { + //Calculate the source coords without -0.5f is equivalent to round the x_scr/y_src coords + x_src = (idx + 0.5f) * wr; + y_src = (idy + 0.5f) * hr; + id.set(0, x_src); + id.set(1, y_src); + + // If coordinates in range of tensor's width or height + if(x_src >= -1 || y_src >= -1 || x_src <= width || y_src <= height) + { + out[element_idx] = tensor_elem_at(in, id, border_mode, constant_border_value); + } + else + { + if(border_mode == BorderMode::CONSTANT) + { + out[element_idx] = constant_border_value; + } + else if(border_mode == BorderMode::REPLICATE) + { + id.set(0, clamp(static_cast(x_src), 0, width - 1)); + id.set(1, clamp(static_cast(y_src), 0, height - 1)); + out[element_idx] = in[coord2index(in.shape(), id)]; + } + } + break; + } + case InterpolationPolicy::BILINEAR: + { + id.set(0, std::floor(x_src)); + id.set(1, std::floor(y_src)); + if(x_src >= -1 || y_src >= -1 || x_src <= width || y_src <= height) + { + out[element_idx] = bilinear_policy(in, id, x_src, y_src, border_mode, constant_border_value); + } + else + { + if(border_mode == BorderMode::CONSTANT) + { + out[element_idx] = constant_border_value; + } + else if(border_mode == BorderMode::REPLICATE) + { + id.set(0, clamp(static_cast(x_src), 0, width - 1)); + id.set(1, clamp(static_cast(y_src), 0, height - 1)); + out[element_idx] = in[coord2index(in.shape(), id)]; + } + } + break; + } + case InterpolationPolicy::AREA: + { + int x_from = std::floor(idx * wr - 0.5f - x_src); + int y_from = std::floor(idy * hr - 0.5f - y_src); + int x_to = std::ceil((idx + 1) * wr - 0.5f - x_src); + int y_to = std::ceil((idy + 1) * hr - 0.5f - y_src); + const int xi = std::floor(x_src); + const int yi = std::floor(y_src); + + // Clamp position to borders + x_src = std::max(-1.f, std::min(x_src, static_cast(width))); + y_src = std::max(-1.f, std::min(y_src, static_cast(height))); + + // Clamp bounding box offsets to borders + x_from = ((x_src + x_from) < -1) ? -1 : x_from; + y_from = ((y_src + y_from) < -1) ? -1 : y_from; + x_to = ((x_src + x_to) > width) ? (width - x_src) : x_to; + y_to = ((y_src + y_to) > height) ? (height - y_src) : y_to; + ARM_COMPUTE_ERROR_ON((x_to - x_from + 1) == 0 || (y_to - y_from + 1) == 0); + + float sum = 0; + for(int j = yi + y_from, je = yi + y_to; j <= je; ++j) + { + for(int i = xi + x_from, ie = xi + x_to; i <= ie; ++i) + { + id.set(0, static_cast(i)); + id.set(1, static_cast(j)); + sum += tensor_elem_at(in, id, border_mode, constant_border_value); + } + } + out[element_idx] = sum / ((x_to - x_from + 1) * (y_to - y_from + 1)); + + break; + } + default: + ARM_COMPUTE_ERROR("Unsupported interpolation mode"); + } + } + + return out; +} + +template SimpleTensor scale(const SimpleTensor &src, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute \ No newline at end of file diff --git a/tests/validation/CPP/Scale.h b/tests/validation/CPP/Scale.h new file mode 100644 index 0000000000..b882915946 --- /dev/null +++ b/tests/validation/CPP/Scale.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_SCALE_H__ +#define __ARM_COMPUTE_TEST_SCALE_H__ + +#include "tests/SimpleTensor.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor scale(const SimpleTensor &in, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value = 0); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_SCALE_H__ */ diff --git a/tests/validation/CPP/SoftmaxLayer.cpp b/tests/validation/CPP/SoftmaxLayer.cpp new file mode 100644 index 0000000000..4fe87d07dc --- /dev/null +++ b/tests/validation/CPP/SoftmaxLayer.cpp @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "SoftmaxLayer.h" + +#include "tests/validation/FixedPoint.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template ::value, int>::type> +SimpleTensor softmax_layer(const SimpleTensor &src) +{ + // Create reference + SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; + + // Compute reference + const int cols = src.shape()[0]; + const int upper_dims = src.num_elements() / cols; + + for(int r = 0; r < upper_dims; ++r) + { + const T *src_row_ptr = src.data() + r * cols; + T *dst_row_ptr = dst.data() + r * cols; + + // Find max + const T max = *std::max_element(src_row_ptr, src_row_ptr + cols); + + // Regularize + T sum(0.f); + std::transform(src_row_ptr, src_row_ptr + cols, dst_row_ptr, [&sum, max](T val) + { + const T res(std::exp(val - max)); + sum += res; + return res; + }); + + // Normalize + std::transform(dst_row_ptr, dst_row_ptr + cols, dst_row_ptr, [sum](T val) + { + return val / sum; + }); + } + + return dst; +} + +template ::value, int>::type> +SimpleTensor softmax_layer(const SimpleTensor &src) +{ + using namespace fixed_point_arithmetic; + + // Create reference + SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; + + // Compute reference + const int cols = src.shape()[0]; + const int upper_dims = src.num_elements() / cols; + + for(int r = 0; r < upper_dims; ++r) + { + const T *src_row_ptr = src.data() + r * cols; + T *dst_row_ptr = dst.data() + r * cols; + + // Find max + const fixed_point max(*std::max_element(src_row_ptr, src_row_ptr + cols), src.fixed_point_position(), true); + + // Regularize + using promoted_type = fixed_point_arithmetic::traits::promote_t; + fixed_point sum(0, src.fixed_point_position(), true); + std::transform(src_row_ptr, src_row_ptr + cols, dst_row_ptr, [&](T val) + { + const fixed_point res = exp(fixed_point(val, src.fixed_point_position(), true) - max); + sum = add(sum, fixed_point(res.raw(), src.fixed_point_position(), true)); + return res.raw(); + }); + + // Normalize + fixed_point saturated_sum(sum); + std::transform(dst_row_ptr, dst_row_ptr + cols, dst_row_ptr, [&](T val) + { + return div(fixed_point(val, src.fixed_point_position(), true), saturated_sum).raw(); + }); + } + + return dst; +} + +template SimpleTensor softmax_layer(const SimpleTensor &src); +template SimpleTensor softmax_layer(const SimpleTensor &src); +template SimpleTensor softmax_layer(const SimpleTensor &src); +template SimpleTensor softmax_layer(const SimpleTensor &src); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/SoftmaxLayer.h b/tests/validation/CPP/SoftmaxLayer.h new file mode 100644 index 0000000000..ab79bc4850 --- /dev/null +++ b/tests/validation/CPP/SoftmaxLayer.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_SOFTMAX_LAYER_H__ +#define __ARM_COMPUTE_TEST_SOFTMAX_LAYER_H__ + +#include "tests/SimpleTensor.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template ::value, int>::type = 0> +SimpleTensor softmax_layer(const SimpleTensor &src); + +template ::value, int>::type = 0> +SimpleTensor softmax_layer(const SimpleTensor &src); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_SOFTMAX_LAYER_H__ */ diff --git a/tests/validation/CPP/Utils.cpp b/tests/validation/CPP/Utils.cpp new file mode 100644 index 0000000000..05443eabae --- /dev/null +++ b/tests/validation/CPP/Utils.cpp @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "Utils.h" + +#include "tests/validation/Helpers.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +// Return a tensor element at a specified coordinate with different border modes +template +T tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, T constant_border_value) +{ + const int x = coord.x(); + const int y = coord.y(); + const auto width = static_cast(in.shape().x()); + const auto height = static_cast(in.shape().y()); + + // If coordinates beyond range of tensor's width or height + if(x < 0 || y < 0 || x >= width || y >= height) + { + if(border_mode == BorderMode::REPLICATE) + { + coord.set(0, std::max(0, std::min(x, width - 1))); + coord.set(1, std::max(0, std::min(y, height - 1))); + } + else + { + return constant_border_value; + } + } + return in[coord2index(in.shape(), coord)]; +} +template float tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, float constant_border_value); +template uint8_t tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, uint8_t constant_border_value); + +// Return the bilinear value at a specified coordinate with different border modes +template +T bilinear_policy(const SimpleTensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value) +{ + int idx = std::floor(xn); + int idy = std::floor(yn); + + const float dx = xn - idx; + const float dy = yn - idy; + const float dx_1 = 1.0f - dx; + const float dy_1 = 1.0f - dy; + + id.set(0, idx); + id.set(1, idy); + const T tl = tensor_elem_at(in, id, border_mode, constant_border_value); + id.set(0, idx + 1); + id.set(1, idy); + const T tr = tensor_elem_at(in, id, border_mode, constant_border_value); + id.set(0, idx); + id.set(1, idy + 1); + const T bl = tensor_elem_at(in, id, border_mode, constant_border_value); + id.set(0, idx + 1); + id.set(1, idy + 1); + const T br = tensor_elem_at(in, id, border_mode, constant_border_value); + + return tl * (dx_1 * dy_1) + tr * (dx * dy_1) + bl * (dx_1 * dy) + br * (dx * dy); +} +template uint8_t bilinear_policy(const SimpleTensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value); + +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/Utils.h b/tests/validation/CPP/Utils.h new file mode 100644 index 0000000000..5e9ec822a5 --- /dev/null +++ b/tests/validation/CPP/Utils.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_VALIDATION_UTILS_H__ +#define __ARM_COMPUTE_TEST_VALIDATION_UTILS_H__ + +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/ILutAccessor.h" +#include "tests/Types.h" + +#include +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +T tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, T constant_border_value); + +template +T bilinear_policy(const SimpleTensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value); +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_VALIDATION_UTILS_H__ */ diff --git a/tests/validation/Datasets.h b/tests/validation/Datasets.h deleted file mode 100644 index 15e1b098e6..0000000000 --- a/tests/validation/Datasets.h +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_VALIDATION_DATASETS_H__ -#define __ARM_COMPUTE_TEST_VALIDATION_DATASETS_H__ - -#include "dataset/ActivationFunctionDataset.h" -#include "dataset/BatchNormalizationLayerDataset.h" -#include "dataset/BorderModeDataset.h" -#include "dataset/ConvertPolicyDataset.h" -#include "dataset/ConvolutionLayerDataset.h" -#include "dataset/DataTypeDatasets.h" -#include "dataset/FullyConnectedLayerDataset.h" -#include "dataset/GEMMDataset.h" -#include "dataset/ImageDatasets.h" -#include "dataset/InterpolationPolicyDataset.h" -#include "dataset/MatrixPatternDataset.h" -#include "dataset/NonLinearFilterFunctionDataset.h" -#include "dataset/NormalizationTypeDataset.h" -#include "dataset/PoolingTypesDataset.h" -#include "dataset/RoundingPolicyDataset.h" -#include "dataset/ShapeDatasets.h" -#include "dataset/ThresholdDataset.h" - -#include "boost_wrapper.h" - -using namespace boost::unit_test::data::monomorphic; - -namespace boost -{ -namespace unit_test -{ -namespace data -{ -namespace monomorphic -{ -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; -} -} -} -} -#endif /* __ARM_COMPUTE_TEST_VALIDATION_DATASETS_H__ */ diff --git a/tests/validation/FixedPoint.h b/tests/validation/FixedPoint.h index 12ffcdfc3d..9691e2a037 100644 --- a/tests/validation/FixedPoint.h +++ b/tests/validation/FixedPoint.h @@ -24,8 +24,8 @@ #ifndef __ARM_COMPUTE_TEST_VALIDATION_FIXEDPOINT_H__ #define __ARM_COMPUTE_TEST_VALIDATION_FIXEDPOINT_H__ -#include "Utils.h" #include "support/ToolchainSupport.h" +#include "tests/Utils.h" #include #include @@ -63,6 +63,8 @@ template <> struct promote { using type = uint64_t; }; template <> struct promote { using type = int64_t; }; template <> struct promote { using type = uint64_t; }; template <> struct promote { using type = int64_t; }; +template +using promote_t = typename promote::type; // clang-format on // *INDENT-ON* } @@ -88,10 +90,6 @@ public: // Static Checks static_assert(std::is_integral::value, "Type is not an integer"); - // Friends - friend struct detail::functions; - friend struct detail::constant_expr; - /** Constructor (from different fixed point type) * * @param[in] val Fixed point @@ -387,7 +385,7 @@ struct functions template static bool signbit(fixed_point x) { - return ((x._value >> std::numeric_limits::digits) != 0); + return ((x.raw() >> std::numeric_limits::digits) != 0); } /** Checks if two fixed point numbers are equal * @@ -399,10 +397,10 @@ struct functions template static bool isequal(fixed_point x, fixed_point y) { - uint8_t p = std::min(x._fixed_point_position, y._fixed_point_position); + uint8_t p = std::min(x.precision(), y.precision()); x.rescale(p); y.rescale(p); - return (x._value == y._value); + return (x.raw() == y.raw()); } /** Checks if two fixed point number are not equal * @@ -426,10 +424,10 @@ struct functions template static bool isgreater(fixed_point x, fixed_point y) { - uint8_t p = std::min(x._fixed_point_position, y._fixed_point_position); + uint8_t p = std::min(x.precision(), y.precision()); x.rescale(p); y.rescale(p); - return (x._value > y._value); + return (x.raw() > y.raw()); } /** Checks if one fixed point is greater or equal than the other * @@ -441,10 +439,10 @@ struct functions template static bool isgreaterequal(fixed_point x, fixed_point y) { - uint8_t p = std::min(x._fixed_point_position, y._fixed_point_position); + uint8_t p = std::min(x.precision(), y.precision()); x.rescale(p); y.rescale(p); - return (x._value >= y._value); + return (x.raw() >= y.raw()); } /** Checks if one fixed point is less than the other * @@ -456,10 +454,10 @@ struct functions template static bool isless(fixed_point x, fixed_point y) { - uint8_t p = std::min(x._fixed_point_position, y._fixed_point_position); + uint8_t p = std::min(x.precision(), y.precision()); x.rescale(p); y.rescale(p); - return (x._value < y._value); + return (x.raw() < y.raw()); } /** Checks if one fixed point is less or equal than the other * @@ -471,10 +469,10 @@ struct functions template static bool islessequal(fixed_point x, fixed_point y) { - uint8_t p = std::min(x._fixed_point_position, y._fixed_point_position); + uint8_t p = std::min(x.precision(), y.precision()); x.rescale(p); y.rescale(p); - return (x._value <= y._value); + return (x.raw() <= y.raw()); } /** Checks if one fixed point is less or greater than the other * @@ -499,7 +497,7 @@ struct functions template static fixed_point clamp(fixed_point x, T min, T max) { - return fixed_point(constant_expr::clamp(x._value, min, max), x._fixed_point_position, true); + return fixed_point(constant_expr::clamp(x.raw(), min, max), x.precision(), true); } /** Negate number * @@ -511,12 +509,12 @@ struct functions static fixed_point negate(fixed_point x) { using promoted_T = typename traits::promote::type; - promoted_T val = -x._value; + promoted_T val = -x.raw(); if(OP == OverflowPolicy::SATURATE) { val = constant_expr::saturate_cast(val); } - return fixed_point(static_cast(val), x._fixed_point_position, true); + return fixed_point(static_cast(val), x.precision(), true); } /** Perform addition among two fixed point numbers * @@ -528,19 +526,19 @@ struct functions template static fixed_point add(fixed_point x, fixed_point y) { - uint8_t p = std::min(x._fixed_point_position, y._fixed_point_position); + uint8_t p = std::min(x.precision(), y.precision()); x.rescale(p); y.rescale(p); if(OP == OverflowPolicy::SATURATE) { using type = typename traits::promote::type; - type val = static_cast(x._value) + static_cast(y._value); + type val = static_cast(x.raw()) + static_cast(y.raw()); val = constant_expr::saturate_cast(val); return fixed_point(static_cast(val), p, true); } else { - return fixed_point(x._value + y._value, p, true); + return fixed_point(x.raw() + y.raw(), p, true); } } /** Perform subtraction among two fixed point numbers @@ -553,19 +551,19 @@ struct functions template static fixed_point sub(fixed_point x, fixed_point y) { - uint8_t p = std::min(x._fixed_point_position, y._fixed_point_position); + uint8_t p = std::min(x.precision(), y.precision()); x.rescale(p); y.rescale(p); if(OP == OverflowPolicy::SATURATE) { using type = typename traits::promote::type; - type val = static_cast(x._value) - static_cast(y._value); + type val = static_cast(x.raw()) - static_cast(y.raw()); val = constant_expr::saturate_cast(val); return fixed_point(static_cast(val), p, true); } else { - return fixed_point(x._value - y._value, p, true); + return fixed_point(x.raw() - y.raw(), p, true); } } /** Perform multiplication among two fixed point numbers @@ -579,10 +577,10 @@ struct functions static fixed_point mul(fixed_point x, fixed_point y) { using promoted_T = typename traits::promote::type; - uint8_t p_min = std::min(x._fixed_point_position, y._fixed_point_position); - uint8_t p_max = std::max(x._fixed_point_position, y._fixed_point_position); + uint8_t p_min = std::min(x.precision(), y.precision()); + uint8_t p_max = std::max(x.precision(), y.precision()); promoted_T round_factor = (1 << (p_max - 1)); - promoted_T val = ((static_cast(x._value) * static_cast(y._value)) + round_factor) >> p_max; + promoted_T val = ((static_cast(x.raw()) * static_cast(y.raw())) + round_factor) >> p_max; if(OP == OverflowPolicy::SATURATE) { val = constant_expr::saturate_cast(val); @@ -600,11 +598,11 @@ struct functions static fixed_point div(fixed_point x, fixed_point y) { using promoted_T = typename traits::promote::type; - uint8_t p = std::min(x._fixed_point_position, y._fixed_point_position); - promoted_T denom = static_cast(y._value); + uint8_t p = std::min(x.precision(), y.precision()); + promoted_T denom = static_cast(y.raw()); if(denom != 0) { - promoted_T val = (static_cast(x._value) << std::max(x._fixed_point_position, y._fixed_point_position)) / denom; + promoted_T val = (static_cast(x.raw()) << std::max(x.precision(), y.precision())) / denom; if(OP == OverflowPolicy::SATURATE) { val = constant_expr::saturate_cast(val); @@ -613,7 +611,7 @@ struct functions } else { - T val = (x._value < 0) ? std::numeric_limits::min() : std::numeric_limits::max(); + T val = (x.raw() < 0) ? std::numeric_limits::min() : std::numeric_limits::max(); return fixed_point(val, p, true); } } @@ -628,12 +626,12 @@ struct functions static fixed_point shift_left(fixed_point x, size_t shift) { using promoted_T = typename traits::promote::type; - promoted_T val = static_cast(x._value) << shift; + promoted_T val = static_cast(x.raw()) << shift; if(OP == OverflowPolicy::SATURATE) { val = constant_expr::saturate_cast(val); } - return fixed_point(static_cast(val), x._fixed_point_position, true); + return fixed_point(static_cast(val), x.precision(), true); } /** Shift right * @@ -645,7 +643,7 @@ struct functions template static fixed_point shift_right(fixed_point x, size_t shift) { - return fixed_point(x._value >> shift, x._fixed_point_position, true); + return fixed_point(x.raw() >> shift, x.precision(), true); } /** Calculate absolute value * @@ -657,8 +655,8 @@ struct functions static fixed_point abs(fixed_point x) { using promoted_T = typename traits::promote::type; - T val = (x._value < 0) ? constant_expr::saturate_cast(-static_cast(x._value)) : x._value; - return fixed_point(val, x._fixed_point_position, true); + T val = (x.raw() < 0) ? constant_expr::saturate_cast(-static_cast(x.raw())) : x.raw(); + return fixed_point(val, x.precision(), true); } /** Calculate the logarithm of a fixed point number * @@ -669,7 +667,7 @@ struct functions template static fixed_point log(fixed_point x) { - uint8_t p = x._fixed_point_position; + uint8_t p = x.precision(); auto const_one = fixed_point(static_cast(1), p); // Logarithm of 1 is zero and logarithm of negative values is not defined in R, so return 0. @@ -684,7 +682,7 @@ struct functions } // Remove even powers of 2 - T shift_val = 31 - __builtin_clz(x._value >> p); + T shift_val = 31 - __builtin_clz(x.raw() >> p); x = shift_right(x, shift_val); x = sub(x, const_one); @@ -716,7 +714,7 @@ struct functions template static fixed_point exp(fixed_point x) { - uint8_t p = x._fixed_point_position; + uint8_t p = x.precision(); // Constants auto const_one = fixed_point(1, p); auto ln2 = fixed_point(0.6931471, p); @@ -726,7 +724,7 @@ struct functions auto C = fixed_point(0.1763723, p); auto D = fixed_point(0.0435108, p); - T scaled_int_part = detail::constant_expr::to_int(mul(x, inv_ln2)._value, p); + T scaled_int_part = detail::constant_expr::to_int(mul(x, inv_ln2).raw(), p); // Polynomial expansion auto frac_part = sub(x, mul(ln2, fixed_point(scaled_int_part, p))); @@ -753,8 +751,8 @@ struct functions template static fixed_point inv_sqrt(fixed_point x) { - const uint8_t p = x._fixed_point_position; - int8_t shift = std::numeric_limits::digits - (p + detail::clz(x._value)); + const uint8_t p = x.precision(); + int8_t shift = std::numeric_limits::digits - (p + detail::clz(x.raw())); shift += std::numeric_limits::is_signed ? 1 : 0; @@ -784,7 +782,7 @@ struct functions template static fixed_point tanh(fixed_point x) { - uint8_t p = x._fixed_point_position; + uint8_t p = x.precision(); // Constants auto const_one = fixed_point(1, p); auto const_two = fixed_point(2, p); diff --git a/tests/validation/Helpers.cpp b/tests/validation/Helpers.cpp new file mode 100644 index 0000000000..d3bcbbd9e4 --- /dev/null +++ b/tests/validation/Helpers.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TensorShape calculate_depth_concatenate_shape(const std::vector &input_shapes) +{ + ARM_COMPUTE_ERROR_ON(input_shapes.empty()); + + TensorShape out_shape = input_shapes[0]; + + size_t max_x = 0; + size_t max_y = 0; + size_t depth = 0; + + for(const auto &shape : input_shapes) + { + max_x = std::max(shape.x(), max_x); + max_y = std::max(shape.y(), max_y); + depth += shape.z(); + } + + out_shape.set(0, max_x); + out_shape.set(1, max_y); + out_shape.set(2, depth); + + return out_shape; +} +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/Helpers.h b/tests/validation/Helpers.h index 19a0c4105c..30959161bb 100644 --- a/tests/validation/Helpers.h +++ b/tests/validation/Helpers.h @@ -25,18 +25,12 @@ #define __ARM_COMPUTE_TEST_VALIDATION_HELPERS_H__ #include "arm_compute/core/Types.h" -#include "tests/Globals.h" -#include "tests/ILutAccessor.h" -#include "tests/Types.h" -#include "tests/validation/ValidationUserConfiguration.h" +#include "arm_compute/core/Utils.h" #include "tests/validation/half.h" -#include -#include #include #include #include -#include namespace arm_compute { @@ -44,158 +38,95 @@ namespace test { namespace validation { -/** Helper function to fill one or more tensors with the uniform distribution with int values. - * - * @param[in] dist Distribution to be used to get the values for the tensor. - * @param[in] seeds List of seeds to be used to fill each tensor. - * @param[in,out] tensor Tensor to be initialized with the values of the distribution. - * @param[in,out] other_tensors (Optional) One or more tensors to be filled. - * - */ -template -void fill_tensors(D &&dist, std::initializer_list seeds, T &&tensor, Ts &&... other_tensors) +template +struct is_floating_point : public std::is_floating_point { - const std::array < T, 1 + sizeof...(Ts) > tensors{ { std::forward(tensor), std::forward(other_tensors)... } }; - std::vector vs(seeds); - ARM_COMPUTE_ERROR_ON(vs.size() != tensors.size()); - int k = 0; - for(auto tp : tensors) - { - library->fill(*tp, std::forward(dist), vs[k++]); - } -} +}; + +template <> +struct is_floating_point : public std::true_type +{ +}; /** Helper function to get the testing range for each activation layer. * * @param[in] activation Activation function to test. - * @param[in] fixed_point_position (Optional) Number of bits for the fractional part. Defaults to 1. + * @param[in] data_type Data type. + * @param[in] fixed_point_position Number of bits for the fractional part. Defaults to 1. * * @return A pair containing the lower upper testing bounds for a given function. */ template -inline std::pair get_activation_layer_test_bounds(ActivationLayerInfo::ActivationFunction activation, int fixed_point_position = 1) +std::pair get_activation_layer_test_bounds(ActivationLayerInfo::ActivationFunction activation, DataType data_type, int fixed_point_position = 0) { - bool is_float = std::is_same::value; - is_float = is_float || std::is_same::value; - std::pair bounds; - // Set initial values - if(is_float) - { - bounds = std::make_pair(-255.f, 255.f); - } - else + switch(data_type) { - bounds = std::make_pair(std::numeric_limits::lowest(), std::numeric_limits::max()); - } + case DataType::F16: + { + using namespace half_float::literal; - // Reduce testing ranges - switch(activation) - { - case ActivationLayerInfo::ActivationFunction::LOGISTIC: - case ActivationLayerInfo::ActivationFunction::SOFT_RELU: - // Reduce range as exponent overflows - if(is_float) + switch(activation) { - bounds.first = -40.f; - bounds.second = 40.f; - } - else - { - bounds.first = -(1 << (fixed_point_position)); - bounds.second = 1 << (fixed_point_position); + case ActivationLayerInfo::ActivationFunction::SQUARE: + case ActivationLayerInfo::ActivationFunction::LOGISTIC: + case ActivationLayerInfo::ActivationFunction::SOFT_RELU: + // Reduce range as exponent overflows + bounds = std::make_pair(-10._h, 10._h); + break; + case ActivationLayerInfo::ActivationFunction::SQRT: + // Reduce range as sqrt should take a non-negative number + bounds = std::make_pair(0._h, 255._h); + break; + default: + bounds = std::make_pair(-255._h, 255._h); + break; } break; - case ActivationLayerInfo::ActivationFunction::TANH: - // Reduce range as exponent overflows - if(!is_float) + } + case DataType::F32: + switch(activation) { - bounds.first = -(1 << (fixed_point_position)); - bounds.second = 1 << (fixed_point_position); + case ActivationLayerInfo::ActivationFunction::LOGISTIC: + case ActivationLayerInfo::ActivationFunction::SOFT_RELU: + // Reduce range as exponent overflows + bounds = std::make_pair(-40.f, 40.f); + break; + case ActivationLayerInfo::ActivationFunction::SQRT: + // Reduce range as sqrt should take a non-negative number + bounds = std::make_pair(0.f, 255.f); + break; + default: + bounds = std::make_pair(-255.f, 255.f); + break; } break; - case ActivationLayerInfo::ActivationFunction::SQRT: - // Reduce range as sqrt should take a non-negative number - bounds.first = (is_float) ? 0 : 1; - break; - default: - break; - } - return bounds; -} -/** Helper function to get the testing range for batch normalization layer. - * - * @param[in] fixed_point_position (Optional) Number of bits for the fractional part. Defaults to 1. - * - * @return A pair containing the lower upper testing bounds. - */ -template -std::pair get_batchnormalization_layer_test_bounds(int fixed_point_position = 1) -{ - bool is_float = std::is_floating_point::value; - std::pair bounds; - - // Set initial values - if(is_float) - { - bounds = std::make_pair(-1.f, 1.f); - } - else - { - bounds = std::make_pair(1, 1 << (fixed_point_position)); - } - - return bounds; -} - -/** Fill mask with the corresponding given pattern. - * - * @param[in,out] mask Mask to be filled according to pattern - * @param[in] cols Columns (width) of mask - * @param[in] rows Rows (height) of mask - * @param[in] pattern Pattern to fill the mask according to - */ -inline void fill_mask_from_pattern(uint8_t *mask, int cols, int rows, MatrixPattern pattern) -{ - unsigned int v = 0; - std::mt19937 gen(user_config.seed.get()); - std::bernoulli_distribution dist(0.5); - - for(int r = 0; r < rows; ++r) - { - for(int c = 0; c < cols; ++c, ++v) - { - uint8_t val = 0; - - switch(pattern) + case DataType::QS8: + case DataType::QS16: + switch(activation) { - case MatrixPattern::BOX: - val = 255; - break; - case MatrixPattern::CROSS: - val = ((r == (rows / 2)) || (c == (cols / 2))) ? 255 : 0; - break; - case MatrixPattern::DISK: - val = (((r - rows / 2.0f + 0.5f) * (r - rows / 2.0f + 0.5f)) / ((rows / 2.0f) * (rows / 2.0f)) + ((c - cols / 2.0f + 0.5f) * (c - cols / 2.0f + 0.5f)) / ((cols / 2.0f) * - (cols / 2.0f))) <= 1.0f ? 255 : 0; + case ActivationLayerInfo::ActivationFunction::LOGISTIC: + case ActivationLayerInfo::ActivationFunction::SOFT_RELU: + case ActivationLayerInfo::ActivationFunction::TANH: + // Reduce range as exponent overflows + bounds = std::make_pair(-(1 << fixed_point_position), 1 << fixed_point_position); break; - case MatrixPattern::OTHER: - val = (dist(gen) ? 0 : 255); + case ActivationLayerInfo::ActivationFunction::SQRT: + // Reduce range as sqrt should take a non-negative number + // Can't be zero either as inv_sqrt is used in NEON. + bounds = std::make_pair(1, std::numeric_limits::max()); break; default: - return; + bounds = std::make_pair(std::numeric_limits::lowest(), std::numeric_limits::max()); + break; } - - mask[v] = val; - } + break; + default: + ARM_COMPUTE_ERROR("Unsupported data type"); } - if(pattern == MatrixPattern::OTHER) - { - std::uniform_int_distribution distribution_u8(0, ((cols * rows) - 1)); - mask[distribution_u8(gen)] = 255; - } + return bounds; } /** Calculate output tensor shape give a vector of input tensor to concatenate @@ -204,69 +135,7 @@ inline void fill_mask_from_pattern(uint8_t *mask, int cols, int rows, MatrixPatt * * @return The shape of output concatenated tensor. */ -inline TensorShape calculate_depth_concatenate_shape(std::vector input_shapes) -{ - TensorShape out_shape = input_shapes.at(0); - - unsigned int max_x = 0; - unsigned int max_y = 0; - unsigned int depth = 0; - - for(auto const &shape : input_shapes) - { - max_x = std::max(shape.x(), max_x); - max_y = std::max(shape.y(), max_y); - depth += shape.z(); - } - - out_shape.set(0, max_x); - out_shape.set(1, max_y); - out_shape.set(2, depth); - - return out_shape; -} - -/** Fill matrix random. - * - * @param[in,out] matrix Matrix - * @param[in] cols Columns (width) of matrix - * @param[in] rows Rows (height) of matrix - */ -template -inline void fill_warp_matrix(std::array &matrix, int cols, int rows) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_real_distribution dist(-1, 1); - - for(int v = 0, r = 0; r < rows; ++r) - { - for(int c = 0; c < cols; ++c, ++v) - { - matrix[v] = dist(gen); - } - } - if(SIZE == 9) - { - matrix[(cols * rows) - 1] = 1; - } -} - -/** Helper function to fill the Lut random by a ILutAccessor. - * - * @param[in,out] table Accessor at the Lut. - * - */ -template -void fill_lookuptable(T &&table) -{ - std::mt19937 generator(user_config.seed.get()); - std::uniform_int_distribution distribution(std::numeric_limits::min(), std::numeric_limits::max()); - - for(int i = std::numeric_limits::min(); i <= std::numeric_limits::max(); i++) - { - table[i] = distribution(generator); - } -} +TensorShape calculate_depth_concatenate_shape(const std::vector &input_shapes); } // namespace validation } // namespace test } // namespace arm_compute diff --git a/tests/validation/NEON/AbsoluteDifference.cpp b/tests/validation/NEON/AbsoluteDifference.cpp deleted file mode 100644 index 1aee95e2d8..0000000000 --- a/tests/validation/NEON/AbsoluteDifference.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEAbsoluteDifference.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon absolute difference function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * - * @return Computed output tensor. - */ -Tensor compute_absolute_difference(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out) -{ - // Create tensors - Tensor src1 = create_tensor(shape, dt_in0); - Tensor src2 = create_tensor(shape, dt_in1); - Tensor dst = create_tensor(shape, dt_out); - - // Create and configure function - NEAbsoluteDifference abs_d; - abs_d.configure(&src1, &src2, &dst); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src1.info()->is_resizable()); - BOOST_TEST(!src2.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src1), 0); - library->fill_tensor_uniform(Accessor(src2), 1); - - // Compute function - abs_d.run(); - - return dst; -} - -void validate_configuration(const Tensor &src1, const Tensor &src2, Tensor &dst, TensorShape shape) -{ - BOOST_TEST(src1.info()->is_resizable()); - BOOST_TEST(src2.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEAbsoluteDifference abs_d; - abs_d.configure(&src1, &src2, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(AbsoluteDifference) - -BOOST_AUTO_TEST_SUITE(U8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()), - shape) -{ - // Create tensors - Tensor src1 = create_tensor(shape, DataType::U8); - Tensor src2 = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - validate_configuration(src1, src2, dst, shape); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), - shape) -{ - // Compute function - Tensor dst = compute_absolute_difference(shape, DataType::U8, DataType::U8, DataType::U8); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_absolute_difference(shape, DataType::U8, DataType::U8, DataType::U8); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes(), - shape) -{ - // Compute function - Tensor dst = compute_absolute_difference(shape, DataType::U8, DataType::U8, DataType::U8); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_absolute_difference(shape, DataType::U8, DataType::U8, DataType::U8); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(S16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, dt) -{ - // Create tensors - Tensor src1 = create_tensor(shape, dt); - Tensor src2 = create_tensor(shape, DataType::S16); - Tensor dst = create_tensor(shape, DataType::S16); - - validate_configuration(src1, src2, dst, shape); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, dt) -{ - // Compute function - Tensor dst = compute_absolute_difference(shape, dt, DataType::S16, DataType::S16); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_absolute_difference(shape, dt, DataType::S16, DataType::S16); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, dt) -{ - // Compute function - Tensor dst = compute_absolute_difference(shape, dt, DataType::S16, DataType::S16); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_absolute_difference(shape, dt, DataType::S16, DataType::S16); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/Accumulate.cpp b/tests/validation/NEON/Accumulate.cpp deleted file mode 100644 index 7e8a85065e..0000000000 --- a/tests/validation/NEON/Accumulate.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEAccumulate.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon accumulate function. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -Tensor compute_accumulate(const TensorShape &shape) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::S16); - - // Create and configure function - NEAccumulate acc; - acc.configure(&src, &dst); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - library->fill_tensor_uniform(Accessor(dst), 1); - - // Compute function - acc.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(Accumulate) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()), - shape) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::S16); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEAccumulate acc; - acc.configure(&src, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), - shape) -{ - // Compute function - Tensor dst = compute_accumulate(shape); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_accumulate(shape); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes(), - shape) -{ - // Compute function - Tensor dst = compute_accumulate(shape); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_accumulate(shape); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/AccumulateSquared.cpp b/tests/validation/NEON/AccumulateSquared.cpp deleted file mode 100644 index 83908425be..0000000000 --- a/tests/validation/NEON/AccumulateSquared.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEAccumulate.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon accumulate squared function. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -Tensor compute_accumulate_squared(const TensorShape &shape, uint32_t shift) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::S16); - - // Create and configure function - NEAccumulateSquared acc; - acc.configure(&src, shift, &dst); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - // dst tensor filled with non-negative values - library->fill_tensor_uniform(Accessor(src), 0); - library->fill_tensor_uniform(Accessor(dst), 1, static_cast(0), std::numeric_limits::max()); - - // Compute function - acc.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(AccumulateSquared) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::xrange(0U, 16U), - shape, shift) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::S16); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEAccumulateSquared acc; - acc.configure(&src, shift, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::xrange(0U, 16U), - shape, shift) -{ - // Compute function - Tensor dst = compute_accumulate_squared(shape, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_accumulate_squared(shape, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ 0U, 1U, 15U }), - shape, shift) -{ - // Compute function - Tensor dst = compute_accumulate_squared(shape, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_accumulate_squared(shape, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/AccumulateWeighted.cpp b/tests/validation/NEON/AccumulateWeighted.cpp deleted file mode 100644 index ea71959c0b..0000000000 --- a/tests/validation/NEON/AccumulateWeighted.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEAccumulate.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon accumulate weighted function. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -Tensor compute_accumulate_weighted(const TensorShape &shape, float alpha) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - // Create and configure function - NEAccumulateWeighted acc; - acc.configure(&src, alpha, &dst); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - library->fill_tensor_uniform(Accessor(dst), 1); - - // Compute function - acc.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(AccumulateWeighted) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ 0.f, 0.5f, 1.f }), - shape, alpha) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEAccumulateWeighted acc; - acc.configure(&src, alpha, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ 0.f, 0.5f, 1.f }), - shape, alpha) -{ - // Compute function - Tensor dst = compute_accumulate_weighted(shape, alpha); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_accumulate_weighted(shape, alpha); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ 0.f, 0.5f, 1.f }), - shape, alpha) -{ - // Compute function - Tensor dst = compute_accumulate_weighted(shape, alpha); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_accumulate_weighted(shape, alpha); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/ActivationLayer.cpp b/tests/validation/NEON/ActivationLayer.cpp new file mode 100644 index 0000000000..1c6811fd1c --- /dev/null +++ b/tests/validation/NEON/ActivationLayer.cpp @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ActivationFunctionsDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/ActivationLayerFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Define tolerance of the activation layer. + * + * @param[in] data_type The data type used. + * @param[in] activation The activation function used. + * + * @return Tolerance depending on the activation function. + */ +AbsoluteTolerance tolerance(DataType data_type, ActivationLayerInfo::ActivationFunction activation) +{ + switch(activation) + { + case ActivationLayerInfo::ActivationFunction::LOGISTIC: + case ActivationLayerInfo::ActivationFunction::SOFT_RELU: + case ActivationLayerInfo::ActivationFunction::SQRT: + case ActivationLayerInfo::ActivationFunction::TANH: + switch(data_type) + { + case DataType::QS8: + return AbsoluteTolerance(5.f); + case DataType::QS16: + return AbsoluteTolerance(11.f); + case DataType::F16: + return AbsoluteTolerance(0.01f); + default: + return AbsoluteTolerance(0.00001f); + } + break; + default: + return AbsoluteTolerance(0.f); + } +} + +/** CNN data types */ +const auto CNNDataTypes = framework::dataset::make("DataType", +{ +#ifdef ARM_COMPUTE_ENABLE_FP16 + DataType::F16, +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + DataType::F32, + DataType::QS8, + DataType::QS16, +}); + +/** Input data sets. */ +const auto ActivationDataset = combine(combine(framework::dataset::make("InPlace", { false, true }), datasets::ActivationFunctions()), framework::dataset::make("AlphaBeta", { 0.5f, 1.f })); +} // namespace + +TEST_SUITE(NEON) +TEST_SUITE(ActivationLayer) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), CNNDataTypes), framework::dataset::make("InPlace", { false, true })), + shape, data_type, in_place) +{ + // Set fixed point position data type allowed + const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; + + // Create tensors + Tensor src = create_tensor(shape, data_type, 1, fixed_point_position); + Tensor dst = create_tensor(shape, data_type, 1, fixed_point_position); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + NEActivationLayer act_layer; + + if(in_place) + { + act_layer.configure(&src, nullptr, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS)); + } + else + { + act_layer.configure(&src, &dst, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS)); + } + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + + if(!in_place) + { + validate(dst.info()->valid_region(), valid_region); + } + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src.info()->padding(), padding); + + if(!in_place) + { + validate(dst.info()->padding(), padding); + } +} + +template +using NEActivationLayerFixture = ActivationValidationFixture; + +TEST_SUITE(Float) +#ifdef ARM_COMPUTE_ENABLE_FP16 +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ActivationDataset), + framework::dataset::make("DataType", + DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance(_data_type, _function)); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ActivationDataset), + framework::dataset::make("DataType", + DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance(_data_type, _function)); +} +TEST_SUITE_END() +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ActivationDataset), framework::dataset::make("DataType", + DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance(_data_type, _function)); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ActivationDataset), framework::dataset::make("DataType", + DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance(_data_type, _function)); +} +TEST_SUITE_END() +TEST_SUITE_END() + +template +using NEActivationLayerFixedPointFixture = ActivationValidationFixedPointFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +// We test for fixed point precision [3,5] because [1,2] and [6,7] ranges cause +// overflowing issues in most of the transcendentals functions. +FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), ActivationDataset), + framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 3, 6))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance(_data_type, _function)); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEActivationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), ActivationDataset), + framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 3, 6))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance(_data_type, _function)); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 +FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), ActivationDataset), + framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance(_data_type, _function)); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEActivationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), ActivationDataset), + framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance(_data_type, _function)); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/ArithmeticAddition.cpp b/tests/validation/NEON/ArithmeticAddition.cpp deleted file mode 100644 index 952dcd207b..0000000000 --- a/tests/validation/NEON/ArithmeticAddition.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEArithmeticAddition.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon arithmetic addition function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] policy Overflow policy of the operation. - * @param[in] fixed_point_position (Optional) Fixed point position that expresses the number of bits for the fractional part of the number when the tensor's data type is QS8 or QS16 (default = 0). - * - * @return Computed output tensor. - */ -Tensor compute_arithmetic_addition(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy policy, int fixed_point_position = 0) -{ - // Create tensors - Tensor src1 = create_tensor(shape, dt_in0, 1, fixed_point_position); - Tensor src2 = create_tensor(shape, dt_in1, 1, fixed_point_position); - Tensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); - - // Create and configure function - NEArithmeticAddition add; - add.configure(&src1, &src2, &dst, policy); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src1.info()->is_resizable()); - BOOST_TEST(!src2.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src1), 0); - library->fill_tensor_uniform(Accessor(src2), 1); - - // Compute function - add.run(); - - return dst; -} - -void validate_configuration(const Tensor &src1, const Tensor &src2, Tensor &dst, TensorShape shape, ConvertPolicy policy) -{ - BOOST_TEST(src1.info()->is_resizable()); - BOOST_TEST(src2.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEArithmeticAddition add; - add.configure(&src1, &src2, &dst, policy); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(ArithmeticAddition) - -BOOST_AUTO_TEST_SUITE(U8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, policy) -{ - // Create tensors - Tensor src1 = create_tensor(shape, DataType::U8); - Tensor src2 = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - validate_configuration(src1, src2, dst, shape, policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, policy) -{ - // Compute function - Tensor dst = compute_arithmetic_addition(shape, DataType::U8, DataType::U8, DataType::U8, policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::U8, DataType::U8, DataType::U8, policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(S16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, dt, policy) -{ - // Create tensors - Tensor src1 = create_tensor(shape, dt); - Tensor src2 = create_tensor(shape, DataType::S16); - Tensor dst = create_tensor(shape, DataType::S16); - - validate_configuration(src1, src2, dst, shape, policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, dt, policy) -{ - // Compute function - Tensor dst = compute_arithmetic_addition(shape, dt, DataType::S16, DataType::S16, policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, dt, DataType::S16, DataType::S16, policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, dt, policy) -{ - // Compute function - Tensor dst = compute_arithmetic_addition(shape, dt, DataType::S16, DataType::S16, policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, dt, DataType::S16, DataType::S16, policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Quantized) -BOOST_AUTO_TEST_SUITE(QS8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 7), - shape, policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_arithmetic_addition(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 7), - shape, policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_arithmetic_addition(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(QS16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 15), - shape, policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_arithmetic_addition(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 15), - shape, policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_arithmetic_addition(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() - -#ifdef ARM_COMPUTE_ENABLE_FP16 -BOOST_AUTO_TEST_SUITE(F16) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) -{ - // Compute function - Tensor dst = compute_arithmetic_addition(shape, DataType::F16, DataType::F16, DataType::F16, ConvertPolicy::WRAP); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::F16, DataType::F16, DataType::F16, ConvertPolicy::WRAP); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -BOOST_AUTO_TEST_SUITE(F32) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, policy) -{ - // Create tensors - Tensor src1 = create_tensor(shape, DataType::F32); - Tensor src2 = create_tensor(shape, DataType::F32); - Tensor dst = create_tensor(shape, DataType::F32); - - validate_configuration(src1, src2, dst, shape, policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) -{ - // Compute function - Tensor dst = compute_arithmetic_addition(shape, DataType::F32, DataType::F32, DataType::F32, ConvertPolicy::WRAP); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::F32, DataType::F32, DataType::F32, ConvertPolicy::WRAP); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, policy) -{ - // Compute function - Tensor dst = compute_arithmetic_addition(shape, DataType::F32, DataType::F32, DataType::F32, policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::F32, DataType::F32, DataType::F32, policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/ArithmeticSubtraction.cpp b/tests/validation/NEON/ArithmeticSubtraction.cpp deleted file mode 100644 index b95bc05d75..0000000000 --- a/tests/validation/NEON/ArithmeticSubtraction.cpp +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEArithmeticSubtraction.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon arithmetic subtraction function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] policy Overflow policy of the operation. - * @param[in] fixed_point_position (Optional) Fixed point position that expresses the number of bits for the fractional part of the number when the tensor's data type is QS8 or QS16 (default = 0). - * - * @return Computed output tensor. - */ -Tensor compute_arithmetic_subtraction(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy policy, int fixed_point_position = 0) -{ - // Create tensors - Tensor src1 = create_tensor(shape, dt_in0, 1, fixed_point_position); - Tensor src2 = create_tensor(shape, dt_in1, 1, fixed_point_position); - Tensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); - - // Create and configure function - NEArithmeticSubtraction sub; - sub.configure(&src1, &src2, &dst, policy); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src1.info()->is_resizable()); - BOOST_TEST(!src2.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src1), 0); - library->fill_tensor_uniform(Accessor(src2), 1); - - // Compute function - sub.run(); - - return dst; -} - -void validate_configuration(const Tensor &src1, const Tensor &src2, Tensor &dst, TensorShape shape, ConvertPolicy policy) -{ - BOOST_TEST(src1.info()->is_resizable()); - BOOST_TEST(src2.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEArithmeticSubtraction sub; - sub.configure(&src1, &src2, &dst, policy); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(ArithmeticSubtraction) - -BOOST_AUTO_TEST_SUITE(U8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, policy) -{ - // Create tensors - Tensor src1 = create_tensor(shape, DataType::U8); - Tensor src2 = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - validate_configuration(src1, src2, dst, shape, policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, policy) -{ - // Compute function - Tensor dst = compute_arithmetic_subtraction(shape, DataType::U8, DataType::U8, DataType::U8, policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::U8, DataType::U8, DataType::U8, policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(S16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, dt, policy) -{ - // Create tensors - Tensor src1 = create_tensor(shape, dt); - Tensor src2 = create_tensor(shape, DataType::S16); - Tensor dst = create_tensor(shape, DataType::S16); - - validate_configuration(src1, src2, dst, shape, policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, dt, policy) -{ - // Compute function - Tensor dst = compute_arithmetic_subtraction(shape, dt, DataType::S16, DataType::S16, policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, dt, DataType::S16, DataType::S16, policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, dt, policy) -{ - // Compute function - Tensor dst = compute_arithmetic_subtraction(shape, dt, DataType::S16, DataType::S16, policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, dt, DataType::S16, DataType::S16, policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Quantized) -BOOST_AUTO_TEST_SUITE(QS8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 7), - shape, policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_arithmetic_subtraction(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 7), - shape, policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_arithmetic_subtraction(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(QS16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 15), - shape, policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_arithmetic_subtraction(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 15), - shape, policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_arithmetic_subtraction(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() - -#ifdef ARM_COMPUTE_ENABLE_FP16 -BOOST_AUTO_TEST_SUITE(Float16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) -{ - // Compute function - Tensor dst = compute_arithmetic_subtraction(shape, DataType::F16, DataType::F16, DataType::F16, ConvertPolicy::WRAP); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::F16, DataType::F16, DataType::F16, ConvertPolicy::WRAP); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -BOOST_AUTO_TEST_SUITE(Float) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, policy) -{ - // Create tensors - Tensor src1 = create_tensor(shape, DataType::F32); - Tensor src2 = create_tensor(shape, DataType::F32); - Tensor dst = create_tensor(shape, DataType::F32); - - validate_configuration(src1, src2, dst, shape, policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) -{ - // Compute function - Tensor dst = compute_arithmetic_subtraction(shape, DataType::F32, DataType::F32, DataType::F32, ConvertPolicy::WRAP); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::F32, DataType::F32, DataType::F32, ConvertPolicy::WRAP); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), - shape, policy) -{ - // Compute function - Tensor dst = compute_arithmetic_subtraction(shape, DataType::F32, DataType::F32, DataType::F32, policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::F32, DataType::F32, DataType::F32, policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/BatchNormalizationLayer.cpp b/tests/validation/NEON/BatchNormalizationLayer.cpp deleted file mode 100644 index 9898beb7db..0000000000 --- a/tests/validation/NEON/BatchNormalizationLayer.cpp +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "NEON/Accessor.h" -#include "TypePrinter.h" -#include "dataset/BatchNormalizationLayerDataset.h" -#include "tests/Globals.h" -#include "tests/NEON/Helper.h" -#include "tests/Utils.h" -#include "tests/validation/Helpers.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/runtime/NEON/functions/NEBatchNormalizationLayer.h" - -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -const float tolerance_qs8 = 6; /**< Tolerance value for comparing reference's output against quantized implementation's output */ -const float tolerance_qs16 = 6; /**< Tolerance value for comparing reference's output against quantized implementation's output */ -const float tolerance_f32 = 1e-05f; /**< Tolerance value for comparing reference's output against floating point implementation's output */ -#ifdef ARM_COMPUTE_ENABLE_FP16 -const float tolerance_f16 = 0.01f; /**< Tolerance value for comparing reference's output against half precision floating point implementation's output */ -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -/** Compute Neon batch normalization function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt Data type of input and output tensors. - * @param[in] norm_info Normalization Layer information. - * - * @return Computed output tensor. - */ -Tensor compute_reference_batch_normalization_layer(const TensorShape &shape0, const TensorShape &shape1, DataType dt, float epsilon, int fixed_point_position = 0) -{ - // Create tensors - Tensor src = create_tensor(shape0, dt, 1, fixed_point_position); - Tensor dst = create_tensor(shape0, dt, 1, fixed_point_position); - Tensor mean = create_tensor(shape1, dt, 1, fixed_point_position); - Tensor var = create_tensor(shape1, dt, 1, fixed_point_position); - Tensor beta = create_tensor(shape1, dt, 1, fixed_point_position); - Tensor gamma = create_tensor(shape1, dt, 1, fixed_point_position); - - // Create and configure function - NEBatchNormalizationLayer norm; - norm.configure(&src, &dst, &mean, &var, &beta, &gamma, epsilon); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - mean.allocator()->allocate(); - var.allocator()->allocate(); - beta.allocator()->allocate(); - gamma.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - BOOST_TEST(!mean.info()->is_resizable()); - BOOST_TEST(!var.info()->is_resizable()); - BOOST_TEST(!beta.info()->is_resizable()); - BOOST_TEST(!gamma.info()->is_resizable()); - - // Fill tensors - switch(dt) - { - case DataType::QS8: - { - const std::pair bounds = get_batchnormalization_layer_test_bounds(fixed_point_position); - std::uniform_int_distribution<> distribution(bounds.first, bounds.second); - std::uniform_int_distribution<> distribution_var(0, bounds.second); - test::fill_tensors(distribution, { 0, 1, 3, 4 }, &src, &mean, &beta, &gamma); - test::fill_tensors(distribution_var, { 0 }, &var); - break; - } - case DataType::QS16: - { - const std::pair bounds = get_batchnormalization_layer_test_bounds(fixed_point_position); - std::uniform_int_distribution<> distribution(bounds.first, bounds.second); - std::uniform_int_distribution<> distribution_var(0, bounds.second); - test::fill_tensors(distribution, { 0, 1, 3, 4 }, &src, &mean, &beta, &gamma); - test::fill_tensors(distribution_var, { 0 }, &var); - break; - } -#ifdef ARM_COMPUTE_ENABLE_FP16 - case DataType::F16: - { - const std::pair bounds = get_batchnormalization_layer_test_bounds(); - std::uniform_real_distribution<> distribution(bounds.first, bounds.second); - std::uniform_real_distribution<> distribution_var(0, bounds.second); - test::fill_tensors(distribution, { 0, 1, 3, 4 }, &src, &mean, &beta, &gamma); - test::fill_tensors(distribution_var, { 0 }, &var); - break; - } -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - case DataType::F32: - { - const std::pair bounds = get_batchnormalization_layer_test_bounds(); - std::uniform_real_distribution<> distribution(bounds.first, bounds.second); - std::uniform_real_distribution<> distribution_var(0, bounds.second); - test::fill_tensors(distribution, { 0, 1, 3, 4 }, &src, &mean, &beta, &gamma); - test::fill_tensors(distribution_var, { 0 }, &var); - break; - } - default: - { - ARM_COMPUTE_ERROR("Not supported"); - break; - } - } - - // Compute function - norm.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(BatchNormalizationLayer) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make({ DataType::QS8, DataType::QS16, DataType::F32 }), obj, dt) -{ - // Set fixed point position data type allowed - int fixed_point_position = (arm_compute::is_data_type_fixed_point(dt)) ? 3 : 0; - - // Create tensors - Tensor src = create_tensor(obj.shape0, dt, 1, fixed_point_position); - Tensor dst = create_tensor(obj.shape0, dt, 1, fixed_point_position); - Tensor mean = create_tensor(obj.shape1, dt, 1, fixed_point_position); - Tensor var = create_tensor(obj.shape1, dt, 1, fixed_point_position); - Tensor beta = create_tensor(obj.shape1, dt, 1, fixed_point_position); - Tensor gamma = create_tensor(obj.shape1, dt, 1, fixed_point_position); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - BOOST_TEST(mean.info()->is_resizable()); - BOOST_TEST(var.info()->is_resizable()); - BOOST_TEST(beta.info()->is_resizable()); - BOOST_TEST(gamma.info()->is_resizable()); - - // Create and configure function - NEBatchNormalizationLayer norm; - norm.configure(&src, &dst, &mean, &var, &beta, &gamma, obj.epsilon); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(obj.shape0); - const ValidRegion valid_region_vec = shape_to_valid_region(obj.shape1); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - validate(mean.info()->valid_region(), valid_region_vec); - validate(var.info()->valid_region(), valid_region_vec); - validate(beta.info()->valid_region(), valid_region_vec); - validate(gamma.info()->valid_region(), valid_region_vec); -} - -BOOST_AUTO_TEST_SUITE(Float) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(Random, - RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::F32), - obj, dt) -{ - // Compute function - Tensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance_f32, 0); -} -BOOST_AUTO_TEST_SUITE_END() - -#ifdef ARM_COMPUTE_ENABLE_FP16 -BOOST_AUTO_TEST_SUITE(Float16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(Random, - RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::F16), - obj, dt) -{ - // Compute function - Tensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance_f16, 0); -} -BOOST_AUTO_TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -BOOST_AUTO_TEST_SUITE(Quantized) -BOOST_AUTO_TEST_SUITE(QS8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(Random, - RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::QS8) * boost::unit_test::data::xrange(1, 6), - obj, dt, fixed_point_position) -{ - // Compute function - Tensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance_qs8); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(QS16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(Random, - RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::QS16) * boost::unit_test::data::xrange(1, 14), - obj, dt, fixed_point_position) -{ - // Compute function - Tensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance_qs16); -} -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/BitwiseAnd.cpp b/tests/validation/NEON/BitwiseAnd.cpp new file mode 100644 index 0000000000..179413ee39 --- /dev/null +++ b/tests/validation/NEON/BitwiseAnd.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEBitwiseAnd.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/BitwiseAndFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(NEON) +TEST_SUITE(BitwiseAnd) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) +{ + // Create tensors + Tensor src1 = create_tensor(shape, data_type); + Tensor src2 = create_tensor(shape, data_type); + Tensor dst = create_tensor(shape, data_type); + + ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + NEBitwiseAnd bitwise_and; + bitwise_and.configure(&src1, &src2, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src1.info()->valid_region(), valid_region); + validate(src2.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src1.info()->padding(), padding); + validate(src2.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using NEBitwiseAndFixture = BitwiseAndValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, NEBitwiseAndFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEBitwiseAndFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate output + validate(Accessor(_target), _reference); +} + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/BitwiseNot.cpp b/tests/validation/NEON/BitwiseNot.cpp new file mode 100644 index 0000000000..c438a5700b --- /dev/null +++ b/tests/validation/NEON/BitwiseNot.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEBitwiseNot.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/BitwiseNotFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(NEON) +TEST_SUITE(BitwiseNot) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) +{ + // Create tensors + Tensor src = create_tensor(shape, data_type); + Tensor dst = create_tensor(shape, data_type); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + NEBitwiseNot bitwise_not; + bitwise_not.configure(&src, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using NEBitwiseNotFixture = BitwiseNotValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, NEBitwiseNotFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEBitwiseNotFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate output + validate(Accessor(_target), _reference); +} + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/BitwiseOr.cpp b/tests/validation/NEON/BitwiseOr.cpp new file mode 100644 index 0000000000..0e4cdbe2c1 --- /dev/null +++ b/tests/validation/NEON/BitwiseOr.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEBitwiseOr.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/BitwiseOrFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(NEON) +TEST_SUITE(BitwiseOr) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) +{ + // Create tensors + Tensor src1 = create_tensor(shape, data_type); + Tensor src2 = create_tensor(shape, data_type); + Tensor dst = create_tensor(shape, data_type); + + ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + NEBitwiseOr bitwise_or; + bitwise_or.configure(&src1, &src2, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src1.info()->valid_region(), valid_region); + validate(src2.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src1.info()->padding(), padding); + validate(src2.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using NEBitwiseOrFixture = BitwiseOrValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, NEBitwiseOrFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEBitwiseOrFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate output + validate(Accessor(_target), _reference); +} + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/BitwiseXor.cpp b/tests/validation/NEON/BitwiseXor.cpp new file mode 100644 index 0000000000..70363c041b --- /dev/null +++ b/tests/validation/NEON/BitwiseXor.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEBitwiseXor.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/BitwiseXorFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(NEON) +TEST_SUITE(BitwiseXor) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) +{ + // Create tensors + Tensor src1 = create_tensor(shape, data_type); + Tensor src2 = create_tensor(shape, data_type); + Tensor dst = create_tensor(shape, data_type); + + ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + NEBitwiseXor bitwise_xor; + bitwise_xor.configure(&src1, &src2, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src1.info()->valid_region(), valid_region); + validate(src2.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src1.info()->padding(), padding); + validate(src2.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using NEBitwiseXorFixture = BitwiseXorValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, NEBitwiseXorFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEBitwiseXorFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate output + validate(Accessor(_target), _reference); +} + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/Box3x3.cpp b/tests/validation/NEON/Box3x3.cpp deleted file mode 100644 index 579b2c8af1..0000000000 --- a/tests/validation/NEON/Box3x3.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEBox3x3.h" -#include "arm_compute/runtime/SubTensor.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -constexpr unsigned int filter_size = 3; /** Size of the kernel/filter in number of elements. */ -constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ - -/** Compute Neon box3x3 filter. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor. - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. - * - * @return Computed output tensor. - */ -Tensor compute_box3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - // Create and configure function - NEBox3x3 box3x3; - box3x3.configure(&src, &dst, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - - // Compute function - box3x3.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(Box3x3) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEBox3x3 box3x3; - box3x3.configure(&src, &dst, border_mode); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(shape); - const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - validate(src.info()->valid_region(), src_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 8); - calculator.set_border_size(1); - calculator.set_border_mode(border_mode); - - const PaddingSize dst_padding = calculator.required_padding(); - - calculator.set_accessed_elements(16); - calculator.set_access_offset(-1); - - const PaddingSize src_padding = calculator.required_padding(); - - validate(src.info()->padding(), src_padding); - validate(dst.info()->padding(), dst_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - Tensor dst = compute_box3x3(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_box3x3(shape, border_mode, border_value); - - // Validate output - validate(Accessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - Tensor dst = compute_box3x3(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_box3x3(shape, border_mode, border_value); - - // Validate output - validate(Accessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/CMakeLists.txt b/tests/validation/NEON/CMakeLists.txt deleted file mode 100644 index bf07d27d6a..0000000000 --- a/tests/validation/NEON/CMakeLists.txt +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright (c) 2017 ARM Limited. -# -# SPDX-License-Identifier: MIT -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -cmake_minimum_required (VERSION 3.1) - -set(arm_compute_test_validation_NEON_SOURCE_FILES - ${CMAKE_SOURCE_DIR}/NEON/Helper.h - ${CMAKE_SOURCE_DIR}/NEON/Accessor.h - ${CMAKE_CURRENT_SOURCE_DIR}/AbsoluteDifference.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Accumulate.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/AccumulateSquared.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/AccumulateWeighted.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ArithmeticAddition.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ArithmeticSubtraction.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/BatchNormalizationLayer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/BitwiseAnd.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/BitwiseNot.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/BitwiseOr.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/BitwiseXor.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Box3x3.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ConvolutionLayer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/DirectConvolutionLayer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/DepthConvert.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FillBorder.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Fixedpoint/Exp_QS8.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Fixedpoint/Invsqrt_QS8.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Fixedpoint/Log_QS8.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Fixedpoint/Reciprocal_QS8.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FullyConnectedLayer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Gaussian3x3.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/GEMM.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/HarrisCorners.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/IntegralImage.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/NormalizationLayer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/PixelWiseMultiplication.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/MeanStdDev.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Pooling/PoolingLayer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Sobel3x3.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Sobel5x5.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/SoftmaxLayer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Threshold.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/MinMaxLocation.cpp -) - -add_library(arm_compute_test_validation_NEON OBJECT - ${arm_compute_test_validation_NEON_SOURCE_FILES} -) - -set(arm_compute_test_validation_TARGET_OBJECTS - ${arm_compute_test_validation_TARGET_OBJECTS} - $ - PARENT_SCOPE -) diff --git a/tests/validation/NEON/ConvolutionLayer.cpp b/tests/validation/NEON/ConvolutionLayer.cpp new file mode 100644 index 0000000000..7a3306d232 --- /dev/null +++ b/tests/validation/NEON/ConvolutionLayer.cpp @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/LargeConvolutionLayerDataset.h" +#include "tests/datasets/SmallConvolutionLayerDataset.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/ConvolutionLayerFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +const AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ +#ifdef ARM_COMPUTE_ENABLE_FP16 +const AbsoluteTolerance tolerance_f16(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F16 */ +#endif /* ARM_COMPUTE_ENABLE_FP16 */ +const AbsoluteTolerance tolerance_q(1.0f); /**< Tolerance value for comparing reference's output against implementation's output for fixed point data types */ + +/** CNN data types */ +const auto CNNDataTypes = framework::dataset::make("DataType", +{ +#ifdef ARM_COMPUTE_ENABLE_FP16 + DataType::F16, +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + DataType::F32, + DataType::QS8, + DataType::QS16, +}); +} // namespace + +TEST_SUITE(NEON) +TEST_SUITE(ConvolutionLayer) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallConvolutionLayerDataset(), datasets::LargeConvolutionLayerDataset()), CNNDataTypes), + input_shape, weights_shape, bias_shape, output_shape, info, data_type) +{ + // Set fixed point position data type allowed + int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; + + // Create tensors + Tensor src = create_tensor(input_shape, data_type, 1, fixed_point_position); + Tensor weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); + Tensor bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); + Tensor dst = create_tensor(output_shape, data_type, 1, fixed_point_position); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + NEConvolutionLayer conv; + conv.configure(&src, &weights, &bias, &dst, info); + + // Validate valid region + const ValidRegion src_valid_region = shape_to_valid_region(input_shape); + const ValidRegion weights_valid_region = shape_to_valid_region(weights_shape); + const ValidRegion bias_valid_region = shape_to_valid_region(bias_shape); + const ValidRegion dst_valid_region = shape_to_valid_region(output_shape); + + validate(src.info()->valid_region(), src_valid_region); + validate(weights.info()->valid_region(), weights_valid_region); + validate(bias.info()->valid_region(), bias_valid_region); + validate(dst.info()->valid_region(), dst_valid_region); + + // Validate padding + //TODO(COMPMID-415) Need to validate padding? +} + +template +using NEConvolutionLayerFixture = ConvolutionValidationFixture; + +TEST_SUITE(Float) +#ifdef ARM_COMPUTE_ENABLE_FP16 +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallConvolutionLayerDataset(), + framework::dataset::make("DataType", + DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeConvolutionLayerDataset(), + framework::dataset::make("DataType", + DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f16); +} +TEST_SUITE_END() +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallConvolutionLayerDataset(), framework::dataset::make("DataType", + DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f32); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeConvolutionLayerDataset(), framework::dataset::make("DataType", + DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() +TEST_SUITE_END() + +template +using NEConvolutionLayerFixedPointFixture = ConvolutionValidationFixedPointFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +// We test for fixed point precision [4,6] +FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallConvolutionLayerDataset(), + framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 4, 7))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_q); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeConvolutionLayerDataset(), + framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 4, 7))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_q); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +// Testing for fixed point position [1,14) +FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallConvolutionLayerDataset(), + framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_q); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeConvolutionLayerDataset(), + framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_q); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/DepthConcatenateLayer.cpp b/tests/validation/NEON/DepthConcatenateLayer.cpp new file mode 100644 index 0000000000..19a41ee9d6 --- /dev/null +++ b/tests/validation/NEON/DepthConcatenateLayer.cpp @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEDepthConcatenate.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/DepthConcatenateLayerFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(NEON) +TEST_SUITE(DepthConcatenateLayer) + +//TODO(COMPMID-415): Add configuration test? + +template +using NEDepthConcatenateLayerFixture = DepthConcatenateValidationFixture; + +TEST_SUITE(Float) +#ifdef ARM_COMPUTE_ENABLE_FP16 +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", + DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", + DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +TEST_SUITE_END() +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", + DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", + DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), + framework::dataset::make("DataType", + DataType::QS8))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), + framework::dataset::make("DataType", + DataType::QS8))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), + framework::dataset::make("DataType", + DataType::QS16))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), + framework::dataset::make("DataType", + DataType::QS16))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/DepthConvert.cpp b/tests/validation/NEON/DepthConvert.cpp deleted file mode 100644 index 0b7a175f4f..0000000000 --- a/tests/validation/NEON/DepthConvert.cpp +++ /dev/null @@ -1,637 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEDepthConvert.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon depth convert function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in Data type of input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] policy Conversion policy. - * @param[in] shift Value for down/up conversions. Must be 0 <= shift < 8. - * @param[in] fixed_point_position_in (Optional) Fixed point position for the input tensor. - * @param[in] fixed_point_position_out (Optional) Fixed point position for the output tensor. - * - * @return Computed output tensor. - */ -Tensor compute_depth_convert(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, - uint32_t shift, uint32_t fixed_point_position_in = 0, uint32_t fixed_point_position_out = 0) -{ - // Create tensors - Tensor src = create_tensor(shape, dt_in, 1, fixed_point_position_in); - Tensor dst = create_tensor(shape, dt_out, 1, fixed_point_position_out); - - // Create and configure function - NEDepthConvert depth_convert; - depth_convert.configure(&src, &dst, policy, shift); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - - // Compute function - depth_convert.run(); - - return dst; -} -/** Configure and validate region/padding function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in Data type of input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] policy Conversion policy. - * @param[in] shift Value for down/up conversions. Must be 0 <= shift < 8. - * @param[in] fixed_point_position_in (Optional) Fixed point position for the input tensor. - * @param[in] fixed_point_position_out (Optional) Fixed point position for the output tensor. - * - */ - -void compute_configure_validate(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, - uint32_t shift, uint32_t fixed_point_position_in = 0, uint32_t fixed_point_position_out = 0) -{ - // Create tensors - Tensor src = create_tensor(shape, dt_in, 1, fixed_point_position_in); - Tensor dst = create_tensor(shape, dt_out, 1, fixed_point_position_out); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEDepthConvert depth_convert; - depth_convert.configure(&src, &dst, policy, shift); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(DepthConvert) - -BOOST_AUTO_TEST_SUITE(QS8_to_QS8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * (boost::unit_test::data::make({ 1, 3, 5, 6 }) ^ boost::unit_test::data::make({ 6, 5, 1, 3 })), - shape, policy, fixed_point_position_in, fixed_point_position_out) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::QS8, DataType::QS8, policy, 0, fixed_point_position_in, fixed_point_position_out); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * (boost::unit_test::data::make({ 1, 3, 5, 6 }) ^ boost::unit_test::data::make({ 6, 5, 1, 3 })), - shape, policy, fixed_point_position_in, fixed_point_position_out) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::QS8, DataType::QS8, policy, 0, fixed_point_position_in, fixed_point_position_out); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::QS8, DataType::QS8, policy, 0, fixed_point_position_in, fixed_point_position_out); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(QS8_to_F32) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * boost::unit_test::data::xrange(1, 7, 1), - shape, policy, fixed_point_position) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::QS8, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * boost::unit_test::data::xrange(1, 7, 1), - shape, policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::QS8, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::QS8, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * boost::unit_test::data::xrange(1, 7, 1), - shape, policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::QS8, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::QS8, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(F32_to_QS8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * boost::unit_test::data::xrange(1, 7, 1), - shape, policy, fixed_point_position) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::F32, DataType::QS8, policy, 0, fixed_point_position, fixed_point_position); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * boost::unit_test::data::xrange(1, 7, 1), - shape, policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::F32, DataType::QS8, policy, 0, fixed_point_position, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::F32, DataType::QS8, policy, 0, fixed_point_position, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * boost::unit_test::data::xrange(1, 7, 1), - shape, policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::F32, DataType::QS8, policy, 0, fixed_point_position, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::F32, DataType::QS8, policy, 0, fixed_point_position, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(QS16_to_QS16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * (boost::unit_test::data::make({ 3, 6, 7, 13, 14 }) ^ boost::unit_test::data::make({ 5, 10, 14, 4, 7 })), - shape, policy, fixed_point_position_in, fixed_point_position_out) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::QS16, DataType::QS16, policy, 0, fixed_point_position_in, fixed_point_position_out); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * (boost::unit_test::data::make({ 3, 6, 7, 13, 14 }) ^ boost::unit_test::data::make({ 5, 10, 14, 4, 7 })), - shape, policy, fixed_point_position_in, fixed_point_position_out) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::QS16, DataType::QS16, policy, 0, fixed_point_position_in, fixed_point_position_out); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::QS16, DataType::QS16, policy, 0, fixed_point_position_in, fixed_point_position_out); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(QS16_to_F32) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * boost::unit_test::data::xrange(1, 15, 1), - shape, policy, fixed_point_position) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::QS16, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * boost::unit_test::data::xrange(1, 15, 1), - shape, policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::QS16, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::QS16, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * boost::unit_test::data::xrange(1, 15, 1), - shape, policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::QS16, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::QS16, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(F32_to_QS16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * boost::unit_test::data::xrange(1, 7, 1), - shape, policy, fixed_point_position) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::F32, DataType::QS16, policy, 0, fixed_point_position, fixed_point_position); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * boost::unit_test::data::xrange(1, 15, 1), - shape, policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::F32, DataType::QS16, policy, 0, fixed_point_position, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::F32, DataType::QS16, policy, 0, fixed_point_position, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) - * boost::unit_test::data::xrange(1, 15, 1), - shape, policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::F32, DataType::QS16, policy, 0, fixed_point_position, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::F32, DataType::QS16, policy, 0, fixed_point_position, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(U8_to_U16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) - -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::U8, DataType::U16, policy, shift, 0); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::U16, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::U16, policy, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::U16, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::U16, policy, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(U8_to_S16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::U8, DataType::S16, policy, shift); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::S16, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S16, policy, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::S16, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S16, policy, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(U8_to_S32) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::U8, DataType::S32, policy, shift); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::S32, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S32, policy, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::S32, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S32, policy, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(U16_to_U8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::U16, DataType::U8, policy, shift); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::U16, DataType::U8, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U8, policy, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::U16, DataType::U8, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U8, policy, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(U16_to_U32) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::U16, DataType::U32, policy, shift); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::U16, DataType::U32, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U32, policy, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::U16, DataType::U32, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U32, policy, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(S16_to_U8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::S16, DataType::U8, policy, shift); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::S16, DataType::U8, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::U8, policy, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::S16, DataType::U8, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::U8, policy, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(S16_to_S32) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute configure and validate region/padding - compute_configure_validate(shape, DataType::S16, DataType::S32, policy, shift); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::S16, DataType::S32, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::S32, policy, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) - * boost::unit_test::data::xrange(0, 7, 1), - shape, policy, shift) -{ - // Compute function - Tensor dst = compute_depth_convert(shape, DataType::S16, DataType::S32, policy, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::S32, policy, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/DequantizationLayer.cpp b/tests/validation/NEON/DequantizationLayer.cpp new file mode 100644 index 0000000000..22d56ab5d8 --- /dev/null +++ b/tests/validation/NEON/DequantizationLayer.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEDequantizationLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/DequantizationLayerFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Tolerance for float operations */ +constexpr AbsoluteTolerance tolerance_f32(0.001f); +} // namespace + +TEST_SUITE(NEON) +TEST_SUITE(DequantizationLayer) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) +{ + // Create tensors + Tensor src = create_tensor(shape, data_type); + Tensor dst = create_tensor(shape, DataType::F32); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + float min = 0.f; + float max = 0.f; + NEDequantizationLayer dequant_layer; + dequant_layer.configure(&src, &dst, &min, &max); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 8).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using NEDequantizationLayerFixture = DequantizationValidationFixture; + +TEST_SUITE(Integer) +TEST_SUITE(U8) +FIXTURE_DATA_TEST_CASE(RunSmall, NEDequantizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::U8))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f32); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEDequantizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", DataType::U8))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/DirectConvolutionLayer.cpp b/tests/validation/NEON/DirectConvolutionLayer.cpp new file mode 100644 index 0000000000..6211d31c45 --- /dev/null +++ b/tests/validation/NEON/DirectConvolutionLayer.cpp @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEDirectConvolutionLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/DirectConvolutionLayerFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +constexpr AbsoluteTolerance tolerance_qs(1.f); /**< Tolerance for fixed point tests */ +#ifdef ARM_COMPUTE_ENABLE_FP16 +constexpr AbsoluteTolerance tolerance_fp16(0.01f); /**< Tolerance for half precision floating point tests */ +#endif /* ARM_COMPUTE_ENABLE_FP16 */ +constexpr AbsoluteTolerance tolerance_fp32(0.001f); /**< Tolerance for floating point tests */ + +/** Direct convolution data set. */ +const auto data_pad_f32 = concat(concat(combine(framework::dataset::make("PadX", 0), + combine(framework::dataset::make("PadY", 0), + framework::dataset::make("KernelSize", 1))), + combine(framework::dataset::make("PadX", 0, 2), + combine(framework::dataset::make("PadY", 0, 2), + framework::dataset::make("KernelSize", 3)))), + combine(framework::dataset::make("PadX", 0, 3), + combine(framework::dataset::make("PadY", 0, 3), + framework::dataset::make("KernelSize", 5)))); + +const auto data_pad_qs8 = concat(combine(framework::dataset::make("PadX", 0), + combine(framework::dataset::make("PadY", 0), + framework::dataset::make("KernelSize", 1))), + combine(framework::dataset::make("PadX", 0, 2), + combine(framework::dataset::make("PadY", 0, 2), + framework::dataset::make("KernelSize", 3)))); + +const auto data_f32 = combine(datasets::SmallDirectConvolutionShapes(), + combine(framework::dataset::make("StrideX", 1, 3), + combine(framework::dataset::make("StrideY", 1, 3), + combine(data_pad_f32, + framework::dataset::make("NumKernels", { 1, 4, 8, 16 }))))); + +const auto data_qs8 = combine(datasets::SmallDirectConvolutionShapes(), + combine(framework::dataset::make("StrideX", 1, 3), + combine(framework::dataset::make("StrideY", 1, 3), + combine(data_pad_qs8, + framework::dataset::make("NumKernels", { 1, 4, 8, 16 }))))); + +/** Direct convolution QS16 data set. */ +const auto data_qs16 = combine(datasets::SmallDirectConvolutionShapes(), + combine(framework::dataset::make("StrideX", 1, 3), + combine(framework::dataset::make("StrideY", 1, 3), + combine(framework::dataset::make("PadX", 0), + combine(framework::dataset::make("PadY", 0), + combine(framework::dataset::make("KernelSize", 1), + framework::dataset::make("NumKernels", { 1, 4, 8, 16 }))))))); +} // namespace + +TEST_SUITE(NEON) +TEST_SUITE(DirectConvolutionLayer) + +//TODO(COMPMID-415): Configuration tests? + +template +using NEDirectConvolutionLayerFixture = DirectConvolutionValidationFixture; + +TEST_SUITE(Float) +#ifdef ARM_COMPUTE_ENABLE_FP16 +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(Run, NEDirectConvolutionLayerFixture, framework::DatasetMode::ALL, combine(data_f32, framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_fp16); +} +TEST_SUITE_END() +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(Run, NEDirectConvolutionLayerFixture, framework::DatasetMode::ALL, combine(data_f32, framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_fp32); +} +TEST_SUITE_END() +TEST_SUITE_END() + +template +using NEDirectConvolutionLayerFixedPointFixture = DirectConvolutionValidationFixedPointFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +// We test for fixed point precision [4,6] +FIXTURE_DATA_TEST_CASE(Run, NEDirectConvolutionLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(data_qs8, framework::dataset::make("DataType", DataType::QS8)), + framework::dataset::make("FractionalBits", 4, 7))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_qs); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +// We test for fixed point precision [4,13] +FIXTURE_DATA_TEST_CASE(Run, NEDirectConvolutionLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(data_qs16, framework::dataset::make("DataType", DataType::QS16)), + framework::dataset::make("FractionalBits", 4, 14))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_qs); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/FillBorder.cpp b/tests/validation/NEON/FillBorder.cpp deleted file mode 100644 index ef2c1ff6f8..0000000000 --- a/tests/validation/NEON/FillBorder.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/NEON/kernels/NEFillBorderKernel.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(FillBorder, BorderModes() * boost::unit_test::data::make({ PaddingSize{ 0 }, PaddingSize{ 1, 0, 1, 2 }, PaddingSize{ 10 } }), border_mode, padding) -{ - constexpr uint8_t border_value = 42U; - constexpr uint8_t tensor_value = 89U; - BorderSize border_size{ 5 }; - - // Create tensors - Tensor src = create_tensor(TensorShape{ 10U, 10U, 2U }, DataType::U8); - - src.info()->extend_padding(padding); - - // Allocate tensor - src.allocator()->allocate(); - - // Check padding is as required - validate(src.info()->padding(), padding); - - // Fill tensor with constant value - std::uniform_int_distribution distribution{ tensor_value, tensor_value }; - library->fill(Accessor(src), distribution, 0); - - // Create and configure kernel - NEFillBorderKernel fill_border; - fill_border.configure(&src, border_size, border_mode, border_value); - - // Run kernel - fill_border.run(fill_border.window()); - - // Validate border - border_size.limit(padding); - validate(Accessor(src), border_size, border_mode, &border_value); - - // Validate tensor - validate(Accessor(src), &tensor_value); -} - -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/Fixedpoint/Exp_QS16.cpp b/tests/validation/NEON/Fixedpoint/Exp_QS16.cpp deleted file mode 100644 index dc8603c963..0000000000 --- a/tests/validation/NEON/Fixedpoint/Exp_QS16.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/ReferenceCPP.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/NEON/NEFixedPoint.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -const float tolerance = 1.0f; /**< Tolerance value for comparing reference's output against implementation's output */ - -/** Compute Neon exponential function for signed 16 bit fixed point. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -Tensor compute_exp_qs16(const TensorShape &shape, int fixed_point_position) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::QS16, 1, fixed_point_position); - Tensor dst = create_tensor(shape, DataType::QS16, 1, fixed_point_position); - - constexpr unsigned int num_elems_processed_per_iteration = 8; - Window window = calculate_max_window(*src.info(), Steps(num_elems_processed_per_iteration)); - AccessWindowHorizontal input_access(src.info(), 0, num_elems_processed_per_iteration); - AccessWindowHorizontal output_access(dst.info(), 0, num_elems_processed_per_iteration); - - update_window_and_padding(window, input_access, output_access); - output_access.set_valid_region(window, src.info()->valid_region()); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors. Keep the range between [-1.0, 1.0) so the result won't - // overflow. - std::uniform_int_distribution<> distribution(-(1 << (fixed_point_position - 1)), (1 << (fixed_point_position - 1))); - library->fill(Accessor(src), distribution, 0); - - Iterator input(&src, window); - Iterator output(&dst, window); - - execute_window_loop(window, [&](const Coordinates & id) - { - qint16x8_t in = vld1q_qs16(reinterpret_cast(input.ptr())); - // Use saturated exp - vst1q_qs16(reinterpret_cast(output.ptr()), vqexpq_qs16(in, fixed_point_position)); - }, - input, output); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(FixedPoint) -BOOST_AUTO_TEST_SUITE(QS16) -BOOST_AUTO_TEST_SUITE(Exp) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(1, 15), shape, fixed_point_position) -{ - // Compute function - Tensor dst = compute_exp_qs16(shape, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS16, DataType::QS16, FixedPointOp::EXP, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance, 0); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/Fixedpoint/Exp_QS8.cpp b/tests/validation/NEON/Fixedpoint/Exp_QS8.cpp deleted file mode 100644 index dae01db41e..0000000000 --- a/tests/validation/NEON/Fixedpoint/Exp_QS8.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/ReferenceCPP.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/NEON/NEFixedPoint.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -const float tolerance = 0.0f; /**< Tolerance value for comparing reference's output against implementation's output */ - -/** Compute Neon exponential function for signed 8bit fixed point. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -Tensor compute_exp_qs8(const TensorShape &shape, int fixed_point_position) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::QS8, 1, fixed_point_position); - Tensor dst = create_tensor(shape, DataType::QS8, 1, fixed_point_position); - - constexpr unsigned int num_elems_processed_per_iteration = 16; - Window window = calculate_max_window(*src.info(), Steps(num_elems_processed_per_iteration)); - AccessWindowHorizontal input_access(src.info(), 0, num_elems_processed_per_iteration); - AccessWindowHorizontal output_access(dst.info(), 0, num_elems_processed_per_iteration); - - update_window_and_padding(window, input_access, output_access); - output_access.set_valid_region(window, src.info()->valid_region()); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors. Keep the range between [-1.0, 1.0) so the result won't - // overflow. E.g. e^7 = 1096, which cannot be represented in QS8 - std::uniform_int_distribution<> distribution(-(1 << (fixed_point_position - 1)), (1 << (fixed_point_position - 1))); - library->fill(Accessor(src), distribution, 0); - - Iterator input(&src, window); - Iterator output(&dst, window); - - execute_window_loop(window, [&](const Coordinates & id) - { - qint8x16_t in = vld1q_s8(reinterpret_cast(input.ptr())); - // Use saturated exp - vst1q_s8(reinterpret_cast(output.ptr()), vqexpq_qs8(in, fixed_point_position)); - }, - input, output); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(FixedPoint) -BOOST_AUTO_TEST_SUITE(QS8) -BOOST_AUTO_TEST_SUITE(Exp) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(1, 7), shape, fixed_point_position) -{ - // Compute function - Tensor dst = compute_exp_qs8(shape, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS8, DataType::QS8, FixedPointOp::EXP, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance, 0); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/Fixedpoint/Invsqrt_QS16.cpp b/tests/validation/NEON/Fixedpoint/Invsqrt_QS16.cpp deleted file mode 100644 index 4306a9a8ba..0000000000 --- a/tests/validation/NEON/Fixedpoint/Invsqrt_QS16.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/ReferenceCPP.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/NEON/NEFixedPoint.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -const float tolerance = 5.0f; /**< Tolerance value for comparing reference's output against implementation's output */ - -/** Compute Neon inverse square root function for signed 16 bit fixed point. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -Tensor compute_invsqrt_qs16(const TensorShape &shape, int fixed_point_position) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::QS16, 1, fixed_point_position); - Tensor dst = create_tensor(shape, DataType::QS16, 1, fixed_point_position); - - constexpr unsigned int num_elems_processed_per_iteration = 8; - Window window = calculate_max_window(*src.info(), Steps(num_elems_processed_per_iteration)); - AccessWindowHorizontal input_access(src.info(), 0, num_elems_processed_per_iteration); - AccessWindowHorizontal output_access(dst.info(), 0, num_elems_processed_per_iteration); - - update_window_and_padding(window, input_access, output_access); - output_access.set_valid_region(window, src.info()->valid_region()); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors. Keep the range between [1, 0x7FFF) - std::uniform_int_distribution<> distribution(1, 0x7FFF); - library->fill(Accessor(src), distribution, 0); - - Iterator input(&src, window); - Iterator output(&dst, window); - - execute_window_loop(window, [&](const Coordinates & id) - { - qint16x8_t in = vld1q_qs16(reinterpret_cast(input.ptr())); - vst1q_qs16(reinterpret_cast(output.ptr()), vqinvsqrtq_qs16(in, fixed_point_position)); - }, - input, output); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(FixedPoint) -BOOST_AUTO_TEST_SUITE(QS16) -BOOST_AUTO_TEST_SUITE(Invsqrt) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunSmall, boost::unit_test::data::xrange(1, 14), fixed_point_position) -{ - TensorShape shape(8192U); - - // Compute function - Tensor dst = compute_invsqrt_qs16(shape, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS16, DataType::QS16, FixedPointOp::INV_SQRT, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance, 0); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/Fixedpoint/Invsqrt_QS8.cpp b/tests/validation/NEON/Fixedpoint/Invsqrt_QS8.cpp deleted file mode 100644 index 1a2acaf34b..0000000000 --- a/tests/validation/NEON/Fixedpoint/Invsqrt_QS8.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/ReferenceCPP.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/NEON/NEFixedPoint.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -const float tolerance = 4.0f; /**< Tolerance value for comparing reference's output against implementation's output */ - -/** Compute Neon inverse square root function for signed 8bit fixed point. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -Tensor compute_invsqrt_qs8(const TensorShape &shape, int fixed_point_position) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::QS8, 1, fixed_point_position); - Tensor dst = create_tensor(shape, DataType::QS8, 1, fixed_point_position); - - constexpr unsigned int num_elems_processed_per_iteration = 16; - Window window = calculate_max_window(*src.info(), Steps(num_elems_processed_per_iteration)); - AccessWindowHorizontal input_access(src.info(), 0, num_elems_processed_per_iteration); - AccessWindowHorizontal output_access(dst.info(), 0, num_elems_processed_per_iteration); - - update_window_and_padding(window, input_access, output_access); - output_access.set_valid_region(window, src.info()->valid_region()); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors. Keep the range between [1, 127). - std::uniform_int_distribution<> distribution(1, 127); - library->fill(Accessor(src), distribution, 0); - - Iterator input(&src, window); - Iterator output(&dst, window); - - execute_window_loop(window, [&](const Coordinates & id) - { - qint8x16_t in = vld1q_s8(reinterpret_cast(input.ptr())); - vst1q_s8(reinterpret_cast(output.ptr()), vqinvsqrtq_qs8(in, fixed_point_position)); - }, - input, output); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(FixedPoint) -BOOST_AUTO_TEST_SUITE(QS8) -BOOST_AUTO_TEST_SUITE(Invsqrt) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Small1DShape, SmallShapes() * boost::unit_test::data::xrange(1, 6), shape, fixed_point_position) -{ - // Compute function - Tensor dst = compute_invsqrt_qs8(shape, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS8, DataType::QS8, FixedPointOp::INV_SQRT, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance, 0); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/Fixedpoint/Log_QS16.cpp b/tests/validation/NEON/Fixedpoint/Log_QS16.cpp deleted file mode 100644 index 71582d8f96..0000000000 --- a/tests/validation/NEON/Fixedpoint/Log_QS16.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/ReferenceCPP.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/NEON/NEFixedPoint.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -const float tolerance = 7.0f; /**< Tolerance value for comparing reference's output against implementation's output */ - -/** Compute Neon logarithm function for signed 16 bit fixed point. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -Tensor compute_log_qs16(const TensorShape &shape, int fixed_point_position) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::QS16, 1, fixed_point_position); - Tensor dst = create_tensor(shape, DataType::QS16, 1, fixed_point_position); - - constexpr unsigned int num_elems_processed_per_iteration = 8; - Window window = calculate_max_window(*src.info(), Steps(num_elems_processed_per_iteration)); - AccessWindowHorizontal input_access(src.info(), 0, num_elems_processed_per_iteration); - AccessWindowHorizontal output_access(dst.info(), 0, num_elems_processed_per_iteration); - - update_window_and_padding(window, input_access, output_access); - output_access.set_valid_region(window, src.info()->valid_region()); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors. Keep the range between [(1 << (fixed_point_position - 1), 0x3FFF) so the result won't - // overflow. - std::uniform_int_distribution<> distribution((1 << (fixed_point_position - 1)), 0x3FFF); - library->fill(Accessor(src), distribution, 0); - - Iterator input(&src, window); - Iterator output(&dst, window); - - execute_window_loop(window, [&](const Coordinates & id) - { - qint16x8_t in = vld1q_qs16(reinterpret_cast(input.ptr())); - vst1q_qs16(reinterpret_cast(output.ptr()), vlogq_qs16(in, fixed_point_position)); - }, - input, output); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(FixedPoint) -BOOST_AUTO_TEST_SUITE(QS16) -BOOST_AUTO_TEST_SUITE(Log) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(4, 14), shape, fixed_point_position) -{ - // Compute function - Tensor dst = compute_log_qs16(shape, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS16, DataType::QS16, FixedPointOp::LOG, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance, 0); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/Fixedpoint/Log_QS8.cpp b/tests/validation/NEON/Fixedpoint/Log_QS8.cpp deleted file mode 100644 index cc74d12e10..0000000000 --- a/tests/validation/NEON/Fixedpoint/Log_QS8.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/ReferenceCPP.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/NEON/NEFixedPoint.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -const float tolerance = 5; /**< Tolerance value for comparing reference's output against implementation's output */ - -/** Compute Neon logarithm function for signed 8bit fixed point. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -Tensor compute_log_qs8(const TensorShape &shape, int fixed_point_position) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::QS8, 1, fixed_point_position); - Tensor dst = create_tensor(shape, DataType::QS8, 1, fixed_point_position); - - constexpr unsigned int num_elems_processed_per_iteration = 16; - Window window = calculate_max_window(*src.info(), Steps(num_elems_processed_per_iteration)); - AccessWindowHorizontal input_access(src.info(), 0, num_elems_processed_per_iteration); - AccessWindowHorizontal output_access(dst.info(), 0, num_elems_processed_per_iteration); - - update_window_and_padding(window, input_access, output_access); - output_access.set_valid_region(window, src.info()->valid_region()); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors. Keep the range between [(1 << (fixed_point_position - 1), 63) so the result won't - // overflow. E.g. for Q2.5 ln(0.001) = -6.9, which cannot be represented. - std::uniform_int_distribution<> distribution((1 << (fixed_point_position - 1)), 0x3F); - library->fill(Accessor(src), distribution, 0); - - Iterator input(&src, window); - Iterator output(&dst, window); - - execute_window_loop(window, [&](const Coordinates & id) - { - qint8x16_t in = vld1q_s8(reinterpret_cast(input.ptr())); - vst1q_s8(reinterpret_cast(output.ptr()), vlogq_qs8(in, fixed_point_position)); - }, - input, output); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(FixedPoint) -BOOST_AUTO_TEST_SUITE(QS8) -BOOST_AUTO_TEST_SUITE(Log) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(3, 6), shape, fixed_point_position) -{ - // Compute function - Tensor dst = compute_log_qs8(shape, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS8, DataType::QS8, FixedPointOp::LOG, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance, 0); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/Fixedpoint/Reciprocal_QS16.cpp b/tests/validation/NEON/Fixedpoint/Reciprocal_QS16.cpp deleted file mode 100644 index 2081948d6c..0000000000 --- a/tests/validation/NEON/Fixedpoint/Reciprocal_QS16.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/ReferenceCPP.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/NEON/NEFixedPoint.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -const float tolerance = 11.0f; /**< Tolerance value for comparing reference's output against implementation's output. */ - -/** Compute Neon reciprocal function for signed 16 bit fixed point. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -Tensor compute_reciprocal_qs16(const TensorShape &shape, int fixed_point_position) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::QS16, 1, fixed_point_position); - Tensor dst = create_tensor(shape, DataType::QS16, 1, fixed_point_position); - - constexpr unsigned int num_elems_processed_per_iteration = 8; - Window window = calculate_max_window(*src.info(), Steps(num_elems_processed_per_iteration)); - AccessWindowHorizontal input_access(src.info(), 0, num_elems_processed_per_iteration); - AccessWindowHorizontal output_access(dst.info(), 0, num_elems_processed_per_iteration); - - update_window_and_padding(window, input_access, output_access); - output_access.set_valid_region(window, src.info()->valid_region()); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors. Keep the range between [15, 0x7FFF) so the result won't - // overflow. - std::uniform_int_distribution<> distribution(15, 0x7FFF); - library->fill(Accessor(src), distribution, 0); - - Iterator input(&src, window); - Iterator output(&dst, window); - - execute_window_loop(window, [&](const Coordinates & id) - { - qint16x8_t in = vld1q_qs16(reinterpret_cast(input.ptr())); - vst1q_qs16(reinterpret_cast(output.ptr()), vqrecipq_qs16(in, fixed_point_position)); - }, - input, output); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(FixedPoint) -BOOST_AUTO_TEST_SUITE(QS16) -BOOST_AUTO_TEST_SUITE(Reciprocal) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(1, 14), shape, fixed_point_position) -{ - // Compute function - Tensor dst = compute_reciprocal_qs16(shape, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS16, DataType::QS16, FixedPointOp::RECIPROCAL, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance, 0); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/Fixedpoint/Reciprocal_QS8.cpp b/tests/validation/NEON/Fixedpoint/Reciprocal_QS8.cpp deleted file mode 100644 index 4b808ce3e0..0000000000 --- a/tests/validation/NEON/Fixedpoint/Reciprocal_QS8.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/ReferenceCPP.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/NEON/NEFixedPoint.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -const float tolerance = 3; /**< Tolerance value for comparing reference's output against implementation's output */ - -/** Compute Neon reciprocal function for signed 8bit fixed point. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -Tensor compute_reciprocal_qs8(const TensorShape &shape, int fixed_point_position) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::QS8, 1, fixed_point_position); - Tensor dst = create_tensor(shape, DataType::QS8, 1, fixed_point_position); - - constexpr unsigned int num_elems_processed_per_iteration = 16; - Window window = calculate_max_window(*src.info(), Steps(num_elems_processed_per_iteration)); - AccessWindowHorizontal input_access(src.info(), 0, num_elems_processed_per_iteration); - AccessWindowHorizontal output_access(dst.info(), 0, num_elems_processed_per_iteration); - - update_window_and_padding(window, input_access, output_access); - output_access.set_valid_region(window, src.info()->valid_region()); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors. Keep the range between [15, 100) so the result won't - // overflow. E.g. for Q2.5 reciprocal(0.001) = 1000, which cannot be represented. - std::uniform_int_distribution<> distribution(15, 0x7F); - library->fill(Accessor(src), distribution, 0); - - Iterator input(&src, window); - Iterator output(&dst, window); - - execute_window_loop(window, [&](const Coordinates & id) - { - qint8x16_t in = vld1q_s8(reinterpret_cast(input.ptr())); - vst1q_s8(reinterpret_cast(output.ptr()), vrecipq_qs8(in, fixed_point_position)); - }, - input, output); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(FixedPoint) -BOOST_AUTO_TEST_SUITE(QS8) -BOOST_AUTO_TEST_SUITE(Reciprocal) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(1, 6), shape, fixed_point_position) -{ - // Compute function - Tensor dst = compute_reciprocal_qs8(shape, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS8, DataType::QS8, FixedPointOp::RECIPROCAL, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance, 0); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/Floor.cpp b/tests/validation/NEON/Floor.cpp new file mode 100644 index 0000000000..ea16e0b21e --- /dev/null +++ b/tests/validation/NEON/Floor.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEFloor.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/FloorFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(NEON) +TEST_SUITE(Floor) + +template +using NEFloorFixture = FloorValidationFixture; + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, NEFloorFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEFloorFixture, framework::DatasetMode::NIGHTLY, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference); +} +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/FullyConnectedLayer.cpp b/tests/validation/NEON/FullyConnectedLayer.cpp new file mode 100644 index 0000000000..55f8da97cf --- /dev/null +++ b/tests/validation/NEON/FullyConnectedLayer.cpp @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/FullyConnectedLayerDataset.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/FullyConnectedLayerFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Tolerance for float operations */ +constexpr AbsoluteTolerance tolerance_f32(0.001f); +#ifdef ARM_COMPUTE_ENABLE_FP16 +constexpr AbsoluteTolerance tolerance_f16(0.01f); +#endif /* ARM_COMPUTE_ENABLE_FP16*/ +/** Tolerance for fixed point operations */ +constexpr AbsoluteTolerance tolerance_fixed_point(1.f); + +/** CNN data types */ +const auto CNNDataTypes = framework::dataset::make("DataType", +{ +#ifdef ARM_COMPUTE_ENABLE_FP16 + DataType::F16, +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + DataType::F32, + DataType::QS8, + DataType::QS16, +}); + +const auto FullyConnectedParameters = combine(framework::dataset::make("TransposeWeights", { false, true }), framework::dataset::make("ReshapeWeights", { false, true })); +} // namespace + +TEST_SUITE(NEON) +TEST_SUITE(FullyConnectedLayer) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(framework::dataset::concat(datasets::SmallFullyConnectedLayerDataset(), datasets::LargeFullyConnectedLayerDataset()), + FullyConnectedParameters), + CNNDataTypes), + src_shape, weights_shape, bias_shape, dst_shape, transpose_weights, reshape_weights, data_type) +{ + // Set fixed point position data type allowed + int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; + + TensorShape ws(weights_shape); + + // Transpose weights if not done in the function + if(!reshape_weights || !transpose_weights) + { + const size_t shape_x = ws.x(); + ws.set(0, ws.y()); + ws.set(1, shape_x); + + // Weights have to be passed reshaped + // Transpose 1xW for batched version + if(!reshape_weights && dst_shape.y() > 1) + { + const float transpose_width = 16.0f / data_size_from_type(data_type); + const size_t shape_x = ws.x(); + ws.set(0, ws.y() * static_cast(transpose_width)); + ws.set(1, static_cast(std::ceil(shape_x / transpose_width))); + } + } + + // Create tensors + Tensor src = create_tensor(src_shape, data_type, 1, fixed_point_position); + Tensor weights = create_tensor(ws, data_type, 1, fixed_point_position); + Tensor bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); + Tensor dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function. + NEFullyConnectedLayer fc; + fc.configure(&src, &weights, &bias, &dst, transpose_weights, !reshape_weights); + + // Validate valid region + const ValidRegion dst_valid_region = shape_to_valid_region(dst_shape); + validate(dst.info()->valid_region(), dst_valid_region); +} + +template +using NEFullyConnectedLayerFixture = FullyConnectedLayerValidationFixture; + +TEST_SUITE(Float) +#ifdef ARM_COMPUTE_ENABLE_FP16 +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEFullyConnectedLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallFullyConnectedLayerDataset(), + FullyConnectedParameters), + framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeFullyConnectedLayerDataset(), + FullyConnectedParameters), + framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f16); +} +TEST_SUITE_END() +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, NEFullyConnectedLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallFullyConnectedLayerDataset(), FullyConnectedParameters), + framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f32); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeFullyConnectedLayerDataset(), FullyConnectedParameters), + framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() +TEST_SUITE_END() + +template +using NEFullyConnectedLayerFixedPointFixture = FullyConnectedLayerValidationFixedPointFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 +FIXTURE_DATA_TEST_CASE(RunSmall, NEFullyConnectedLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallFullyConnectedLayerDataset(), + FullyConnectedParameters), + framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 1, 6))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_fixed_point); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEFullyConnectedLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeFullyConnectedLayerDataset(), + FullyConnectedParameters), + framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 1, 6))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_fixed_point); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 +FIXTURE_DATA_TEST_CASE(RunSmall, NEFullyConnectedLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallFullyConnectedLayerDataset(), + FullyConnectedParameters), + framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_fixed_point); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEFullyConnectedLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeFullyConnectedLayerDataset(), + FullyConnectedParameters), + framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_fixed_point); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/GEMM.cpp b/tests/validation/NEON/GEMM.cpp new file mode 100644 index 0000000000..05db3bbd6d --- /dev/null +++ b/tests/validation/NEON/GEMM.cpp @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEGEMM.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/LargeGEMMDataset.h" +#include "tests/datasets/SmallGEMMDataset.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/GEMMFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +constexpr AbsoluteTolerance tolerance_f(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for floating point data types */ +constexpr AbsoluteTolerance tolerance_q(1.0f); /**< Tolerance value for comparing reference's output against implementation's output for fixed point data types */ + +/** CNN data types */ +const auto CNNDataTypes = framework::dataset::make("DataType", +{ +#ifdef ARM_COMPUTE_ENABLE_FP16 + DataType::F16, +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + DataType::F32, + DataType::QS8, + DataType::QS16, +}); +} // namespace + +TEST_SUITE(NEON) +TEST_SUITE(GEMM) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallGEMMDataset(), datasets::LargeGEMMDataset()), CNNDataTypes), + shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type) +{ + // Set fixed point position data type allowed + const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; + + // Create tensors + Tensor a = create_tensor(shape_a, data_type, 1, fixed_point_position); + Tensor b = create_tensor(shape_b, data_type, 1, fixed_point_position); + Tensor c = create_tensor(shape_c, data_type, 1, fixed_point_position); + Tensor dst = create_tensor(output_shape, data_type, 1, fixed_point_position); + + ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(c.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + NEGEMM gemm; + gemm.configure(&a, &b, &c, &dst, alpha, beta); + + //TODO(COMPMID-415): Validate valid region +} + +template +using NEGEMMFixture = GEMMValidationFixture; + +TEST_SUITE(Float) +#ifdef ARM_COMPUTE_ENABLE_FP16 +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallGEMMDataset(), framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMDataset(), framework::dataset::make("DataType", + DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f); +} +TEST_SUITE_END() +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallGEMMDataset(), framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMDataset(), framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f); +} +TEST_SUITE_END() +TEST_SUITE_END() + +template +using NEGEMMFixedPointFixture = GEMMValidationFixedPointFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(), + framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 1, 7))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_q); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeGEMMDataset(), + framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 1, 7))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_q); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(), + framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_q); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeGEMMDataset(), + framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_q); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/Gaussian3x3.cpp b/tests/validation/NEON/Gaussian3x3.cpp deleted file mode 100644 index b7f9150283..0000000000 --- a/tests/validation/NEON/Gaussian3x3.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEGaussian3x3.h" -#include "arm_compute/runtime/SubTensor.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -constexpr unsigned int filter_size = 3; /** Size of the kernel/filter in number of elements. */ -constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ - -/** Compute Neon gaussian3x3 filter. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor. - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. - * - * @return Computed output tensor. - */ -Tensor compute_gaussian3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - // Create and configure function - NEGaussian3x3 gaussian3x3; - gaussian3x3.configure(&src, &dst, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - - // Compute function - gaussian3x3.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(Gaussian3x3) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEGaussian3x3 gaussian3x3; - gaussian3x3.configure(&src, &dst, border_mode); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(shape); - const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - validate(src.info()->valid_region(), src_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 8); - calculator.set_border_size(1); - calculator.set_border_mode(border_mode); - - const PaddingSize dst_padding = calculator.required_padding(); - - calculator.set_accessed_elements(16); - calculator.set_access_offset(-1); - - const PaddingSize src_padding = calculator.required_padding(); - - validate(src.info()->padding(), src_padding); - validate(dst.info()->padding(), dst_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - Tensor dst = compute_gaussian3x3(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gaussian3x3(shape, border_mode, border_value); - - // Validate output - validate(Accessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - Tensor dst = compute_gaussian3x3(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gaussian3x3(shape, border_mode, border_value); - - // Validate output - validate(Accessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/Gaussian5x5.cpp b/tests/validation/NEON/Gaussian5x5.cpp deleted file mode 100644 index 7727340f66..0000000000 --- a/tests/validation/NEON/Gaussian5x5.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEGaussian5x5.h" -#include "arm_compute/runtime/SubTensor.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -constexpr unsigned int filter_size = 5; /** Size of the kernel/filter in number of elements. */ -constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ - -/** Compute Neon gaussian5x5 filter. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor. - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. - * - * @return Computed output tensor. - */ -Tensor compute_gaussian5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - // Create and configure function - NEGaussian5x5 gaussian5x5; - gaussian5x5.configure(&src, &dst, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - - // Compute function - gaussian5x5.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(Gaussian5x5) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEGaussian5x5 gaussian5x5; - gaussian5x5.configure(&src, &dst, border_mode); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(shape); - const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - validate(src.info()->valid_region(), src_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 16); - calculator.set_border_size(2); - calculator.set_border_mode(border_mode); - - const PaddingSize dst_padding = calculator.required_padding(); - - calculator.set_processed_elements(8); - calculator.set_access_offset(-2); - - const PaddingSize src_padding = calculator.required_padding(); - - validate(src.info()->padding(), src_padding); - validate(dst.info()->padding(), dst_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - Tensor dst = compute_gaussian5x5(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gaussian5x5(shape, border_mode, border_value); - - // Validate output - validate(Accessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - Tensor dst = compute_gaussian5x5(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gaussian5x5(shape, border_mode, border_value); - - // Validate output - validate(Accessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/HarrisCorners.cpp b/tests/validation/NEON/HarrisCorners.cpp deleted file mode 100644 index 6793e21c34..0000000000 --- a/tests/validation/NEON/HarrisCorners.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "NEON/Helper.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEHarrisCorners.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "PaddingCalculator.h" -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon Harris corners function. - * - * @param[in] shape Shape of input tensor - * @param[in] threshold Minimum threshold with which to eliminate Harris Corner scores (computed using the normalized Sobel kernel). - * @param[in] min_dist Radial Euclidean distance for the euclidean distance stage - * @param[in] sensitivity Sensitivity threshold k from the Harris-Stephens equation - * @param[in] gradient_size The gradient window size to use on the input. The implementation supports 3, 5, and 7 - * @param[in] block_size The block window size used to compute the Harris Corner score. The implementation supports 3, 5, and 7. - * @param[in] border_mode Border mode to use - * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. - * @param[in] use_fp16 If true the FP16 kernels will be used. If false F32 kernels are used. - * - * @return Computed corners' keypoints. - */ -KeyPointArray compute_harris_corners(const TensorShape &shape, float threshold, float min_dist, float sensitivity, - int32_t gradient_size, int32_t block_size, BorderMode border_mode, uint8_t constant_border_value, bool use_fp16) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - src.info()->set_format(Format::U8); - - // Create array of keypoints - KeyPointArray corners(shape.total_size()); - - // Create harris corners configure function - NEHarrisCorners harris_corners; - harris_corners.configure(&src, threshold, min_dist, sensitivity, gradient_size, block_size, &corners, border_mode, constant_border_value, use_fp16); - - // Allocate tensors - src.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - - // Compute function - harris_corners.run(); - - return corners; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(HarrisCorners) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (Small2DShapes() + Large2DShapes()) * BorderModes() - * boost::unit_test::data::make({ 3, 5, 7 }) * boost::unit_test::data::make({ 3, 5, 7 }), - shape, border_mode, gradient, block) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - src.info()->set_format(Format::U8); - - KeyPointArray corners; - - uint8_t constant_border_value = 0; - - std::mt19937 gen(user_config.seed.get()); - std::uniform_real_distribution real_dist(0.01, std::numeric_limits::min()); - - const float threshold = real_dist(gen); - const float sensitivity = real_dist(gen); - const float max_euclidean_distance = 30.f; - - real_dist = std::uniform_real_distribution(0.f, max_euclidean_distance); - const float min_dist = real_dist(gen); - - // 50% chance to use fp16 - bool use_fp16 = real_dist(gen) < max_euclidean_distance / 2 ? true : false; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::uniform_int_distribution int_dist(0, 255); - constant_border_value = int_dist(gen); - } - - BOOST_TEST(src.info()->is_resizable()); - - // Create harris corners configure function - NEHarrisCorners harris_corners; - harris_corners.configure(&src, threshold, min_dist, sensitivity, gradient, block, &corners, border_mode, constant_border_value, use_fp16); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - - validate(src.info()->valid_region(), valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 8); - - calculator.set_border_mode(border_mode); - calculator.set_border_size(gradient / 2); - calculator.set_access_offset(-gradient / 2); - calculator.set_accessed_elements(16); - - const PaddingSize padding = calculator.required_padding(); - - validate(src.info()->padding(), padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, Small2DShapes() * BorderModes() * boost::unit_test::data::make({ 3, 5, 7 }) * boost::unit_test::data::make({ 3, 5, 7 }), shape, border_mode, gradient, block) -{ - uint8_t constant_border_value = 0; - - std::mt19937 gen(user_config.seed.get()); - std::uniform_real_distribution real_dist(0.01, std::numeric_limits::min()); - - const float threshold = real_dist(gen); - const float sensitivity = real_dist(gen); - const float max_euclidean_distance = 30.f; - - real_dist = std::uniform_real_distribution(0.f, max_euclidean_distance); - const float min_dist = real_dist(gen); - - // 50% chance to use fp16 - bool use_fp16 = real_dist(gen) < max_euclidean_distance / 2 ? true : false; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::uniform_int_distribution int_dist(0, 255); - constant_border_value = int_dist(gen); - } - - // Compute function - KeyPointArray dst = compute_harris_corners(shape, threshold, min_dist, sensitivity, gradient, block, border_mode, constant_border_value, use_fp16); - - // Compute reference - KeyPointArray ref_dst = Reference::compute_reference_harris_corners(shape, threshold, min_dist, sensitivity, gradient, block, border_mode, constant_border_value); - - // Validate output - validate(dst, ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, Large2DShapes() * BorderModes() * boost::unit_test::data::make({ 3, 5, 7 }) * boost::unit_test::data::make({ 3, 5, 7 }), shape, border_mode, gradient, block) -{ - uint8_t constant_border_value = 0; - - std::mt19937 gen(user_config.seed.get()); - std::uniform_real_distribution real_dist(0.01, std::numeric_limits::min()); - - const float threshold = real_dist(gen); - const float sensitivity = real_dist(gen); - const float max_euclidean_distance = 30.f; - - real_dist = std::uniform_real_distribution(0.f, max_euclidean_distance); - float min_dist = real_dist(gen); - - // 50% chance to use fp16 - bool use_fp16 = real_dist(gen) < max_euclidean_distance / 2 ? true : false; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::uniform_int_distribution int_dist(0, 255); - constant_border_value = int_dist(gen); - } - - // Compute function - KeyPointArray dst = compute_harris_corners(shape, threshold, min_dist, sensitivity, gradient, block, border_mode, constant_border_value, use_fp16); - - // Compute reference - KeyPointArray ref_dst = Reference::compute_reference_harris_corners(shape, threshold, min_dist, sensitivity, gradient, block, border_mode, constant_border_value); - - // Validate output - validate(dst, ref_dst); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/IntegralImage.cpp b/tests/validation/NEON/IntegralImage.cpp deleted file mode 100644 index d5ad33e2a5..0000000000 --- a/tests/validation/NEON/IntegralImage.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEIntegralImage.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon integral image function. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -Tensor compute_integral_image(const TensorShape &shape) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U32); - - // Create integral image configure function - NEIntegralImage integral_image; - integral_image.configure(&src, &dst); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - - // Compute function - integral_image.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(IntegralImage) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, SmallShapes() + LargeShapes(), shape) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U32); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create integral image configure function - NEIntegralImage integral_image; - integral_image.configure(&src, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize src_padding = PaddingCalculator(shape.x(), 16).required_padding(); - const PaddingSize dst_padding(1, src_padding.right, 0, 1); - - validate(src.info()->padding(), src_padding); - validate(dst.info()->padding(), dst_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) -{ - // Compute function - Tensor dst = compute_integral_image(shape); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_integral_image(shape); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes(), shape) -{ - // Compute function - Tensor dst = compute_integral_image(shape); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_integral_image(shape); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/L2Normalize.cpp b/tests/validation/NEON/L2Normalize.cpp new file mode 100644 index 0000000000..4f94c15767 --- /dev/null +++ b/tests/validation/NEON/L2Normalize.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEL2Normalize.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/L2NormalizeFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Tolerance for float operations */ +constexpr RelativeTolerance tolerance_f32(0.00001f); +} // namespace + +TEST_SUITE(NEON) +TEST_SUITE(L2Normalize) + +template +using NEL2NormalizeFixture = L2NormalizeValidationFixture; + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, NEL2NormalizeFixture, framework::DatasetMode::PRECOMMIT, + combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), framework::dataset::make("Epsilon", { 1e-12 }))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f32); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NEL2NormalizeFixture, framework::DatasetMode::NIGHTLY, + combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), framework::dataset::make("Epsilon", { 1e-12 }))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/MeanStdDev.cpp b/tests/validation/NEON/MeanStdDev.cpp new file mode 100644 index 0000000000..42d887960e --- /dev/null +++ b/tests/validation/NEON/MeanStdDev.cpp @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/runtime/NEON/functions/NEMeanStdDev.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Macros.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/MeanStdDevFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +constexpr RelativeTolerance tolerance_rel_high_error(0.05f); +constexpr RelativeTolerance tolerance_rel_low_error(0.0005f); +} // namespace + +TEST_SUITE(NEON) +TEST_SUITE(MeanStdDev) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) +{ + // Create tensors + Tensor src = create_tensor(shape, data_type); + + // Create output variables + float mean = 0.f; + float std_dev = 0.f; + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create configure function + NEMeanStdDev mean_std_dev_image; + mean_std_dev_image.configure(&src, &mean, &std_dev); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src.info()->padding(), padding); +} + +template +using NEMeanStdDevFixture = MeanStdDevValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, NEMeanStdDevFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate mean output + validate(_target.first, _reference.first); + + // Validate std_dev output + validate(_target.second, _reference.second, tolerance_rel_high_error); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEMeanStdDevFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", + DataType::U8))) +{ + // Validate mean output + validate(_target.first, _reference.first, tolerance_rel_low_error); + + // Validate std_dev output + validate(_target.second, _reference.second, tolerance_rel_high_error); +} + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/MinMaxLocation.cpp b/tests/validation/NEON/MinMaxLocation.cpp deleted file mode 100644 index a467172550..0000000000 --- a/tests/validation/NEON/MinMaxLocation.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "NEON/Helper.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEMinMaxLocation.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon MinMaxLocation function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in Data type of first input tensor. - * @param[out] min Minimum value of tensor - * @param[out] max Maximum value of tensor - * @param[out] min_loc Array with locations of minimum values - * @param[out] max_loc Array with locations of maximum values - * @param[out] min_count Number of minimum values found - * @param[out] max_count Number of maximum values found - * - * @return Computed output tensor. - */ - -void compute_min_max_location(const TensorShape &shape, DataType dt_in, void *min, void *max, - Coordinates2DArray &min_loc, Coordinates2DArray &max_loc, uint32_t &min_count, uint32_t &max_count) -{ - // Create tensor - Tensor src = create_tensor(shape, dt_in); - - // Create and configure min_max_location configure function - NEMinMaxLocation min_max_loc; - min_max_loc.configure(&src, min, max, &min_loc, &max_loc, &min_count, &max_count); - - // Allocate tensors - src.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - - // Compute function - min_max_loc.run(); -} - -void validate_configuration(const Tensor &src, TensorShape shape) -{ - BOOST_TEST(src.info()->is_resizable()); - - // Create output storage - int32_t min; - int32_t max; - Coordinates2DArray min_loc; - Coordinates2DArray max_loc; - uint32_t min_count; - uint32_t max_count; - - // Create and configure function - NEMinMaxLocation min_max_loc; - min_max_loc.configure(&src, &min, &max, &min_loc, &max_loc, &min_count, &max_count); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 1).required_padding(); - validate(src.info()->padding(), padding); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(MinMaxLocation) - -BOOST_AUTO_TEST_SUITE(Integer) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (Small2DShapes() + Large2DShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, dt) -{ - // Create tensor - Tensor src = create_tensor(shape, dt); - src.info()->set_format(dt == DataType::U8 ? Format::U8 : Format::S16); - - validate_configuration(src, shape); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, Small2DShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, dt) -{ - // Create output storage - int32_t min; - int32_t max; - Coordinates2DArray min_loc(shape.total_size()); - Coordinates2DArray max_loc(shape.total_size()); - uint32_t min_count; - uint32_t max_count; - - int32_t ref_min; - int32_t ref_max; - Coordinates2DArray ref_min_loc(shape.total_size()); - Coordinates2DArray ref_max_loc(shape.total_size()); - uint32_t ref_min_count; - uint32_t ref_max_count; - - // Compute function - compute_min_max_location(shape, dt, &min, &max, min_loc, max_loc, min_count, max_count); - - // Compute reference - Reference::compute_reference_min_max_location(shape, dt, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); - - // Validate output - validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, Large2DShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, dt) -{ - // Create output storage - int32_t min; - int32_t max; - Coordinates2DArray min_loc(shape.total_size()); - Coordinates2DArray max_loc(shape.total_size()); - uint32_t min_count; - uint32_t max_count; - - int32_t ref_min; - int32_t ref_max; - Coordinates2DArray ref_min_loc(shape.total_size()); - Coordinates2DArray ref_max_loc(shape.total_size()); - uint32_t ref_min_count; - uint32_t ref_max_count; - - // Compute function - compute_min_max_location(shape, dt, &min, &max, min_loc, max_loc, min_count, max_count); - - // Compute reference - Reference::compute_reference_min_max_location(shape, dt, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); - - // Validate output - validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Float) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, Small2DShapes() * DataType::F32, - shape, dt) -{ - // Create output storage - float min; - float max; - Coordinates2DArray min_loc(shape.total_size()); - Coordinates2DArray max_loc(shape.total_size()); - uint32_t min_count; - uint32_t max_count; - - float ref_min; - float ref_max; - Coordinates2DArray ref_min_loc(shape.total_size()); - Coordinates2DArray ref_max_loc(shape.total_size()); - uint32_t ref_min_count; - uint32_t ref_max_count; - - // Compute function - compute_min_max_location(shape, dt, &min, &max, min_loc, max_loc, min_count, max_count); - - // Compute reference - Reference::compute_reference_min_max_location(shape, dt, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); - - // Validate output - validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); -} - -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/NonLinearFilter.cpp b/tests/validation/NEON/NonLinearFilter.cpp deleted file mode 100644 index ff0a8e71f2..0000000000 --- a/tests/validation/NEON/NonLinearFilter.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Helpers.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NENonLinearFilter.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute NonLinearFilter function. - * - * @param[in] input Shape of the input and output tensors. - * @param[in] function Non linear function to perform - * @param[in] mask_size Mask size. Supported sizes: 3, 5 - * @param[in] pattern Mask pattern - * @param[in] mask The given mask. Will be used only if pattern is specified to PATTERN_OTHER - * @param[in] border_mode Strategy to use for borders. - * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT. - * - * @return Computed output tensor. - */ -Tensor compute_non_linear_filter(const TensorShape &shape, NonLinearFilterFunction function, unsigned int mask_size, - MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, - uint8_t constant_border_value) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - // Create and configure function - NENonLinearFilter filter; - filter.configure(&src, &dst, function, mask_size, pattern, mask, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - - // Compute function - filter.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(NonLinearFilter) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) - * NonLinearFilterFunctions() * boost::unit_test::data::make({ 3U, 5U }) - * MatrixPatterns() * BorderModes(), - shape, function, mask_size, pattern, border_mode) -{ - std::mt19937 generator(user_config.seed.get()); - std::uniform_int_distribution distribution_u8(0, 255); - const uint8_t constant_border_value = distribution_u8(generator); - - // Create the mask - uint8_t mask[mask_size * mask_size]; - fill_mask_from_pattern(mask, mask_size, mask_size, pattern); - const auto half_mask_size = static_cast(mask_size / 2); - - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NENonLinearFilter filter; - filter.configure(&src, &dst, function, mask_size, pattern, mask, border_mode, constant_border_value); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(shape); - const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, BorderSize(half_mask_size)); - - validate(src.info()->valid_region(), src_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), ((MatrixPattern::OTHER == pattern) ? 1 : 8)); - calculator.set_border_mode(border_mode); - calculator.set_border_size(half_mask_size); - - const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER); - - calculator.set_accessed_elements(16); - calculator.set_access_offset(-half_mask_size); - - const PaddingSize read_padding = calculator.required_padding(PaddingCalculator::Option::INCLUDE_BORDER); - - validate(src.info()->padding(), read_padding); - validate(dst.info()->padding(), write_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() - * NonLinearFilterFunctions() * boost::unit_test::data::make({ 3U, 5U }) - * MatrixPatterns() * BorderModes(), - shape, function, mask_size, pattern, border_mode) -{ - std::mt19937 generator(user_config.seed.get()); - std::uniform_int_distribution distribution_u8(0, 255); - const uint8_t constant_border_value = distribution_u8(generator); - - // Create the mask - uint8_t mask[mask_size * mask_size]; - fill_mask_from_pattern(mask, mask_size, mask_size, pattern); - - // Compute function - Tensor dst = compute_non_linear_filter(shape, function, mask_size, pattern, mask, border_mode, constant_border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_non_linear_filter(shape, function, mask_size, pattern, mask, border_mode, constant_border_value); - - // Calculate valid region - const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, BorderSize(static_cast(mask_size / 2))); - - // Validate output - validate(Accessor(dst), ref_dst, valid_region); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() - * NonLinearFilterFunctions() * boost::unit_test::data::make({ 3U, 5U }) - * MatrixPatterns() * BorderModes(), - shape, function, mask_size, pattern, border_mode) -{ - std::mt19937 generator(user_config.seed.get()); - std::uniform_int_distribution distribution_u8(0, 255); - const uint8_t constant_border_value = distribution_u8(generator); - - // Create the mask - uint8_t mask[mask_size * mask_size]; - fill_mask_from_pattern(mask, mask_size, mask_size, pattern); - - // Compute function - Tensor dst = compute_non_linear_filter(shape, function, mask_size, pattern, mask, border_mode, constant_border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_non_linear_filter(shape, function, mask_size, pattern, mask, border_mode, constant_border_value); - - // Calculate valid region - const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, BorderSize(static_cast(mask_size / 2))); - - // Validate output - validate(Accessor(dst), ref_dst, valid_region); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/NormalizationLayer.cpp b/tests/validation/NEON/NormalizationLayer.cpp new file mode 100644 index 0000000000..5d792e9e09 --- /dev/null +++ b/tests/validation/NEON/NormalizationLayer.cpp @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NENormalizationLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/NormalizationTypesDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/NormalizationLayerFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Tolerance for float operations */ +#ifdef ARM_COMPUTE_ENABLE_FP16 +constexpr AbsoluteTolerance tolerance_f16(0.001f); +#endif /* ARM_COMPUTE_ENABLE_FP16 */ +constexpr AbsoluteTolerance tolerance_f32(0.00001f); +/** Tolerance for fixed point operations */ +constexpr AbsoluteTolerance tolerance_qs8(2); +constexpr AbsoluteTolerance tolerance_qs16(3); + +/** Input data set. */ +const auto NormalizationDataset = combine(combine(combine(datasets::SmallShapes(), datasets::NormalizationTypes()), framework::dataset::make("NormalizationSize", 3, 9, 2)), + framework::dataset::make("Beta", { 0.5f, 1.f, 2.f })); +} // namespace + +TEST_SUITE(NEON) +TEST_SUITE(NormalizationLayer) + +//TODO(COMPMID-415): Missing configuration? + +template +using NENormalizationLayerFixture = NormalizationValidationFixture; + +TEST_SUITE(Float) +#ifdef ARM_COMPUTE_ENABLE_FP16 +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, NENormalizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NENormalizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f16); +} +TEST_SUITE_END() +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, NENormalizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f32); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NENormalizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() +TEST_SUITE_END() + +template +using NENormalizationLayerFixedPointFixture = NormalizationValidationFixedPointFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 +FIXTURE_DATA_TEST_CASE(RunSmall, NENormalizationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(NormalizationDataset, framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 1, 6))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_qs8); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NENormalizationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(NormalizationDataset, framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 1, 6))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_qs8); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 +FIXTURE_DATA_TEST_CASE(RunSmall, NENormalizationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(NormalizationDataset, framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_qs16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NENormalizationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(NormalizationDataset, framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_qs16); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/PixelWiseMultiplication.cpp b/tests/validation/NEON/PixelWiseMultiplication.cpp deleted file mode 100644 index f80944821c..0000000000 --- a/tests/validation/NEON/PixelWiseMultiplication.cpp +++ /dev/null @@ -1,583 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEPixelWiseMultiplication.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon pixel-wise multiplication function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] scale Non-negative scale. - * @param[in] convert_policy Overflow policy of the operation. - * @param[in] rounding_policy Rounding policy of the operation. - * @param[in] fixed_point_position (Optional) Fixed point position that expresses the number of bits for the fractional part of the number. - * - * @return Computed output tensor. - */ -Tensor compute_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy, - int fixed_point_position = 0) -{ - // Create tensors - Tensor src1 = create_tensor(shape, dt_in0, 1, fixed_point_position); - Tensor src2 = create_tensor(shape, dt_in1, 1, fixed_point_position); - Tensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); - - // Create and configure function - NEPixelWiseMultiplication multiply; - multiply.configure(&src1, &src2, &dst, scale, convert_policy, rounding_policy); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src1.info()->is_resizable()); - BOOST_TEST(!src2.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src1), 0); - library->fill_tensor_uniform(Accessor(src2), 1); - - // Compute function - multiply.run(); - - return dst; -} - -void validate_configuration(const Tensor &src1, const Tensor &src2, Tensor &dst, TensorShape shape, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) -{ - BOOST_TEST(src1.info()->is_resizable()); - BOOST_TEST(src2.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEPixelWiseMultiplication multiply; - multiply.configure(&src1, &src2, &dst, scale, convert_policy, rounding_policy); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(PixelWiseMultiplication) - -BOOST_AUTO_TEST_SUITE(U8) -BOOST_AUTO_TEST_SUITE(Scale255) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * (1.f / 255.f) * ConvertPolicies() - * RoundingPolicy::TO_NEAREST_UP, - shape, scale, convert_policy, rounding_policy) -{ - // Create tensors - Tensor src1 = create_tensor(shape, DataType::U8); - Tensor src2 = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy, - rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, - DataType::U8, scale, convert_policy, rounding_policy); - - // Validate output - // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion - validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits::max()); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy, - rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, - DataType::U8, scale, convert_policy, rounding_policy); - - // Validate output - // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion - validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits::max()); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(ScaleOther) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) - * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, scale, convert_policy, rounding_policy) -{ - // Create tensors - Tensor src1 = create_tensor(shape, DataType::U8); - Tensor src2 = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy, - rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, - DataType::U8, scale, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy, - rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, - DataType::U8, scale, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(S16) -BOOST_AUTO_TEST_SUITE(Scale255) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * (1.f / 255.f) * ConvertPolicies() - * RoundingPolicy::TO_NEAREST_UP, - shape, dt, scale, convert_policy, rounding_policy) -{ - // Create tensors - Tensor src1 = create_tensor(shape, dt); - Tensor src2 = create_tensor(shape, DataType::S16); - Tensor dst = create_tensor(shape, DataType::S16); - - validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * (1.f / 255.f) * ConvertPolicies() - * RoundingPolicy::TO_NEAREST_UP, - shape, dt, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); - - // Validate output - // Allow tolerance value of 2.f to counteract imprecision due to 32-bit float conversion - validate(Accessor(dst), ref_dst, 2.f, 0.f, std::numeric_limits::max()); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * (1.f / 255.f) * ConvertPolicies() - * RoundingPolicy::TO_NEAREST_UP, - shape, dt, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, - scale, convert_policy, rounding_policy); - - // Validate output - // Allow tolerance value of 2.f to counteract imprecision due to 32-bit float conversion - validate(Accessor(dst), ref_dst, 2.f, 0.f, std::numeric_limits::max()); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(ScaleOther) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) - * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, dt, scale, convert_policy, rounding_policy) -{ - // Create tensors - Tensor src1 = create_tensor(shape, dt); - Tensor src2 = create_tensor(shape, DataType::S16); - Tensor dst = create_tensor(shape, DataType::S16); - - validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, dt, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, dt, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, - scale, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() - -#ifdef ARM_COMPUTE_ENABLE_FP16 -BOOST_AUTO_TEST_SUITE(F16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) - -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F16, DataType::F16, DataType::F16, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F16, DataType::F16, DataType::F16, scale, convert_policy, rounding_policy); - - // Validate output - // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion - validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits::max()); -} - -BOOST_AUTO_TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -BOOST_AUTO_TEST_SUITE(F32) -BOOST_AUTO_TEST_SUITE(Scale255) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * (1.f / 255.f) * ConvertPolicies() - * RoundingPolicy::TO_NEAREST_UP, - shape, scale, convert_policy, rounding_policy) -{ - // Create tensors - Tensor src1 = create_tensor(shape, DataType::F32); - Tensor src2 = create_tensor(shape, DataType::F32); - Tensor dst = create_tensor(shape, DataType::F32); - - validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * (1.f / 255.f) * ConvertPolicies() - * RoundingPolicy::TO_NEAREST_UP, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); - - // Validate output - // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion - validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits::max()); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * (1.f / 255.f) * ConvertPolicies() - * RoundingPolicy::TO_NEAREST_UP, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, - scale, convert_policy, rounding_policy); - - // Validate output - // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion - validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits::max()); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(ScaleOther) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) - * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, scale, convert_policy, rounding_policy) -{ - // Create tensors - Tensor src1 = create_tensor(shape, DataType::F32); - Tensor src2 = create_tensor(shape, DataType::F32); - Tensor dst = create_tensor(shape, DataType::F32); - - validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() - * RoundingPolicy::TO_ZERO, - shape, scale, convert_policy, rounding_policy) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, - scale, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Quantized) -BOOST_AUTO_TEST_SUITE(QS8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 7), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmallScale255, SmallShapes() * DataType::QS8 * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP * boost::unit_test::data::xrange(1, 7), - shape, dt, scale, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmallScaleOther, SmallShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 7), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - const float scale = 1.f / static_cast(1 << fixed_point_position); - - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst, 1.f); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 7), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLargeScale255, LargeShapes() * DataType::QS8 * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 7), - shape, dt, scale, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLargeScaleOther, LargeShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 7), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - const float scale = 1.f / static_cast(1 << fixed_point_position); - - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst, 1.f); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(QS16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::QS16 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 15), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmallScale255, SmallShapes() * DataType::QS16 * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP * boost::unit_test::data::xrange(1, 15), - shape, dt, scale, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmallScaleOther, SmallShapes() * DataType::QS16 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 15), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - const float scale = 1.f / static_cast(1 << fixed_point_position); - - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst, 1.f); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * DataType::QS16 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 15), - shape, dt, convert_policy, rounding_policy, fixed_point_position) -{ - // Compute function - Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/PoolingLayer.cpp b/tests/validation/NEON/PoolingLayer.cpp new file mode 100644 index 0000000000..ac5a28b527 --- /dev/null +++ b/tests/validation/NEON/PoolingLayer.cpp @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/PoolingTypesDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/PoolingLayerFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Input data set for float data types */ +const auto PoolingLayerDatasetFP = combine(combine(datasets::PoolingTypes(), framework::dataset::make("PoolingSize", { 2, 3, 7 })), + framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) })); + +/** Input data set for quantized data types */ +const auto PoolingLayerDatasetQS = combine(combine(datasets::PoolingTypes(), framework::dataset::make("PoolingSize", { 2, 3 })), + framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) })); + +constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for float types */ +#ifdef ARM_COMPUTE_ENABLE_FP16 +constexpr AbsoluteTolerance tolerance_f16(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for float types */ +#endif /* ARM_COMPUTE_ENABLE_FP16 */ +constexpr AbsoluteTolerance tolerance_qs8(0); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */ +constexpr AbsoluteTolerance tolerance_qs16(0); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */ +} // namespace + +TEST_SUITE(NEON) +TEST_SUITE(PoolingLayer) + +//TODO(COMPMID-415): Configuration tests? + +template +using NEPoolingLayerFixture = PoolingLayerValidationFixture; + +TEST_SUITE(Float) +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType", + DataType::F32)))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f32); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType", + DataType::F32)))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() + +#ifdef ARM_COMPUTE_ENABLE_FP16 +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP, + framework::dataset::make("DataType", DataType::F16)))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP, + framework::dataset::make("DataType", DataType::F16)))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f16); +} +TEST_SUITE_END() +#endif /* ARM_COMPUTE_ENABLE_FP16 */ +TEST_SUITE_END() + +template +using NEPoolingLayerFixedPointFixture = PoolingLayerValidationFixedPointFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS, + framework::dataset::make("DataType", DataType::QS8))), + framework::dataset::make("FractionalBits", 1, 5))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_qs8); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS, + framework::dataset::make("DataType", DataType::QS8))), + framework::dataset::make("FractionalBits", 1, 5))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_qs8); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS, + framework::dataset::make("DataType", DataType::QS16))), + framework::dataset::make("FractionalBits", 1, 13))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_qs16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS, + framework::dataset::make("DataType", DataType::QS16))), + framework::dataset::make("FractionalBits", 1, 13))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_qs16); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/QuantizationLayer.cpp b/tests/validation/NEON/QuantizationLayer.cpp new file mode 100644 index 0000000000..5c2fab4653 --- /dev/null +++ b/tests/validation/NEON/QuantizationLayer.cpp @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEQuantizationLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/QuantizationLayerFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Tolerance for quantization */ +constexpr AbsoluteTolerance tolerance_u8(1); +} // namespace + +TEST_SUITE(NEON) +TEST_SUITE(QuantizationLayer) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), framework::dataset::make("DataType", DataType::F32)), shape, data_type) +{ + // Create tensors + Tensor src = create_tensor(shape, data_type); + Tensor dst = create_tensor(shape, DataType::U8); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + NEQuantizationLayer quant_layer; + quant_layer.configure(&src, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 8).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using NEQuantizationLayerFixture = QuantizationValidationFixture; + +TEST_SUITE(Float) +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, NEQuantizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_u8); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEQuantizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_u8); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/ROIPoolingLayer.cpp b/tests/validation/NEON/ROIPoolingLayer.cpp deleted file mode 100644 index 523885d908..0000000000 --- a/tests/validation/NEON/ROIPoolingLayer.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "NEON/Accessor.h" -#include "NEON/ArrayAccessor.h" -#include "TypePrinter.h" -#include "arm_compute/runtime/NEON/functions/NEROIPoolingLayer.h" -#include "tests/Globals.h" -#include "tests/Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -Tensor compute_roi_pooling_layer(const TensorShape &shape, DataType dt, const std::vector &rois, ROIPoolingLayerInfo pool_info) -{ - TensorShape shape_dst; - shape_dst.set(0, pool_info.pooled_width()); - shape_dst.set(1, pool_info.pooled_height()); - shape_dst.set(2, shape.z()); - shape_dst.set(3, rois.size()); - - // Create tensors - Tensor src = create_tensor(shape, dt); - Tensor dst = create_tensor(shape_dst, dt); - - // Create ROI array - Array rois_array(rois.size()); - fill_array(ArrayAccessor(rois_array), rois); - - // Create and configure function - NEROIPoolingLayer roi_pool; - roi_pool.configure(&src, &rois_array, &dst, pool_info); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - std::uniform_real_distribution<> distribution(-1, 1); - library->fill(Accessor(src), distribution, 0); - - // Compute function - roi_pool.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(ROIPoolingLayer) - -BOOST_AUTO_TEST_SUITE(Float) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, CNNFloatDataTypes() * boost::unit_test::data::make({ 10, 20, 40 }) * boost::unit_test::data::make({ 7, 9 }) * boost::unit_test::data::make({ 1.f / 8.f, 1.f / 16.f }), - dt, num_rois, roi_pool_size, roi_scale) -{ - TensorShape shape(50U, 47U, 2U, 3U); - ROIPoolingLayerInfo pool_info(roi_pool_size, roi_pool_size, roi_scale); - - // Construct ROI vector - std::vector rois = generate_random_rois(shape, pool_info, num_rois, user_config.seed); - - // Compute function - Tensor dst = compute_roi_pooling_layer(shape, dt, rois, pool_info); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_roi_pooling_layer(shape, dt, rois, pool_info); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/ReductionOperation.cpp b/tests/validation/NEON/ReductionOperation.cpp new file mode 100644 index 0000000000..4ea71a6336 --- /dev/null +++ b/tests/validation/NEON/ReductionOperation.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEReductionOperation.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ReductionOperationDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/ReductionOperationFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Tolerance for float operations */ +constexpr RelativeTolerance tolerance_f32(0.00001f); +} // namespace + +TEST_SUITE(NEON) +TEST_SUITE(ReductionOperation) + +template +using NEReductionOperationFixture = ReductionOperationValidationFixture; + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, NEReductionOperationFixture, framework::DatasetMode::PRECOMMIT, + combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), datasets::ReductionOperations())) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f32); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEReductionOperationFixture, framework::DatasetMode::NIGHTLY, + combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), datasets::ReductionOperations())) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/Scale.cpp b/tests/validation/NEON/Scale.cpp new file mode 100644 index 0000000000..2fbd7c7014 --- /dev/null +++ b/tests/validation/NEON/Scale.cpp @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEScale.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/BorderModeDataset.h" +#include "tests/datasets/InterpolationPolicyDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Helpers.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/ScaleFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +TEST_SUITE(NEON) +TEST_SUITE(Scale) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes()), + shape, data_type, policy, border_mode) +{ + std::mt19937 generator(library->seed()); + std::uniform_real_distribution distribution_float(0.25, 2); + const float scale_x = distribution_float(generator); + const float scale_y = distribution_float(generator); + uint8_t constant_border_value = 0; + if(border_mode == BorderMode::CONSTANT) + { + std::uniform_int_distribution distribution_u8(0, 255); + constant_border_value = distribution_u8(generator); + } + + // Create tensors + Tensor src = create_tensor(shape, data_type); + TensorShape shape_scaled(shape); + shape_scaled.set(0, shape[0] * scale_x); + shape_scaled.set(1, shape[1] * scale_y); + Tensor dst = create_tensor(shape_scaled, data_type); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + NEScale nescale; + nescale.configure(&src, &dst, policy, border_mode, constant_border_value); + + // Validate valid region + const ValidRegion dst_valid_region = calculate_valid_region_scale(*(src.info()), shape_scaled, policy, BorderSize(1), (border_mode == BorderMode::UNDEFINED)); + + validate(dst.info()->valid_region(), dst_valid_region); + + // Validate padding + PaddingCalculator calculator(shape_scaled.x(), 16); + calculator.set_border_mode(border_mode); + + const PaddingSize read_padding(1); + const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER); + validate(src.info()->padding(), read_padding); + validate(dst.info()->padding(), write_padding); +} + +template +using NEScaleFixture = ScaleValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::U8)), + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes())) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(Accessor(_target), _reference, valid_region); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::U8)), + framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), + datasets::BorderModes())) +{ + //Create valid region + TensorInfo src_info(_shape, 1, _data_type); + ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED)); + + // Validate output + validate(Accessor(_target), _reference, valid_region); +} + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/Sobel3x3.cpp b/tests/validation/NEON/Sobel3x3.cpp deleted file mode 100644 index 74a3144de4..0000000000 --- a/tests/validation/NEON/Sobel3x3.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NESobel3x3.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "PaddingCalculator.h" -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -constexpr unsigned int filter_size = 3; /** Size of the kernel/filter in number of elements. */ -constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ - -/** Compute Neon Sobel 3x3 function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT - * - * @return Computed output tensor. - */ -std::pair compute_sobel_3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst_x = create_tensor(shape, DataType::S16); - Tensor dst_y = create_tensor(shape, DataType::S16); - - src.info()->set_format(Format::U8); - dst_x.info()->set_format(Format::S16); - dst_y.info()->set_format(Format::S16); - - // Create sobel image configure function - NESobel3x3 sobel_3x3; - sobel_3x3.configure(&src, &dst_x, &dst_y, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst_x.allocator()->allocate(); - dst_y.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst_x.info()->is_resizable()); - BOOST_TEST(!dst_y.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - - // Compute function - sobel_3x3.run(); - - return std::make_pair(std::move(dst_x), std::move(dst_y)); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(Sobel3x3) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst_x = create_tensor(shape, DataType::S16); - Tensor dst_y = create_tensor(shape, DataType::S16); - - src.info()->set_format(Format::U8); - dst_x.info()->set_format(Format::S16); - dst_y.info()->set_format(Format::S16); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst_x.info()->is_resizable()); - BOOST_TEST(dst_y.info()->is_resizable()); - - // Create sobel 3x3 configure function - NESobel3x3 sobel_3x3; - sobel_3x3.configure(&src, &dst_x, &dst_y, border_mode); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(shape); - const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - - validate(src.info()->valid_region(), src_valid_region); - validate(dst_x.info()->valid_region(), dst_valid_region); - validate(dst_y.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 8); - - calculator.set_border_mode(border_mode); - calculator.set_border_size(1); - - const PaddingSize dst_padding = calculator.required_padding(); - - calculator.set_accessed_elements(16); - calculator.set_access_offset(-1); - - const PaddingSize src_padding = calculator.required_padding(); - - validate(src.info()->padding(), src_padding); - validate(dst_x.info()->padding(), dst_padding); - validate(dst_y.info()->padding(), dst_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) -{ - uint8_t constant_border_value = 0; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - constant_border_value = distribution(gen); - } - - // Compute function - std::pair dst = compute_sobel_3x3(shape, border_mode, constant_border_value); - - // Compute reference - std::pair ref_dst = Reference::compute_reference_sobel_3x3(shape, border_mode, constant_border_value); - - // Calculate valid region - const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - - // Validate output - validate(Accessor(dst.first), ref_dst.first, valid_region); - validate(Accessor(dst.second), ref_dst.second, valid_region); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) -{ - uint8_t constant_border_value = 0; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - constant_border_value = distribution(gen); - } - - // Compute function - std::pair dst = compute_sobel_3x3(shape, border_mode, constant_border_value); - - // Compute reference - std::pair ref_dst = Reference::compute_reference_sobel_3x3(shape, border_mode, constant_border_value); - - // Calculate valid region - const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - - // Validate output - validate(Accessor(dst.first), ref_dst.first, valid_region); - validate(Accessor(dst.second), ref_dst.second, valid_region); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/Sobel5x5.cpp b/tests/validation/NEON/Sobel5x5.cpp deleted file mode 100644 index d4d48f6afa..0000000000 --- a/tests/validation/NEON/Sobel5x5.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NESobel5x5.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -constexpr unsigned int filter_size = 5; /** Size of the kernel/filter in number of elements. */ -constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ - -/** Compute Neon Sobel 5x5 function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT - * - * @return Computed output tensor. - */ -std::pair compute_sobel_5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst_x = create_tensor(shape, DataType::S16); - Tensor dst_y = create_tensor(shape, DataType::S16); - - src.info()->set_format(Format::U8); - dst_x.info()->set_format(Format::S16); - dst_y.info()->set_format(Format::S16); - - // Create sobel image configure function - NESobel5x5 sobel_5x5; - sobel_5x5.configure(&src, &dst_x, &dst_y, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst_x.allocator()->allocate(); - dst_y.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst_x.info()->is_resizable()); - BOOST_TEST(!dst_y.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - - // Compute function - sobel_5x5.run(); - - return std::make_pair(std::move(dst_x), std::move(dst_y)); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(Sobel5x5) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst_x = create_tensor(shape, DataType::S16); - Tensor dst_y = create_tensor(shape, DataType::S16); - - src.info()->set_format(Format::U8); - dst_x.info()->set_format(Format::S16); - dst_y.info()->set_format(Format::S16); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst_x.info()->is_resizable()); - BOOST_TEST(dst_y.info()->is_resizable()); - - // Create sobel 5x5 configure function - NESobel5x5 sobel_5x5; - sobel_5x5.configure(&src, &dst_x, &dst_y, border_mode); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(shape); - const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - - validate(src.info()->valid_region(), src_valid_region); - validate(dst_x.info()->valid_region(), dst_valid_region); - validate(dst_y.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 16); - - calculator.set_border_mode(border_mode); - calculator.set_border_size(2); - - const PaddingSize dst_padding = calculator.required_padding(); - - calculator.set_processed_elements(8); - calculator.set_access_offset(-2); - - const PaddingSize src_padding = calculator.required_padding(); - - validate(src.info()->padding(), src_padding); - validate(dst_x.info()->padding(), dst_padding); - validate(dst_y.info()->padding(), dst_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) -{ - uint8_t constant_border_value = 0; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - constant_border_value = distribution(gen); - } - - // Compute function - std::pair dst = compute_sobel_5x5(shape, border_mode, constant_border_value); - - // Compute reference - std::pair ref_dst = Reference::compute_reference_sobel_5x5(shape, border_mode, constant_border_value); - - // Calculate valid region - const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - - // Validate output - validate(Accessor(dst.first), ref_dst.first, valid_region); - validate(Accessor(dst.second), ref_dst.second, valid_region); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) -{ - uint8_t constant_border_value = 0; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution(0, 255); - constant_border_value = distribution(gen); - } - - // Compute function - std::pair dst = compute_sobel_5x5(shape, border_mode, constant_border_value); - - // Compute reference - std::pair ref_dst = Reference::compute_reference_sobel_5x5(shape, border_mode, constant_border_value); - - // Calculate valid region - const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - - // Validate output - validate(Accessor(dst.first), ref_dst.first, valid_region); - validate(Accessor(dst.second), ref_dst.second, valid_region); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/SoftmaxLayer.cpp b/tests/validation/NEON/SoftmaxLayer.cpp new file mode 100644 index 0000000000..36f1881147 --- /dev/null +++ b/tests/validation/NEON/SoftmaxLayer.cpp @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NESoftmaxLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/SoftmaxLayerFixture.h" +#include "tests/validation/half.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Tolerance for float operations */ +constexpr AbsoluteTolerance tolerance_f32(0.000001f); +#ifdef ARM_COMPUTE_ENABLE_FP16 +constexpr AbsoluteTolerance tolerance_f16(0.0001f); +#endif /* ARM_COMPUTE_ENABLE_FP16*/ +/** Tolerance for fixed point operations */ +constexpr AbsoluteTolerance tolerance_fixed_point(2); + +/** CNN data types */ +const auto CNNDataTypes = framework::dataset::make("DataType", +{ +#ifdef ARM_COMPUTE_ENABLE_FP16 + DataType::F16, +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + DataType::F32, + DataType::QS8, + DataType::QS16, +}); +} // namespace + +TEST_SUITE(NEON) +TEST_SUITE(SoftmaxLayer) + +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), CNNDataTypes), shape, data_type) +{ + // Set fixed point position data type allowed + const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; + + // Create tensors + Tensor src = create_tensor(shape, data_type, 1, fixed_point_position); + Tensor dst = create_tensor(shape, data_type, 1, fixed_point_position); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Create and configure function + NESoftmaxLayer smx_layer; + smx_layer.configure(&src, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const int step = 16 / data_size_from_type(data_type); + const PaddingSize padding = PaddingCalculator(shape.x(), step).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using NESoftmaxLayerFixture = SoftmaxValidationFixture; + +TEST_SUITE(Float) +#ifdef ARM_COMPUTE_ENABLE_FP16 +TEST_SUITE(FP16) +FIXTURE_DATA_TEST_CASE(RunSmall, NESoftmaxLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f16); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NESoftmaxLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F16))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f16); +} +TEST_SUITE_END() +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + +TEST_SUITE(FP32) +FIXTURE_DATA_TEST_CASE(RunSmall, NESoftmaxLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f32); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NESoftmaxLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_f32); +} +TEST_SUITE_END() +TEST_SUITE_END() + +template +using NESoftmaxLayerFixedPointFixture = SoftmaxValidationFixedPointFixture; + +TEST_SUITE(Quantized) +TEST_SUITE(QS8) +// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 +FIXTURE_DATA_TEST_CASE(RunSmall, NESoftmaxLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 1, 6))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_fixed_point); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NESoftmaxLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::QS8)), + framework::dataset::make("FractionalBits", 1, 6))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_fixed_point); +} +TEST_SUITE_END() + +TEST_SUITE(QS16) +// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 +FIXTURE_DATA_TEST_CASE(RunSmall, NESoftmaxLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_fixed_point); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NESoftmaxLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::QS16)), + framework::dataset::make("FractionalBits", 1, 14))) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance_fixed_point); +} +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/TableLookup.cpp b/tests/validation/NEON/TableLookup.cpp deleted file mode 100644 index 70b767eb16..0000000000 --- a/tests/validation/NEON/TableLookup.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "NEON/Helper.h" -#include "NEON/LutAccessor.h" -#include "PaddingCalculator.h" -#include "RawLutAccessor.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Helpers.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NETableLookup.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Table Lookup function. - * - * @param[in] shape Shape of the input tensors - * @param[in] data_type Datatype of the input/output tensors - * @param[in] lut The input LUT. - * - * @return Computed output tensor. - */ -Tensor compute_table_lookup(const TensorShape &shape, DataType data_type, Lut &lut) -{ - // Create tensors - Tensor src = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); - - // Create and configure function - NETableLookup table_lookup; - table_lookup.configure(&src, &lut, &dst); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - - // Compute function - table_lookup.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(TableLookup) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, data_type) -{ - //Create Lut - const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; - Lut lut(num_elem, data_type); - - if(data_type == DataType::U8) - { - fill_lookuptable(LutAccessor(lut)); - } - else - { - fill_lookuptable(LutAccessor(lut)); - } - - // Create tensors - Tensor src = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NETableLookup table_lookup; - table_lookup.configure(&src, &lut, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, - SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, data_type) -{ - //Create Lut - const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; - Lut lut(num_elem, data_type); - - if(data_type == DataType::U8) - { - //Create rawLut - std::map rawlut; - - //Fill the Lut - fill_lookuptable(LutAccessor(lut)); - fill_lookuptable(RawLutAccessor(rawlut)); - - // Compute function - Tensor dst = compute_table_lookup(shape, data_type, lut); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); - - // Validate output - validate(Accessor(dst), ref_dst); - } - else - { - //Create rawLut - std::map rawlut; - - //Fill the Lut - fill_lookuptable(LutAccessor(lut)); - fill_lookuptable(RawLutAccessor(rawlut)); - - // Compute function - Tensor dst = compute_table_lookup(shape, data_type, lut); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); - - // Validate output - validate(Accessor(dst), ref_dst); - } -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, - LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, data_type) -{ - //Create Lut - const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; - Lut lut(num_elem, data_type); - - if(data_type == DataType::U8) - { - //Create rawLut - std::map rawlut; - - //Fill the Lut - fill_lookuptable(LutAccessor(lut)); - fill_lookuptable(RawLutAccessor(rawlut)); - - // Compute function - Tensor dst = compute_table_lookup(shape, data_type, lut); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); - - // Validate output - validate(Accessor(dst), ref_dst); - } - else - { - //Create rawLut - std::map rawlut; - - //Fill the Lut - fill_lookuptable(LutAccessor(lut)); - fill_lookuptable(RawLutAccessor(rawlut)); - - // Compute function - Tensor dst = compute_table_lookup(shape, data_type, lut); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); - - // Validate output - validate(Accessor(dst), ref_dst); - } -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/Threshold.cpp b/tests/validation/NEON/Threshold.cpp deleted file mode 100644 index f5382d4bfa..0000000000 --- a/tests/validation/NEON/Threshold.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "dataset/ThresholdDataset.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEThreshold.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Threshold function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] threshold Threshold. When the threshold type is RANGE, this is used as the lower threshold. - * @param[in] false_value value to set when the condition is not respected. - * @param[in] true_value value to set when the condition is respected. - * @param[in] type Thresholding type. Either RANGE or BINARY. - * @param[in] upper Upper threshold. Only used when the thresholding type is RANGE. - * - * @return Computed output tensor. - */ -Tensor compute_threshold(const TensorShape &shape, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) -{ - // Create tensors - Tensor src1 = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - // Create and configure function - NEThreshold thrsh; - thrsh.configure(&src1, &dst, threshold, false_value, true_value, type, upper); - - // Allocate tensors - src1.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src1.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src1), 0); - - // Compute function - thrsh.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(Threshold) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, - (SmallShapes() + LargeShapes()) * ThresholdDataset(), - shape, thrshConf) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEThreshold thrsh; - thrsh.configure(&src, &dst, thrshConf.threshold, thrshConf.false_value, thrshConf.true_value, thrshConf.type, thrshConf.upper); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, - SmallShapes() * ThresholdDataset(), - shape, thrshConf) -{ - // Compute function - Tensor dst = compute_threshold(shape, thrshConf.threshold, thrshConf.false_value, thrshConf.true_value, thrshConf.type, thrshConf.upper); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_threshold(shape, thrshConf.threshold, thrshConf.false_value, thrshConf.true_value, thrshConf.type, thrshConf.upper); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, - LargeShapes() * ThresholdDataset(), - shape, thrshConf) -{ - // Compute function - Tensor dst = compute_threshold(shape, thrshConf.threshold, thrshConf.false_value, thrshConf.true_value, thrshConf.type, thrshConf.upper); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_threshold(shape, thrshConf.threshold, thrshConf.false_value, thrshConf.true_value, thrshConf.type, thrshConf.upper); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/WarpPerspective.cpp b/tests/validation/NEON/WarpPerspective.cpp deleted file mode 100644 index 2c102ea37e..0000000000 --- a/tests/validation/NEON/WarpPerspective.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "validation/Datasets.h" -#include "validation/Helpers.h" -#include "validation/Reference.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEWarpPerspective.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Warp Perspective function. - * - * @param[in] input Shape of the input and output tensors. - * @param[in] matrix The perspective matrix. Must be 3x3 of type float. - * @param[in] policy The interpolation type. - * @param[in] border_mode Strategy to use for borders. - * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. - * - * @return Computed output tensor. - */ -Tensor compute_warp_perspective(const TensorShape &shape, const float *matrix, InterpolationPolicy policy, - BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - // Create and configure function - NEWarpPerspective warp_perspective; - warp_perspective.configure(&src, &dst, matrix, policy, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - - // Compute function - warp_perspective.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(WarpPerspective) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) - * boost::unit_test::data::make({ InterpolationPolicy::BILINEAR, InterpolationPolicy::NEAREST_NEIGHBOR }) * BorderModes(), - shape, policy, border_mode) -{ - uint8_t constant_border_value = 0; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution_u8(0, 255); - constant_border_value = distribution_u8(gen); - } - - // Create the matrix - std::array matrix; - fill_warp_matrix<9>(matrix, 3, 3); - - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEWarpPerspective warp_perspective; - warp_perspective.configure(&src, &dst, matrix.data(), policy, border_mode, constant_border_value); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 1); - calculator.set_border_mode(border_mode); - calculator.set_border_size(1); - - const PaddingSize read_padding(1); - const PaddingSize write_padding = calculator.required_padding(); - - validate(src.info()->padding(), read_padding); - validate(dst.info()->padding(), write_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() - * boost::unit_test::data::make({ InterpolationPolicy::BILINEAR, InterpolationPolicy::NEAREST_NEIGHBOR }) - * BorderModes(), - shape, policy, border_mode) -{ - uint8_t constant_border_value = 0; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution_u8(0, 255); - constant_border_value = distribution_u8(gen); - } - - // Create the valid mask Tensor - RawTensor valid_mask(shape, DataType::U8); - - // Create the matrix - std::array matrix; - fill_warp_matrix<9>(matrix, 3, 3); - - // Compute function - Tensor dst = compute_warp_perspective(shape, matrix.data(), policy, border_mode, constant_border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_warp_perspective(shape, valid_mask, matrix.data(), policy, border_mode, constant_border_value); - - // Validate output - validate(Accessor(dst), ref_dst, valid_mask, 1, 0.2f); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() - * boost::unit_test::data::make({ InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR }) * BorderModes(), - shape, policy, border_mode) -{ - uint8_t constant_border_value = 0; - - // Generate a random constant value if border_mode is constant - if(border_mode == BorderMode::CONSTANT) - { - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution distribution_u8(0, 255); - constant_border_value = distribution_u8(gen); - } - - // Create the valid mask Tensor - RawTensor valid_mask(shape, DataType::U8); - - // Create the matrix - std::array matrix; - fill_warp_matrix<9>(matrix, 3, 3); - - // Compute function - Tensor dst = compute_warp_perspective(shape, matrix.data(), policy, border_mode, constant_border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_warp_perspective(shape, valid_mask, matrix.data(), policy, border_mode, constant_border_value); - - // Validate output - validate(Accessor(dst), ref_dst, valid_mask, 1, 0.2f); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/Reference.cpp b/tests/validation/Reference.cpp deleted file mode 100644 index a621fea8a9..0000000000 --- a/tests/validation/Reference.cpp +++ /dev/null @@ -1,510 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Reference.h" - -#include "AssetsLibrary.h" -#include "Globals.h" -#include "Helpers.h" -#include "ReferenceCPP.h" -#include "validation/Helpers.h" - -#include -#include - -using namespace arm_compute::test; - -#ifndef DOXYGEN_SKIP_THIS -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -std::pair Reference::compute_reference_sobel_3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create reference - RawTensor ref_src(shape, Format::U8); - RawTensor ref_dst_x(shape, Format::S16); - RawTensor ref_dst_y(shape, Format::S16); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::sobel_3x3(ref_src, ref_dst_x, ref_dst_y, border_mode, constant_border_value); - - return std::make_pair(ref_dst_x, ref_dst_y); -} - -std::pair Reference::compute_reference_sobel_5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create reference - RawTensor ref_src(shape, Format::U8); - RawTensor ref_dst_x(shape, Format::S16); - RawTensor ref_dst_y(shape, Format::S16); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::sobel_5x5(ref_src, ref_dst_x, ref_dst_y, border_mode, constant_border_value); - - return std::make_pair(ref_dst_x, ref_dst_y); -} -void Reference::compute_reference_min_max_location(const TensorShape &shape, DataType dt_in, void *min, void *max, IArray &min_loc, IArray &max_loc, - uint32_t &min_count, uint32_t &max_count) -{ - // Create reference - RawTensor ref_src(shape, dt_in); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::min_max_location(ref_src, min, max, min_loc, max_loc, min_count, max_count); -} - -KeyPointArray Reference::compute_reference_harris_corners(const TensorShape &shape, float threshold, float min_dist, float sensitivity, - int32_t gradient_size, int32_t block_size, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create reference - RawTensor ref_src(shape, Format::U8); - RawTensor raw_Gx(shape, (gradient_size == 7) ? Format::S32 : Format::S16); - RawTensor raw_Gy(shape, (gradient_size == 7) ? Format::S32 : Format::S16); - RawTensor raw_candidates(shape, Format::F32); - RawTensor raw_non_maxima(shape, Format::F32); - - KeyPointArray corners(shape.total_size()); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::harris_corners(ref_src, raw_Gx, raw_Gy, raw_candidates, raw_non_maxima, threshold, min_dist, sensitivity, gradient_size, block_size, corners, border_mode, constant_border_value); - - return corners; -} - -RawTensor Reference::compute_reference_integral_image(const TensorShape &shape) -{ - // Create reference - RawTensor ref_src(shape, DataType::U8); - RawTensor ref_dst(shape, DataType::U32); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::integral_image(ref_src, ref_dst); - - return ref_dst; -} - -RawTensor Reference::compute_reference_absolute_difference(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out) -{ - // Create reference - RawTensor ref_src1(shape, dt_in0); - RawTensor ref_src2(shape, dt_in1); - RawTensor ref_dst(shape, dt_out); - - // Fill reference - library->fill_tensor_uniform(ref_src1, 0); - library->fill_tensor_uniform(ref_src2, 1); - - // Compute reference - ReferenceCPP::absolute_difference(ref_src1, ref_src2, ref_dst); - - return ref_dst; -} - -RawTensor Reference::compute_reference_accumulate(const TensorShape &shape) -{ - // Create reference - RawTensor ref_src(shape, DataType::U8); - RawTensor ref_dst(shape, DataType::S16); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - library->fill_tensor_uniform(ref_dst, 1); - - // Compute reference - ReferenceCPP::accumulate(ref_src, ref_dst); - - return ref_dst; -} - -RawTensor Reference::compute_reference_accumulate_squared(const TensorShape &shape, uint32_t shift) -{ - // Create reference - RawTensor ref_src(shape, DataType::U8); - RawTensor ref_dst(shape, DataType::S16); - - // Fill reference - // ref_dst tensor filled with non-negative values - library->fill_tensor_uniform(ref_src, 0); - library->fill_tensor_uniform(ref_dst, 1, static_cast(0), std::numeric_limits::max()); - - // Compute reference - ReferenceCPP::accumulate_squared(ref_src, ref_dst, shift); - - return ref_dst; -} - -RawTensor Reference::compute_reference_accumulate_weighted(const TensorShape &shape, float alpha) -{ - // Create reference - RawTensor ref_src(shape, DataType::U8); - RawTensor ref_dst(shape, DataType::U8); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - library->fill_tensor_uniform(ref_dst, 1); - - // Compute reference - ReferenceCPP::accumulate_weighted(ref_src, ref_dst, alpha); - - return ref_dst; -} - -RawTensor Reference::compute_reference_arithmetic_addition(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy convert_policy, int fixed_point_position) -{ - // Create reference - RawTensor ref_src1(shape, dt_in0, 1, fixed_point_position); - RawTensor ref_src2(shape, dt_in1, 1, fixed_point_position); - RawTensor ref_dst(shape, dt_out, 1, fixed_point_position); - - // Fill reference - library->fill_tensor_uniform(ref_src1, 0); - library->fill_tensor_uniform(ref_src2, 1); - - // Compute reference - ReferenceCPP::arithmetic_addition(ref_src1, ref_src2, ref_dst, convert_policy); - - return ref_dst; -} - -RawTensor Reference::compute_reference_arithmetic_subtraction(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy convert_policy, int fixed_point_position) -{ - // Create reference - RawTensor ref_src1(shape, dt_in0, 1, fixed_point_position); - RawTensor ref_src2(shape, dt_in1, 1, fixed_point_position); - RawTensor ref_dst(shape, dt_out, 1, fixed_point_position); - - // Fill reference - library->fill_tensor_uniform(ref_src1, 0); - library->fill_tensor_uniform(ref_src2, 1); - - // Compute reference - ReferenceCPP::arithmetic_subtraction(ref_src1, ref_src2, ref_dst, convert_policy); - - return ref_dst; -} - -RawTensor Reference::compute_reference_box3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create reference - RawTensor ref_src(shape, DataType::U8); - RawTensor ref_dst(shape, DataType::U8); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::box3x3(ref_src, ref_dst, border_mode, constant_border_value); - - return ref_dst; -} - -RawTensor Reference::compute_reference_depth_convert(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, - uint32_t shift, uint32_t fixed_point_position_in, uint32_t fixed_point_position_out) -{ - RawTensor ref_src(shape, dt_in, 1, fixed_point_position_in); - RawTensor ref_dst(shape, dt_out, 1, fixed_point_position_out); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::depth_convert(ref_src, ref_dst, policy, shift); - - return ref_dst; -} - -RawTensor Reference::compute_reference_gaussian3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create reference - RawTensor ref_src(shape, DataType::U8); - RawTensor ref_dst(shape, DataType::U8); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::gaussian3x3(ref_src, ref_dst, border_mode, constant_border_value); - - return ref_dst; -} - -RawTensor Reference::compute_reference_gaussian5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create reference - RawTensor ref_src(shape, DataType::U8); - RawTensor ref_dst(shape, DataType::U8); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::gaussian5x5(ref_src, ref_dst, border_mode, constant_border_value); - - return ref_dst; -} - -RawTensor Reference::compute_reference_non_linear_filter(const TensorShape &shape, NonLinearFilterFunction function, unsigned int mask_size, - MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create reference - RawTensor ref_src(shape, DataType::U8); - RawTensor ref_dst(shape, DataType::U8); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::non_linear_filter(ref_src, ref_dst, function, mask_size, pattern, mask, border_mode, constant_border_value); - - return ref_dst; -} - -RawTensor Reference::compute_reference_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, ConvertPolicy convert_policy, - RoundingPolicy rounding_policy) -{ - // Create reference - RawTensor ref_src1(shape, dt_in0); - RawTensor ref_src2(shape, dt_in1); - RawTensor ref_dst(shape, dt_out); - - // Fill reference - library->fill_tensor_uniform(ref_src1, 0); - library->fill_tensor_uniform(ref_src2, 1); - - // Compute reference - ReferenceCPP::pixel_wise_multiplication(ref_src1, ref_src2, ref_dst, scale, convert_policy, rounding_policy); - - return ref_dst; -} - -RawTensor Reference::compute_reference_fixed_point_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, int fixed_point_position, - ConvertPolicy convert_policy, RoundingPolicy rounding_policy) -{ - // Create reference - RawTensor ref_src1(shape, dt_in0, 1, fixed_point_position); - RawTensor ref_src2(shape, dt_in1, 1, fixed_point_position); - RawTensor ref_dst(shape, dt_out, 1, fixed_point_position); - - // Fill reference - library->fill_tensor_uniform(ref_src1, 0); - library->fill_tensor_uniform(ref_src2, 1); - - // Compute reference - ReferenceCPP::fixed_point_pixel_wise_multiplication(ref_src1, ref_src2, ref_dst, scale, convert_policy, rounding_policy); - - return ref_dst; -} - -template -RawTensor Reference::compute_reference_table_lookup(const TensorShape &shape, DataType dt_inout, std::map &lut) -{ - // Create reference - RawTensor ref_src(shape, dt_inout); - RawTensor ref_dst(shape, dt_inout); - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::table_lookup(ref_src, ref_dst, lut); - - return ref_dst; -} -template RawTensor arm_compute::test::validation::Reference::compute_reference_table_lookup(const TensorShape &shape, DataType dt_inout, std::map &lut); -template RawTensor arm_compute::test::validation::Reference::compute_reference_table_lookup(const TensorShape &shape, DataType dt_inout, std::map &lut); - -RawTensor Reference::compute_reference_threshold(const TensorShape &shape, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) -{ - // Create reference - RawTensor ref_src(shape, DataType::U8); - RawTensor ref_dst(shape, DataType::U8); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::threshold(ref_src, ref_dst, threshold, false_value, true_value, type, upper); - - return ref_dst; -} - -RawTensor Reference::compute_reference_warp_perspective(const TensorShape &shape, RawTensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, - uint8_t constant_border_value) -{ - // Create reference - RawTensor ref_src(shape, DataType::U8); - RawTensor ref_dst(shape, DataType::U8); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::warp_perspective(ref_src, ref_dst, valid_mask, matrix, policy, border_mode, constant_border_value); - - return ref_dst; -} - -RawTensor Reference::compute_reference_batch_normalization_layer(const TensorShape &shape0, const TensorShape &shape1, DataType dt, float epsilon, int fixed_point_position) -{ - // Create reference - RawTensor ref_src(shape0, dt, 1, fixed_point_position); - RawTensor ref_dst(shape0, dt, 1, fixed_point_position); - RawTensor ref_mean(shape1, dt, 1, fixed_point_position); - RawTensor ref_var(shape1, dt, 1, fixed_point_position); - RawTensor ref_beta(shape1, dt, 1, fixed_point_position); - RawTensor ref_gamma(shape1, dt, 1, fixed_point_position); - - // Fill tensors - switch(dt) - { - case DataType::QS8: - { - const std::pair bounds = get_batchnormalization_layer_test_bounds(fixed_point_position); - std::uniform_int_distribution<> distribution(bounds.first, bounds.second); - std::uniform_int_distribution<> distribution_var(0, bounds.second); - fill_tensors(distribution, { 0, 1, 3, 4 }, &ref_src, &ref_mean, &ref_beta, &ref_gamma); - fill_tensors(distribution_var, { 0 }, &ref_var); - break; - } - case DataType::QS16: - { - const std::pair bounds = get_batchnormalization_layer_test_bounds(fixed_point_position); - std::uniform_int_distribution<> distribution(bounds.first, bounds.second); - std::uniform_int_distribution<> distribution_var(0, bounds.second); - fill_tensors(distribution, { 0, 1, 3, 4 }, &ref_src, &ref_mean, &ref_beta, &ref_gamma); - fill_tensors(distribution_var, { 0 }, &ref_var); - break; - } - case DataType::F16: - { - const std::pair bounds = get_batchnormalization_layer_test_bounds(); - std::uniform_real_distribution<> distribution(bounds.first, bounds.second); - std::uniform_real_distribution<> distribution_var(0, bounds.second); - fill_tensors(distribution, { 0, 1, 3, 4 }, &ref_src, &ref_mean, &ref_beta, &ref_gamma); - fill_tensors(distribution_var, { 0 }, &ref_var); - break; - } - case DataType::F32: - { - const std::pair bounds = get_batchnormalization_layer_test_bounds(); - std::uniform_real_distribution<> distribution(bounds.first, bounds.second); - std::uniform_real_distribution<> distribution_var(0, bounds.second); - fill_tensors(distribution, { 0, 1, 3, 4 }, &ref_src, &ref_mean, &ref_beta, &ref_gamma); - fill_tensors(distribution_var, { 0 }, &ref_var); - break; - } - default: - { - ARM_COMPUTE_ERROR("Not supported"); - break; - } - } - - // Compute reference - ReferenceCPP::batch_normalization_layer(ref_src, ref_dst, ref_mean, ref_var, ref_beta, ref_gamma, epsilon, fixed_point_position); - - return ref_dst; -} - -RawTensor Reference::compute_reference_roi_pooling_layer(const TensorShape &shape, DataType dt, const std::vector &rois, const ROIPoolingLayerInfo &pool_info) -{ - TensorShape shape_dst; - shape_dst.set(0, pool_info.pooled_width()); - shape_dst.set(1, pool_info.pooled_height()); - shape_dst.set(2, shape.z()); - shape_dst.set(3, rois.size()); - - // Create reference - RawTensor ref_src(shape, dt); - RawTensor ref_dst(shape_dst, dt); - - // Fill reference - std::uniform_real_distribution<> distribution(-1, 1); - library->fill(ref_src, distribution, 0.0); - - // Compute reference - ReferenceCPP::roi_pooling_layer(ref_src, ref_dst, rois, pool_info); - - return ref_dst; -} - -RawTensor Reference::compute_reference_fixed_point_operation(const TensorShape &shape, DataType dt_in, DataType dt_out, FixedPointOp op, int fixed_point_position) -{ - // Create reference - RawTensor ref_src(shape, dt_in, 1, fixed_point_position); - RawTensor ref_dst(shape, dt_out, 1, fixed_point_position); - - // Fill reference - int min = 0; - int max = 0; - switch(op) - { - case(FixedPointOp::INV_SQRT): - min = 1; - max = (dt_in == DataType::QS8) ? 0x7F : 0x7FFF; - break; - case(FixedPointOp::LOG): - min = (1 << (fixed_point_position - 1)); - max = (dt_in == DataType::QS8) ? 0x3F : 0x3FFF; - break; - case(FixedPointOp::EXP): - min = -(1 << (fixed_point_position - 1)); - max = (1 << (fixed_point_position - 1)); - break; - case(FixedPointOp::RECIPROCAL): - min = 15; - max = (dt_in == DataType::QS8) ? 0x7F : 0x7FFF; - break; - default: - ARM_COMPUTE_ERROR("Fixed point operation not supported"); - } - std::uniform_int_distribution<> distribution(min, max); - library->fill(ref_src, distribution, 0); - - // Compute reference - ReferenceCPP::fixed_point_operation(ref_src, ref_dst, op); - - return ref_dst; -} - -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/Reference.h b/tests/validation/Reference.h deleted file mode 100644 index 698b60e96b..0000000000 --- a/tests/validation/Reference.h +++ /dev/null @@ -1,316 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_H__ -#define __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_H__ - -#include "RawTensor.h" -#include "Types.h" -#include "arm_compute/runtime/Array.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -/** Interface for reference implementations. */ -class Reference -{ -public: - /** Compute reference sobel 3x3. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode Border mode to use for input tensor - * @param[in] constant_border_value Constant value to use if @p border_mode is constant - * - * @return Computed raw tensors along x and y axis. - */ - static std::pair compute_reference_sobel_3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); - /** Compute reference sobel 5x5. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode Border mode to use for input tensor - * @param[in] constant_border_value Constant value to use if @p border_mode is constant - * - * @return Computed raw tensors along x and y axis. - */ - static std::pair compute_reference_sobel_5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); - /** Compute reference Harris corners. - * - * @param[in] shape Shape of input tensor - * @param[in] threshold Minimum threshold with which to eliminate Harris Corner scores (computed using the normalized Sobel kernel). - * @param[in] min_dist Radial Euclidean distance for the euclidean distance stage - * @param[in] sensitivity Sensitivity threshold k from the Harris-Stephens equation - * @param[in] gradient_size The gradient window size to use on the input. The implementation supports 3, 5, and 7 - * @param[in] block_size The block window size used to compute the Harris Corner score. The implementation supports 3, 5, and 7. - * @param[in] border_mode Border mode to use - * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. - * - * @return Computed corners' keypoints. - */ - static KeyPointArray compute_reference_harris_corners(const TensorShape &shape, float threshold, float min_dist, float sensitivity, - int32_t gradient_size, int32_t block_size, BorderMode border_mode, uint8_t constant_border_value); - /** Compute min max location. - * - * @param[in] shape Shape of the input tensors. - * @param[in] dt_in Data type of input tensor. - * @param[out] min Minimum value of tensor - * @param[out] max Maximum value of tensor - * @param[out] min_loc Array with locations of minimum values - * @param[out] max_loc Array with locations of maximum values - * @param[out] min_count Number of minimum values found - * @param[out] max_count Number of maximum values found - * - * @return Computed minimum, maximum values and their locations. - */ - static void compute_reference_min_max_location(const TensorShape &shape, DataType dt_in, void *min, void *max, IArray &min_loc, IArray &max_loc, - uint32_t &min_count, - uint32_t &max_count); - /** Compute reference integral image. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_integral_image(const TensorShape &shape); - /** Compute reference absolute difference. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_absolute_difference(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out); - /** Compute reference accumulate. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_accumulate(const TensorShape &shape); - /** Compute reference accumulate. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] shift A uint32_t value within the range of [0, 15] - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_accumulate_squared(const TensorShape &shape, uint32_t shift); - /** Compute reference accumulate. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] alpha A float value within the range of [0, 1] - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_accumulate_weighted(const TensorShape &shape, float alpha); - /** Compute reference arithmetic addition. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] convert_policy Overflow policy of the operation. - * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_arithmetic_addition(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy convert_policy, int fixed_point_position = 0); - /** Compute reference arithmetic subtraction. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] convert_policy Overflow policy of the operation. - * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_arithmetic_subtraction(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy convert_policy, int fixed_point_position = 0); - /** Compute reference box3x3 filter. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor. - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_box3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); - /** Compute reference depth convert. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in Data type of input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] policy Overflow policy of the operation. - * @param[in] shift Value for down/up conversions. Must be 0 <= shift < 8. - * @param[in] fixed_point_position_in (Optional) Fixed point position for the input tensor. - * @param[in] fixed_point_position_out (Optional) Fixed point position for the output tensor. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_depth_convert(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, - uint32_t shift, uint32_t fixed_point_position_in = 0, uint32_t fixed_point_position_out = 0); - /** Compute reference gaussian3x3 filter. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_gaussian3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); - /** Compute reference gaussian5x5 filter. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor. - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_gaussian5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); - /** Compute reference non linear filter function - * - * @param[in] shape Shape of the input and output tensors.Data type supported: U8 - * @param[in] function Non linear function to perform - * @param[in] mask_size Mask size. Supported sizes: 3, 5 - * @param[in] pattern Matrix pattern - * @param[in] mask The given mask. Will be used only if pattern is specified to PATTERN_OTHER - * @param[in] border_mode Strategy to use for borders. - * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_non_linear_filter(const TensorShape &shape, NonLinearFilterFunction function, unsigned int mask_size, - MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value = 0); - /** Compute reference pixel-wise multiplication - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] scale Non-negative scale. - * @param[in] convert_policy Overflow policy of the operation. - * @param[in] rounding_policy Rounding policy of the operation. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, ConvertPolicy convert_policy, - RoundingPolicy rounding_policy); - /** Compute reference pixel-wise multiplication. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] scale Scale to apply after multiplication. Must be positive. - * @param[in] fixed_point_position Fixed point position that expresses the number of bits for the fractional part of the number. - * @param[in] convert_policy Overflow policy of the operation. - * @param[in] rounding_policy Rounding policy of the operation. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_fixed_point_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, int fixed_point_position, - ConvertPolicy convert_policy, RoundingPolicy rounding_policy); - /** Compute reference Table Lookup. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_inout Data type of input/output tensor. - * @param[in] lut Input lookup table. - * - * @return Computed raw tensor. - */ - template - static RawTensor compute_reference_table_lookup(const TensorShape &shape, DataType dt_inout, std::map &lut); - /** Compute reference threshold. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] threshold Threshold. When the threshold type is RANGE, this is used as the lower threshold. - * @param[in] false_value value to set when the condition is not respected. - * @param[in] true_value value to set when the condition is respected. - * @param[in] type Thresholding type. Either RANGE or BINARY. - * @param[in] upper Upper threshold. Only used when the thresholding type is RANGE. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_threshold(const TensorShape &shape, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper); - - /** Compute reference Warp Perspective. - * - * @param[in] shape Shape of the input and output tensors. - * @param[out] valid_mask Valid mask tensor. - * @param[in] matrix The perspective matrix. Must be 3x3 of type float. - * @param[in] policy The interpolation type. - * @param[in] border_mode Strategy to use for borders. - * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_warp_perspective(const TensorShape &shape, RawTensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, - uint8_t constant_border_value); - - /** Compute reference batch normalization layer. - * - * @param[in] shape0 Shape of the input and output tensors. - * @param[in] shape1 Shape of the vector tensors. - * @param[in] dt Data type of all input and output tensors. - * @param[in] epsilon Small value to avoid division with zero. - * @param[in] fixed_point_position Fixed point position. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_batch_normalization_layer(const TensorShape &shape0, const TensorShape &shape1, DataType dt, float epsilon, int fixed_point_position = 0); - /** Compute reference roi pooling layer. - * - * @param[in] shape Shape of the input tensor. - * @param[in] dt Data type of input and output tensors. - * @param[in] rois Region of interest vector. - * @param[in] pool_info ROI Pooling Layer information. - */ - static RawTensor compute_reference_roi_pooling_layer(const TensorShape &shape, DataType dt, const std::vector &rois, const ROIPoolingLayerInfo &pool_info); - /** Compute reference fixed point operation. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in Data type of the input tensor. - * @param[in] dt_out Data type of the output tensor. - * @param[in] op Fixed point operation to perform. - * @param[in] fixed_point_position Number of bits for the fractional part of the fixed point numbers - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_fixed_point_operation(const TensorShape &shape, DataType dt_in, DataType dt_out, FixedPointOp op, int fixed_point_position); - -protected: - Reference() = default; - ~Reference() = default; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_H__ */ diff --git a/tests/validation/ReferenceCPP.cpp b/tests/validation/ReferenceCPP.cpp deleted file mode 100644 index 029f6586f5..0000000000 --- a/tests/validation/ReferenceCPP.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "ReferenceCPP.h" - -#include "TensorFactory.h" -#include "TensorOperations.h" -#include "TensorVisitors.h" -#include "TypePrinter.h" - -#include "arm_compute/core/Coordinates.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/runtime/Tensor.h" - -#include "boost_wrapper.h" - -#include -#include -#include -#include -#include - -using namespace arm_compute::test::validation::tensor_visitors; - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -// Sobel 3x3 -void ReferenceCPP::sobel_3x3(RawTensor &src, RawTensor &dst_x, RawTensor &dst_y, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst_x.data_type() != DataType::S16 || dst_y.data_type() != DataType::S16); - Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor dx(dst_x.shape(), dst_x.data_type(), dst_x.fixed_point_position(), reinterpret_cast(dst_x.data())); - Tensor dy(dst_y.shape(), dst_y.data_type(), dst_y.fixed_point_position(), reinterpret_cast(dst_y.data())); - tensor_operations::sobel_3x3(s, dx, dy, border_mode, constant_border_value); -} - -// Sobel 5x5 -void ReferenceCPP::sobel_5x5(RawTensor &src, RawTensor &dst_x, RawTensor &dst_y, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst_x.data_type() != DataType::S16 || dst_y.data_type() != DataType::S16); - Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor dx(dst_x.shape(), dst_x.data_type(), dst_x.fixed_point_position(), reinterpret_cast(dst_x.data())); - Tensor dy(dst_y.shape(), dst_y.data_type(), dst_y.fixed_point_position(), reinterpret_cast(dst_y.data())); - tensor_operations::sobel_5x5(s, dx, dy, border_mode, constant_border_value); -} - -// Harris corners -void ReferenceCPP::harris_corners(RawTensor &src, RawTensor &Gx, RawTensor &Gy, const RawTensor &candidates, const RawTensor &non_maxima, float threshold, float min_dist, float sensitivity, - int32_t gradient_size, int32_t block_size, KeyPointArray &corners, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || (Gx.data_type() != DataType::S16 && Gx.data_type() != DataType::S32) || (Gy.data_type() != DataType::S16 && Gy.data_type() != DataType::S32) - || candidates.data_type() != DataType::F32 || non_maxima.data_type() != DataType::F32); - - Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor c(candidates.shape(), candidates.data_type(), candidates.fixed_point_position(), const_cast(reinterpret_cast(candidates.data()))); // NOLINT - Tensor nm(non_maxima.shape(), non_maxima.data_type(), non_maxima.fixed_point_position(), const_cast(reinterpret_cast(non_maxima.data()))); // NOLINT - - if(gradient_size == 7) - { - Tensor gx(Gx.shape(), Gx.data_type(), Gx.fixed_point_position(), reinterpret_cast(Gx.data())); - Tensor gy(Gy.shape(), Gy.data_type(), Gy.fixed_point_position(), reinterpret_cast(Gy.data())); - tensor_operations::harris_corners(s, gx, gy, c, nm, threshold, min_dist, sensitivity, gradient_size, block_size, corners, border_mode, constant_border_value); - } - else - { - Tensor gx(Gx.shape(), Gx.data_type(), Gx.fixed_point_position(), reinterpret_cast(Gx.data())); - Tensor gy(Gy.shape(), Gy.data_type(), Gy.fixed_point_position(), reinterpret_cast(Gy.data())); - tensor_operations::harris_corners(s, gx, gy, c, nm, threshold, min_dist, sensitivity, gradient_size, block_size, corners, border_mode, constant_border_value); - } -} - -// Minimum maximum location -void ReferenceCPP::min_max_location(const RawTensor &src, void *min, void *max, IArray &min_loc, IArray &max_loc, uint32_t &min_count, uint32_t &max_count) -{ - const TensorVariant s = TensorFactory::get_tensor(src); - boost::apply_visitor(tensor_visitors::min_max_location_visitor(min, max, min_loc, max_loc, min_count, max_count), s); -} - -// Absolute difference -void ReferenceCPP::absolute_difference(const RawTensor &src1, const RawTensor &src2, RawTensor &dst) -{ - const TensorVariant s1 = TensorFactory::get_tensor(src1); - const TensorVariant s2 = TensorFactory::get_tensor(src2); - TensorVariant d = TensorFactory::get_tensor(dst); - boost::apply_visitor(absolute_difference_visitor(), s1, s2, d); -} - -// Integral image -void ReferenceCPP::integral_image(const RawTensor &src, RawTensor &dst) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U32); - const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); - tensor_operations::integral_image(s, d); -} - -// Accumulate -void ReferenceCPP::accumulate(const RawTensor &src, RawTensor &dst) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::S16); - const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); - tensor_operations::accumulate(s, d); -} - -// Accumulate squared -void ReferenceCPP::accumulate_squared(const RawTensor &src, RawTensor &dst, uint32_t shift) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::S16); - const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); - tensor_operations::accumulate_squared(s, d, shift); -} - -// Accumulate weighted -void ReferenceCPP::accumulate_weighted(const RawTensor &src, RawTensor &dst, float alpha) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); - const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); - tensor_operations::accumulate_weighted(s, d, alpha); -} - -// Arithmetic addition -void ReferenceCPP::arithmetic_addition(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, ConvertPolicy convert_policy) -{ - const TensorVariant s1 = TensorFactory::get_tensor(src1); - const TensorVariant s2 = TensorFactory::get_tensor(src2); - TensorVariant d = TensorFactory::get_tensor(dst); - boost::apply_visitor(arithmetic_addition_visitor(convert_policy), s1, s2, d); -} - -// Arithmetic subtraction -void ReferenceCPP::arithmetic_subtraction(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, ConvertPolicy convert_policy) -{ - const TensorVariant s1 = TensorFactory::get_tensor(src1); - const TensorVariant s2 = TensorFactory::get_tensor(src2); - TensorVariant d = TensorFactory::get_tensor(dst); - boost::apply_visitor(arithmetic_subtraction_visitor(convert_policy), s1, s2, d); -} - -// Box3x3 filter -void ReferenceCPP::box3x3(const RawTensor &src, RawTensor &dst, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); - const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); - tensor_operations::box3x3(s, d, border_mode, constant_border_value); -} - -// Depth conversion -void ReferenceCPP::depth_convert(const RawTensor &src, RawTensor &dst, ConvertPolicy policy, uint32_t shift) -{ - const TensorVariant s = TensorFactory::get_tensor(src); - TensorVariant d = TensorFactory::get_tensor(dst); - boost::apply_visitor(tensor_visitors::depth_convert_visitor(policy, shift), s, d); -} - -// Gaussian3x3 filter -void ReferenceCPP::gaussian3x3(const RawTensor &src, RawTensor &dst, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); - const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); - tensor_operations::gaussian3x3(s, d, border_mode, constant_border_value); -} - -// Gaussian5x5 filter -void ReferenceCPP::gaussian5x5(const RawTensor &src, RawTensor &dst, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); - const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); - tensor_operations::gaussian5x5(s, d, border_mode, constant_border_value); -} - -// Non linear filter -void ReferenceCPP::non_linear_filter(const RawTensor &src, RawTensor &dst, NonLinearFilterFunction function, unsigned int mask_size, - MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); - const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); - tensor_operations::non_linear_filter(s, d, function, mask_size, pattern, mask, border_mode, constant_border_value); -} - -// Pixel-wise multiplication -void ReferenceCPP::pixel_wise_multiplication(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) -{ - const TensorVariant s1 = TensorFactory::get_tensor(src1); - const TensorVariant s2 = TensorFactory::get_tensor(src2); - TensorVariant d = TensorFactory::get_tensor(dst); - boost::apply_visitor(pixel_wise_multiplication_visitor(scale, convert_policy, rounding_policy), s1, s2, d); -} - -// Fixed-point Pixel-wise multiplication -void ReferenceCPP::fixed_point_pixel_wise_multiplication(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) -{ - const TensorVariant s1 = TensorFactory::get_tensor(src1); - const TensorVariant s2 = TensorFactory::get_tensor(src2); - TensorVariant d = TensorFactory::get_tensor(dst); - boost::apply_visitor(tensor_visitors::fixed_point_pixel_wise_multiplication_visitor(s1, s2, scale, convert_policy, rounding_policy), d); -} - -// Table lookup -template -void ReferenceCPP::table_lookup(const RawTensor &src, RawTensor &dst, std::map &lut) -{ - const TensorVariant s = TensorFactory::get_tensor(src); - TensorVariant d = TensorFactory::get_tensor(dst); - boost::apply_visitor(tensor_visitors::table_lookup(s, lut), d); -} -#ifndef DOXYGEN_SKIP_THIS -template void arm_compute::test::validation::ReferenceCPP::table_lookup(const RawTensor &src, RawTensor &dst, std::map &lut); -template void arm_compute::test::validation::ReferenceCPP::table_lookup(const RawTensor &src, RawTensor &dst, std::map &lut); -#endif /* DOXYGEN_SKIP_THIS */ - -// Threshold -void ReferenceCPP::threshold(const RawTensor &src, RawTensor &dst, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); - const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); - tensor_operations::threshold(s, d, threshold, false_value, true_value, type, upper); -} - -// Warp perspective -void ReferenceCPP::warp_perspective(const RawTensor &src, RawTensor &dst, RawTensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); - const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); - Tensor vmask(valid_mask.shape(), valid_mask.data_type(), valid_mask.fixed_point_position(), reinterpret_cast(valid_mask.data())); - tensor_operations::warp_perspective(s, d, vmask, matrix, policy, border_mode, constant_border_value); -} - -// Batch Normalization Layer -void ReferenceCPP::batch_normalization_layer(const RawTensor &src, RawTensor &dst, const RawTensor &mean, const RawTensor &var, const RawTensor &beta, const RawTensor &gamma, float epsilon, - int fixed_point_position) -{ - const TensorVariant s = TensorFactory::get_tensor(src); - TensorVariant d = TensorFactory::get_tensor(dst); - const TensorVariant m = TensorFactory::get_tensor(mean); - const TensorVariant v = TensorFactory::get_tensor(var); - const TensorVariant b = TensorFactory::get_tensor(beta); - const TensorVariant g = TensorFactory::get_tensor(gamma); - boost::apply_visitor(tensor_visitors::batch_normalization_layer_visitor(s, m, v, b, g, epsilon, fixed_point_position), d); -} - -// ROI Pooling Layer -void ReferenceCPP::roi_pooling_layer(const RawTensor &src, RawTensor &dst, const std::vector &rois, const ROIPoolingLayerInfo &pool_info) -{ - const TensorVariant s = TensorFactory::get_tensor(src); - TensorVariant d = TensorFactory::get_tensor(dst); - boost::apply_visitor(tensor_visitors::roi_pooling_layer_visitor(s, rois, pool_info), d); -} - -// Fixed point operation -void ReferenceCPP::fixed_point_operation(const RawTensor &src, RawTensor &dst, FixedPointOp op) -{ - const TensorVariant s = TensorFactory::get_tensor(src); - TensorVariant d = TensorFactory::get_tensor(dst); - boost::apply_visitor(tensor_visitors::fixed_point_operation_visitor(s, op), d); -} - -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/ReferenceCPP.h b/tests/validation/ReferenceCPP.h deleted file mode 100644 index fcc4da471d..0000000000 --- a/tests/validation/ReferenceCPP.h +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_CPP_H__ -#define __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_CPP_H__ - -#include "RawTensor.h" -#include "Reference.h" - -#include -#include -#include -#include - -namespace arm_compute -{ -class Tensor; - -namespace test -{ -namespace validation -{ -/** C++ reference implementation. */ -class ReferenceCPP final : public Reference -{ -public: - /** Function to compute reference sobel 3x3. - * - * @param[in] src Input tensor. - * @param[in] dst_x Result tensor along x axis - * @param[in] dst_y Result tensor along y axis - * @param[in] border_mode Border mode to use for input tensor - * @param[in] constant_border_value Constant value to use if @p border_mode is constant - * - */ - static void sobel_3x3(RawTensor &src, RawTensor &dst_x, RawTensor &dst_y, BorderMode border_mode, uint8_t constant_border_value); - /** Function to compute reference sobel 5x5. - * - * @param[in] src Input tensor. - * @param[in] dst_x Result tensor along x axis - * @param[in] dst_y Result tensor along y axis - * @param[in] border_mode Border mode to use for input tensor - * @param[in] constant_border_value Constant value to use if @p border_mode is constant - * - */ - static void sobel_5x5(RawTensor &src, RawTensor &dst_x, RawTensor &dst_y, BorderMode border_mode, uint8_t constant_border_value); - /** Function to compute reference Harris corners. - * - * @param[in] src Input tensor - * @param[in] Gx Tensor used to compute Sobel along the x axis - * @param[in] Gy Tensor used to compute Sobel along the y axis - * @param[in] candidates Tensor used to store candidate corners - * @param[in] non_maxima Tensor used to store non_maxima suppressed candidate corners - * @param[in] threshold Minimum threshold with which to eliminate Harris Corner scores (computed using the normalized Sobel kernel). - * @param[in] min_dist Radial Euclidean distance for the euclidean distance stage - * @param[in] sensitivity Sensitivity threshold k from the Harris-Stephens equation - * @param[in] gradient_size The gradient window size to use on the input. The implementation supports 3, 5, and 7 - * @param[in] block_size The block window size used to compute the Harris Corner score. The implementation supports 3, 5, and 7. - * @param[out] corners Array of keypoints to store the results. - * @param[in] border_mode Border mode to use - * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. - * - */ - static void harris_corners(RawTensor &src, RawTensor &Gx, RawTensor &Gy, const RawTensor &candidates, const RawTensor &non_maxima, float threshold, float min_dist, float sensitivity, - int32_t gradient_size, int32_t block_size, KeyPointArray &corners, BorderMode border_mode, uint8_t constant_border_value); - /** Function to compute the min max values and their location in a tensor. - * - * @param[in] src Input tensor. - * @param[out] min Minimum value of the tensor. - * @param[out] max Maximum value of the tensor - * @param[out] min_loc Array with locations of minimum values - * @param[out] max_loc Array with locations of maximum values - * @param[out] min_count Number of minimum values found - * @param[out] max_count Number of maximum values found - */ - static void min_max_location(const RawTensor &src, void *min, void *max, IArray &min_loc, IArray &max_loc, uint32_t &min_count, uint32_t &max_count); - /** Function to compute the integral image of a tensor. - * - * @param[in] src Input tensor. - * @param[out] dst Result tensor. - */ - static void integral_image(const RawTensor &src, RawTensor &dst); - /** Function to compute the absolute difference between two tensors. - * - * @param[in] src1 First tensor. - * @param[in] src2 Second tensor. - * @param[out] dst Result tensor. - */ - static void absolute_difference(const RawTensor &src1, const RawTensor &src2, RawTensor &dst); - /** Function to accumulate an input tensor into an output tensor. - * - * @param[in] src Input tensor. - * @param[in, out] dst Result tensor. - */ - static void accumulate(const RawTensor &src, RawTensor &dst); - /** Function to accumulate a squared value from an input tensor to an output tensor. - * - * @param[in] src Input tensor. - * @param[in, out] dst Result tensor. - * @param[in] shift A uint32_t value within the range of [0, 15] - */ - static void accumulate_squared(const RawTensor &src, RawTensor &dst, uint32_t shift); - /** Function to accumulate a weighted value from an input tensor to an output tensor. - * - * @param[in] src Input tensor. - * @param[in, out] dst Result tensor. - * @param[in] alpha A float value within the range of [0, 1] - */ - static void accumulate_weighted(const RawTensor &src, RawTensor &dst, float alpha); - /** Arithmetic addition of @p src1 and @p src2 - * - * @param[in] src1 First tensor. - * @param[in] src2 Second tensor. - * @param[out] dst Result tensor. - * @param[in] convert_policy Overflow policy. - */ - static void arithmetic_addition(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, ConvertPolicy convert_policy); - /** Arithmetic subtraction of @p src2 from @p src1 - * - * @param[in] src1 First tensor. - * @param[in] src2 Second tensor. - * @param[out] dst Result tensor. - * @param[in] convert_policy Overflow policy. - */ - static void arithmetic_subtraction(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, ConvertPolicy convert_policy); - /** Function to compute box3x3 filtered result tensor. - * - * @param[in] src Input tensor. - * @param[out] dst Result tensor. - * @param[in] border_mode Border mode. - * @param[in] constant_border_value Constant border value if @p border_mode is BorderMode::CONSTANT. - */ - static void box3x3(const RawTensor &src, RawTensor &dst, BorderMode border_mode, uint8_t constant_border_value); - /** Depth conversion from @p src to @p dst - * - * @param[in] src First tensor. - * @param[out] dst Result tensor. - * @param[in] policy Overflow policy. - * @param[in] shift Value for down/up conversions. - */ - static void depth_convert(const RawTensor &src, RawTensor &dst, ConvertPolicy policy, uint32_t shift); - /** Function to compute gaussian3x3 filtered result tensor. - * - * @param[in] src Input tensor. - * @param[out] dst Result tensor. - * @param[in] border_mode Border mode - * @param[in] constant_border_value Constant border value if @p border_mode is BorderMode::CONSTANT - */ - static void gaussian3x3(const RawTensor &src, RawTensor &dst, BorderMode border_mode, uint8_t constant_border_value); - /** Function to compute gaussian5x5 filtered result tensor. - * - * @param[in] src Input tensor. - * @param[out] dst Result tensor. - * @param[in] border_mode Border mode - * @param[in] constant_border_value Constant border value if @p border_mode is BorderMode::CONSTANT - */ - static void gaussian5x5(const RawTensor &src, RawTensor &dst, BorderMode border_mode, uint8_t constant_border_value); - /** Compute non linear filter function. - * - * @param[in] src First input tensor - * @param[out] dst Output tensor - * @param[in] function Non linear function to perform - * @param[in] mask_size Mask size. Supported sizes: 3, 5 - * @param[in] pattern Matrix pattern - * @param[in] mask The given mask. - * @param[in] border_mode Strategy to use for borders. - * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT. - */ - static void non_linear_filter(const RawTensor &src, RawTensor &dst, NonLinearFilterFunction function, unsigned int mask_size, - MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value = 0); - /** Element-wise multiplication of @p src1, @p src2 and @p scale - * - * @param[in] src1 First tensor. - * @param[in] src2 Second tensor. - * @param[out] dst Result tensor. - * @param[in] scale A non-negative float multiplied to each product. - * @param[in] convert_policy Overflow policy. - * @param[in] rounding_policy Rounding policy. - */ - static void pixel_wise_multiplication(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy); - /** Fixed-point Pixel-wise multiplication of @p src1 by @p src2 - * - * @param[in] src1 First tensor. - * @param[in] src2 Second tensor. - * @param[out] dst Result tensor. - * @param[in] scale A non-negative float multiplied to each product. - * @param[in] convert_policy Overflow policy. - * @param[in] rounding_policy Rounding policy. - */ - static void fixed_point_pixel_wise_multiplication(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy); - /** Table Lookup f@p src to @p dst - * - * @param[in] src Input tensor. - * @param[out] dst Result tensor. - * @param[in] lut Input lookup table. - */ - template - static void table_lookup(const RawTensor &src, RawTensor &dst, std::map &lut); - /** Threshold of@p src to @p dst - * - * @param[in] src Input tensor. - * @param[out] dst Result tensor. - * @param[in] threshold Threshold. When the threhold type is RANGE, this is used as the lower threshold. - * @param[in] false_value value to set when the condition is not respected. - * @param[in] true_value value to set when the condition is respected. - * @param[in] type Thresholding type. Either RANGE or BINARY. - * @param[in] upper Upper threshold. Only used when the thresholding type is RANGE. - */ - static void threshold(const RawTensor &src, RawTensor &dst, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper); - /** Warp perspective of@p src to @p dst - * - * @param[in] src First tensor. - * @param[out] dst Result tensor. - * @param[out] valid_mask Valid mask tensor. - * @param[in] matrix The perspective matrix. Must be 3x3 of type float. - * @param[in] policy The interpolation type. - * @param[in] border_mode Strategy to use for borders. - * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. - */ - static void warp_perspective(const RawTensor &src, RawTensor &dst, RawTensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value); - - /** Batch Normalization of @p src based on the information from @p norm_info. - * - * @param[in] src Input tensor. - * @param[out] dst Result tensor. - * @param[out] mean Mean vector tensor. - * @param[out] var Var vector tensor. - * @param[out] beta Beta vector tensor. - * @param[out] gamma Gamma vector tensor. - * @param[in] epsilon Small value to avoid division with zero. - * @param[in] fixed_point_position Fixed point position. - */ - static void batch_normalization_layer(const RawTensor &src, RawTensor &dst, const RawTensor &mean, const RawTensor &var, const RawTensor &beta, const RawTensor &gamma, float epsilon, - int fixed_point_position = 0); - /** ROI Pooling layer of @p src based on the information from @p pool_info and @p rois. - * - * @param[in] src Input tensor. - * @param[out] dst Result tensor. - * @param[in] rois Region of Interest points. - * @param[in] pool_info ROI Pooling Layer information. - */ - static void roi_pooling_layer(const RawTensor &src, RawTensor &dst, const std::vector &rois, const ROIPoolingLayerInfo &pool_info); - /** Fixed point operations of @p src - * - * @param[in] src Input tensor. - * @param[out] dst Result tensor. - * @param[in] op Fixed point operation to perform. - */ - static void fixed_point_operation(const RawTensor &src, RawTensor &dst, FixedPointOp op); - -private: - ReferenceCPP() = delete; - ~ReferenceCPP() = delete; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_CPP_H__ */ diff --git a/tests/validation/Tensor.h b/tests/validation/Tensor.h deleted file mode 100644 index 84d76e7143..0000000000 --- a/tests/validation/Tensor.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_TENSOR_H__ -#define __ARM_COMPUTE_TEST_TENSOR_H__ - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class Tensor -{ -public: - Tensor() - : _shape(), _dt(DataType::UNKNOWN), _fixed_point_position(0), _ptr(nullptr), _ptr_const(nullptr) {}; - - Tensor(TensorShape shape, DataType dt, int fixed_point_position, T *ptr) - : _shape(shape), _dt(dt), _fixed_point_position(fixed_point_position), _ptr(ptr), _ptr_const(nullptr) {}; - - Tensor(TensorShape shape, DataType dt, int fixed_point_position, const T *ptr) - : _shape(shape), _dt(dt), _fixed_point_position(fixed_point_position), _ptr(nullptr), _ptr_const(ptr) {}; - - Tensor(const Tensor &tensor) = delete; - Tensor &operator=(const Tensor &) = delete; - Tensor(Tensor &&) = default; - Tensor &operator=(Tensor &&) = default; - - ~Tensor() = default; - - T &operator[](size_t offset) - { - ARM_COMPUTE_ERROR_ON(_ptr == nullptr); - - return _ptr[offset]; - } - - const T &operator[](size_t offset) const - { - const T *ptr = (_ptr_const != nullptr) ? _ptr_const : _ptr; - - ARM_COMPUTE_ERROR_ON(ptr == nullptr); - - return ptr[offset]; // NOLINT - } - - int num_elements() const - { - return std::accumulate(_shape.cbegin(), _shape.cend(), 1, std::multiplies()); - } - - TensorShape shape() const - { - return _shape; - } - - DataType data_type() const - { - return _dt; - } - - int fixed_point_position() const - { - return _fixed_point_position; - } - - const T *data() const - { - return (_ptr_const != nullptr) ? _ptr_const : _ptr; - } - - T *data() - { - return _ptr; - } - - const T *data_const() const - { - return _ptr_const; - } - -private: - TensorShape _shape; - DataType _dt; - int _fixed_point_position; - T *_ptr; - const T *_ptr_const; -}; -} // namespace validation -} // test -} // arm_compute - -#endif /* __ARM_COMPUTE_TEST_TENSOR_H__ */ diff --git a/tests/validation/TensorFactory.h b/tests/validation/TensorFactory.h deleted file mode 100644 index a3bb5f9615..0000000000 --- a/tests/validation/TensorFactory.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_TENSOR_FACTORY_H__ -#define __ARM_COMPUTE_TEST_TENSOR_FACTORY_H__ - -#include "arm_compute/core/Error.h" -#include "tests/RawTensor.h" -#include "tests/validation/Tensor.h" -#include "tests/validation/half.h" - -#include "boost_wrapper.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -using TensorVariant = boost::variant, Tensor, - Tensor, Tensor, - Tensor, Tensor, - Tensor, - Tensor>; - -/** Helper to create a constant type if the passed reference is constant. */ -template -struct match_const -{ - using type = typename std::conditional::type>::value, const T, T>::type; -}; - -class TensorFactory -{ -public: - template - static TensorVariant get_tensor(R &&raw) - { - TensorVariant v; - DataType dt = raw.data_type(); - int fixed_point_position = raw.fixed_point_position(); - auto shape = raw.shape(); - auto data = raw.data(); - - switch(dt) - { - case DataType::U8: - using value_type_u8 = typename match_const::type; - v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); - break; - case DataType::S8: - case DataType::QS8: - using value_type_s8 = typename match_const::type; - v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); - break; - case DataType::U16: - using value_type_u16 = typename match_const::type; - v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); - break; - case DataType::S16: - case DataType::QS16: - using value_type_s16 = typename match_const::type; - v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); - break; - case DataType::U32: - using value_type_u32 = typename match_const::type; - v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); - break; - case DataType::S32: - using value_type_s32 = typename match_const::type; - v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); - break; - case DataType::F16: - using value_type_f16 = typename match_const::type; - v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); - break; - case DataType::F32: - using value_type_f32 = typename match_const::type; - v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); - break; - default: - ARM_COMPUTE_ERROR("NOT SUPPORTED!"); - } - return v; - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute - -#endif /* __ARM_COMPUTE_TEST_TENSOR_FACTORY_H__ */ diff --git a/tests/validation/TensorOperations.h b/tests/validation/TensorOperations.h deleted file mode 100644 index b9ffa49544..0000000000 --- a/tests/validation/TensorOperations.h +++ /dev/null @@ -1,1178 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_TENSOR_OPERATIONS_H__ -#define __ARM_COMPUTE_TEST_TENSOR_OPERATIONS_H__ - -#include "arm_compute/core/FixedPoint.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "support/ToolchainSupport.h" -#include "tests/Types.h" -#include "tests/Utils.h" -#include "tests/validation/FixedPoint.h" -#include "tests/validation/Tensor.h" -#include "tests/validation/ValidationUserConfiguration.h" -#include "tests/validation/half.h" - -#include -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace tensor_operations -{ -namespace -{ -template -struct is_floating_point - : std::integral_constant < bool, - std::is_same::type>::value || std::is_same::type>::value - || std::is_same::type>::value || std::is_same::type>::value > -{ -}; - -// Return a tensor element at a specified coordinate with different border modes -template -T tensor_elem_at(const Tensor &in, Coordinates coord, BorderMode border_mode, T constant_border_value) -{ - const int x = coord.x(); - const int y = coord.y(); - const int width = static_cast(in.shape().x()); - const int height = static_cast(in.shape().y()); - - // If coordinates beyond range of tensor's width or height - if(x < 0 || y < 0 || x >= width || y >= height) - { - if(border_mode == BorderMode::REPLICATE) - { - coord.set(0, std::max(0, std::min(x, width - 1))); - coord.set(1, std::max(0, std::min(y, height - 1))); - } - else - { - return constant_border_value; - } - } - - return in[coord2index(in.shape(), coord)]; -} - -/** Apply 2D spatial filter on a single element of @p in at coordinates @p coord - * - * - filter sizes have to be odd number - * - Row major order of filter assumed - * - TO_ZERO rounding policy assumed - * - SATURATE convert policy assumed - * - */ -template -void apply_2d_spatial_filter(Coordinates coord, const Tensor &in, Tensor &out, const TensorShape &filter_shape, const T2 *filter_itr, float scale, BorderMode border_mode, - T1 constant_border_value = 0) -{ - double val = 0; - const int x = coord.x(); - const int y = coord.y(); - for(int j = y - static_cast(filter_shape[1] / 2); j <= y + static_cast(filter_shape[1] / 2); ++j) - { - for(int i = x - static_cast(filter_shape[0] / 2); i <= x + static_cast(filter_shape[0] / 2); ++i) - { - coord.set(0, i); - coord.set(1, j); - val += static_cast(*filter_itr) * tensor_elem_at(in, coord, border_mode, constant_border_value); - ++filter_itr; - } - } - coord.set(0, x); - coord.set(1, y); - const double rounded_val = support::cpp11::trunc(val * static_cast(scale)); - out[coord2index(in.shape(), coord)] = saturate_cast(rounded_val); -} -} // namespace - -template -T bilinear_policy(const Tensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value) -{ - int idx = std::floor(xn); - int idy = std::floor(yn); - - const float dx = xn - idx; - const float dy = yn - idy; - const float dx_1 = 1.0f - dx; - const float dy_1 = 1.0f - dy; - - id.set(0, idx); - id.set(1, idy); - const T tl = tensor_elem_at(in, id, border_mode, constant_border_value); - id.set(0, idx + 1); - id.set(1, idy); - const T tr = tensor_elem_at(in, id, border_mode, constant_border_value); - id.set(0, idx); - id.set(1, idy + 1); - const T bl = tensor_elem_at(in, id, border_mode, constant_border_value); - id.set(0, idx + 1); - id.set(1, idy + 1); - const T br = tensor_elem_at(in, id, border_mode, constant_border_value); - - return tl * (dx_1 * dy_1) + tr * (dx * dy_1) + bl * (dx_1 * dy) + br * (dx * dy); -} - -bool valid_bilinear_policy(float xn, float yn, int width, int height, BorderMode border_mode) -{ - if(border_mode != BorderMode::UNDEFINED) - { - return true; - } - if((0 <= yn + 1) && (yn + 1 < height) && (0 <= xn + 1) && (xn + 1 < width)) - { - return true; - } - return false; -} - -// Sobel 3x3 -template -void sobel_3x3(Tensor &in, Tensor &out_x, Tensor &out_y, BorderMode border_mode, uint8_t constant_border_value) -{ - const std::array sobel_x{ { -1, 0, 1, -2, 0, 2, -1, 0, 1 } }; - const std::array sobel_y{ { -1, -2, -1, 0, 0, 0, 1, 2, 1 } }; - - for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) - { - const Coordinates id = index2coord(in.shape(), element_idx); - - apply_2d_spatial_filter(id, in, out_x, TensorShape(3U, 3U), sobel_x.data(), 1.f, border_mode, constant_border_value); - apply_2d_spatial_filter(id, in, out_y, TensorShape(3U, 3U), sobel_y.data(), 1.f, border_mode, constant_border_value); - } -} - -// Sobel 5x5 -template -void sobel_5x5(Tensor &in, Tensor &out_x, Tensor &out_y, BorderMode border_mode, uint8_t constant_border_value) -{ - const std::array sobel_x{ { - -1, -2, 0, 2, 1, - -4, -8, 0, 8, 4, - -6, -12, 0, 12, 6, - -4, -8, 0, 8, 4, - -1, -2, 0, 2, 1 - } }; - - const std::array sobel_y{ { - -1, -4, -6, -4, -1, - -2, -8, -12, -8, -2, - 0, 0, 0, 0, 0, - 2, 8, 12, 8, 2, - 1, 4, 6, 4, 1 - } }; - - for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) - { - const Coordinates id = index2coord(in.shape(), element_idx); - - apply_2d_spatial_filter(id, in, out_x, TensorShape(5U, 5U), sobel_x.data(), 1.f, border_mode, constant_border_value); - apply_2d_spatial_filter(id, in, out_y, TensorShape(5U, 5U), sobel_y.data(), 1.f, border_mode, constant_border_value); - } -} - -// Sobel 7x7 -template -void sobel_7x7(Tensor &in, Tensor &out_x, Tensor &out_y, BorderMode border_mode, uint8_t constant_border_value) -{ - const std::array sobel_x{ { - -1, -4, -5, 0, 5, 4, 1, - -6, -24, -30, 0, 30, 24, 6, - -15, -60, -75, 0, 75, 60, 15, - -20, -80, -100, 0, 100, 80, 20, - -15, -60, -75, 0, 75, 60, 15, - -6, -24, -30, 0, 30, 24, 6, - -1, -4, -5, 0, 5, 4, 1 - } }; - - const std::array sobel_y{ { - -1, -6, -15, -20, -15, -6, -1, - -4, -24, -60, -80, -60, -24, -4, - -5, -30, -75, -100, -75, -30, -5, - 0, 0, 0, 0, 0, 0, 0, - 5, 30, 75, 100, 75, 30, 5, - 4, 24, 60, 80, 60, 24, 4, - 1, 6, 15, 20, 15, 6, 1 - } }; - - for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) - { - const Coordinates id = index2coord(in.shape(), element_idx); - - apply_2d_spatial_filter(id, in, out_x, TensorShape(7U, 7U), sobel_x.data(), 1.f, border_mode, constant_border_value); - apply_2d_spatial_filter(id, in, out_y, TensorShape(7U, 7U), sobel_y.data(), 1.f, border_mode, constant_border_value); - } -} - -template -void non_maxima_suppression_3x3(Tensor &in, Tensor &out, BorderMode border_mode) -{ - for(int i = 0; i < in.num_elements(); ++i) - { - Coordinates coord = index2coord(in.shape(), i); - int x = coord.x(); - int y = coord.y(); - - if(in[i] >= tensor_elem_at(in, Coordinates(x - 1, y - 1), border_mode, 0.f) && in[i] >= tensor_elem_at(in, Coordinates(x, y - 1), border_mode, 0.f) - && in[i] >= tensor_elem_at(in, Coordinates(x + 1, y - 1), border_mode, 0.f) && in[i] >= tensor_elem_at(in, Coordinates(x - 1, y), border_mode, 0.f) - && in[i] > tensor_elem_at(in, Coordinates(x + 1, y), border_mode, 0.f) && in[i] > tensor_elem_at(in, Coordinates(x - 1, y + 1), border_mode, 0.f) - && in[i] > tensor_elem_at(in, Coordinates(x, y + 1), border_mode, 0.f) && in[i] > tensor_elem_at(in, Coordinates(x + 1, y + 1), border_mode, 0.f)) - { - out[i] = in[i]; - } - else - { - out[i] = 0; - } - } -} - -// Harris corners -template -void harris_corners(Tensor &in, Tensor &Gx, Tensor &Gy, Tensor &candidates, Tensor &non_maxima, float threshold, float min_dist, float sensitivity, - int32_t gradient_size, int32_t block_size, KeyPointArray &corners, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(block_size != 3 && block_size != 5 && block_size != 7); - - ValidRegion valid_region = shape_to_valid_region(candidates.shape()); - float norm_factor = 0.f; - - // Sobel - switch(gradient_size) - { - case 3: - sobel_3x3(in, Gx, Gy, border_mode, constant_border_value); - norm_factor = 1.f / (4 * 255 * block_size); - break; - case 5: - sobel_5x5(in, Gx, Gy, border_mode, constant_border_value); - norm_factor = 1.f / (16 * 255 * block_size); - break; - case 7: - sobel_7x7(in, Gx, Gy, border_mode, constant_border_value); - norm_factor = 1.f / (64 * 255 * block_size); - break; - default: - ARM_COMPUTE_ERROR("Gradient size not supported."); - } - - //Calculate scores - for(int i = 0; i < in.num_elements(); ++i) - { - Coordinates in_coord = index2coord(in.shape(), i); - - float Gx2 = 0; - float Gy2 = 0; - float Gxy = 0; - - // Calculate Gx^2, Gy^2 and Gxy within the given window - for(int y = in_coord.y() - block_size / 2; y <= in_coord.y() + block_size / 2; ++y) - { - for(int x = in_coord.x() - block_size / 2; x <= in_coord.x() + block_size / 2; ++x) - { - Coordinates block_coord(x, y); - - float norm_gx = tensor_elem_at(Gx, block_coord, border_mode, static_cast(constant_border_value)) * norm_factor; - float norm_gy = tensor_elem_at(Gy, block_coord, border_mode, static_cast(constant_border_value)) * norm_factor; - - Gx2 += std::pow(norm_gx, 2); - Gy2 += std::pow(norm_gy, 2); - Gxy += norm_gx * norm_gy; - } - } - - float trace2 = std::pow(Gx2 + Gy2, 2); - float det = Gx2 * Gy2 - std::pow(Gxy, 2); - float response = det - sensitivity * trace2; - - if(response > threshold) - { - candidates[i] = response; - } - else - { - candidates[i] = 0.f; - } - } - - // Update valid region and remove candidates on borders for border_mode == UNDEFINED - if(border_mode == BorderMode::UNDEFINED) - { - valid_region = shape_to_valid_region(candidates.shape(), true, BorderSize((gradient_size / 2) + (block_size / 2))); - - for(int i = 0; i < candidates.num_elements(); ++i) - { - if(!is_in_valid_region(valid_region, index2coord(candidates.shape(), i))) - { - candidates[i] = 0.f; - } - } - } - - // Suppress non-maxima candidates - non_maxima_suppression_3x3(candidates, non_maxima, border_mode != BorderMode::UNDEFINED ? BorderMode::CONSTANT : BorderMode::UNDEFINED); - if(border_mode == BorderMode::UNDEFINED) - { - valid_region = shape_to_valid_region(non_maxima.shape(), true, BorderSize((gradient_size / 2) + (block_size / 2) + 1)); - } - - // Create vector of candidate corners - KeyPointArray candidates_vector(corners.max_num_values()); - for(int i = 0; i < non_maxima.num_elements(); ++i) - { - Coordinates coord = index2coord(non_maxima.shape(), i); - - if(non_maxima[i] != 0.f && is_in_valid_region(valid_region, coord)) - { - KeyPoint corner; - corner.x = coord.x(); - corner.y = coord.y(); - corner.tracking_status = 1; - corner.strength = non_maxima[i]; - - corner.scale = 0.f; - corner.orientation = 0.f; - corner.error = 0.f; - - candidates_vector.push_back(corner); - } - } - - // If there are any candidates, sort them by strength and add them to the output corners vector if there are no stronger corners within the given euclidean radius - if(candidates_vector.num_values() > 0) - { - std::sort(candidates_vector.buffer(), candidates_vector.buffer() + candidates_vector.num_values(), [](KeyPoint a, KeyPoint b) - { - return a.strength > b.strength; - }); - corners.push_back(candidates_vector.at(0)); - - for(size_t j = 0; j < candidates_vector.num_values(); ++j) - { - bool found = false; - int32_t x = candidates_vector.at(j).x; - int32_t y = candidates_vector.at(j).y; - - for(size_t i = 0; i < corners.num_values(); ++i) - { - int32_t corners_x = corners.at(i).x; - int32_t corners_y = corners.at(i).y; - - // Euclidean distance - if(std::sqrt((std::pow(x - corners_x, 2) + std::pow(y - corners_y, 2))) < min_dist) - { - found = true; - } - } - - // If no stronger corners within the given euclidean radius - if(!found) - { - corners.push_back(candidates_vector.at(j)); - } - } - } -} - -template -void compute_min_max(const Tensor &in, void *min, void *max) -{ - using type = typename std::conditional::value, float, int32_t>::type; - - // Set min and max to first pixel - type tmp_min = static_cast(in[0]); - type tmp_max = static_cast(in[0]); - - // Look for min and max values - for(int i = 1; i < in.num_elements(); ++i) - { - if(static_cast(in[i]) < tmp_min) - { - tmp_min = static_cast(in[i]); - } - if(static_cast(in[i]) > tmp_max) - { - tmp_max = static_cast(in[i]); - } - } - - *static_cast(min) = tmp_min; - *static_cast(max) = tmp_max; -} - -// Min max location -template -void min_max_location(const Tensor &in, void *min, void *max, IArray &min_loc, IArray &max_loc, uint32_t &min_count, uint32_t &max_count) -{ - const size_t width = in.shape().x(); - - compute_min_max(in, min, max); - - using type = typename std::conditional::value, float, int32_t>::type; - - type min_value = *static_cast(min); - type max_value = *static_cast(max); - - min_count = 0; - max_count = 0; - for(int i = 0; i < in.num_elements(); ++i) - { - if(static_cast(in[i]) == min_value) - { - Coordinates2D min_coord; - min_coord.x = static_cast(i % width); - min_coord.y = static_cast(i / width); - - min_loc.push_back(min_coord); - - min_count++; - } - if(static_cast(in[i]) == max_value) - { - Coordinates2D max_coord; - max_coord.x = static_cast(i % width); - max_coord.y = static_cast(i / width); - - max_loc.push_back(max_coord); - - max_count++; - } - } -} - -// Integral Image -void integral_image(const Tensor &in, Tensor &out) -{ - // Length of dimensions - const size_t width = in.shape().x(); - const size_t height = in.shape().y(); - const size_t depth = in.shape().z() * in.shape()[3] * in.shape()[4] * in.shape()[5]; - - const size_t image_size = width * height; - - for(size_t z = 0; z < depth; ++z) - { - size_t current_image = z * image_size; - - //First element of each image - out[current_image] = in[current_image]; - - // First row of each image (add only pixel on the left) - for(size_t x = 1; x < width; ++x) - { - out[current_image + x] = static_cast(in[current_image + x]) + out[current_image + x - 1]; - } - - // Subsequent rows - for(size_t y = 1; y < height; ++y) - { - size_t current_row = current_image + (width * y); - - // First element of each row (add only pixel up) - out[current_row] = static_cast(in[current_row]) + out[current_row - width]; - - // Following row elements - for(size_t x = 1; x < width; ++x) - { - size_t current_pixel = current_row + x; - - // out = in + up(out) + left(out) - up_left(out) - out[current_pixel] = static_cast(in[current_pixel]) + out[current_pixel - 1] - + out[current_pixel - width] - out[current_pixel - width - 1]; - } - } - } -} - -// Absolute difference -template -void absolute_difference(const Tensor &in1, const Tensor &in2, Tensor &out) -{ - using intermediate_type = typename common_promoted_signed_type::intermediate_type; - - for(int i = 0; i < in1.num_elements(); ++i) - { - intermediate_type val(std::abs(static_cast(in1[i]) - static_cast(in2[i]))); - out[i] = saturate_cast(val); - } -} - -// Accumulate -template -void accumulate(const Tensor &in, Tensor &out) -{ - using intermediate_type = typename common_promoted_signed_type::intermediate_type; - - for(int i = 0; i < in.num_elements(); ++i) - { - intermediate_type val = static_cast(out[i]) + static_cast(in[i]); - out[i] = saturate_cast(val); - } -} - -// Accumulate squared -template -void accumulate_squared(const Tensor &in, Tensor &out, uint32_t shift) -{ - if(shift > 15) - { - ARM_COMPUTE_ERROR("Shift in accumulate_squared must be within the range [0, 15]"); - } - using intermediate_type = typename common_promoted_signed_type::intermediate_type; - intermediate_type denom = 1 << shift; - - for(int i = 0; i < in.num_elements(); ++i) - { - intermediate_type val = static_cast(out[i]) + (static_cast(in[i]) * static_cast(in[i]) / denom); - out[i] = saturate_cast(val); - } -} - -// Accumulate weighted total_size = init_auto_padding(tensor_shape, num_channels, type); -template -void accumulate_weighted(const Tensor &in, Tensor &out, float alpha) -{ - if(alpha < 0.f || alpha > 1.f) - { - ARM_COMPUTE_ERROR("Weight (alpha) specified in accumulate_weighted must be within the range [0, 1]"); - } - using intermediate_type = typename common_promoted_signed_type::intermediate_type; - - for(int i = 0; i < in.num_elements(); ++i) - { - double val = (1. - static_cast(alpha)) * static_cast(out[i]) + static_cast(alpha) * static_cast(in[i]); - out[i] = static_cast(val); - } -} - -// Arithmetic addition -template -void arithmetic_addition(const Tensor &in1, const Tensor &in2, Tensor &out, ConvertPolicy convert_policy) -{ - using intermediate_type = typename common_promoted_signed_type::intermediate_type; - - for(int i = 0; i < in1.num_elements(); ++i) - { - intermediate_type val = static_cast(in1[i]) + static_cast(in2[i]); - out[i] = (convert_policy == ConvertPolicy::SATURATE) ? saturate_cast(val) : static_cast(val); - } -} - -// Arithmetic Subtraction -template -void arithmetic_subtraction(const Tensor &in1, const Tensor &in2, Tensor &out, ConvertPolicy convert_policy) -{ - using intermediate_type = typename common_promoted_signed_type::intermediate_type; - - for(int i = 0; i < in1.num_elements(); ++i) - { - intermediate_type val = static_cast(in1[i]) - static_cast(in2[i]); - out[i] = (convert_policy == ConvertPolicy::SATURATE) ? saturate_cast(val) : static_cast(val); - } -} - -// Box3x3 filter -template ::value>::type> -void box3x3(const Tensor &in, Tensor &out, BorderMode border_mode, T constant_border_value) -{ - const std::array filter{ { 1, 1, 1, 1, 1, 1, 1, 1, 1 } }; - float scale = 1.f / static_cast(filter.size()); - for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) - { - const Coordinates id = index2coord(in.shape(), element_idx); - apply_2d_spatial_filter(id, in, out, TensorShape(3U, 3U), filter.data(), scale, border_mode, constant_border_value); - } -} - -// Depth conversion -template < typename T1, typename T2, typename std::enable_if < std::is_integral::value &&is_floating_point::value, int >::type = 0 > -void depth_convert(const Tensor &in, Tensor &out, ConvertPolicy policy, uint32_t shift) -{ - using namespace fixed_point_arithmetic; - - const int fixed_point_position = in.fixed_point_position(); - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = static_cast(fixed_point(in[i], fixed_point_position, true)); - } -} - -template < typename T1, typename T2, typename std::enable_if < is_floating_point::value &&std::is_integral::value, int >::type = 0 > -void depth_convert(const Tensor &in, Tensor &out, ConvertPolicy policy, uint32_t shift) -{ - using namespace fixed_point_arithmetic; - - const int fixed_point_position = out.fixed_point_position(); - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = fixed_point(in[i], fixed_point_position).raw(); - } -} - -template < typename T1, typename T2, typename std::enable_if < std::is_integral::value &&std::is_integral::value &&!std::is_same::value, int >::type = 0 > -void depth_convert(const Tensor &in, Tensor &out, ConvertPolicy policy, uint32_t shift) -{ - // Up-casting - if(std::numeric_limits::digits <= std::numeric_limits::digits) - { - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = static_cast(in[i]) << shift; - } - } - // Down-casting - else - { - for(int i = 0; i < in.num_elements(); ++i) - { - T1 val = in[i] >> shift; - out[i] = ((policy == ConvertPolicy::SATURATE) ? saturate_cast(val) : static_cast(val)); - } - } -} - -template < typename T1, typename T2, typename std::enable_if < std::is_integral::value &&std::is_integral::value &&std::is_same::value, int >::type = 0 > -void depth_convert(const Tensor &in, Tensor &out, ConvertPolicy policy, uint32_t shift) -{ - using namespace fixed_point_arithmetic; - bool is_in_place = (&in == &out); - - const int fixed_point_position_in = in.fixed_point_position(); - const int fixed_point_position_out = (is_in_place) ? static_cast(shift) : out.fixed_point_position(); - - if(!is_in_place || (fixed_point_position_in != fixed_point_position_out)) - { - for(int i = 0; i < in.num_elements(); ++i) - { - auto x = fixed_point(in[i], fixed_point_position_in, true); - x.rescale(fixed_point_position_out); - out[i] = x.raw(); - } - } -} - -template < typename T1, typename T2, typename std::enable_if < is_floating_point::value &&is_floating_point::value, int >::type = 0 > -void depth_convert(const Tensor &in, Tensor &out, ConvertPolicy policy, uint32_t shift) -{ - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = static_cast(in[i]); - } -} - -// Gaussian3x3 filter -template ::value>::type> -void gaussian3x3(const Tensor &in, Tensor &out, BorderMode border_mode, T constant_border_value) -{ - const std::array filter{ { 1, 2, 1, 2, 4, 2, 1, 2, 1 } }; - const float scale = 1.f / 16.f; - for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) - { - const Coordinates id = index2coord(in.shape(), element_idx); - apply_2d_spatial_filter(id, in, out, TensorShape(3U, 3U), filter.data(), scale, border_mode, constant_border_value); - } -} - -// Gaussian5x5 filter -template ::value>::type> -void gaussian5x5(const Tensor &in, Tensor &out, BorderMode border_mode, T constant_border_value) -{ - const std::array filter{ { - 1, 4, 6, 4, 1, - 4, 16, 24, 16, 4, - 6, 24, 36, 24, 6, - 4, 16, 24, 16, 4, - 1, 4, 6, 4, 1 - } }; - const float scale = 1.f / 256.f; - for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) - { - const Coordinates id = index2coord(in.shape(), element_idx); - apply_2d_spatial_filter(id, in, out, TensorShape(5U, 5U), filter.data(), scale, border_mode, constant_border_value); - } -} - -// Non linear filter -template -void non_linear_filter(const Tensor &in, Tensor &out, NonLinearFilterFunction function, unsigned int mask_size, - MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(pattern == MatrixPattern::OTHER && mask == nullptr); - - using intermediate_type = typename common_promoted_signed_type::intermediate_type; - - const int sq_mask_size = mask_size * mask_size; - const int half_mask_size = mask_size / 2; - std::vector vals(sq_mask_size); - intermediate_type current_value = 0; - - const ValidRegion valid_region = shape_to_valid_region(in.shape(), border_mode == BorderMode::UNDEFINED, BorderSize(half_mask_size)); - - for(int element_idx = 0, count = 0, index = 0; element_idx < in.num_elements(); ++element_idx, count = 0, index = 0) - { - Coordinates id = index2coord(in.shape(), element_idx); - if(is_in_valid_region(valid_region, id)) - { - int idx = id.x(); - int idy = id.y(); - for(int y = idy - half_mask_size; y <= idy + half_mask_size; ++y) - { - for(int x = idx - half_mask_size; x <= idx + half_mask_size; ++x, ++index) - { - id.set(0, x); - id.set(1, y); - current_value = tensor_elem_at(in, id, border_mode, constant_border_value); - - if(mask[index] == 255) - { - vals[count] = static_cast(current_value); - ++count; - } - } - } - std::sort(vals.begin(), vals.begin() + count); - switch(function) - { - case NonLinearFilterFunction::MIN: - out[element_idx] = saturate_cast(vals[0]); - break; - case NonLinearFilterFunction::MAX: - out[element_idx] = saturate_cast(vals[count - 1]); - break; - case NonLinearFilterFunction::MEDIAN: - out[element_idx] = saturate_cast(vals[count / 2]); - break; - default: - ARM_COMPUTE_ERROR("Unsupported NonLinearFilter function."); - } - } - } -} - -// Pixel-wise multiplication -template -void pixel_wise_multiplication(const Tensor &in1, const Tensor &in2, Tensor &out, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) -{ - if(scale < 0) - { - ARM_COMPUTE_ERROR("Scale of pixel-wise multiplication must be non-negative"); - } - using intermediate_type = typename common_promoted_signed_type::intermediate_type; - for(int i = 0; i < in1.num_elements(); ++i) - { - double val = static_cast(in1[i]) * static_cast(in2[i]) * static_cast(scale); - if(is_floating_point::value) - { - out[i] = val; - } - else - { - double rounded_val = 0; - switch(rounding_policy) - { - case(RoundingPolicy::TO_ZERO): - rounded_val = support::cpp11::trunc(val); - break; - case(RoundingPolicy::TO_NEAREST_UP): - rounded_val = round_half_up(val); - break; - case(RoundingPolicy::TO_NEAREST_EVEN): - rounded_val = round_half_even(val); - break; - default: - ARM_COMPUTE_ERROR("Unsupported rounding policy"); - } - out[i] = (convert_policy == ConvertPolicy::SATURATE) ? saturate_cast(rounded_val) : static_cast(rounded_val); - } - } -} - -// Fixed-point Pixel-wise Multiplication -template ::value>::type> -void fixed_point_pixel_wise_multiplication(const Tensor &in1, const Tensor &in2, Tensor &out, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) -{ - using namespace fixed_point_arithmetic; - - const int fixed_point_position = in1.fixed_point_position(); - - ARM_COMPUTE_ERROR_ON_MSG(in1.data_type() != in2.data_type() || in1.data_type() != out.data_type(), - "Tensors must all have the same DataType"); - ARM_COMPUTE_ERROR_ON_MSG(fixed_point_position != in2.fixed_point_position() || fixed_point_position != out.fixed_point_position(), - "Fixed-point position must be the same for both inputs and outputs"); - - // Validate fixed_point_position - ARM_COMPUTE_ERROR_ON((in1.data_type() == DataType::QS8) && (fixed_point_position == 0 || fixed_point_position > 7)); - ARM_COMPUTE_ERROR_ON((in1.data_type() == DataType::QS16) && (fixed_point_position == 0 || fixed_point_position > 15)); - - const fixed_point fp_scale(scale, fixed_point_position); - const bool is_sat = convert_policy == ConvertPolicy::SATURATE; - - for(int i = 0; i < in1.num_elements(); ++i) - { - const fixed_point val1(in1[i], fixed_point_position, true); - fixed_point res(in2[i], fixed_point_position, true); - if(is_sat) - { - res = mul(mul(res, val1), fp_scale); - } - else - { - res = mul(mul(res, val1), fp_scale); - } - out[i] = res.raw(); - } -} - -//Table Lookup -template -void table_lookup(const Tensor &in, Tensor &out, std::map &lut) -{ - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = static_cast(lut[in[i]]); - } -} - -// Threshold -template -void threshold(const Tensor &in, Tensor &out, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) -{ - switch(type) - { - case ThresholdType::BINARY: - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = ((in[i] > threshold) ? true_value : false_value); - } - break; - case ThresholdType::RANGE: - for(int i = 0; i < in.num_elements(); ++i) - { - if(in[i] > upper) - { - out[i] = false_value; - } - else if(in[i] < threshold) - { - out[i] = false_value; - } - else - { - out[i] = true_value; - } - } - break; - default: - ARM_COMPUTE_ERROR("Thresholding type not recognised"); - break; - } -} - -// Warp Perspective -template -void warp_perspective(const Tensor &in, Tensor &out, Tensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) -{ - // x0 = M00 * x + M01 * y + M02 - // y0 = M10 * x + M11 * y + M12 - // z0 = M20 * x + M21 * y + M22 - // xn = x0 / z0 - // yn = y0 / z0 - const float M00 = matrix[0]; - const float M10 = matrix[1]; - const float M20 = matrix[2]; - const float M01 = matrix[0 + 1 * 3]; - const float M11 = matrix[1 + 1 * 3]; - const float M21 = matrix[2 + 1 * 3]; - const float M02 = matrix[0 + 2 * 3]; - const float M12 = matrix[1 + 2 * 3]; - const float M22 = matrix[2 + 2 * 3]; - - const int width = in.shape().x(); - const int height = in.shape().y(); - - for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) - { - valid_mask[element_idx] = 1; - Coordinates id = index2coord(in.shape(), element_idx); - int idx = id.x(); - int idy = id.y(); - const float z0 = M20 * idx + M21 * idy + M22; - - float x0 = (M00 * idx + M01 * idy + M02); - float y0 = (M10 * idx + M11 * idy + M12); - - float xn = x0 / z0; - float yn = y0 / z0; - id.set(0, static_cast(std::floor(xn))); - id.set(1, static_cast(std::floor(yn))); - if((0 <= yn) && (yn < height) && (0 <= xn) && (xn < width)) - { - switch(policy) - { - case InterpolationPolicy::NEAREST_NEIGHBOR: - out[element_idx] = tensor_elem_at(in, id, border_mode, constant_border_value); - break; - case InterpolationPolicy::BILINEAR: - (valid_bilinear_policy(xn, yn, width, height, border_mode)) ? out[element_idx] = bilinear_policy(in, id, xn, yn, border_mode, constant_border_value) : valid_mask[element_idx] = 0; - break; - case InterpolationPolicy::AREA: - default: - ARM_COMPUTE_ERROR("Interpolation not supported"); - } - } - else - { - if(border_mode == BorderMode::UNDEFINED) - { - valid_mask[element_idx] = 0; - } - else - { - switch(policy) - { - case InterpolationPolicy::NEAREST_NEIGHBOR: - if(border_mode == BorderMode::CONSTANT) - { - out[element_idx] = constant_border_value; - } - else if(border_mode == BorderMode::REPLICATE) - { - id.set(0, std::max(0, std::min(static_cast(xn), width - 1))); - id.set(1, std::max(0, std::min(static_cast(yn), height - 1))); - out[element_idx] = in[coord2index(in.shape(), id)]; - } - break; - case InterpolationPolicy::BILINEAR: - out[element_idx] = bilinear_policy(in, id, xn, yn, border_mode, constant_border_value); - break; - case InterpolationPolicy::AREA: - default: - ARM_COMPUTE_ERROR("Interpolation not supported"); - } - } - } - } -} - -// Batch Normalization Layer for fixed point type -template ::value, int>::type * = nullptr> -void batch_normalization_layer(const Tensor &in, Tensor &out, const Tensor &mean, const Tensor &var, const Tensor &beta, const Tensor &gamma, float epsilon, int fixed_point_position) -{ - const int cols = static_cast(in.shape()[0]); - const int rows = static_cast(in.shape()[1]); - const int depth = static_cast(in.shape()[2]); - int upper_dims = in.shape().total_size() / (cols * rows * depth); - - for(int r = 0; r < upper_dims; ++r) - { - for(int i = 0; i < depth; ++i) - { - for(int k = 0; k < rows; ++k) - { - for(int l = 0; l < cols; ++l) - { - const int pos = l + k * cols + i * rows * cols + r * cols * rows * depth; - fixed_point_arithmetic::fixed_point in_qs(in[pos], fixed_point_position, true); - fixed_point_arithmetic::fixed_point var_qs(var[i], fixed_point_position, true); - fixed_point_arithmetic::fixed_point mean_qs(mean[i], fixed_point_position, true); - fixed_point_arithmetic::fixed_point beta_qs(beta[i], fixed_point_position, true); - fixed_point_arithmetic::fixed_point gamma_qs(gamma[i], fixed_point_position, true); - fixed_point_arithmetic::fixed_point epsilon_qs(epsilon, fixed_point_position); - - auto denominator = fixed_point_arithmetic::inv_sqrt(var_qs + epsilon_qs); - auto numerator = in_qs - mean_qs; - auto x_bar = numerator * denominator; - x_bar = beta_qs + x_bar * gamma_qs; - out[pos] = x_bar.raw(); - } - } - } - } -} - -// Batch Normalization Layer for floating point type -template ::value, int>::type * = nullptr> -void batch_normalization_layer(const Tensor &in, Tensor &out, const Tensor &mean, const Tensor &var, const Tensor &beta, const Tensor &gamma, float epsilon, int fixed_point_position) -{ - const int cols = static_cast(in.shape()[0]); - const int rows = static_cast(in.shape()[1]); - const int depth = static_cast(in.shape()[2]); - int upper_dims = in.shape().total_size() / (cols * rows * depth); - - for(int r = 0; r < upper_dims; ++r) - { - for(int i = 0; i < depth; ++i) - { - for(int k = 0; k < rows; ++k) - { - for(int l = 0; l < cols; ++l) - { - const int pos = l + k * cols + i * rows * cols + r * cols * rows * depth; - const float denominator = sqrt(var[i] + epsilon); - const float numerator = in[pos] - mean[i]; - const float x_bar = numerator / denominator; - out[pos] = beta[i] + x_bar * gamma[i]; - } - } - } - } -} - -// ROI Pooling layer -template -void roi_pooling_layer(const Tensor &in, Tensor &out, const std::vector &rois, const ROIPoolingLayerInfo &pool_info) -{ - const int num_rois = rois.size(); - const int width_in = in.shape().x(); - const int height_in = in.shape().y(); - const int fms = in.shape().z(); - const int volume_in = width_in * height_in * fms; - const int pool_w = pool_info.pooled_width(); - const int pool_h = pool_info.pooled_height(); - const int volume_out = pool_w * pool_h * fms; - const float roi_scale = pool_info.spatial_scale(); - - // Iterate through all rois - for(int roi_idx = 0; roi_idx < num_rois; ++roi_idx) - { - // Get dimensions of current ROI - const ROI &roi = rois[roi_idx]; - - int batch_id = roi.batch_idx; - int roi_start_x = support::cpp11::round(roi.rect.x * roi_scale); - int roi_start_y = support::cpp11::round(roi.rect.y * roi_scale); - int roi_width = std::max(support::cpp11::round(roi.rect.width * roi_scale), 1.f); - int roi_height = std::max(support::cpp11::round(roi.rect.height * roi_scale), 1.f); - - // Determine pooling regions - float pool_region_size_x = static_cast(roi_width) / pool_w; - float pool_region_size_y = static_cast(roi_height) / pool_h; - - // Iterate through all channel - for(int fm = 0; fm < fms; ++fm) - { - // Calculate each output pixel - for(int py = 0; py < pool_h; ++py) - { - for(int px = 0; px < pool_w; ++px) - { - int region_start_x = static_cast(std::floor(px * pool_region_size_x)); - int region_end_x = static_cast(std::ceil((px + 1) * pool_region_size_x)); - int region_start_y = static_cast(std::floor(py * pool_region_size_y)); - int region_end_y = static_cast(std::ceil((py + 1) * pool_region_size_y)); - - region_start_x = std::min(std::max(region_start_x + roi_start_x, 0), width_in); - region_end_x = std::min(std::max(region_end_x + roi_start_x, 0), width_in); - region_start_y = std::min(std::max(region_start_y + roi_start_y, 0), height_in); - region_end_y = std::min(std::max(region_end_y + roi_start_y, 0), height_in); - - // Iterate through each pixel in the pooling region - if((region_end_x <= region_start_x) || (region_end_y <= region_start_y)) - { - out[roi_idx * volume_out + fm * pool_w * pool_h + py * pool_w + px] = 0; - } - else - { - T curr_max = std::numeric_limits::lowest(); - for(int j = region_start_y; j < region_end_y; ++j) - { - for(int i = region_start_x; i < region_end_x; ++i) - { - const auto val = in[batch_id * volume_in + fm * width_in * height_in + j * width_in + i]; - curr_max = std::max(val, curr_max); - } - } - out[roi_idx * volume_out + fm * pool_w * pool_h + py * pool_w + px] = curr_max; - } - } - } - } - } -} - -// Fixed point operations -template -void fixed_point_operation(const Tensor &in, Tensor &out, FixedPointOp op) -{ - int p = in.fixed_point_position(); - switch(op) - { - case FixedPointOp::EXP: - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = fixed_point_arithmetic::exp(fixed_point_arithmetic::fixed_point(in[i], p, true)).raw(); - } - break; - case FixedPointOp::LOG: - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = fixed_point_arithmetic::log(fixed_point_arithmetic::fixed_point(in[i], p, true)).raw(); - } - break; - case FixedPointOp::INV_SQRT: - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = fixed_point_arithmetic::inv_sqrt(fixed_point_arithmetic::fixed_point(in[i], p, true)).raw(); - } - break; - case FixedPointOp::RECIPROCAL: - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = fixed_point_arithmetic::div(fixed_point_arithmetic::fixed_point(1, p), fixed_point_arithmetic::fixed_point(in[i], p, true)).raw(); - } - break; - default: - ARM_COMPUTE_ERROR("Fixed point operation not supported"); - break; - } -} - -// Tensor print -template -void print(const Tensor &in, std::ostream &out) -{ - out << "\n"; - for(int i = 0; i < in.num_elements(); ++i) - { - out << in[i] << " "; - } - out << "\n"; -} -} // namespace tensor_operations -} // namespace validation -} // namespace test -} // namespace arm_compute - -#endif /* __ARM_COMPUTE_TEST_TENSOR_OPERATIONS_H__ */ diff --git a/tests/validation/TensorVisitors.h b/tests/validation/TensorVisitors.h deleted file mode 100644 index a15d2ad1dd..0000000000 --- a/tests/validation/TensorVisitors.h +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_TENSOR_VISITORS_H__ -#define __ARM_COMPUTE_TEST_TENSOR_VISITORS_H__ - -#include "Tensor.h" -#include "TensorOperations.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/runtime/Lut.h" - -#include "boost_wrapper.h" - -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace tensor_visitors -{ -// Min max location visitor -struct min_max_location_visitor : public boost::static_visitor<> -{ -public: - explicit min_max_location_visitor(void *min, void *max, IArray &min_loc, IArray &max_loc, uint32_t &min_count, uint32_t &max_count) - : _min(min), _max(max), _min_loc(min_loc), _max_loc(max_loc), _min_count(min_count), _max_count(max_count) - { - } - template - void operator()(const Tensor &in) const - { - tensor_operations::min_max_location(in, _min, _max, _min_loc, _max_loc, _min_count, _max_count); - } - -private: - void *_min; - void *_max; - IArray &_min_loc; - IArray &_max_loc; - uint32_t &_min_count; - uint32_t &_max_count; -}; -// Absolute Difference visitor -struct absolute_difference_visitor : public boost::static_visitor<> -{ -public: - template - void operator()(const Tensor &in1, const Tensor &in2, Tensor &out) const - { - tensor_operations::absolute_difference(in1, in2, out); - } -}; -// Arithmetic Addition visitor -struct arithmetic_addition_visitor : public boost::static_visitor<> -{ -public: - explicit arithmetic_addition_visitor(ConvertPolicy convert_policy) - : _policy(convert_policy) - { - } - - template - void operator()(const Tensor &in1, const Tensor &in2, Tensor &out) const - { - tensor_operations::arithmetic_addition(in1, in2, out, _policy); - } - -private: - ConvertPolicy _policy; -}; -// Arithmetic Subtraction visitor -struct arithmetic_subtraction_visitor : public boost::static_visitor<> -{ -public: - explicit arithmetic_subtraction_visitor(ConvertPolicy convert_policy) - : _policy(convert_policy) - { - } - - template - void operator()(const Tensor &in1, const Tensor &in2, Tensor &out) const - { - tensor_operations::arithmetic_subtraction(in1, in2, out, _policy); - } - -private: - ConvertPolicy _policy; -}; -// Depth Convert visitor -struct depth_convert_visitor : public boost::static_visitor<> -{ -public: - explicit depth_convert_visitor(ConvertPolicy policy, uint32_t shift) - : _policy(policy), _shift(shift) - { - } - - template - void operator()(const Tensor &in, Tensor &out) const - { - tensor_operations::depth_convert(in, out, _policy, _shift); - } - -private: - ConvertPolicy _policy; - uint32_t _shift; -}; -// Pixel-wise Multiplication visitor -struct pixel_wise_multiplication_visitor : public boost::static_visitor<> -{ -public: - explicit pixel_wise_multiplication_visitor(float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) - : _scale(scale), _convert_policy(convert_policy), _rounding_policy(rounding_policy) - { - } - - template - void operator()(const Tensor &in1, const Tensor &in2, Tensor &out) const - { - tensor_operations::pixel_wise_multiplication(in1, in2, out, _scale, _convert_policy, _rounding_policy); - } - -private: - float _scale; - ConvertPolicy _convert_policy; - RoundingPolicy _rounding_policy; -}; -// Fixed Point Pixel-wise Multiplication visitor -struct fixed_point_pixel_wise_multiplication_visitor : public boost::static_visitor<> -{ -public: - explicit fixed_point_pixel_wise_multiplication_visitor(const TensorVariant &in1, const TensorVariant &in2, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) - : _in1(in1), _in2(in2), _scale(scale), _convert_policy(convert_policy), _rounding_policy(rounding_policy) - { - } - - template ::value>::type> - void operator()(Tensor &out) const - { - const Tensor &in1 = boost::get>(_in1); - const Tensor &in2 = boost::get>(_in2); - tensor_operations::fixed_point_pixel_wise_multiplication(in1, in2, out, _scale, _convert_policy, _rounding_policy); - } - template < typename T, typename std::enable_if < !std::is_integral::value, int >::type = 0 > - void operator()(Tensor &out) const - { - ARM_COMPUTE_ERROR("NOT SUPPORTED!"); - } - -private: - const TensorVariant &_in1; - const TensorVariant &_in2; - float _scale; - ConvertPolicy _convert_policy; - RoundingPolicy _rounding_policy; -}; -// Table lookup operation -template -struct table_lookup : public boost::static_visitor<> -{ -public: - explicit table_lookup(const TensorVariant &in, std::map &lut) - : _in(in), _lut(lut) - { - } - - template - void operator()(Tensor &out) const - { - const auto &in = boost::get>(_in); - tensor_operations::table_lookup(in, out, _lut); - } - -private: - const TensorVariant &_in; - std::map &_lut; -}; -template struct arm_compute::test::validation::tensor_visitors::table_lookup; -template struct arm_compute::test::validation::tensor_visitors::table_lookup; - -// Batch Normalization Layer visitor -struct batch_normalization_layer_visitor : public boost::static_visitor<> -{ -public: - explicit batch_normalization_layer_visitor(const TensorVariant &in, const TensorVariant &mean, const TensorVariant &var, const TensorVariant &beta, const TensorVariant &gamma, float epsilon, - int fixed_point_position = 0) - : _in(in), _mean(mean), _var(var), _beta(beta), _gamma(gamma), _epsilon(epsilon), _fixed_point_position(fixed_point_position) - { - } - - template - void operator()(Tensor &out) const - { - const Tensor &in = boost::get>(_in); - const Tensor &mean = boost::get>(_mean); - const Tensor &var = boost::get>(_var); - const Tensor &beta = boost::get>(_beta); - const Tensor &gamma = boost::get>(_gamma); - tensor_operations::batch_normalization_layer(in, out, mean, var, beta, gamma, _epsilon, _fixed_point_position); - } - -private: - const TensorVariant &_in, &_mean, &_var, &_beta, &_gamma; - float _epsilon; - int _fixed_point_position; -}; - -// ROI Pooling layer -struct roi_pooling_layer_visitor : public boost::static_visitor<> -{ -public: - explicit roi_pooling_layer_visitor(const TensorVariant &in, const std::vector &rois, ROIPoolingLayerInfo pool_info) - : _in(in), _rois(rois), _pool_info(pool_info) - { - } - - template - void operator()(Tensor &out) const - { - const Tensor &in = boost::get>(_in); - tensor_operations::roi_pooling_layer(in, out, _rois, _pool_info); - } - -private: - const TensorVariant &_in; - const std::vector &_rois; - ROIPoolingLayerInfo _pool_info; -}; - -// Fixed Point operations visitor -struct fixed_point_operation_visitor : public boost::static_visitor<> -{ -public: - explicit fixed_point_operation_visitor(const TensorVariant &in, FixedPointOp op) - : _in(in), _op(op) - { - } - - template ::value, int>::type = 0> - void operator()(Tensor &out) const - { - const Tensor &in = boost::get>(_in); - tensor_operations::fixed_point_operation(in, out, _op); - } - template < typename T, typename std::enable_if < !std::is_integral::value, int >::type = 0 > - void operator()(Tensor &out) const - { - ARM_COMPUTE_ERROR("NOT SUPPORTED!"); - } - -private: - const TensorVariant &_in; - FixedPointOp _op; -}; -// Print Tensor visitor -struct print_visitor : public boost::static_visitor<> -{ -public: - explicit print_visitor(std::ostream &out) - : _out(out) - { - } - - template - void operator()(const Tensor &in) const - { - tensor_operations::print(in, _out); - } - -private: - std::ostream &_out; -}; -} // namespace tensor_visitors -} // namespace validation -} // namespace test -} // namespace arm_compute - -#endif /* __ARM_COMPUTE_TEST_TENSOR_VISITORS_H__ */ diff --git a/tests/validation/UNIT/CMakeLists.txt b/tests/validation/UNIT/CMakeLists.txt deleted file mode 100644 index a0603f150c..0000000000 --- a/tests/validation/UNIT/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (c) 2017 ARM Limited. -# -# SPDX-License-Identifier: MIT -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -cmake_minimum_required (VERSION 3.1) - -set(arm_compute_test_validation_UNIT_SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/TensorInfo.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Utils.cpp -) - -add_library(arm_compute_test_validation_UNIT OBJECT - ${arm_compute_test_validation_UNIT_SOURCE_FILES} -) - -set(arm_compute_test_validation_TARGET_OBJECTS - ${arm_compute_test_validation_TARGET_OBJECTS} - $ - PARENT_SCOPE -) diff --git a/tests/validation/UNIT/FixedPoint.cpp b/tests/validation/UNIT/FixedPoint.cpp deleted file mode 100644 index 00cab9eb29..0000000000 --- a/tests/validation/UNIT/FixedPoint.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "validation/FixedPoint.h" - -#include "TypePrinter.h" -#include "Utils.h" -#include "support/ToolchainSupport.h" -#include "validation/Validation.h" -#include "validation/ValidationUserConfiguration.h" - -#include "boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -std::string func_names[] = -{ - "add", "sub", "mul", "exp", "log", "inv_sqrt" -}; -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(UNIT) -BOOST_AUTO_TEST_SUITE(FixedPoint) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(FixedPointQS8Inputs, boost::unit_test::data::make(func_names) * boost::unit_test::data::xrange(1, 7), func_name, frac_bits) -{ - const std::string base_file_name = user_config.path.get() + "/dumps/" + func_name + "_Q8." + support::cpp11::to_string(frac_bits); - std::ifstream inputs_file{ base_file_name + ".in", std::ios::binary | std::ios::in }; - - BOOST_TEST_INFO(base_file_name + ".in"); - BOOST_TEST_REQUIRE(inputs_file.good()); - - float float_val = 0.f; - - // Read first value - inputs_file.read(reinterpret_cast(&float_val), sizeof(float_val)); - - while(inputs_file.good()) - { - // Convert to fixed point - fixed_point_arithmetic::fixed_point in_val(float_val, frac_bits); - - // Check that the value didn't change - BOOST_TEST(static_cast(in_val) == float_val); - - // Read next value - inputs_file.read(reinterpret_cast(&float_val), sizeof(float_val)); - } -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -//FIXME: Figure out how to handle expected failures properly -// The last input argument specifies the expected number of failures for a -// given combination of (function name, number of fractional bits) as defined -// by the first two arguments. -BOOST_DATA_TEST_CASE(FixedPointQS8Outputs, (boost::unit_test::data::make(func_names) * boost::unit_test::data::xrange(1, 7)) ^ (boost::unit_test::data::make({ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 13, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 33, 96 })), - func_name, frac_bits, expected_failures) -{ - const std::string base_file_name = user_config.path.get() + "/dumps/" + func_name + "_Q8." + support::cpp11::to_string(frac_bits); - std::ifstream inputs_file{ base_file_name + ".in", std::ios::binary | std::ios::in }; - std::ifstream reference_file{ base_file_name + ".out", std::ios::binary | std::ios::in }; - - BOOST_TEST_INFO(base_file_name + ".in"); - BOOST_TEST_REQUIRE(inputs_file.good()); - BOOST_TEST_INFO(base_file_name + ".out"); - BOOST_TEST_REQUIRE(reference_file.good()); - - const float step_size = std::pow(2.f, -frac_bits); - - float float_val = 0.f; - float ref_val = 0.f; - int64_t num_mismatches = 0; - - // Read first values - inputs_file.read(reinterpret_cast(&float_val), sizeof(float_val)); - reference_file.read(reinterpret_cast(&ref_val), sizeof(ref_val)); - - while(inputs_file.good() && reference_file.good()) - { - fixed_point_arithmetic::fixed_point in_val(float_val, frac_bits); - fixed_point_arithmetic::fixed_point out_val(0.f, frac_bits); - - float tolerance = 0.f; - - if(func_name == "add") - { - out_val = in_val + in_val; - } - else if(func_name == "sub") - { - out_val = in_val - in_val; //NOLINT - } - else if(func_name == "mul") - { - tolerance = 1.f * step_size; - out_val = in_val * in_val; - } - else if(func_name == "exp") - { - tolerance = 2.f * step_size; - out_val = fixed_point_arithmetic::exp(in_val); - } - else if(func_name == "log") - { - tolerance = 4.f * step_size; - out_val = fixed_point_arithmetic::log(in_val); - } - else if(func_name == "inv_sqrt") - { - tolerance = 5.f * step_size; - out_val = fixed_point_arithmetic::inv_sqrt(in_val); - } - - if(std::abs(static_cast(out_val) - ref_val) > tolerance) - { - BOOST_TEST_INFO("input = " << in_val); - BOOST_TEST_INFO("output = " << out_val); - BOOST_TEST_INFO("reference = " << ref_val); - BOOST_TEST_INFO("tolerance = " << tolerance); - BOOST_TEST_WARN((std::abs(static_cast(out_val) - ref_val) <= tolerance)); - - ++num_mismatches; - } - - // Read next values - inputs_file.read(reinterpret_cast(&float_val), sizeof(float_val)); - reference_file.read(reinterpret_cast(&ref_val), sizeof(ref_val)); - } - - BOOST_TEST(num_mismatches == expected_failures); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/UNIT/TensorInfo.cpp b/tests/validation/UNIT/TensorInfo.cpp deleted file mode 100644 index c74cfebfe4..0000000000 --- a/tests/validation/UNIT/TensorInfo.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "TypePrinter.h" -#include "validation/Validation.h" - -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Types.h" - -#include "boost_wrapper.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(UNIT) -BOOST_AUTO_TEST_SUITE(TensorInfoValidation) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(AutoPadding, - boost::unit_test::data::make({ TensorShape{}, - TensorShape{ 10U }, - TensorShape{ 10U, 10U }, - TensorShape{ 10U, 10U, 10U }, - TensorShape{ 10U, 10U, 10U, 10U }, - TensorShape{ 10U, 10U, 10U, 10U, 10U }, - TensorShape{ 10U, 10U, 10U, 10U, 10U, 10U } - }) - ^ boost::unit_test::data::make({ PaddingSize{ 0, 0, 0, 0 }, - PaddingSize{ 0, 36, 0, 4 }, - PaddingSize{ 4, 36, 4, 4 }, - PaddingSize{ 4, 36, 4, 4 }, - PaddingSize{ 4, 36, 4, 4 }, - PaddingSize{ 4, 36, 4, 4 }, - PaddingSize{ 4, 36, 4, 4 } - }) - ^ boost::unit_test::data::make({ Strides{}, - Strides{ 1U }, - Strides{ 1U, 50U }, - Strides{ 1U, 50U, 900U }, - Strides{ 1U, 50U, 900U, 9000U }, - Strides{ 1U, 50U, 900U, 9000U, 90000U }, - Strides{ 1U, 50U, 900U, 9000U, 90000U, 900000U } - }) - ^ boost::unit_test::data::make( -{ - 0, - 4, - 204, - 204, - 204, - 204, - 204, -}), -shape, auto_padding, strides, offset) -{ - TensorInfo info{ shape, Format::U8 }; - - BOOST_TEST(!info.has_padding()); - - info.auto_padding(); - - validate(info.padding(), auto_padding); - BOOST_TEST(compare_dimensions(info.strides_in_bytes(), strides)); - BOOST_TEST(info.offset_first_element_in_bytes() == offset); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/UNIT/TensorShape.cpp b/tests/validation/UNIT/TensorShape.cpp deleted file mode 100644 index 4c1ef680b5..0000000000 --- a/tests/validation/UNIT/TensorShape.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "TypePrinter.h" -#include "validation/Validation.h" - -#include "arm_compute/core/TensorShape.h" - -#include "boost_wrapper.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(UNIT) -BOOST_AUTO_TEST_SUITE(TensorShapeValidation) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Construction, - boost::unit_test::data::make({ TensorShape{}, - TensorShape{ 1U }, - TensorShape{ 2U }, - TensorShape{ 2U, 3U }, - TensorShape{ 2U, 3U, 5U }, - TensorShape{ 2U, 3U, 5U, 7U }, - TensorShape{ 2U, 3U, 5U, 7U, 11U }, - TensorShape{ 2U, 3U, 5U, 7U, 11U, 13U } - }) - ^ boost::unit_test::data::make({ 0, 0, 1, 2, 3, 4, 5, 6 }) ^ boost::unit_test::data::make({ 0, 1, 2, 6, 30, 210, 2310, 30030 }), - shape, num_dimensions, total_size) -{ - BOOST_TEST(shape.num_dimensions() == num_dimensions); - BOOST_TEST(shape.total_size() == total_size); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(SetEmpty, boost::unit_test::data::make({ 0, 1, 2, 3, 4, 5 }), dimension) -{ - TensorShape shape; - - shape.set(dimension, 10); - - BOOST_TEST(shape.num_dimensions() == dimension + 1); - BOOST_TEST(shape.total_size() == 10); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/UNIT/Utils.cpp b/tests/validation/UNIT/Utils.cpp deleted file mode 100644 index e28ca19620..0000000000 --- a/tests/validation/UNIT/Utils.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Utils.h" - -#include "TypePrinter.h" -#include "validation/Validation.h" - -#include "boost_wrapper.h" - -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(UNIT) -BOOST_AUTO_TEST_SUITE(Utils) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RoundHalfUp, boost::unit_test::data::make({ 1.f, 1.2f, 1.5f, 2.5f, 2.9f, -3.f, -3.5f, -3.8f, -4.3f, -4.5f }) ^ boost::unit_test::data::make({ 1.f, 1.f, 2.f, 3.f, 3.f, -3.f, -3.f, -4.f, -4.f, -4.f }), - value, result) -{ - BOOST_TEST(round_half_up(value) == result); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RoundHalfEven, boost::unit_test::data::make({ 1.f, 1.2f, 1.5f, 2.5f, 2.9f, -3.f, -3.5f, -3.8f, -4.3f, -4.5f }) ^ boost::unit_test::data::make({ 1.f, 1.f, 2.f, 2.f, 3.f, -3.f, -4.f, -4.f, -4.f, -4.f }), - value, result) -{ - BOOST_TEST(round_half_even(value) == result); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Index2Coord, boost::unit_test::data::make({ TensorShape{ 1U }, TensorShape{ 2U }, TensorShape{ 2U, 3U } }) ^ boost::unit_test::data::make({ 0, 1, 2 }) ^ - boost::unit_test::data::make({ Coordinates{ 0 }, Coordinates{ 1 }, Coordinates{ 0, 1 } }), shape, index, ref_coordinate) -{ - Coordinates coordinate = index2coord(shape, index); - - BOOST_TEST(compare_dimensions(coordinate, ref_coordinate)); -} - -//FIXME: Negative tests only work in debug mode -#if 0 -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Index2CoordFail, boost::unit_test::data::make({ TensorShape{}, TensorShape{ 2U }, TensorShape{ 2U } }) ^ boost::unit_test::data::make({ 0, -1, 2 }), shape, index) -{ - BOOST_CHECK_THROW(index2coord(shape, index), std::runtime_error); -} -#endif /* 0 */ - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Coord2Index, boost::unit_test::data::make({ TensorShape{ 1U }, TensorShape{ 2U }, TensorShape{ 2U, 3U } }) ^ boost::unit_test::data::make({ Coordinates{ 0 }, Coordinates{ 1 }, Coordinates{ 0, 1 } }) - ^ boost::unit_test::data::make({ 0, 1, 2 }), - shape, coordinate, ref_index) -{ - int index = coord2index(shape, coordinate); - - BOOST_TEST(index == ref_index); -} - -//FIXME: Negative tests only work in debug mode -#if 0 -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Coord2IndexFail, boost::unit_test::data::make({ TensorShape{}, TensorShape{ 2U } }) ^ boost::unit_test::data::make({ Coordinates{ 0 }, Coordinates{} }), shape, coordinate) -{ - BOOST_CHECK_THROW(coord2index(shape, coordinate), std::runtime_error); -} -#endif /* 0 */ - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/Validation.cpp b/tests/validation/Validation.cpp index d321e63d77..fec7c10939 100644 --- a/tests/validation/Validation.cpp +++ b/tests/validation/Validation.cpp @@ -25,22 +25,14 @@ #include "arm_compute/core/Coordinates.h" #include "arm_compute/core/Error.h" -#include "arm_compute/core/FixedPoint.h" -#include "arm_compute/core/IArray.h" #include "arm_compute/core/TensorShape.h" #include "arm_compute/runtime/Tensor.h" -#include "tests/IAccessor.h" -#include "tests/RawTensor.h" -#include "tests/TypePrinter.h" -#include "tests/Utils.h" #include "tests/validation/half.h" #include #include #include #include -#include -#include namespace arm_compute { @@ -99,39 +91,6 @@ double get_double_data(const void *ptr, DataType data_type) } } -bool is_equal(double target, double ref, double max_absolute_error = std::numeric_limits::epsilon(), double max_relative_error = 0.0001f) -{ - if(!std::isfinite(target) || !std::isfinite(ref)) - { - return false; - } - - // No need further check if they are equal - if(ref == target) - { - return true; - } - - // Need this check for the situation when the two values close to zero but have different sign - if(std::abs(std::abs(ref) - std::abs(target)) <= max_absolute_error) - { - return true; - } - - double relative_error = 0; - - if(std::abs(target) > std::abs(ref)) - { - relative_error = std::abs((target - ref) / target); - } - else - { - relative_error = std::abs((ref - target) / ref); - } - - return relative_error <= max_relative_error; -} - void check_border_element(const IAccessor &tensor, const Coordinates &id, const BorderMode &border_mode, const void *border_value, int64_t &num_elements, int64_t &num_mismatches) @@ -142,61 +101,46 @@ void check_border_element(const IAccessor &tensor, const Coordinates &id, if(border_mode == BorderMode::REPLICATE) { Coordinates border_id{ id }; - border_id.set(1, 0); - border_value = tensor(border_id); - } - // Iterate over all channels within one element - for(int channel = 0; channel < tensor.num_channels(); ++channel) - { - const size_t channel_offset = channel * channel_size; - const double target = get_double_data(ptr + channel_offset, tensor.data_type()); - const double ref = get_double_data(static_cast(border_value) + channel_offset, tensor.data_type()); - const bool equal = is_equal(target, ref); - - BOOST_TEST_INFO("id = " << id); - BOOST_TEST_INFO("channel = " << channel); - BOOST_TEST_INFO("reference = " << std::setprecision(5) << ref); - BOOST_TEST_INFO("target = " << std::setprecision(5) << target); - BOOST_TEST_WARN(equal); + if(id.x() < 0) + { + border_id.set(0, 0); + } + else if(static_cast(id.x()) >= tensor.shape().x()) + { + border_id.set(0, tensor.shape().x() - 1); + } - if(!equal) + if(id.y() < 0) { - ++num_mismatches; + border_id.set(1, 0); + } + else if(static_cast(id.y()) >= tensor.shape().y()) + { + border_id.set(1, tensor.shape().y() - 1); } - ++num_elements; + border_value = tensor(border_id); } -} - -void check_single_element(const Coordinates &id, const IAccessor &tensor, const RawTensor &reference, float tolerance_value, - uint64_t wrap_range, int min_channels, size_t channel_size, int64_t &num_mismatches, int64_t &num_elements) -{ - const auto ptr = static_cast(tensor(id)); - const auto ref_ptr = static_cast(reference(id)); // Iterate over all channels within one element - for(int channel = 0; channel < min_channels; ++channel) + for(int channel = 0; channel < tensor.num_channels(); ++channel) { const size_t channel_offset = channel * channel_size; - const double target = get_double_data(ptr + channel_offset, reference.data_type()); - const double ref = get_double_data(ref_ptr + channel_offset, reference.data_type()); - bool equal = is_equal(target, ref, tolerance_value); + const double target = get_double_data(ptr + channel_offset, tensor.data_type()); + const double reference = get_double_data(static_cast(border_value) + channel_offset, tensor.data_type()); - if(wrap_range != 0 && !equal) + if(!compare, double>(target, reference)) { - equal = is_equal(target, ref, wrap_range - tolerance_value); - } + ARM_COMPUTE_TEST_INFO("id = " << id); + ARM_COMPUTE_TEST_INFO("channel = " << channel); + ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << target); + ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << reference); + ARM_COMPUTE_EXPECT_EQUAL(target, reference, framework::LogLevel::DEBUG); - if(!equal) - { - BOOST_TEST_INFO("id = " << id); - BOOST_TEST_INFO("channel = " << channel); - BOOST_TEST_INFO("reference = " << std::setprecision(5) << ref); - BOOST_TEST_INFO("target = " << std::setprecision(5) << target); - BOOST_TEST_WARN(equal); ++num_mismatches; } + ++num_elements; } } @@ -204,107 +148,31 @@ void check_single_element(const Coordinates &id, const IAccessor &tensor, const void validate(const arm_compute::ValidRegion ®ion, const arm_compute::ValidRegion &reference) { - BOOST_TEST(region.anchor.num_dimensions() == reference.anchor.num_dimensions()); - BOOST_TEST(region.shape.num_dimensions() == reference.shape.num_dimensions()); + ARM_COMPUTE_EXPECT_EQUAL(region.anchor.num_dimensions(), reference.anchor.num_dimensions(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT_EQUAL(region.shape.num_dimensions(), reference.shape.num_dimensions(), framework::LogLevel::ERRORS); for(unsigned int d = 0; d < region.anchor.num_dimensions(); ++d) { - BOOST_TEST(region.anchor[d] == reference.anchor[d]); + ARM_COMPUTE_EXPECT_EQUAL(region.anchor[d], reference.anchor[d], framework::LogLevel::ERRORS); } for(unsigned int d = 0; d < region.shape.num_dimensions(); ++d) { - BOOST_TEST(region.shape[d] == reference.shape[d]); + ARM_COMPUTE_EXPECT_EQUAL(region.shape[d], reference.shape[d], framework::LogLevel::ERRORS); } } void validate(const arm_compute::PaddingSize &padding, const arm_compute::PaddingSize &reference) { - BOOST_TEST(padding.top == reference.top); - BOOST_TEST(padding.right == reference.right); - BOOST_TEST(padding.bottom == reference.bottom); - BOOST_TEST(padding.left == reference.left); -} - -void validate(const IAccessor &tensor, const RawTensor &reference, float tolerance_value, float tolerance_number, uint64_t wrap_range) -{ - // Validate with valid region covering the entire shape - validate(tensor, reference, shape_to_valid_region(tensor.shape()), tolerance_value, tolerance_number, wrap_range); -} - -void validate(const IAccessor &tensor, const RawTensor &reference, const ValidRegion &valid_region, float tolerance_value, float tolerance_number, uint64_t wrap_range) -{ - int64_t num_mismatches = 0; - int64_t num_elements = 0; - - BOOST_TEST(tensor.element_size() == reference.element_size()); - BOOST_TEST(tensor.format() == reference.format()); - BOOST_TEST(tensor.data_type() == reference.data_type()); - BOOST_TEST(tensor.num_channels() == reference.num_channels()); - BOOST_TEST(compare_dimensions(tensor.shape(), reference.shape())); - - const int min_elements = std::min(tensor.num_elements(), reference.num_elements()); - const int min_channels = std::min(tensor.num_channels(), reference.num_channels()); - const size_t channel_size = element_size_from_data_type(reference.data_type()); - - // Iterate over all elements within valid region, e.g. U8, S16, RGB888, ... - for(int element_idx = 0; element_idx < min_elements; ++element_idx) - { - const Coordinates id = index2coord(reference.shape(), element_idx); - if(is_in_valid_region(valid_region, id)) - { - check_single_element(id, tensor, reference, tolerance_value, wrap_range, min_channels, channel_size, num_mismatches, num_elements); - } - } - - const int64_t absolute_tolerance_number = tolerance_number * num_elements; - const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; - - BOOST_TEST(num_mismatches <= absolute_tolerance_number, - num_mismatches << " values (" << std::setprecision(2) << percent_mismatches - << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)"); -} - -void validate(const IAccessor &tensor, const RawTensor &reference, const RawTensor &valid_mask, float tolerance_value, float tolerance_number, uint64_t wrap_range) -{ - int64_t num_mismatches = 0; - int64_t num_elements = 0; - - BOOST_TEST(tensor.element_size() == reference.element_size()); - BOOST_TEST(tensor.format() == reference.format()); - BOOST_TEST(tensor.data_type() == reference.data_type()); - BOOST_TEST(tensor.num_channels() == reference.num_channels()); - BOOST_TEST(compare_dimensions(tensor.shape(), reference.shape())); - - const int min_elements = std::min(tensor.num_elements(), reference.num_elements()); - const int min_channels = std::min(tensor.num_channels(), reference.num_channels()); - const size_t channel_size = element_size_from_data_type(reference.data_type()); - - // Iterate over all elements within valid region, e.g. U8, S16, RGB888, ... - for(int element_idx = 0; element_idx < min_elements; ++element_idx) - { - const Coordinates id = index2coord(reference.shape(), element_idx); - if(valid_mask[element_idx] == 1) - { - check_single_element(id, tensor, reference, tolerance_value, wrap_range, min_channels, channel_size, num_mismatches, num_elements); - } - else - { - ++num_elements; - } - } - - const int64_t absolute_tolerance_number = tolerance_number * num_elements; - const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; - - BOOST_TEST(num_mismatches <= absolute_tolerance_number, - num_mismatches << " values (" << std::setprecision(2) << percent_mismatches - << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)"); + ARM_COMPUTE_EXPECT_EQUAL(padding.top, reference.top, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT_EQUAL(padding.right, reference.right, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT_EQUAL(padding.bottom, reference.bottom, framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT_EQUAL(padding.left, reference.left, framework::LogLevel::ERRORS); } void validate(const IAccessor &tensor, const void *reference_value) { - BOOST_TEST_REQUIRE((reference_value != nullptr)); + ARM_COMPUTE_ASSERT(reference_value != nullptr); int64_t num_mismatches = 0; int64_t num_elements = 0; @@ -322,17 +190,16 @@ void validate(const IAccessor &tensor, const void *reference_value) { const size_t channel_offset = channel * channel_size; const double target = get_double_data(ptr + channel_offset, tensor.data_type()); - const double ref = get_double_data(reference_value, tensor.data_type()); - const bool equal = is_equal(target, ref); - - BOOST_TEST_INFO("id = " << id); - BOOST_TEST_INFO("channel = " << channel); - BOOST_TEST_INFO("reference = " << std::setprecision(5) << ref); - BOOST_TEST_INFO("target = " << std::setprecision(5) << target); - BOOST_TEST_WARN(equal); + const double reference = get_double_data(reference_value, tensor.data_type()); - if(!equal) + if(!compare, double>(target, reference)) { + ARM_COMPUTE_TEST_INFO("id = " << id); + ARM_COMPUTE_TEST_INFO("channel = " << channel); + ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << target); + ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << reference); + ARM_COMPUTE_EXPECT_EQUAL(target, reference, framework::LogLevel::DEBUG); + ++num_mismatches; } @@ -340,10 +207,13 @@ void validate(const IAccessor &tensor, const void *reference_value) } } - const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; + if(num_elements > 0) + { + const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; - BOOST_TEST(num_mismatches == 0, - num_mismatches << " values (" << std::setprecision(2) << percent_mismatches << "%) mismatched"); + ARM_COMPUTE_TEST_INFO(num_mismatches << " values (" << std::fixed << std::setprecision(2) << percent_mismatches << "%) mismatched"); + ARM_COMPUTE_EXPECT_EQUAL(num_mismatches, 0, framework::LogLevel::ERRORS); + } } void validate(const IAccessor &tensor, BorderSize border_size, const BorderMode &border_mode, const void *border_value) @@ -354,7 +224,7 @@ void validate(const IAccessor &tensor, BorderSize border_size, const BorderMode } else if(border_mode == BorderMode::CONSTANT) { - BOOST_TEST((border_value != nullptr)); + ARM_COMPUTE_ASSERT(border_value != nullptr); } int64_t num_mismatches = 0; @@ -414,63 +284,23 @@ void validate(const IAccessor &tensor, BorderSize border_size, const BorderMode } } - const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; + if(num_elements > 0) + { + const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; - BOOST_TEST(num_mismatches == 0, - num_mismatches << " values (" << std::setprecision(2) << percent_mismatches << "%) mismatched"); + ARM_COMPUTE_TEST_INFO(num_mismatches << " values (" << std::fixed << std::setprecision(2) << percent_mismatches << "%) mismatched"); + ARM_COMPUTE_EXPECT_EQUAL(num_mismatches, 0, framework::LogLevel::ERRORS); + } } void validate(std::vector classified_labels, std::vector expected_labels) { - ARM_COMPUTE_UNUSED(classified_labels); - ARM_COMPUTE_UNUSED(expected_labels); - BOOST_TEST(expected_labels.size() != 0); - BOOST_TEST(classified_labels.size() == expected_labels.size()); + ARM_COMPUTE_EXPECT_EQUAL(classified_labels.size(), expected_labels.size(), framework::LogLevel::ERRORS); for(unsigned int i = 0; i < expected_labels.size(); ++i) { - BOOST_TEST(classified_labels[i] == expected_labels[i]); - } -} - -void validate(float target, float ref, float tolerance_abs_error, float tolerance_relative_error) -{ - const bool equal = is_equal(target, ref, tolerance_abs_error, tolerance_relative_error); - - BOOST_TEST_INFO("reference = " << std::setprecision(5) << ref); - BOOST_TEST_INFO("target = " << std::setprecision(5) << target); - BOOST_TEST(equal); -} - -void validate(IArray &target, IArray &ref, int64_t tolerance) -{ - int64_t num_mismatches = 0; - - BOOST_TEST_WARN(target.num_values() == ref.num_values()); - - for(size_t i = 0; i < target.num_values(); ++i) - { - KeyPoint *ref_val = std::find_if(ref.buffer(), ref.buffer() + ref.num_values(), [&target, i](KeyPoint key) - { - return key.x == target.at(i).x && key.y == target.at(i).y; - }); - - const KeyPoint &key = target.at(i); - - if((ref_val == ref.buffer() + ref.num_values()) || !(is_equal(key.strength, ref_val->strength) && is_equal(key.scale, ref_val->scale) && is_equal(key.orientation, ref_val->orientation) - && is_equal(key.tracking_status, ref_val->tracking_status) && is_equal(key.error, ref_val->error))) - { - ++num_mismatches; - - BOOST_TEST_WARN(is_equal(key.strength, ref_val->strength)); - BOOST_TEST_WARN(is_equal(key.scale, ref_val->scale)); - BOOST_TEST_WARN(is_equal(key.orientation, ref_val->orientation)); - BOOST_TEST_WARN(is_equal(key.tracking_status, ref_val->tracking_status)); - BOOST_TEST_WARN(is_equal(key.error, ref_val->error)); - } + ARM_COMPUTE_EXPECT_EQUAL(classified_labels[i], expected_labels[i], framework::LogLevel::ERRORS); } - - BOOST_TEST(num_mismatches <= tolerance); } } // namespace validation } // namespace test diff --git a/tests/validation/Validation.h b/tests/validation/Validation.h index 57013312e1..db95e06058 100644 --- a/tests/validation/Validation.h +++ b/tests/validation/Validation.h @@ -21,44 +21,123 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_H__ -#define __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_H__ +#ifndef __ARM_COMPUTE_TEST_VALIDATION_H__ +#define __ARM_COMPUTE_TEST_VALIDATION_H__ +#include "arm_compute/core/FixedPoint.h" #include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Array.h" -#include "tests/RawTensor.h" - -#include "boost_wrapper.h" +#include "tests/IAccessor.h" +#include "tests/SimpleTensor.h" +#include "tests/TypePrinter.h" +#include "tests/Utils.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Exceptions.h" +#include +#include #include namespace arm_compute { -class Tensor; - namespace test { -class IAccessor; - namespace validation { +/** Class reprensenting an absolute tolerance value. */ +template +class AbsoluteTolerance +{ +public: + /** Underlying type. */ + using value_type = T; + + /* Default constructor. + * + * Initialises the tolerance to 0. + */ + AbsoluteTolerance() = default; + + /** Constructor. + * + * @param[in] value Absolute tolerance value. + */ + explicit constexpr AbsoluteTolerance(T value) + : _value{ value } + { + } + + /** Implicit conversion to the underlying type. */ + constexpr operator T() const + { + return _value; + } + +private: + T _value{ std::numeric_limits::epsilon() }; +}; + +/** Class reprensenting a relative tolerance value. */ +class RelativeTolerance +{ +public: + /** Underlying type. */ + using value_type = double; + + /* Default constructor. + * + * Initialises the tolerance to 0. + */ + RelativeTolerance() = default; + + /** Constructor. + * + * @param[in] value Relative tolerance value. + */ + explicit constexpr RelativeTolerance(value_type value) + : _value{ value } + { + } + + /** Implicit conversion to the underlying type. */ + constexpr operator value_type() const + { + return _value; + } + +private: + value_type _value{ 0 }; +}; + +/** Print AbsoluteTolerance type. */ +template +inline ::std::ostream &operator<<(::std::ostream &os, const AbsoluteTolerance &tolerance) +{ + os << static_cast::value_type>(tolerance); + + return os; +} + +/** Print RelativeTolerance type. */ +inline ::std::ostream &operator<<(::std::ostream &os, const RelativeTolerance &tolerance) +{ + os << static_cast(tolerance); + + return os; +} + template -boost::test_tools::predicate_result compare_dimensions(const Dimensions &dimensions1, const Dimensions &dimensions2) +bool compare_dimensions(const Dimensions &dimensions1, const Dimensions &dimensions2) { if(dimensions1.num_dimensions() != dimensions2.num_dimensions()) { - boost::test_tools::predicate_result result(false); - result.message() << "Different dimensionality [" << dimensions1.num_dimensions() << "!=" << dimensions2.num_dimensions() << "]"; - return result; + return false; } for(unsigned int i = 0; i < dimensions1.num_dimensions(); ++i) { if(dimensions1[i] != dimensions2[i]) { - boost::test_tools::predicate_result result(false); - result.message() << "Mismatch in dimension " << i << " [" << dimensions1[i] << "!=" << dimensions2[i] << "]"; - return result; + return false; } } @@ -89,7 +168,8 @@ void validate(const arm_compute::PaddingSize &padding, const arm_compute::Paddin * reference tensor and test tensor is multiple of wrap_range), but such errors would be detected by * other test cases. */ -void validate(const IAccessor &tensor, const RawTensor &reference, float tolerance_value = 0.f, float tolerance_number = 0.f, uint64_t wrap_range = 0); +template > +void validate(const IAccessor &tensor, const SimpleTensor &reference, U tolerance_value = U(), float tolerance_number = 0.f); /** Validate tensors with valid region. * @@ -101,19 +181,8 @@ void validate(const IAccessor &tensor, const RawTensor &reference, float toleran * reference tensor and test tensor is multiple of wrap_range), but such errors would be detected by * other test cases. */ -void validate(const IAccessor &tensor, const RawTensor &reference, const ValidRegion &valid_region, float tolerance_value = 0.f, float tolerance_number = 0.f, uint64_t wrap_range = 0); - -/** Validate tensors with valid mask. - * - * - Dimensionality has to be the same. - * - All values have to match. - * - * @note: wrap_range allows cases where reference tensor rounds up to the wrapping point, causing it to wrap around to - * zero while the test tensor stays at wrapping point to pass. This may permit true erroneous cases (difference between - * reference tensor and test tensor is multiple of wrap_range), but such errors would be detected by - * other test cases. - */ -void validate(const IAccessor &tensor, const RawTensor &reference, const RawTensor &valid_mask, float tolerance_value = 0.f, float tolerance_number = 0.f, uint64_t wrap_range = 0); +template > +void validate(const IAccessor &tensor, const SimpleTensor &reference, const ValidRegion &valid_region, U tolerance_value = U(), float tolerance_number = 0.f); /** Validate tensors against constant value. * @@ -139,54 +208,143 @@ void validate(std::vector classified_labels, std::vector::epsilon(), float tolerance_relative_error = 0.0001f); +template +void validate(T target, T reference, U tolerance = AbsoluteTolerance()); -/** Validate min max location. - * - * - All values should match - */ template -void validate_min_max_loc(T min, T ref_min, T max, T ref_max, - IArray &min_loc, IArray &ref_min_loc, IArray &max_loc, IArray &ref_max_loc, - uint32_t min_count, uint32_t ref_min_count, uint32_t max_count, uint32_t ref_max_count) +struct compare_base { - BOOST_TEST(min == ref_min); - BOOST_TEST(max == ref_max); + compare_base(typename T::value_type target, typename T::value_type reference, T tolerance = T(0)) + : _target{ target }, _reference{ reference }, _tolerance{ tolerance } + { + } + + typename T::value_type _target{}; + typename T::value_type _reference{}; + T _tolerance{}; +}; - BOOST_TEST(min_count == min_loc.num_values()); - BOOST_TEST(max_count == max_loc.num_values()); - BOOST_TEST(ref_min_count == ref_min_loc.num_values()); - BOOST_TEST(ref_max_count == ref_max_loc.num_values()); +template +struct compare; - BOOST_TEST(min_count == ref_min_count); - BOOST_TEST(max_count == ref_max_count); +template +struct compare, U> : public compare_base> +{ + using compare_base>::compare_base; - for(uint32_t i = 0; i < min_count; i++) + operator bool() const { - Coordinates2D *same_coords = std::find_if(ref_min_loc.buffer(), ref_min_loc.buffer() + min_count, [&min_loc, i](Coordinates2D coord) + if(!std::isfinite(this->_target) || !std::isfinite(this->_reference)) { - return coord.x == min_loc.at(i).x && coord.y == min_loc.at(i).y; - }); + return false; + } + else if(this->_target == this->_reference) + { + return true; + } - BOOST_TEST(same_coords != ref_min_loc.buffer() + min_count); + return static_cast(std::abs(this->_target - this->_reference)) <= static_cast(this->_tolerance); } +}; + +template +struct compare : public compare_base +{ + using compare_base::compare_base; - for(uint32_t i = 0; i < max_count; i++) + operator bool() const { - Coordinates2D *same_coords = std::find_if(ref_max_loc.buffer(), ref_max_loc.buffer() + max_count, [&max_loc, i](Coordinates2D coord) + if(!std::isfinite(_target) || !std::isfinite(_reference)) { - return coord.x == max_loc.at(i).x && coord.y == max_loc.at(i).y; - }); + return false; + } + else if(_target == _reference) + { + return true; + } - BOOST_TEST(same_coords != ref_max_loc.buffer() + max_count); + const double relative_change = std::abs(static_cast(_target - _reference)) / _reference; + + return relative_change <= _tolerance; } +}; + +template +void validate(const IAccessor &tensor, const SimpleTensor &reference, U tolerance_value, float tolerance_number) +{ + // Validate with valid region covering the entire shape + validate(tensor, reference, shape_to_valid_region(tensor.shape()), tolerance_value, tolerance_number); } -/** Validate KeyPoint arrays. - * - * - All values should match - */ -void validate(IArray &target, IArray &ref, int64_t tolerance = 0); +template +void validate(const IAccessor &tensor, const SimpleTensor &reference, const ValidRegion &valid_region, U tolerance_value, float tolerance_number) +{ + int64_t num_mismatches = 0; + int64_t num_elements = 0; + + ARM_COMPUTE_EXPECT_EQUAL(tensor.element_size(), reference.element_size(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT_EQUAL(tensor.data_type(), reference.data_type(), framework::LogLevel::ERRORS); + + if(reference.format() != Format::UNKNOWN) + { + ARM_COMPUTE_EXPECT_EQUAL(tensor.format(), reference.format(), framework::LogLevel::ERRORS); + } + + ARM_COMPUTE_EXPECT_EQUAL(tensor.num_channels(), reference.num_channels(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(compare_dimensions(tensor.shape(), reference.shape()), framework::LogLevel::ERRORS); + + const int min_elements = std::min(tensor.num_elements(), reference.num_elements()); + const int min_channels = std::min(tensor.num_channels(), reference.num_channels()); + + // Iterate over all elements within valid region, e.g. U8, S16, RGB888, ... + for(int element_idx = 0; element_idx < min_elements; ++element_idx) + { + const Coordinates id = index2coord(reference.shape(), element_idx); + + if(is_in_valid_region(valid_region, id)) + { + // Iterate over all channels within one element + for(int c = 0; c < min_channels; ++c) + { + const T &target_value = reinterpret_cast(tensor(id))[c]; + const T &reference_value = reinterpret_cast(reference(id))[c]; + + if(!compare(target_value, reference_value, tolerance_value)) + { + ARM_COMPUTE_TEST_INFO("id = " << id); + ARM_COMPUTE_TEST_INFO("channel = " << c); + ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target_value)); + ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference_value)); + ARM_COMPUTE_TEST_INFO("tolerance = " << std::setprecision(5) << framework::make_printable(static_cast(tolerance_value))); + ARM_COMPUTE_EXPECT_EQUAL(target_value, reference_value, framework::LogLevel::DEBUG); + + ++num_mismatches; + } + + ++num_elements; + } + } + } + + if(num_elements > 0) + { + const int64_t absolute_tolerance_number = tolerance_number * num_elements; + const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; + + ARM_COMPUTE_TEST_INFO(num_mismatches << " values (" << std::fixed << std::setprecision(2) << percent_mismatches + << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)"); + ARM_COMPUTE_EXPECT(num_mismatches <= absolute_tolerance_number, framework::LogLevel::ERRORS); + } +} + +template +void validate(T target, T reference, U tolerance) +{ + ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference)); + ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target)); + ARM_COMPUTE_TEST_INFO("tolerance = " << std::setprecision(5) << framework::make_printable(static_cast(tolerance))); + ARM_COMPUTE_EXPECT((compare(target, reference, tolerance)), framework::LogLevel::ERRORS); +} } // namespace validation } // namespace test } // namespace arm_compute diff --git a/tests/validation/ValidationProgramOptions.cpp b/tests/validation/ValidationProgramOptions.cpp deleted file mode 100644 index adb8c5ab6c..0000000000 --- a/tests/validation/ValidationProgramOptions.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "ValidationProgramOptions.h" - -#include - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Weffc++" -#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" -#include "boost/program_options.hpp" -#pragma GCC diagnostic pop - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -ValidationProgramOptions::ValidationProgramOptions() -{ - boost::program_options::options_description options("Validation options"); - options.add_options()("runs", boost::program_options::value()->default_value(1), "Repetitions per test"); - options.add_options()("threads", boost::program_options::value()->default_value(std::thread::hardware_concurrency()), "Number of parallel CPU threads"); - add_options(options); -} -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/ValidationProgramOptions.h b/tests/validation/ValidationProgramOptions.h deleted file mode 100644 index 6b29b807de..0000000000 --- a/tests/validation/ValidationProgramOptions.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_VALIDATION_PROGRAM_OPTIONS_H__ -#define __ARM_COMPUTE_TEST_VALIDATION_PROGRAM_OPTIONS_H__ - -#include "ProgramOptions.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -/** Subclass of @ref ProgramOptions that adds validation specific options. */ -class ValidationProgramOptions : public ProgramOptions -{ -public: - /** Defines additonal options. */ - ValidationProgramOptions(); -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_VALIDATION_PROGRAM_OPTIONS_H__ */ diff --git a/tests/validation/ValidationUserConfiguration.h b/tests/validation/ValidationUserConfiguration.h deleted file mode 100644 index a9b8b4fe40..0000000000 --- a/tests/validation/ValidationUserConfiguration.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_USER_CONFIGURATION_H__ -#define __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_USER_CONFIGURATION_H__ - -#include "UserConfiguration.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -// Validation requires no specific configuration -using ValidationUserConfiguration = UserConfiguration; -} // namespace validation - -extern validation::ValidationUserConfiguration user_config; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_USER_CONFIGURATION_H__ */ diff --git a/tests/validation/fixtures/ActivationLayerFixture.h b/tests/validation/fixtures/ActivationLayerFixture.h new file mode 100644 index 0000000000..384e63bf49 --- /dev/null +++ b/tests/validation/fixtures/ActivationLayerFixture.h @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_ACTIVATION_LAYER_FIXTURE +#define ARM_COMPUTE_TEST_ACTIVATION_LAYER_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/ActivationLayer.h" +#include "tests/validation/Helpers.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class ActivationValidationFixedPointFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, bool in_place, ActivationLayerInfo::ActivationFunction function, float alpha_beta, DataType data_type, int fractional_bits) + { + _fractional_bits = fractional_bits; + _data_type = data_type; + _function = function; + + ActivationLayerInfo info(function, alpha_beta, alpha_beta); + + _target = compute_target(shape, in_place, info, data_type, fractional_bits); + _reference = compute_reference(shape, info, data_type, fractional_bits); + } + +protected: + template + void fill(U &&tensor) + { + if(is_data_type_float(_data_type)) + { + float min_bound = 0; + float max_bound = 0; + std::tie(min_bound, max_bound) = get_activation_layer_test_bounds(_function, _data_type); + std::uniform_real_distribution<> distribution(min_bound, max_bound); + library->fill(tensor, distribution, 0); + } + else + { + int min_bound = 0; + int max_bound = 0; + std::tie(min_bound, max_bound) = get_activation_layer_test_bounds(_function, _data_type, _fractional_bits); + std::uniform_int_distribution<> distribution(min_bound, max_bound); + library->fill(tensor, distribution, 0); + } + } + + TensorType compute_target(const TensorShape &shape, bool in_place, ActivationLayerInfo info, DataType data_type, int fixed_point_position = 0) + { + // Create tensors + TensorType src = create_tensor(shape, data_type, 1, fixed_point_position); + TensorType dst = create_tensor(shape, data_type, 1, fixed_point_position); + + // Create and configure function + FunctionType act_layer; + + TensorType *dst_ptr = in_place ? &src : &dst; + + act_layer.configure(&src, dst_ptr, info); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src.allocator()->allocate(); + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + + if(!in_place) + { + dst.allocator()->allocate(); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + } + + // Fill tensors + fill(AccessorType(src)); + + // Compute function + act_layer.run(); + + if(in_place) + { + return src; + } + else + { + return dst; + } + } + + SimpleTensor compute_reference(const TensorShape &shape, ActivationLayerInfo info, DataType data_type, int fixed_point_position = 0) + { + // Create reference + SimpleTensor src{ shape, data_type, 1, fixed_point_position }; + + // Fill reference + fill(src); + + return reference::activation_layer(src, info); + } + + TensorType _target{}; + SimpleTensor _reference{}; + int _fractional_bits{}; + DataType _data_type{}; + ActivationLayerInfo::ActivationFunction _function{}; +}; + +template +class ActivationValidationFixture : public ActivationValidationFixedPointFixture +{ +public: + template + void setup(TensorShape shape, bool in_place, ActivationLayerInfo::ActivationFunction function, float alpha_beta, DataType data_type) + { + ActivationValidationFixedPointFixture::setup(shape, in_place, function, alpha_beta, data_type, 0); + } +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ACTIVATION_LAYER_FIXTURE */ diff --git a/tests/validation/fixtures/BitwiseAndFixture.h b/tests/validation/fixtures/BitwiseAndFixture.h new file mode 100644 index 0000000000..0dfff868ab --- /dev/null +++ b/tests/validation/fixtures/BitwiseAndFixture.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_BITWISE_AND_FIXTURE +#define ARM_COMPUTE_TEST_BITWISE_AND_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/BitwiseAnd.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class BitwiseAndValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type) + { + _target = compute_target(shape, data_type); + _reference = compute_reference(shape, data_type); + } + +protected: + template + void fill(U &&tensor, int i) + { + library->fill_tensor_uniform(tensor, i); + } + + TensorType compute_target(const TensorShape &shape, DataType data_type) + { + // Create tensors + TensorType src1 = create_tensor(shape, data_type); + TensorType src2 = create_tensor(shape, data_type); + TensorType dst = create_tensor(shape, data_type); + + // Create and configure function + FunctionType bitwise_and; + + bitwise_and.configure(&src1, &src2, &dst); + + ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src1.allocator()->allocate(); + src2.allocator()->allocate(); + dst.allocator()->allocate(); + ARM_COMPUTE_EXPECT(!src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src1), 0); + fill(AccessorType(src2), 1); + + // Compute function + bitwise_and.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) + { + // Create reference + SimpleTensor src1{ shape, data_type }; + SimpleTensor src2{ shape, data_type }; + + // Fill reference + fill(src1, 0); + fill(src2, 1); + + return reference::bitwise_and(src1, src2); + } + + TensorType _target{}; + SimpleTensor _reference{}; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_BITWISE_AND_FIXTURE */ diff --git a/tests/validation/fixtures/BitwiseNotFixture.h b/tests/validation/fixtures/BitwiseNotFixture.h new file mode 100644 index 0000000000..e5bf69992e --- /dev/null +++ b/tests/validation/fixtures/BitwiseNotFixture.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_BITWISE_NOT_FIXTURE +#define ARM_COMPUTE_TEST_BITWISE_NOT_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/BitwiseNot.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class BitwiseNotValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type) + { + _target = compute_target(shape, data_type); + _reference = compute_reference(shape, data_type); + } + +protected: + template + void fill(U &&tensor) + { + library->fill_tensor_uniform(tensor, 0); + } + + TensorType compute_target(const TensorShape &shape, DataType data_type) + { + // Create tensors + TensorType src = create_tensor(shape, data_type); + TensorType dst = create_tensor(shape, data_type); + + // Create and configure function + FunctionType bitwise_not; + + bitwise_not.configure(&src, &dst); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src)); + + // Compute function + bitwise_not.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) + { + // Create reference + SimpleTensor src{ shape, data_type }; + + // Fill reference + fill(src); + + return reference::bitwise_not(src); + } + + TensorType _target{}; + SimpleTensor _reference{}; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_BITWISE_NOT_FIXTURE */ diff --git a/tests/validation/fixtures/BitwiseOrFixture.h b/tests/validation/fixtures/BitwiseOrFixture.h new file mode 100644 index 0000000000..d61e767bf3 --- /dev/null +++ b/tests/validation/fixtures/BitwiseOrFixture.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_BITWISE_OR_FIXTURE +#define ARM_COMPUTE_TEST_BITWISE_OR_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/BitwiseOr.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class BitwiseOrValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type) + { + _target = compute_target(shape, data_type); + _reference = compute_reference(shape, data_type); + } + +protected: + template + void fill(U &&tensor, int i) + { + library->fill_tensor_uniform(tensor, i); + } + + TensorType compute_target(const TensorShape &shape, DataType data_type) + { + // Create tensors + TensorType src1 = create_tensor(shape, data_type); + TensorType src2 = create_tensor(shape, data_type); + TensorType dst = create_tensor(shape, data_type); + + // Create and configure function + FunctionType bitwise_or; + + bitwise_or.configure(&src1, &src2, &dst); + + ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src1.allocator()->allocate(); + src2.allocator()->allocate(); + dst.allocator()->allocate(); + ARM_COMPUTE_EXPECT(!src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src1), 0); + fill(AccessorType(src2), 1); + + // Compute function + bitwise_or.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) + { + // Create reference + SimpleTensor src1{ shape, data_type }; + SimpleTensor src2{ shape, data_type }; + + // Fill reference + fill(src1, 0); + fill(src2, 1); + + return reference::bitwise_or(src1, src2); + } + + TensorType _target{}; + SimpleTensor _reference{}; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_BITWISE_OR_FIXTURE */ diff --git a/tests/validation/fixtures/BitwiseXorFixture.h b/tests/validation/fixtures/BitwiseXorFixture.h new file mode 100644 index 0000000000..16fa8c0422 --- /dev/null +++ b/tests/validation/fixtures/BitwiseXorFixture.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_BITWISE_XOR_FIXTURE +#define ARM_COMPUTE_TEST_BITWISE_XOR_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/BitwiseXor.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class BitwiseXorValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type) + { + _target = compute_target(shape, data_type); + _reference = compute_reference(shape, data_type); + } + +protected: + template + void fill(U &&tensor, int i) + { + library->fill_tensor_uniform(tensor, i); + } + + TensorType compute_target(const TensorShape &shape, DataType data_type) + { + // Create tensors + TensorType src1 = create_tensor(shape, data_type); + TensorType src2 = create_tensor(shape, data_type); + TensorType dst = create_tensor(shape, data_type); + + // Create and configure function + FunctionType bitwise_xor; + + bitwise_xor.configure(&src1, &src2, &dst); + + ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src1.allocator()->allocate(); + src2.allocator()->allocate(); + dst.allocator()->allocate(); + ARM_COMPUTE_EXPECT(!src1.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!src2.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src1), 0); + fill(AccessorType(src2), 1); + + // Compute function + bitwise_xor.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) + { + // Create reference + SimpleTensor src1{ shape, data_type }; + SimpleTensor src2{ shape, data_type }; + + // Fill reference + fill(src1, 0); + fill(src2, 1); + + return reference::bitwise_xor(src1, src2); + } + + TensorType _target{}; + SimpleTensor _reference{}; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_BITWISE_XOR_FIXTURE */ diff --git a/tests/validation/fixtures/ConvolutionLayerFixture.h b/tests/validation/fixtures/ConvolutionLayerFixture.h new file mode 100644 index 0000000000..87b11ac130 --- /dev/null +++ b/tests/validation/fixtures/ConvolutionLayerFixture.h @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_CONVOLUTION_LAYER_FIXTURE +#define ARM_COMPUTE_TEST_CONVOLUTION_LAYER_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/ConvolutionLayer.h" +#include "tests/validation/Helpers.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class ConvolutionValidationFixedPointFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, PadStrideInfo info, DataType data_type, int fractional_bits) + { + _fractional_bits = fractional_bits; + _data_type = data_type; + + _target = compute_target(input_shape, weights_shape, bias_shape, output_shape, info, data_type, fractional_bits); + _reference = compute_reference(input_shape, weights_shape, bias_shape, output_shape, info, data_type, fractional_bits); + } + +protected: + template + void fill(U &&tensor, int i) + { + switch(tensor.data_type()) + { + case DataType::F16: + case DataType::F32: + { + std::uniform_real_distribution<> distribution(-1.0f, 1.0f); + library->fill(tensor, distribution, i); + break; + } + default: + library->fill_tensor_uniform(tensor, i); + } + } + + TensorType compute_target(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, const PadStrideInfo &info, + DataType data_type, int fixed_point_position) + { + // Create tensors + TensorType src = create_tensor(input_shape, data_type, 1, fixed_point_position); + TensorType weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); + TensorType bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); + TensorType dst = create_tensor(output_shape, data_type, 1, fixed_point_position); + + // Create and configure function + FunctionType conv; + conv.configure(&src, &weights, &bias, &dst, info); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src.allocator()->allocate(); + weights.allocator()->allocate(); + bias.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!weights.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!bias.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src), 0); + fill(AccessorType(weights), 1); + fill(AccessorType(bias), 2); + + // Compute NEConvolutionLayer function + conv.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, const PadStrideInfo &info, + DataType data_type, int fixed_point_position) + { + // Create reference + SimpleTensor src{ input_shape, data_type, 1, fixed_point_position }; + SimpleTensor weights{ weights_shape, data_type, 1, fixed_point_position }; + SimpleTensor bias{ bias_shape, data_type, 1, fixed_point_position }; + + // Fill reference + fill(src, 0); + fill(weights, 1); + fill(bias, 2); + + return reference::convolution_layer(src, weights, bias, output_shape, info); + } + + TensorType _target{}; + SimpleTensor _reference{}; + int _fractional_bits{}; + DataType _data_type{}; +}; + +template +class ConvolutionValidationFixture : public ConvolutionValidationFixedPointFixture +{ +public: + template + void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, PadStrideInfo info, DataType data_type) + { + ConvolutionValidationFixedPointFixture::setup(input_shape, weights_shape, bias_shape, output_shape, info, data_type, 0); + } +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_CONVOLUTION_LAYER_FIXTURE */ diff --git a/tests/validation/fixtures/DepthConcatenateLayerFixture.h b/tests/validation/fixtures/DepthConcatenateLayerFixture.h new file mode 100644 index 0000000000..2a2e96e821 --- /dev/null +++ b/tests/validation/fixtures/DepthConcatenateLayerFixture.h @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_FIXTURE +#define ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/DepthConcatenateLayer.h" +#include "tests/validation/Helpers.h" + +#include + +namespace arm_compute +{ +class ITensor; +class Tensor; +class ICLTensor; +class CLTensor; + +namespace test +{ +namespace validation +{ +template +class DepthConcatenateValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type) + { + // Create input shapes + std::mt19937 gen(library->seed()); + std::uniform_int_distribution<> num_dis(2, 6); + const int num_tensors = num_dis(gen); + + std::vector shapes(num_tensors, shape); + std::uniform_int_distribution<> depth_dis(1, 7); + std::bernoulli_distribution mutate_dis(0.25f); + std::uniform_real_distribution<> change_dis(-0.25f, 0.f); + + // Generate more shapes based on the input + for(auto &s : shapes) + { + // Set the depth of the tensor + s.set(2, depth_dis(gen)); + + // Randomly change the first dimension + if(mutate_dis(gen)) + { + // Decrease the dimension by a small percentage. Don't increase + // as that could make tensor too large. Also the change must be + // an even number. Otherwise out depth concatenate fails. + s.set(0, s[0] + 2 * static_cast(s[0] * change_dis(gen))); + } + + // Repeat the same as above for the second dimension + if(mutate_dis(gen)) + { + s.set(1, s[1] + 2 * static_cast(s[1] * change_dis(gen))); + } + } + + _target = compute_target(shapes, data_type); + _reference = compute_reference(shapes, data_type); + } + +protected: + template + void fill(U &&tensor, int i) + { + library->fill_tensor_uniform(tensor, i); + } + + TensorType compute_target(std::vector shapes, DataType data_type) + { + using ITensorType = typename std::conditional::value, ITensor, ICLTensor>::type; + + std::vector srcs; + std::vector src_ptrs; + + // Create tensors + srcs.reserve(shapes.size()); + + for(const auto &shape : shapes) + { + srcs.emplace_back(create_tensor(shape, data_type, 1, _fractional_bits)); + src_ptrs.emplace_back(&srcs.back()); + } + + TensorShape dst_shape = calculate_depth_concatenate_shape(shapes); + TensorType dst = create_tensor(dst_shape, data_type, 1, _fractional_bits); + + // Create and configure function + FunctionType depth_concat; + depth_concat.configure(src_ptrs, &dst); + + for(auto &src : srcs) + { + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + } + + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + for(auto &src : srcs) + { + src.allocator()->allocate(); + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + } + + dst.allocator()->allocate(); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + int i = 0; + for(auto &src : srcs) + { + fill(AccessorType(src), i++); + } + + // Compute function + depth_concat.run(); + + return dst; + } + + SimpleTensor compute_reference(std::vector shapes, DataType data_type) + { + std::vector> srcs; + + // Create and fill tensors + int i = 0; + for(const auto &shape : shapes) + { + srcs.emplace_back(shape, data_type, 1, _fractional_bits); + fill(srcs.back(), i++); + } + + return reference::depthconcatenate_layer(srcs); + } + + TensorType _target{}; + SimpleTensor _reference{}; + +private: + int _fractional_bits{ 1 }; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_FIXTURE */ diff --git a/tests/validation/fixtures/DepthwiseConvolutionFixture.h b/tests/validation/fixtures/DepthwiseConvolutionFixture.h new file mode 100644 index 0000000000..462c0f888c --- /dev/null +++ b/tests/validation/fixtures/DepthwiseConvolutionFixture.h @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_FIXTURE +#define ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/DepthwiseConvolution.h" +#include "tests/validation/Helpers.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class DepthwiseConvolutionValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape in_shape, TensorShape weights_shape, TensorShape out_shape, PadStrideInfo pad_stride_info) + { + _target = compute_target(in_shape, weights_shape, out_shape, pad_stride_info); + _reference = compute_reference(in_shape, weights_shape, out_shape, pad_stride_info); + } + +protected: + template + void fill(U &&tensor, int i) + { + switch(tensor.data_type()) + { + case DataType::F32: + { + std::uniform_real_distribution<> distribution(-1.0f, 1.0f); + library->fill(tensor, distribution, i); + break; + } + default: + library->fill_tensor_uniform(tensor, i); + } + } + + TensorType compute_target(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &output_shape, PadStrideInfo &pad_stride_info) + { + // Create tensors + TensorType src = create_tensor(input_shape, DataType::F32); + TensorType weights = create_tensor(weights_shape, DataType::F32); + TensorType dst = create_tensor(output_shape, DataType::F32); + + // Create Depthwise Convolution configure function + CLDepthwiseConvolution depthwise_convolution; + depthwise_convolution.configure(&src, &dst, &weights, pad_stride_info); + + // Allocate tensors + src.allocator()->allocate(); + weights.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!weights.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src), 0); + fill(AccessorType(weights), 1); + + // Compute function + depthwise_convolution.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &in_shape, const TensorShape &weights_shape, const TensorShape &out_shape, const PadStrideInfo &pad_stride_info) + { + SimpleTensor src(in_shape, DataType::F32); + SimpleTensor weights(weights_shape, DataType::F32); + + fill(src, 0); + fill(weights, 1); + + return reference::depthwise_convolution(src, weights, out_shape, pad_stride_info); + } + + TensorType _target{}; + SimpleTensor _reference{}; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_FIXTURE */ diff --git a/tests/validation/fixtures/DepthwiseSeparableConvolutionLayerFixture.h b/tests/validation/fixtures/DepthwiseSeparableConvolutionLayerFixture.h new file mode 100644 index 0000000000..e8f6854b49 --- /dev/null +++ b/tests/validation/fixtures/DepthwiseSeparableConvolutionLayerFixture.h @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_FIXTURE +#define ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/DepthwiseSeparableConvolutionLayer.h" +#include "tests/validation/Helpers.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class DepthwiseSeparableConvolutionValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape in_shape, TensorShape depthwise_weights_shape, TensorShape depthwise_out_shape, TensorShape pointwise_weights_shape, TensorShape biases_shape, TensorShape output_shape, + PadStrideInfo pad_stride_depthwise_info, PadStrideInfo pad_stride_pointwise_info) + { + _target = compute_target(in_shape, depthwise_weights_shape, depthwise_out_shape, pointwise_weights_shape, biases_shape, output_shape, pad_stride_depthwise_info, pad_stride_pointwise_info); + _reference = compute_reference(in_shape, depthwise_weights_shape, depthwise_out_shape, pointwise_weights_shape, biases_shape, output_shape, pad_stride_depthwise_info, pad_stride_pointwise_info); + } + +protected: + template + void fill(U &&tensor, int i) + { + switch(tensor.data_type()) + { + case DataType::F32: + { + std::uniform_real_distribution<> distribution(-1.0f, 1.0f); + library->fill(tensor, distribution, i); + break; + } + default: + library->fill_tensor_uniform(tensor, i); + } + } + + TensorType compute_target(const TensorShape &input_shape, const TensorShape &depthwise_weights_shape, const TensorShape &depthwise_out_shape, const TensorShape &pointwise_weights_shape, + const TensorShape &biases_shape, + const TensorShape &output_shape, const PadStrideInfo &pad_stride_depthwise_info, const PadStrideInfo &pad_stride_pointwise_info) + { + // Create tensors + TensorType src = create_tensor(input_shape, DataType::F32); + TensorType depthwise_weights = create_tensor(depthwise_weights_shape, DataType::F32); + TensorType depthwise_out = create_tensor(depthwise_out_shape, DataType::F32); + TensorType pointwise_weights = create_tensor(pointwise_weights_shape, DataType::F32); + TensorType biases = create_tensor(biases_shape, DataType::F32); + TensorType dst = create_tensor(output_shape, DataType::F32); + + // Create Depthwise Separable Convolution Layer configure function + CLDepthwiseSeparableConvolutionLayer depthwise_separable_convolution_layer; + depthwise_separable_convolution_layer.configure(&src, &depthwise_weights, &depthwise_out, &pointwise_weights, &biases, &dst, pad_stride_depthwise_info, pad_stride_pointwise_info); + + // Allocate tensors + src.allocator()->allocate(); + depthwise_weights.allocator()->allocate(); + depthwise_out.allocator()->allocate(); + pointwise_weights.allocator()->allocate(); + biases.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!depthwise_weights.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!depthwise_out.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!pointwise_weights.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!biases.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src), 0); + fill(AccessorType(depthwise_weights), 1); + fill(AccessorType(pointwise_weights), 2); + fill(AccessorType(biases), 3); + + // Compute function + depthwise_separable_convolution_layer.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &in_shape, const TensorShape &depthwise_weights_shape, const TensorShape &depthwise_out_shape, const TensorShape &pointwise_weights_shape, + const TensorShape &biases_shape, const TensorShape &dst_shape, const PadStrideInfo &pad_stride_depthwise_info, const PadStrideInfo &pad_stride_pointwise_info) + { + SimpleTensor src(in_shape, DataType::F32); + SimpleTensor depthwise_weights(depthwise_weights_shape, DataType::F32); + SimpleTensor pointwise_weights(pointwise_weights_shape, DataType::F32); + SimpleTensor biases(biases_shape, DataType::F32); + + fill(src, 0); + fill(depthwise_weights, 1); + fill(pointwise_weights, 2); + fill(biases, 3); + + return reference::depthwise_separable_convolution_layer(src, depthwise_weights, depthwise_out_shape, pointwise_weights, biases, dst_shape, pad_stride_depthwise_info, pad_stride_pointwise_info); + } + + TensorType _target{}; + SimpleTensor _reference{}; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_FIXTURE */ diff --git a/tests/validation/fixtures/DequantizationLayerFixture.h b/tests/validation/fixtures/DequantizationLayerFixture.h new file mode 100644 index 0000000000..7543eb2d2e --- /dev/null +++ b/tests/validation/fixtures/DequantizationLayerFixture.h @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_FIXTURE +#define ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/DequantizationLayer.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class DequantizationValidationFixedPointFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type) + { + // Initialize random min and max values + rand_min_max(&_min, &_max); + + _target = compute_target(shape, data_type, _min, _max); + _reference = compute_reference(shape, data_type, _min, _max); + } + +protected: + template + void fill(U &&tensor) + { + library->fill_tensor_uniform(tensor, 0); + } + + TensorType compute_target(const TensorShape &shape, DataType data_type, float min, float max) + { + // Create tensors + TensorType src = create_tensor(shape, data_type); + TensorType dst = create_tensor(shape, DataType::F32); + + // Create and configure function + FunctionType dequantization_layer; + dequantization_layer.configure(&src, &dst, &min, &max); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src)); + + // Compute function + dequantization_layer.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &shape, DataType data_type, float min, float max) + { + // Create reference + SimpleTensor src{ shape, data_type }; + + // Fill reference + fill(src); + + return reference::dequantization_layer(src, min, max); + } + + /** Generate random constant values to be used as min and max for dequantization. + */ + void rand_min_max(float *min, float *max) + { + std::mt19937 gen(library->seed()); + std::uniform_real_distribution distribution(-10000.0, 10000.0); + + const float n1 = distribution(gen); + const float n2 = distribution(gen); + + if(n1 < n2) + { + *min = n1; + *max = n2; + } + else + { + *min = n2; + *max = n1; + } + } + + TensorType _target{}; + SimpleTensor _reference{}; + float _min = 0.f; + float _max = 0.f; +}; + +template +class DequantizationValidationFixture : public DequantizationValidationFixedPointFixture +{ +public: + template + void setup(TensorShape shape, DataType data_type) + { + DequantizationValidationFixedPointFixture::setup(shape, data_type); + } +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_FIXTURE */ diff --git a/tests/validation/fixtures/DirectConvolutionLayerFixture.h b/tests/validation/fixtures/DirectConvolutionLayerFixture.h new file mode 100644 index 0000000000..6ffebce108 --- /dev/null +++ b/tests/validation/fixtures/DirectConvolutionLayerFixture.h @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/ConvolutionLayer.h" +#include "tests/validation/Helpers.h" +#include "tests/validation/fixtures/ConvolutionLayerFixture.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class DirectConvolutionValidationFixedPointFixture : public ConvolutionValidationFixedPointFixture +{ +public: + template + void setup(TensorShape input_shape, int stride_x, int stride_y, int pad_x, int pad_y, unsigned int kernel_size, unsigned int num_kernels, DataType data_type, int fractional_bits) + { + const TensorShape weights_shape(kernel_size, kernel_size, input_shape.z(), num_kernels); + const TensorShape bias_shape(num_kernels); + const PadStrideInfo info(stride_x, stride_y, pad_x, pad_y, DimensionRoundingType::FLOOR); + const TensorShape output_shape = get_output_shape(input_shape, weights_shape, info); + + ConvolutionValidationFixedPointFixture::setup(input_shape, weights_shape, bias_shape, output_shape, info, data_type, fractional_bits); + } + +private: + TensorShape get_output_shape(TensorShape in_shape, TensorShape kernel_shape, const PadStrideInfo &info) + { + TensorShape out_shape(in_shape); + const std::pair scaled_dims = scaled_dimensions(in_shape.x(), + in_shape.y(), + kernel_shape.x(), + kernel_shape.y(), + info); + out_shape.set(0, scaled_dims.first); + out_shape.set(1, scaled_dims.second); + out_shape.set(2, kernel_shape[3]); + return out_shape; + } +}; + +template +class DirectConvolutionValidationFixture : public DirectConvolutionValidationFixedPointFixture +{ +public: + template + void setup(TensorShape input_shape, int stride_x, int stride_y, int pad_x, int pad_y, unsigned int kernel_size, unsigned int num_kernels, DataType data_type) + { + DirectConvolutionValidationFixedPointFixture::setup(input_shape, stride_x, stride_y, pad_x, pad_y, kernel_size, num_kernels, data_type, 0); + } +}; +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/fixtures/FloorFixture.h b/tests/validation/fixtures/FloorFixture.h new file mode 100644 index 0000000000..3f948412af --- /dev/null +++ b/tests/validation/fixtures/FloorFixture.h @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_FLOOR_FIXTURE +#define ARM_COMPUTE_TEST_FLOOR_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/Floor.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class FloorValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type) + { + _target = compute_target(shape, data_type); + _reference = compute_reference(shape, data_type); + } + +protected: + template + void fill(U &&tensor) + { + library->fill_tensor_uniform(tensor, 0); + } + + TensorType compute_target(const TensorShape &shape, DataType data_type) + { + // Create tensors + TensorType src = create_tensor(shape, data_type); + TensorType dst = create_tensor(shape, data_type); + + // Create and configure function + FunctionType floor_func; + floor_func.configure(&src, &dst); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src)); + + // Compute function + floor_func.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) + { + // Create reference + SimpleTensor src{ shape, data_type }; + + // Fill reference + fill(src); + + return reference::floor_layer(src); + } + + TensorType _target{}; + SimpleTensor _reference{}; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_FLOOR_FIXTURE */ diff --git a/tests/validation/fixtures/FullyConnectedLayerFixture.h b/tests/validation/fixtures/FullyConnectedLayerFixture.h new file mode 100644 index 0000000000..d4d68f1af8 --- /dev/null +++ b/tests/validation/fixtures/FullyConnectedLayerFixture.h @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_FIXTURE +#define ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/core/Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/RawTensor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/FullyConnectedLayer.h" +#include "tests/validation/Helpers.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +RawTensor transpose(const RawTensor &src, int interleave = 1) +{ + // Create reference + TensorShape dst_shape(src.shape()); + dst_shape.set(0, src.shape().y() * interleave); + dst_shape.set(1, std::ceil(src.shape().x() / static_cast(interleave))); + + RawTensor dst{ dst_shape, src.data_type() }; + + // Compute reference + uint8_t *out_ptr = dst.data(); + + for(int i = 0; i < dst.num_elements(); i += interleave) + { + Coordinates coord = index2coord(dst.shape(), i); + size_t coord_x = coord.x(); + coord.set(0, coord.y() * interleave); + coord.set(1, coord_x / interleave); + + const int num_elements = std::min(interleave, src.shape().x() - coord.x()); + + std::copy_n(static_cast(src(coord)), num_elements * src.element_size(), out_ptr); + + out_ptr += interleave * dst.element_size(); + } + + return dst; +} +} // namespace + +template +class FullyConnectedLayerValidationFixedPointFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, bool transpose_weights, bool reshape_weights, DataType data_type, int fractional_bits) + { + ARM_COMPUTE_UNUSED(weights_shape); + ARM_COMPUTE_UNUSED(bias_shape); + + _fractional_bits = fractional_bits; + _data_type = data_type; + + _target = compute_target(input_shape, weights_shape, bias_shape, output_shape, transpose_weights, reshape_weights, data_type, fractional_bits); + _reference = compute_reference(input_shape, weights_shape, bias_shape, output_shape, transpose_weights, reshape_weights, data_type, fractional_bits); + } + +protected: + template + void fill(U &&tensor, int i) + { + if(is_data_type_float(_data_type)) + { + std::uniform_real_distribution<> distribution(0.5f, 1.f); + library->fill(tensor, distribution, i); + } + else + { + library->fill_tensor_uniform(tensor, i); + } + } + + TensorType compute_target(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, bool transpose_weights, + bool reshape_weights, DataType data_type, int fixed_point_position) + { + TensorShape reshaped_weights_shape(weights_shape); + + // Test actions depending on the target settings + // + // | reshape | !reshape + // -----------+-----------+--------------------------- + // transpose | | *** + // -----------+-----------+--------------------------- + // !transpose | transpose | transpose & + // | | transpose1xW (if required) + // + // ***: That combination is invalid. But we can ignore the transpose flag and handle all !reshape the same + if(!reshape_weights || !transpose_weights) + { + const size_t shape_x = reshaped_weights_shape.x(); + reshaped_weights_shape.set(0, reshaped_weights_shape.y()); + reshaped_weights_shape.set(1, shape_x); + + // Weights have to be passed reshaped + // Transpose 1xW for batched version + if(!reshape_weights && output_shape.y() > 1 && run_interleave) + { + const int transpose_width = 16 / data_size_from_type(data_type); + const float shape_x = reshaped_weights_shape.x(); + reshaped_weights_shape.set(0, reshaped_weights_shape.y() * transpose_width); + reshaped_weights_shape.set(1, static_cast(std::ceil(shape_x / transpose_width))); + } + } + + // Create tensors + TensorType src = create_tensor(input_shape, data_type, 1, fixed_point_position); + TensorType weights = create_tensor(reshaped_weights_shape, data_type, 1, fixed_point_position); + TensorType bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); + TensorType dst = create_tensor(output_shape, data_type, 1, fixed_point_position); + + // Create and configure function. + FunctionType fc; + fc.configure(&src, &weights, &bias, &dst, transpose_weights, !reshape_weights); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src.allocator()->allocate(); + weights.allocator()->allocate(); + bias.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!weights.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!bias.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src), 0); + fill(AccessorType(bias), 2); + + if(!reshape_weights || !transpose_weights) + { + TensorShape tmp_shape(weights_shape); + RawTensor tmp(tmp_shape, data_type, 1, fixed_point_position); + + // Fill with original shape + fill(tmp, 1); + + // Transpose elementwise + tmp = transpose(tmp); + + // Reshape weights for batched runs + if(!reshape_weights && output_shape.y() > 1 && run_interleave) + { + // Transpose with interleave + const int interleave_size = 16 / tmp.element_size(); + tmp = transpose(tmp, interleave_size); + } + + AccessorType weights_accessor(weights); + + for(int i = 0; i < tmp.num_elements(); ++i) + { + Coordinates coord = index2coord(tmp.shape(), i); + std::copy_n(static_cast(tmp(coord)), + tmp.element_size(), + static_cast(weights_accessor(coord))); + } + } + else + { + fill(AccessorType(weights), 1); + } + + // Compute NEFullyConnectedLayer function + fc.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, bool transpose_weights, + bool reshape_weights, DataType data_type, int fixed_point_position = 0) + { + // Create reference + SimpleTensor src{ input_shape, data_type, 1, fixed_point_position }; + SimpleTensor weights{ weights_shape, data_type, 1, fixed_point_position }; + SimpleTensor bias{ bias_shape, data_type, 1, fixed_point_position }; + + // Fill reference + fill(src, 0); + fill(weights, 1); + fill(bias, 2); + + return reference::fully_connected_layer(src, weights, bias, output_shape); + } + + TensorType _target{}; + SimpleTensor _reference{}; + int _fractional_bits{}; + DataType _data_type{}; +}; + +template +class FullyConnectedLayerValidationFixture : public FullyConnectedLayerValidationFixedPointFixture +{ +public: + template + void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, bool transpose_weights, bool reshape_weights, DataType data_type) + { + FullyConnectedLayerValidationFixedPointFixture::setup(input_shape, weights_shape, bias_shape, output_shape, transpose_weights, + reshape_weights, data_type, + 0); + } +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_FIXTURE */ diff --git a/tests/validation/fixtures/GEMMFixture.h b/tests/validation/fixtures/GEMMFixture.h new file mode 100644 index 0000000000..923a29c7d0 --- /dev/null +++ b/tests/validation/fixtures/GEMMFixture.h @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_GEMM_FIXTURE +#define ARM_COMPUTE_TEST_GEMM_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/GEMM.h" +#include "tests/validation/Helpers.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class GEMMValidationFixedPointFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape_a, TensorShape shape_b, TensorShape shape_c, TensorShape output_shape, float alpha, float beta, DataType data_type, int fractional_bits) + { + _fractional_bits = fractional_bits; + _data_type = data_type; + + _target = compute_target(shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type, fractional_bits); + _reference = compute_reference(shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type, fractional_bits); + } + +protected: + template + void fill(U &&tensor, int i) + { + switch(tensor.data_type()) + { + case DataType::F16: + case DataType::F32: + { + std::uniform_real_distribution<> distribution(-1.0f, 1.0f); + library->fill(tensor, distribution, i); + break; + } + default: + library->fill_tensor_uniform(tensor, i); + } + } + + TensorType compute_target(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_c, const TensorShape &output_shape, float alpha, float beta, + DataType data_type, int fixed_point_position) + { + // Create tensors + TensorType a = create_tensor(shape_a, data_type, 1, fixed_point_position); + TensorType b = create_tensor(shape_b, data_type, 1, fixed_point_position); + TensorType c = create_tensor(shape_c, data_type, 1, fixed_point_position); + TensorType dst = create_tensor(output_shape, data_type, 1, fixed_point_position); + + // Create and configure function + FunctionType gemm; + gemm.configure(&a, &b, &c, &dst, alpha, beta); + + ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(c.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + a.allocator()->allocate(); + b.allocator()->allocate(); + c.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!a.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!b.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!c.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(a), 0); + fill(AccessorType(b), 1); + fill(AccessorType(c), 2); + + // Compute GEMM function + gemm.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_c, const TensorShape &output_shape, float alpha, float beta, + DataType data_type, int fixed_point_position) + { + // Create reference + SimpleTensor a{ shape_a, data_type, 1, fixed_point_position }; + SimpleTensor b{ shape_b, data_type, 1, fixed_point_position }; + SimpleTensor c{ shape_c, data_type, 1, fixed_point_position }; + + // Fill reference + fill(a, 0); + fill(b, 1); + fill(c, 2); + + return reference::gemm(a, b, c, alpha, beta); + } + + TensorType _target{}; + SimpleTensor _reference{}; + int _fractional_bits{}; + DataType _data_type{}; +}; + +template +class GEMMValidationFixture : public GEMMValidationFixedPointFixture +{ +public: + template + void setup(TensorShape shape_a, TensorShape shape_b, TensorShape shape_c, TensorShape output_shape, float alpha, float beta, DataType data_type) + { + GEMMValidationFixedPointFixture::setup(shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type, 0); + } +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GEMM_FIXTURE */ diff --git a/tests/validation/fixtures/L2NormalizeFixture.h b/tests/validation/fixtures/L2NormalizeFixture.h new file mode 100644 index 0000000000..e6113937f1 --- /dev/null +++ b/tests/validation/fixtures/L2NormalizeFixture.h @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_L2NORMALIZE_FIXTURE +#define ARM_COMPUTE_TEST_L2NORMALIZE_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/L2Normalize.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class L2NormalizeValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type, unsigned int axis, float epsilon) + { + _target = compute_target(shape, data_type, axis, epsilon); + _reference = compute_reference(shape, data_type, axis, epsilon); + } + +protected: + template + void fill(U &&tensor) + { + library->fill_tensor_uniform(tensor, 0); + } + + TensorType compute_target(const TensorShape &shape, DataType data_type, unsigned int axis, float epsilon) + { + // Create tensors + TensorType src = create_tensor(shape, data_type); + TensorType dst = create_tensor(shape, data_type); + + // Create and configure function + FunctionType l2_norm_func; + l2_norm_func.configure(&src, &dst, axis, epsilon); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src)); + + // Compute function + l2_norm_func.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &shape, DataType data_type, unsigned int axis, float epsilon) + { + // Create reference + SimpleTensor src{ shape, data_type }; + + // Fill reference + fill(src); + + return reference::l2_normalize(src, axis, epsilon); + } + + TensorType _target{}; + SimpleTensor _reference{}; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_L2NORMALIZE_FIXTURE */ diff --git a/tests/validation/fixtures/MeanStdDevFixture.h b/tests/validation/fixtures/MeanStdDevFixture.h new file mode 100644 index 0000000000..37f538b216 --- /dev/null +++ b/tests/validation/fixtures/MeanStdDevFixture.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_MEAN_STD_DEV_FIXTURE +#define ARM_COMPUTE_TEST_MEAN_STD_DEV_FIXTURE + +#include "tests/Globals.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/MeanStdDev.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class MeanStdDevValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type) + { + _target = compute_target(shape, data_type); + _reference = compute_reference(shape, data_type); + } + +protected: + template + void fill(U &&tensor) + { + library->fill_tensor_uniform(tensor, 0); + } + + std::pair compute_target(const TensorShape &shape, DataType data_type) + { + // Create tensors + TensorType src = create_tensor(shape, data_type); + + // Create output variables + float mean = 0.0f; + float std_dev = 0.0f; + + // Create and configure function + FunctionType mean_std_dev; + mean_std_dev.configure(&src, &mean, &std_dev); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src.allocator()->allocate(); + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src)); + + // Compute function + mean_std_dev.run(); + + return std::make_pair(mean, std_dev); + } + + std::pair compute_reference(const TensorShape &shape, DataType data_type) + { + // Create reference + SimpleTensor src{ shape, data_type }; + + // Fill reference + fill(src); + + // Compute reference + return reference::mean_and_standard_deviation(src); + } + + std::pair _target{}; + std::pair _reference{}; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_MEAN_STD_DEV_FIXTURE */ diff --git a/tests/validation/fixtures/NormalizationLayerFixture.h b/tests/validation/fixtures/NormalizationLayerFixture.h new file mode 100644 index 0000000000..696d14fbbb --- /dev/null +++ b/tests/validation/fixtures/NormalizationLayerFixture.h @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_NORMALIZATION_LAYER_FIXTURE +#define ARM_COMPUTE_TEST_NORMALIZATION_LAYER_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/NormalizationLayer.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class NormalizationValidationFixedPointFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, NormType norm_type, int norm_size, float beta, DataType data_type, int fractional_bits) + { + _fractional_bits = fractional_bits; + NormalizationLayerInfo info(norm_type, norm_size, 5, beta); + + _target = compute_target(shape, info, data_type, fractional_bits); + _reference = compute_reference(shape, info, data_type, fractional_bits); + } + +protected: + template + void fill(U &&tensor) + { + if(_fractional_bits == 0) + { + library->fill_tensor_uniform(tensor, 0); + } + else + { + const int one_fixed = 1 << _fractional_bits; + std::uniform_int_distribution<> distribution(-one_fixed, one_fixed); + library->fill(tensor, distribution, 0); + } + } + + TensorType compute_target(const TensorShape &shape, NormalizationLayerInfo info, DataType data_type, int fixed_point_position = 0) + { + // Create tensors + TensorType src = create_tensor(shape, data_type, 1, fixed_point_position); + TensorType dst = create_tensor(shape, data_type, 1, fixed_point_position); + + // Create and configure function + FunctionType norm_layer; + norm_layer.configure(&src, &dst, info); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src)); + + // Compute function + norm_layer.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &shape, NormalizationLayerInfo info, DataType data_type, int fixed_point_position = 0) + { + // Create reference + SimpleTensor src{ shape, data_type, 1, fixed_point_position }; + + // Fill reference + fill(src); + + return reference::normalization_layer(src, info); + } + + TensorType _target{}; + SimpleTensor _reference{}; + int _fractional_bits{}; +}; + +template +class NormalizationValidationFixture : public NormalizationValidationFixedPointFixture +{ +public: + template + void setup(TensorShape shape, NormType norm_type, int norm_size, float beta, DataType data_type) + { + NormalizationValidationFixedPointFixture::setup(shape, norm_type, norm_size, beta, data_type, 0); + } +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_NORMALIZATION_LAYER_FIXTURE */ diff --git a/tests/validation/fixtures/PoolingLayerFixture.h b/tests/validation/fixtures/PoolingLayerFixture.h new file mode 100644 index 0000000000..5ce4aa6755 --- /dev/null +++ b/tests/validation/fixtures/PoolingLayerFixture.h @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_POOLING_LAYER_FIXTURE +#define ARM_COMPUTE_TEST_POOLING_LAYER_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/PoolingLayer.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class PoolingLayerValidationFixedPointFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, PoolingType pool_type, int pool_size, PadStrideInfo pad_stride_info, DataType data_type, int fractional_bits) + { + _fractional_bits = fractional_bits; + PoolingLayerInfo info(pool_type, pool_size, pad_stride_info); + + _target = compute_target(shape, info, data_type, fractional_bits); + _reference = compute_reference(shape, info, data_type, fractional_bits); + } + +protected: + template + void fill(U &&tensor) + { + if(_fractional_bits == 0) + { + std::uniform_real_distribution<> distribution(-1.f, 1.f); + library->fill(tensor, distribution, 0); + } + else + { + const int one_fixed = 1 << _fractional_bits; + std::uniform_int_distribution<> distribution(-one_fixed, one_fixed); + library->fill(tensor, distribution, 0); + } + } + + TensorType compute_target(const TensorShape &shape, PoolingLayerInfo info, DataType data_type, int fixed_point_position = 0) + { + // Create tensors + TensorType src = create_tensor(shape, data_type, 1, fixed_point_position); + TensorType dst; + + // Create and configure function + FunctionType pool_layer; + pool_layer.configure(&src, &dst, info); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src)); + + // Compute function + pool_layer.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &shape, PoolingLayerInfo info, DataType data_type, int fixed_point_position = 0) + { + // Create reference + SimpleTensor src{ shape, data_type, 1, fixed_point_position }; + + // Fill reference + fill(src); + + return reference::pooling_layer(src, info); + } + + TensorType _target{}; + SimpleTensor _reference{}; + int _fractional_bits{}; +}; + +template +class PoolingLayerValidationFixture : public PoolingLayerValidationFixedPointFixture +{ +public: + template + void setup(TensorShape shape, PoolingType pool_type, int pool_size, PadStrideInfo pad_stride_info, DataType data_type) + { + PoolingLayerValidationFixedPointFixture::setup(shape, pool_type, pool_size, pad_stride_info, data_type, 0); + } +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_POOLING_LAYER_FIXTURE */ diff --git a/tests/validation/fixtures/QuantizationLayerFixture.h b/tests/validation/fixtures/QuantizationLayerFixture.h new file mode 100644 index 0000000000..83ee0495f3 --- /dev/null +++ b/tests/validation/fixtures/QuantizationLayerFixture.h @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_QUANTIZATION_LAYER_FIXTURE +#define ARM_COMPUTE_TEST_QUANTIZATION_LAYER_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/QuantizationLayer.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class QuantizationValidationFixedPointFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type) + { + _target = compute_target(shape, data_type); + _reference = compute_reference(shape, data_type); + } + +protected: + template + void fill(U &&tensor) + { + library->fill_tensor_uniform(tensor, 0); + } + + TensorType compute_target(const TensorShape &shape, DataType data_type) + { + // Create tensors + TensorType src = create_tensor(shape, data_type); + TensorType dst = create_tensor(shape, DataType::U8); + + // Create and configure function + FunctionType quantization_layer; + quantization_layer.configure(&src, &dst); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src)); + + // Compute function + quantization_layer.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) + { + // Create reference + SimpleTensor src{ shape, data_type }; + + // Fill reference + fill(src); + + return reference::quantization_layer(src); + } + + TensorType _target{}; + SimpleTensor _reference{}; +}; + +template +class QuantizationValidationFixture : public QuantizationValidationFixedPointFixture +{ +public: + template + void setup(TensorShape shape, DataType data_type) + { + QuantizationValidationFixedPointFixture::setup(shape, data_type); + } +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_QUANTIZATION_LAYER_FIXTURE */ diff --git a/tests/validation/fixtures/ReductionOperationFixture.h b/tests/validation/fixtures/ReductionOperationFixture.h new file mode 100644 index 0000000000..7c871aed3b --- /dev/null +++ b/tests/validation/fixtures/ReductionOperationFixture.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_REDUCTION_OPERATION_FIXTURE +#define ARM_COMPUTE_TEST_REDUCTION_OPERATION_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/ReductionOperation.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class ReductionOperationValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type, unsigned int axis, ReductionOperation op) + { + const TensorShape output_shape = get_output_shape(shape, axis); + _target = compute_target(shape, output_shape, data_type, axis, op); + _reference = compute_reference(shape, output_shape, data_type, axis, op); + } + +protected: + template + void fill(U &&tensor) + { + library->fill_tensor_uniform(tensor, 0); + } + + TensorType compute_target(const TensorShape &src_shape, const TensorShape &dst_shape, DataType data_type, unsigned int axis, ReductionOperation op) + { + // Create tensors + TensorType src = create_tensor(src_shape, data_type); + TensorType dst = create_tensor(dst_shape, data_type); + + // Create and configure function + FunctionType reduction_func; + reduction_func.configure(&src, &dst, axis, op); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src)); + + // Compute function + reduction_func.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &src_shape, const TensorShape &dst_shape, DataType data_type, unsigned int axis, ReductionOperation op) + { + // Create reference + SimpleTensor src{ src_shape, data_type }; + + // Fill reference + fill(src); + + return reference::reduction_operation(src, dst_shape, axis, op); + } + + TensorType _target{}; + SimpleTensor _reference{}; + +private: + TensorShape get_output_shape(TensorShape shape, unsigned int axis) + { + TensorShape output_shape(shape); + output_shape.set(axis, 1); + return output_shape; + } +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_REDUCTION_OPERATION_FIXTURE */ diff --git a/tests/validation/fixtures/ScaleFixture.h b/tests/validation/fixtures/ScaleFixture.h new file mode 100644 index 0000000000..53bb0f2124 --- /dev/null +++ b/tests/validation/fixtures/ScaleFixture.h @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_SCALE_FIXTURE +#define ARM_COMPUTE_TEST_SCALE_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/Scale.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class ScaleValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type, InterpolationPolicy policy, BorderMode border_mode) + { + _shape = shape; + _policy = policy; + _border_mode = border_mode; + _data_type = data_type; + + std::mt19937 generator(library->seed()); + std::uniform_real_distribution distribution_float(0.25, 4); + const float scale_x = distribution_float(generator); + const float scale_y = distribution_float(generator); + std::uniform_int_distribution distribution_u8(0, 255); + uint8_t constant_border_value = distribution_u8(generator); + + _target = compute_target(shape, scale_x, scale_y, policy, border_mode, constant_border_value); + _reference = compute_reference(shape, scale_x, scale_y, policy, border_mode, constant_border_value); + } + +protected: + template + void fill(U &&tensor) + { + library->fill_tensor_uniform(tensor, 0); + } + + TensorType compute_target(const TensorShape &shape, const float scale_x, const float scale_y, + InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) + { + // Create tensors + TensorType src = create_tensor(shape, _data_type); + TensorShape shape_scaled(shape); + shape_scaled.set(0, shape[0] * scale_x); + shape_scaled.set(1, shape[1] * scale_y); + TensorType dst = create_tensor(shape_scaled, _data_type); + + // Create and configure function + FunctionType scale; + + scale.configure(&src, &dst, policy, border_mode, constant_border_value); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src)); + + // Compute function + scale.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &shape, const float scale_x, const float scale_y, + InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) + { + // Create reference + SimpleTensor src{ shape, _data_type }; + + // Fill reference + fill(src); + + return reference::scale(src, scale_x, scale_y, policy, border_mode, constant_border_value); + } + + TensorType _target{}; + SimpleTensor _reference{}; + TensorShape _shape{}; + InterpolationPolicy _policy{}; + BorderMode _border_mode{}; + DataType _data_type{}; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_SCALE_FIXTURE */ \ No newline at end of file diff --git a/tests/validation/fixtures/SoftmaxLayerFixture.h b/tests/validation/fixtures/SoftmaxLayerFixture.h new file mode 100644 index 0000000000..9c8f044e81 --- /dev/null +++ b/tests/validation/fixtures/SoftmaxLayerFixture.h @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_SOFTMAX_LAYER_FIXTURE +#define ARM_COMPUTE_TEST_SOFTMAX_LAYER_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/SoftmaxLayer.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class SoftmaxValidationFixedPointFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type, int fractional_bits) + { + _fractional_bits = fractional_bits; + + _target = compute_target(shape, data_type, fractional_bits); + _reference = compute_reference(shape, data_type, fractional_bits); + } + +protected: + template + void fill(U &&tensor) + { + if(_fractional_bits == 0) + { + std::uniform_real_distribution<> distribution(-1000.f, 1000.f); + library->fill(tensor, distribution, 0); + } + else + { + const int one_fixed = 1 << _fractional_bits; + std::uniform_int_distribution<> distribution(-one_fixed, one_fixed); + library->fill(tensor, distribution, 0); + } + } + + TensorType compute_target(const TensorShape &shape, DataType data_type, int fixed_point_position = 0) + { + // Create tensors + TensorType src = create_tensor(shape, data_type, 1, fixed_point_position); + TensorType dst = create_tensor(shape, data_type, 1, fixed_point_position); + + // Create and configure function + FunctionType smx_layer; + smx_layer.configure(&src, &dst); + + ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Fill tensors + fill(AccessorType(src)); + + // Compute function + smx_layer.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &shape, DataType data_type, int fixed_point_position = 0) + { + // Create reference + SimpleTensor src{ shape, data_type, 1, fixed_point_position }; + + // Fill reference + fill(src); + + return reference::softmax_layer(src); + } + + TensorType _target{}; + SimpleTensor _reference{}; + int _fractional_bits{}; +}; + +template +class SoftmaxValidationFixture : public SoftmaxValidationFixedPointFixture +{ +public: + template + void setup(TensorShape shape, DataType data_type) + { + SoftmaxValidationFixedPointFixture::setup(shape, data_type, 0); + } +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_SOFTMAX_LAYER_FIXTURE */ diff --git a/tests/validation/half.h b/tests/validation/half.h index d8aa341068..0ca620cf57 100644 --- a/tests/validation/half.h +++ b/tests/validation/half.h @@ -34,4 +34,5 @@ #define HALF_ROUND_TIES_TO_EVEN 1 #include "half/half.hpp" + #endif /* __ARM_COMPUTE_TEST_HALF_H__ */ diff --git a/tests/validation/main.cpp b/tests/validation/main.cpp deleted file mode 100644 index a6c02ed4dd..0000000000 --- a/tests/validation/main.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#define BOOST_TEST_ALTERNATIVE_INIT_API - -#include "AssetsLibrary.h" -#include "Globals.h" -#include "Utils.h" -#include "ValidationProgramOptions.h" -#include "ValidationUserConfiguration.h" -#include "support/ToolchainSupport.h" - -#include "arm_compute/runtime/Scheduler.h" - -#include "boost_wrapper.h" - -#include -#include -#include - -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace arm_compute -{ -namespace test -{ -ValidationUserConfiguration user_config; -std::unique_ptr library; -} // namespace test -} // namespace arm_compute - -struct GlobalFixture -{ - GlobalFixture() - { - library = arm_compute::support::cpp14::make_unique(user_config.path.get(), user_config.seed); - std::cout << "Seed: " << library->seed() << "\n"; - } -}; - -BOOST_GLOBAL_FIXTURE(GlobalFixture); - -bool init_unit_test() -{ - boost::unit_test::framework::master_test_suite().p_name.value = "Compute Library Validation Tests"; - - ValidationProgramOptions options; - - int &argc = boost::unit_test::framework::master_test_suite().argc; - char **argv = boost::unit_test::framework::master_test_suite().argv; - - try - { - options.parse_commandline(argc, argv); - - if(options.wants_help()) - { - std::cout << "Usage: " << argv[0] << " [options] PATH\n"; - std::cout << options.get_help() << "\n"; - return false; - } - - user_config = ValidationUserConfiguration(options); - } - catch(const boost::program_options::required_option &err) - { - std::cerr << "Error: " << err.what() << "\n"; - std::cout << "\nUsage: " << argv[0] << " [options] PATH\n"; - std::cout << options.get_help() << "\n"; - return false; - } - - std::cout << "Using " << user_config.threads << " CPU " << (user_config.threads == 1 ? "thread" : "threads") << "\n"; - arm_compute::Scheduler::get().set_num_threads(user_config.threads); - return true; -} diff --git a/tests/validation/system_tests/CL/AlexNet.cpp b/tests/validation/system_tests/CL/AlexNet.cpp deleted file mode 100644 index 2b1d31f65f..0000000000 --- a/tests/validation/system_tests/CL/AlexNet.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifdef INTERNAL_ONLY //FIXME Delete this file before the release -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "CL/CLAccessor.h" -#include "validation/Validation.h" - -#include "arm_compute/runtime/CL/CLSubTensor.h" -#include "arm_compute/runtime/CL/functions/CLActivationLayer.h" -#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h" -#include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h" -#include "arm_compute/runtime/CL/functions/CLNormalizationLayer.h" -#include "arm_compute/runtime/CL/functions/CLPoolingLayer.h" -#include "arm_compute/runtime/CL/functions/CLSoftmaxLayer.h" - -#include "model_objects/AlexNet.h" - -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -using CLAlexNetModel = model_objects::AlexNet; -std::vector compute_alexnet(unsigned int batches, std::string input_file) -{ - std::vector weight_files = { "cnn_data/alexnet_model/conv1_w.dat", - "cnn_data/alexnet_model/conv2_w.dat", - "cnn_data/alexnet_model/conv3_w.dat", - "cnn_data/alexnet_model/conv4_w.dat", - "cnn_data/alexnet_model/conv5_w.dat", - "cnn_data/alexnet_model/fc6_w.dat", - "cnn_data/alexnet_model/fc7_w.dat", - "cnn_data/alexnet_model/fc8_w.dat" - }; - - std::vector bias_files = { "cnn_data/alexnet_model/conv1_b.dat", - "cnn_data/alexnet_model/conv2_b.dat", - "cnn_data/alexnet_model/conv3_b.dat", - "cnn_data/alexnet_model/conv4_b.dat", - "cnn_data/alexnet_model/conv5_b.dat", - "cnn_data/alexnet_model/fc6_b.dat", - "cnn_data/alexnet_model/fc7_b.dat", - "cnn_data/alexnet_model/fc8_b.dat" - }; - CLAlexNetModel network{}; - network.init_weights(batches); - network.build(); - network.allocate(); - network.fill(weight_files, bias_files); - network.feed(std::move(input_file)); - network.run(); - - return network.get_classifications(); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(SYSTEM_TESTS) -BOOST_AUTO_TEST_SUITE(CL) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_AUTO_TEST_CASE(AlexNet) -{ - // Compute alexnet - std::vector classified_labels = compute_alexnet(1, "cnn_data/imagenet_data/shark.dat"); - - // Expected labels - std::vector expected_labels = { 2 }; - - // Validate labels - validate(classified_labels, expected_labels); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ -#endif /* INTERNAL_ONLY */ diff --git a/tests/validation/system_tests/CL/LeNet5.cpp b/tests/validation/system_tests/CL/LeNet5.cpp deleted file mode 100644 index 4b3d969a1d..0000000000 --- a/tests/validation/system_tests/CL/LeNet5.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifdef INTERNAL_ONLY //FIXME Delete this file before the release -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "CL/CLAccessor.h" -#include "validation/Validation.h" - -#include "arm_compute/runtime/CL/functions/CLActivationLayer.h" -#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h" -#include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h" -#include "arm_compute/runtime/CL/functions/CLPoolingLayer.h" -#include "arm_compute/runtime/CL/functions/CLSoftmaxLayer.h" - -#include "model_objects/LeNet5.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -using CLLeNet5Model = model_objects::LeNet5; -std::vector compute_lenet5(unsigned int batches, std::string input_file) -{ - std::vector weight_files = { "cnn_data/lenet_model/conv1_w.dat", - "cnn_data/lenet_model/conv2_w.dat", - "cnn_data/lenet_model/ip1_w.dat", - "cnn_data/lenet_model/ip2_w.dat" - }; - - std::vector bias_files = { "cnn_data/lenet_model/conv1_b.dat", - "cnn_data/lenet_model/conv2_b.dat", - "cnn_data/lenet_model/ip1_b.dat", - "cnn_data/lenet_model/ip2_b.dat" - }; - CLLeNet5Model network{}; - network.build(batches); - network.fill(weight_files, bias_files); - network.feed(std::move(input_file)); - network.run(); - - return network.get_classifications(); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(SYSTEM_TESTS) -BOOST_AUTO_TEST_SUITE(CL) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_AUTO_TEST_CASE(LeNet5) -{ - // Compute alexnet - std::vector classified_labels = compute_lenet5(10, "cnn_data/mnist_data/input100.dat"); - - // Expected labels - std::vector expected_labels = { 7, 2, 1, 0, 4, 1, 4, 9, 5, 9 }; - - // Validate labels - validate(classified_labels, expected_labels); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ -#endif /* INTERNAL_ONLY */ diff --git a/tests/validation/system_tests/NEON/AlexNet.cpp b/tests/validation/system_tests/NEON/AlexNet.cpp deleted file mode 100644 index 20a612fd64..0000000000 --- a/tests/validation/system_tests/NEON/AlexNet.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifdef INTERNAL_ONLY //FIXME Delete this file before the release -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "NEON/Accessor.h" -#include "validation/Validation.h" - -#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" -#include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" -#include "arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h" -#include "arm_compute/runtime/NEON/functions/NENormalizationLayer.h" -#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" -#include "arm_compute/runtime/NEON/functions/NESoftmaxLayer.h" -#include "arm_compute/runtime/SubTensor.h" - -#include "model_objects/AlexNet.h" - -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -using NEAlexNetModel = model_objects::AlexNet; -std::vector compute_alexnet(unsigned int batches, std::string input_file) -{ - std::vector weight_files = { "cnn_data/alexnet_model/conv1_w.dat", - "cnn_data/alexnet_model/conv2_w.dat", - "cnn_data/alexnet_model/conv3_w.dat", - "cnn_data/alexnet_model/conv4_w.dat", - "cnn_data/alexnet_model/conv5_w.dat", - "cnn_data/alexnet_model/fc6_w.dat", - "cnn_data/alexnet_model/fc7_w.dat", - "cnn_data/alexnet_model/fc8_w.dat" - }; - - std::vector bias_files = { "cnn_data/alexnet_model/conv1_b.dat", - "cnn_data/alexnet_model/conv2_b.dat", - "cnn_data/alexnet_model/conv3_b.dat", - "cnn_data/alexnet_model/conv4_b.dat", - "cnn_data/alexnet_model/conv5_b.dat", - "cnn_data/alexnet_model/fc6_b.dat", - "cnn_data/alexnet_model/fc7_b.dat", - "cnn_data/alexnet_model/fc8_b.dat" - }; - NEAlexNetModel network{}; - - network.init_weights(batches); - network.build(); - network.allocate(); - network.fill(weight_files, bias_files); - network.feed(std::move(input_file)); - network.run(); - - return network.get_classifications(); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(SYSTEM_TESTS) -BOOST_AUTO_TEST_SUITE(NEON) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_AUTO_TEST_CASE(AlexNet) -{ - // Compute alexnet - std::vector classified_labels = compute_alexnet(1, "cnn_data/imagenet_data/shark.dat"); - - // Expected labels - std::vector expected_labels = { 2 }; - - // Validate labels - validate(classified_labels, expected_labels); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ -#endif /* INTERNAL_ONLY */ diff --git a/tests/validation/system_tests/NEON/LeNet5.cpp b/tests/validation/system_tests/NEON/LeNet5.cpp deleted file mode 100644 index c745613959..0000000000 --- a/tests/validation/system_tests/NEON/LeNet5.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifdef INTERNAL_ONLY //FIXME Delete this file before the release -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "NEON/Accessor.h" -#include "validation/Validation.h" - -#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" -#include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" -#include "arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h" -#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" -#include "arm_compute/runtime/NEON/functions/NESoftmaxLayer.h" - -#include "model_objects/LeNet5.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -using NELeNet5Model = model_objects::LeNet5; -std::vector compute_lenet5(unsigned int batches, std::string input_file) -{ - std::vector weight_files = { "cnn_data/lenet_model/conv1_w.dat", - "cnn_data/lenet_model/conv2_w.dat", - "cnn_data/lenet_model/ip1_w.dat", - "cnn_data/lenet_model/ip2_w.dat" - }; - - std::vector bias_files = { "cnn_data/lenet_model/conv1_b.dat", - "cnn_data/lenet_model/conv2_b.dat", - "cnn_data/lenet_model/ip1_b.dat", - "cnn_data/lenet_model/ip2_b.dat" - }; - NELeNet5Model network{}; - network.build(batches); - network.fill(weight_files, bias_files); - network.feed(std::move(input_file)); - network.run(); - - return network.get_classifications(); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(SYSTEM_TESTS) -BOOST_AUTO_TEST_SUITE(NEON) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_AUTO_TEST_CASE(LeNet5) -{ - // Compute alexnet - std::vector classified_labels = compute_lenet5(10, "cnn_data/mnist_data/input100.dat"); - - // Expected labels - std::vector expected_labels = { 7, 2, 1, 0, 4, 1, 4, 9, 5, 9 }; - - // Validate labels - validate(classified_labels, expected_labels); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ -#endif /* INTERNAL_ONLY */ diff --git a/tests/validation_new/CL/ActivationLayer.cpp b/tests/validation_new/CL/ActivationLayer.cpp deleted file mode 100644 index c8fddc7db6..0000000000 --- a/tests/validation_new/CL/ActivationLayer.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLActivationLayer.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ActivationFunctionsDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/ActivationLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Define tolerance of the activation layer. - * - * @param[in] activation The activation function used. - * @param[in] data_type Data type. - * - * @return Tolerance depending on the activation function. - */ -AbsoluteTolerance tolerance(ActivationLayerInfo::ActivationFunction activation, DataType data_type) -{ - constexpr float epsilon = 1e-6f; - - switch(activation) - { - case ActivationLayerInfo::ActivationFunction::LINEAR: - return AbsoluteTolerance(data_type == DataType::F16 ? 0.2f : epsilon); - case ActivationLayerInfo::ActivationFunction::SQUARE: - return AbsoluteTolerance(data_type == DataType::F16 ? 0.1f : epsilon); - case ActivationLayerInfo::ActivationFunction::LOGISTIC: - if(is_data_type_fixed_point(data_type)) - { - return AbsoluteTolerance(5.f); - } - else - { - return AbsoluteTolerance(data_type == DataType::F16 ? 0.001f : epsilon); - } - case ActivationLayerInfo::ActivationFunction::LEAKY_RELU: - return AbsoluteTolerance(data_type == DataType::F16 ? 0.00001f : epsilon); - case ActivationLayerInfo::ActivationFunction::SOFT_RELU: - case ActivationLayerInfo::ActivationFunction::SQRT: - if(is_data_type_fixed_point(data_type)) - { - return AbsoluteTolerance(5.f); - } - else - { - return AbsoluteTolerance(data_type == DataType::F16 ? 0.01f : 0.00001f); - } - case ActivationLayerInfo::ActivationFunction::TANH: - if(is_data_type_fixed_point(data_type)) - { - return AbsoluteTolerance(5.f); - } - else - { - return AbsoluteTolerance(data_type == DataType::F16 ? 0.001f : 0.00001f); - } - default: - return AbsoluteTolerance(epsilon); - } -} - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ - DataType::F16, - DataType::F32, - DataType::QS8, - DataType::QS16, -}); - -/** Input data sets. */ -const auto ActivationDataset = combine(combine(framework::dataset::make("InPlace", { false, true }), datasets::ActivationFunctions()), framework::dataset::make("AlphaBeta", { 0.5f, 1.f })); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(ActivationLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), CNNDataTypes), framework::dataset::make("InPlace", { false, true })), - shape, data_type, in_place) -{ - // Set fixed point position data type allowed - const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - // Create tensors - CLTensor src = create_tensor(shape, data_type, 1, fixed_point_position); - CLTensor dst = create_tensor(shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLActivationLayer act_layer; - - if(in_place) - { - act_layer.configure(&src, nullptr, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS)); - } - else - { - act_layer.configure(&src, &dst, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS)); - } - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - - if(!in_place) - { - validate(dst.info()->valid_region(), valid_region); - } - - // Validate padding - const int step = 16 / arm_compute::data_size_from_type(data_type); - const PaddingSize padding = PaddingCalculator(shape.x(), step).required_padding(); - validate(src.info()->padding(), padding); - - if(!in_place) - { - validate(dst.info()->padding(), padding); - } -} - -template -using CLActivationLayerFixture = ActivationValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); -} -TEST_SUITE_END() - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ActivationDataset), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ActivationDataset), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using CLActivationLayerFixedPointFixture = ActivationValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// We test for fixed point precision [3,5] because [1,2] and [6,7] ranges cause -// overflowing issues in most of the transcendentals functions. -FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 3, 6))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLActivationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 3, 6))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 -FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLActivationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/BitwiseAnd.cpp b/tests/validation_new/CL/BitwiseAnd.cpp deleted file mode 100644 index af40812b2a..0000000000 --- a/tests/validation_new/CL/BitwiseAnd.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLBitwiseAnd.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/BitwiseAndFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(CL) -TEST_SUITE(BitwiseAnd) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - CLTensor src1 = create_tensor(shape, data_type); - CLTensor src2 = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLBitwiseAnd bitwise_and; - bitwise_and.configure(&src1, &src2, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using CLBitwiseAndFixture = BitwiseAndValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, CLBitwiseAndFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLBitwiseAndFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/BitwiseNot.cpp b/tests/validation_new/CL/BitwiseNot.cpp deleted file mode 100644 index e95619f481..0000000000 --- a/tests/validation_new/CL/BitwiseNot.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLBitwiseNot.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/BitwiseNotFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(CL) -TEST_SUITE(BitwiseNot) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - CLTensor src = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLBitwiseNot bitwise_not; - bitwise_not.configure(&src, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using CLBitwiseNotFixture = BitwiseNotValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, CLBitwiseNotFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLBitwiseNotFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/BitwiseOr.cpp b/tests/validation_new/CL/BitwiseOr.cpp deleted file mode 100644 index 15964eecc3..0000000000 --- a/tests/validation_new/CL/BitwiseOr.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLBitwiseOr.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/BitwiseOrFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(CL) -TEST_SUITE(BitwiseOr) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - CLTensor src1 = create_tensor(shape, data_type); - CLTensor src2 = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLBitwiseOr bitwise_or; - bitwise_or.configure(&src1, &src2, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using CLBitwiseOrFixture = BitwiseOrValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, CLBitwiseOrFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLBitwiseOrFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/BitwiseXor.cpp b/tests/validation_new/CL/BitwiseXor.cpp deleted file mode 100644 index 8e8852209b..0000000000 --- a/tests/validation_new/CL/BitwiseXor.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLBitwiseXor.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/BitwiseXorFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(CL) -TEST_SUITE(BitwiseXor) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - CLTensor src1 = create_tensor(shape, data_type); - CLTensor src2 = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLBitwiseXor bitwise_xor; - bitwise_xor.configure(&src1, &src2, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using CLBitwiseXorFixture = BitwiseXorValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, CLBitwiseXorFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLBitwiseXorFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/ConvolutionLayer.cpp b/tests/validation_new/CL/ConvolutionLayer.cpp deleted file mode 100644 index 9703e0bcba..0000000000 --- a/tests/validation_new/CL/ConvolutionLayer.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/LargeConvolutionLayerDataset.h" -#include "tests/datasets_new/SmallConvolutionLayerDataset.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/ConvolutionLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ -constexpr AbsoluteTolerance tolerance_f16(0.1f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F16 */ -constexpr AbsoluteTolerance tolerance_q(1.0f); /**< Tolerance value for comparing reference's output against implementation's output for fixed point data types */ - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ - DataType::F16, - DataType::F32, - DataType::QS8, - DataType::QS16, -}); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(ConvolutionLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallConvolutionLayerDataset(), datasets::LargeConvolutionLayerDataset()), CNNDataTypes), - input_shape, weights_shape, bias_shape, output_shape, info, data_type) -{ - // Set fixed point position data type allowed - int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - // Create tensors - CLTensor src = create_tensor(input_shape, data_type, 1, fixed_point_position); - CLTensor weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); - CLTensor bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); - CLTensor dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLConvolutionLayer conv; - conv.configure(&src, &weights, &bias, &dst, info); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(input_shape); - const ValidRegion weights_valid_region = shape_to_valid_region(weights_shape); - const ValidRegion bias_valid_region = shape_to_valid_region(bias_shape); - const ValidRegion dst_valid_region = shape_to_valid_region(output_shape); - - validate(src.info()->valid_region(), src_valid_region); - validate(weights.info()->valid_region(), weights_valid_region); - validate(bias.info()->valid_region(), bias_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - //TODO(COMPMID-415) Need to validate padding? -} - -template -using CLConvolutionLayerFixture = ConvolutionValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallConvolutionLayerDataset(), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeConvolutionLayerDataset(), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using CLConvolutionLayerFixedPointFixture = ConvolutionValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// We test for fixed point precision [4,6] -FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 4, 7))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_q); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 4, 7))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_q); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) -FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_q); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_q); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/DepthConcatenateLayer.cpp b/tests/validation_new/CL/DepthConcatenateLayer.cpp deleted file mode 100644 index ff64e2340b..0000000000 --- a/tests/validation_new/CL/DepthConcatenateLayer.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLDepthConcatenate.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/DepthConcatenateLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(CL) -TEST_SUITE(DepthConcatenateLayer) - -//TODO(COMPMID-415): Add configuration test? - -template -using CLDepthConcatenateLayerFixture = DepthConcatenateValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -TEST_SUITE_END() - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), - framework::dataset::make("DataType", - DataType::QS8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), - framework::dataset::make("DataType", - DataType::QS8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), - framework::dataset::make("DataType", - DataType::QS16))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), - framework::dataset::make("DataType", - DataType::QS16))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/DepthwiseConvolution.cpp b/tests/validation_new/CL/DepthwiseConvolution.cpp deleted file mode 100644 index 3fda275715..0000000000 --- a/tests/validation_new/CL/DepthwiseConvolution.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLDepthwiseConvolution.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/LargeDepthwiseConvolutionDataset.h" -#include "tests/datasets_new/SmallDepthwiseConvolutionDataset.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/DepthwiseConvolutionFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(DepthwiseConvolution) - -template -using CLDepthwiseConvolutionFixture = DepthwiseConvolutionValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionFixture, framework::DatasetMode::PRECOMMIT, datasets::SmallDepthwiseConvolutionDataset()) -{ - validate(CLAccessor(_target), _reference, tolerance_f32); -} - -FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionFixture, framework::DatasetMode::NIGHTLY, datasets::LargeDepthwiseConvolutionDataset()) -{ - validate(CLAccessor(_target), _reference, tolerance_f32); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/DepthwiseSeparableConvolutionLayer.cpp b/tests/validation_new/CL/DepthwiseSeparableConvolutionLayer.cpp deleted file mode 100644 index e577f5af04..0000000000 --- a/tests/validation_new/CL/DepthwiseSeparableConvolutionLayer.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLDepthwiseSeparableConvolutionLayer.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/MobileNetDepthwiseSeparableConvolutionLayerDataset.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/DepthwiseSeparableConvolutionLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(DepthwiseSeparableConvolutionLayer) - -// Configuration test to do - -template -using CLDepthwiseSeparableConvolutionLayerFixture = DepthwiseSeparableConvolutionValidationFixture; -FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseSeparableConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, datasets::MobileNetDepthwiseSeparableConvolutionLayerDataset()) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/DirectConvolutionLayer.cpp b/tests/validation_new/CL/DirectConvolutionLayer.cpp deleted file mode 100644 index 1c698ace0f..0000000000 --- a/tests/validation_new/CL/DirectConvolutionLayer.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLDirectConvolutionLayer.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/DirectConvolutionLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance tolerance_fp16(0.1f); /**< Tolerance for floating point tests */ -constexpr AbsoluteTolerance tolerance_fp32(0.001f); /**< Tolerance for floating point tests */ - -constexpr AbsoluteTolerance tolerance_qs8(0); /**< Tolerance for fixed point tests */ -constexpr AbsoluteTolerance tolerance_qs16(0); /**< Tolerance for fixed point tests */ - -/** Direct convolution data set. */ -const auto data_quantized = combine(datasets::SmallDirectConvolutionShapes(), - combine(framework::dataset::make("StrideX", 1, 3), - combine(framework::dataset::make("StrideY", 1, 3), - combine(concat(combine(framework::dataset::make("PadX", 0), - combine(framework::dataset::make("PadY", 0), - framework::dataset::make("KernelSize", 1))), - combine(framework::dataset::make("PadX", 0, 2), - combine(framework::dataset::make("PadY", 0, 2), - framework::dataset::make("KernelSize", { 3 })))), - framework::dataset::make("NumKernels", { 1, 4, 8, 16 }))))); - -const auto data = combine(datasets::SmallDirectConvolutionShapes(), - combine(framework::dataset::make("StrideX", 1, 3), - combine(framework::dataset::make("StrideY", 1, 3), - combine(concat(combine(framework::dataset::make("PadX", 0), - combine(framework::dataset::make("PadY", 0), - framework::dataset::make("KernelSize", 1))), - combine(framework::dataset::make("PadX", 0, 2), - combine(framework::dataset::make("PadY", 0, 2), - framework::dataset::make("KernelSize", { 3, 5 })))), - framework::dataset::make("NumKernels", { 1, 4, 8, 16 }))))); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(DirectConvolutionLayer) - -//TODO(COMPMID-415): Configuration tests? - -template -using CLDirectConvolutionLayerFixture = DirectConvolutionValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionLayerFixture, framework::DatasetMode::ALL, combine(data, framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fp16); -} -TEST_SUITE_END() - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionLayerFixture, framework::DatasetMode::ALL, combine(data, framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fp32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using CLDirectConvolutionLayerFixedPointFixture = DirectConvolutionValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(data_quantized, framework::dataset::make("DataType", DataType::QS8)), - framework::dataset::make("FractionalBits", 2, 7))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs8); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(data_quantized, framework::dataset::make("DataType", DataType::QS16)), - framework::dataset::make("FractionalBits", 2, 15))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs16); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/Floor.cpp b/tests/validation_new/CL/Floor.cpp deleted file mode 100644 index 461a914be9..0000000000 --- a/tests/validation_new/CL/Floor.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLFloor.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/FloorFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(CL) -TEST_SUITE(Floor) - -template -using CLFloorFixture = FloorValidationFixture; - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLFloorFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLFloorFixture, framework::DatasetMode::NIGHTLY, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/FullyConnectedLayer.cpp b/tests/validation_new/CL/FullyConnectedLayer.cpp deleted file mode 100644 index e43997c47b..0000000000 --- a/tests/validation_new/CL/FullyConnectedLayer.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/FullyConnectedLayerDataset.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/FullyConnectedLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr AbsoluteTolerance tolerance_f32(0.001f); -constexpr AbsoluteTolerance tolerance_f16(0.4f); -/** Tolerance for fixed point operations */ -constexpr AbsoluteTolerance tolerance_fixed_point(1.f); - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ - DataType::F16, - DataType::F32, - DataType::QS8, - DataType::QS16, -}); - -const auto FullyConnectedParameters = combine(framework::dataset::make("TransposeWeights", { false, true }), framework::dataset::make("ReshapeWeights", { false, true })); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(FullyConnectedLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(framework::dataset::concat(datasets::SmallFullyConnectedLayerDataset(), datasets::LargeFullyConnectedLayerDataset()), - FullyConnectedParameters), - CNNDataTypes), - src_shape, weights_shape, bias_shape, dst_shape, transpose_weights, reshape_weights, data_type) -{ - // Set fixed point position data type allowed - int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - TensorShape ws(weights_shape); - - // Transpose weights if not done in the function - if(!reshape_weights || !transpose_weights) - { - const size_t shape_x = ws.x(); - ws.set(0, ws.y()); - ws.set(1, shape_x); - } - - // Create tensors - CLTensor src = create_tensor(src_shape, data_type, 1, fixed_point_position); - CLTensor weights = create_tensor(ws, data_type, 1, fixed_point_position); - CLTensor bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); - CLTensor dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function. - CLFullyConnectedLayer fc; - fc.configure(&src, &weights, &bias, &dst, transpose_weights, !reshape_weights); - - // Validate valid region - const ValidRegion dst_valid_region = shape_to_valid_region(dst_shape); - validate(dst.info()->valid_region(), dst_valid_region); -} - -template -using CLFullyConnectedLayerFixture = FullyConnectedLayerValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLFullyConnectedLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLFullyConnectedLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallFullyConnectedLayerDataset(), FullyConnectedParameters), - framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeFullyConnectedLayerDataset(), FullyConnectedParameters), - framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using CLFullyConnectedLayerFixedPointFixture = FullyConnectedLayerValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 -FIXTURE_DATA_TEST_CASE(RunSmall, CLFullyConnectedLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fixed_point); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLFullyConnectedLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fixed_point); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 -FIXTURE_DATA_TEST_CASE(RunSmall, CLFullyConnectedLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fixed_point); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLFullyConnectedLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fixed_point); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/GEMM.cpp b/tests/validation_new/CL/GEMM.cpp deleted file mode 100644 index 7da5da3ed9..0000000000 --- a/tests/validation_new/CL/GEMM.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLGEMM.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/LargeGEMMDataset.h" -#include "tests/datasets_new/SmallGEMMDataset.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/GEMMFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for floating point data types */ -constexpr AbsoluteTolerance tolerance_f16(0.1f); /**< Tolerance value for comparing reference's output against implementation's output for floating point data types */ -constexpr AbsoluteTolerance tolerance_q(1.0f); /**< Tolerance value for comparing reference's output against implementation's output for fixed point data types */ - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ - DataType::F16, - DataType::F32, - DataType::QS8, - DataType::QS16, -}); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(GEMM) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallGEMMDataset(), datasets::LargeGEMMDataset()), CNNDataTypes), - shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type) -{ - // Set fixed point position data type allowed - const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - // Create tensors - CLTensor a = create_tensor(shape_a, data_type, 1, fixed_point_position); - CLTensor b = create_tensor(shape_b, data_type, 1, fixed_point_position); - CLTensor c = create_tensor(shape_c, data_type, 1, fixed_point_position); - CLTensor dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(c.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLGEMM gemm; - gemm.configure(&a, &b, &c, &dst, alpha, beta); - - //TODO(COMPMID-415): Validate valid region -} - -template -using CLGEMMFixture = GEMMValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallGEMMDataset(), framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMDataset(), framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallGEMMDataset(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMDataset(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using CLGEMMFixedPointFixture = GEMMValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 7))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_q); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeGEMMDataset(), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 7))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_q); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_q); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeGEMMDataset(), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_q); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/L2Normalize.cpp b/tests/validation_new/CL/L2Normalize.cpp deleted file mode 100644 index d7882a842a..0000000000 --- a/tests/validation_new/CL/L2Normalize.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLL2Normalize.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/L2NormalizeFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr AbsoluteTolerance tolerance_f32(0.00001f); - -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(L2Normalize) - -template -using CLL2NormalizeFixture = L2NormalizeValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLL2NormalizeFixture, framework::DatasetMode::PRECOMMIT, - combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), framework::dataset::make("Epsilon", { 1e-12 }))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLL2NormalizeFixture, framework::DatasetMode::NIGHTLY, - combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), framework::dataset::make("Epsilon", { 1e-12 }))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/MeanStdDev.cpp b/tests/validation_new/CL/MeanStdDev.cpp deleted file mode 100644 index 494e1001bc..0000000000 --- a/tests/validation_new/CL/MeanStdDev.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/CL/functions/CLMeanStdDev.h" -#include "framework/Macros.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/MeanStdDevFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr RelativeTolerance tolerance_rel_high_error(0.05f); -constexpr RelativeTolerance tolerance_rel_low_error(0.0005f); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(MeanStdDev) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - CLTensor src = create_tensor(shape, data_type); - - // Create output variables - float mean = 0.f; - float std_dev = 0.f; - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create configure function - CLMeanStdDev mean_std_dev_image; - mean_std_dev_image.configure(&src, &mean, &std_dev); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 8).required_padding(); - validate(src.info()->padding(), padding); -} - -template -using CLMeanStdDevFixture = MeanStdDevValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, CLMeanStdDevFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate mean output - validate(_target.first, _reference.first); - - // Validate std_dev output - validate(_target.second, _reference.second, tolerance_rel_high_error); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLMeanStdDevFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate mean output - validate(_target.first, _reference.first, tolerance_rel_low_error); - - // Validate std_dev output - validate(_target.second, _reference.second, tolerance_rel_high_error); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/NormalizationLayer.cpp b/tests/validation_new/CL/NormalizationLayer.cpp deleted file mode 100644 index 37e77f3632..0000000000 --- a/tests/validation_new/CL/NormalizationLayer.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLNormalizationLayer.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/NormalizationTypesDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/NormalizationLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr AbsoluteTolerance tolerance_f16(0.01f); -constexpr AbsoluteTolerance tolerance_f32(0.00001f); -/** Tolerance for fixed point operations */ -constexpr AbsoluteTolerance tolerance_qs8(2); -constexpr AbsoluteTolerance tolerance_qs16(2); - -/** Input data set. */ -const auto NormalizationDataset = combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("NormType", { NormType::IN_MAP_1D, NormType::CROSS_MAP })), - framework::dataset::make("NormalizationSize", 3, 9, 2)), - framework::dataset::make("Beta", { 0.5f, 1.f, 2.f })); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(NormalizationLayer) - -//TODO(COMPMID-415): Missing configuration? - -template -using CLNormalizationLayerFixture = NormalizationValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLNormalizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLNormalizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using CLNormalizationLayerFixedPointFixture = NormalizationValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 -FIXTURE_DATA_TEST_CASE(RunSmall, CLNormalizationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(NormalizationDataset, framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs8); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLNormalizationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(NormalizationDataset, framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs8); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 5 -FIXTURE_DATA_TEST_CASE(RunSmall, CLNormalizationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(NormalizationDataset, framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLNormalizationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(NormalizationDataset, framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs16); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/PoolingLayer.cpp b/tests/validation_new/CL/PoolingLayer.cpp deleted file mode 100644 index d38a3b2c6a..0000000000 --- a/tests/validation_new/CL/PoolingLayer.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLPoolingLayer.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/PoolingTypesDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/PoolingLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Input data set for float data types */ -const auto PoolingLayerDatasetFP = combine(combine(datasets::PoolingTypes(), framework::dataset::make("PoolingSize", { 2, 3, 7 })), - framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) })); - -/** Input data set for quantized data types */ -const auto PoolingLayerDatasetQS = combine(combine(datasets::PoolingTypes(), framework::dataset::make("PoolingSize", { 2, 3 })), - framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) })); - -constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for float types */ -constexpr AbsoluteTolerance tolerance_f16(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for float types */ -constexpr AbsoluteTolerance tolerance_qs8(3); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */ -constexpr AbsoluteTolerance tolerance_qs16(6); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */ -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(PoolingLayer) - -template -using CLPoolingLayerFixture = PoolingLayerValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLPoolingLayerFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType", - DataType::F32)))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType", - DataType::F32)))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() - -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLPoolingLayerFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP, - framework::dataset::make("DataType", DataType::F16)))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP, - framework::dataset::make("DataType", DataType::F16)))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using CLPoolingLayerFixedPointFixture = PoolingLayerValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -FIXTURE_DATA_TEST_CASE(RunSmall, CLPoolingLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS, - framework::dataset::make("DataType", DataType::QS8))), - framework::dataset::make("FractionalBits", 1, 4))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs8); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLPoolingLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS, - framework::dataset::make("DataType", DataType::QS8))), - framework::dataset::make("FractionalBits", 1, 4))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs8); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLPoolingLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS, - framework::dataset::make("DataType", DataType::QS16))), - framework::dataset::make("FractionalBits", 1, 12))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLPoolingLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS, - framework::dataset::make("DataType", DataType::QS16))), - framework::dataset::make("FractionalBits", 1, 12))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs16); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/ReductionOperation.cpp b/tests/validation_new/CL/ReductionOperation.cpp deleted file mode 100644 index af49d736ab..0000000000 --- a/tests/validation_new/CL/ReductionOperation.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLReductionOperation.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ReductionOperationDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/ReductionOperationFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr RelativeTolerance tolerance_f32(0.00001f); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(ReductionOperation) - -template -using CLReductionOperationFixture = ReductionOperationValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLReductionOperationFixture, framework::DatasetMode::PRECOMMIT, - combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), datasets::ReductionOperations())) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLReductionOperationFixture, framework::DatasetMode::NIGHTLY, - combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), datasets::ReductionOperations())) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/Scale.cpp b/tests/validation_new/CL/Scale.cpp deleted file mode 100644 index e28555ac21..0000000000 --- a/tests/validation_new/CL/Scale.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLScale.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/BorderModeDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/ScaleFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance */ -constexpr AbsoluteTolerance tolerance(1); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(Scale) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), - framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - datasets::BorderModes()), - shape, data_type, policy, border_mode) -{ - std::mt19937 generator(library->seed()); - std::uniform_real_distribution distribution_float(0.25, 2); - const float scale_x = distribution_float(generator); - const float scale_y = distribution_float(generator); - std::uniform_int_distribution distribution_u8(0, 255); - uint8_t constant_border_value = distribution_u8(generator); - - // Create tensors - CLTensor src = create_tensor(shape, data_type); - TensorShape shape_scaled(shape); - shape_scaled.set(0, shape[0] * scale_x); - shape_scaled.set(1, shape[1] * scale_y); - CLTensor dst = create_tensor(shape_scaled, data_type); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLScale clscale; - clscale.configure(&src, &dst, policy, border_mode, constant_border_value); - - // Validate valid region - const ValidRegion dst_valid_region = calculate_valid_region_scale(*(src.info()), shape_scaled, policy, BorderSize(1), (border_mode == BorderMode::UNDEFINED)); - - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape_scaled.x(), 4); - calculator.set_border_mode(border_mode); - - const PaddingSize read_padding(1); - const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER); - validate(src.info()->padding(), read_padding); - validate(dst.info()->padding(), write_padding); -} - -template -using CLScaleFixture = ScaleValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8)), - framework::dataset::make("InterpolationPolicy", -{ InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), -datasets::BorderModes())) -{ - //Create valid region - TensorInfo src_info(_shape, 1, _data_type); - const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED)); - - // Validate output - validate(CLAccessor(_target), _reference, valid_region, tolerance); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8)), - framework::dataset::make("InterpolationPolicy", -{ InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), -datasets::BorderModes())) -{ - //Create valid region - TensorInfo src_info(_shape, 1, _data_type); - const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED)); - - // Validate output - validate(CLAccessor(_target), _reference, valid_region, tolerance); -} -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/SoftmaxLayer.cpp b/tests/validation_new/CL/SoftmaxLayer.cpp deleted file mode 100644 index d13236a2f9..0000000000 --- a/tests/validation_new/CL/SoftmaxLayer.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLSoftmaxLayer.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/SoftmaxLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr AbsoluteTolerance tolerance_f16(0.002f); -constexpr AbsoluteTolerance tolerance_f32(0.000001f); -/** Tolerance for fixed point operations */ -constexpr AbsoluteTolerance tolerance_fixed_point(2); - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ - DataType::F16, - DataType::F32, - DataType::QS8, - DataType::QS16, -}); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(SoftmaxLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), CNNDataTypes), shape, data_type) -{ - // Set fixed point position data type allowed - const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - // Create tensors - CLTensor src = create_tensor(shape, data_type, 1, fixed_point_position); - CLTensor dst = create_tensor(shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLSoftmaxLayer smx_layer; - smx_layer.configure(&src, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using CLSoftmaxLayerFixture = SoftmaxValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLSoftmaxLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLSoftmaxLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLSoftmaxLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLSoftmaxLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using CLSoftmaxLayerFixedPointFixture = SoftmaxValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 -FIXTURE_DATA_TEST_CASE(RunSmall, CLSoftmaxLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fixed_point); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLSoftmaxLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fixed_point); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 -FIXTURE_DATA_TEST_CASE(RunSmall, CLSoftmaxLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fixed_point); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLSoftmaxLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fixed_point); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/ActivationLayer.cpp b/tests/validation_new/CPP/ActivationLayer.cpp deleted file mode 100644 index 052c3aa566..0000000000 --- a/tests/validation_new/CPP/ActivationLayer.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "ActivationLayer.h" - -#include "tests/validation_new/FixedPoint.h" -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type> -SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info) -{ - // Create reference - SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; - - // Compute reference - const T a(info.a()); - const T b(info.b()); - - for(int i = 0; i < src.num_elements(); ++i) - { - T x = src[i]; - - switch(info.activation()) - { - case ActivationLayerInfo::ActivationFunction::ABS: - dst[i] = std::abs(x); - break; - case ActivationLayerInfo::ActivationFunction::LINEAR: - dst[i] = a * x + b; - break; - case ActivationLayerInfo::ActivationFunction::LOGISTIC: - dst[i] = static_cast(1) / (static_cast(1) + std::exp(-x)); - break; - case ActivationLayerInfo::ActivationFunction::RELU: - dst[i] = std::max(static_cast(0), x); - break; - case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU: - dst[i] = std::min(a, std::max(static_cast(0), x)); - break; - case ActivationLayerInfo::ActivationFunction::LEAKY_RELU: - dst[i] = (x > 0) ? x : a * x; - break; - case ActivationLayerInfo::ActivationFunction::SOFT_RELU: - dst[i] = std::log(static_cast(1) + std::exp(x)); - break; - case ActivationLayerInfo::ActivationFunction::SQRT: - dst[i] = std::sqrt(x); - break; - case ActivationLayerInfo::ActivationFunction::SQUARE: - dst[i] = x * x; - break; - case ActivationLayerInfo::ActivationFunction::TANH: - dst[i] = a * std::tanh(b * x); - break; - default: - ARM_COMPUTE_ERROR("Unsupported activation function"); - } - } - - return dst; -} - -template ::value, int>::type> -SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info) -{ - using namespace fixed_point_arithmetic; - - // Create reference - SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; - - // Compute reference - const int fixed_point_position = src.fixed_point_position(); - const fixed_point a(info.a(), fixed_point_position); - const fixed_point b(info.b(), fixed_point_position); - const fixed_point const_0(0, fixed_point_position); - const fixed_point const_1(1, fixed_point_position); - - for(int i = 0; i < src.num_elements(); ++i) - { - fixed_point x(src[i], fixed_point_position, true); - - switch(info.activation()) - { - case ActivationLayerInfo::ActivationFunction::ABS: - dst[i] = abs(x).raw(); - break; - case ActivationLayerInfo::ActivationFunction::LINEAR: - dst[i] = add(b, mul(a, x)).raw(); - break; - case ActivationLayerInfo::ActivationFunction::LOGISTIC: - dst[i] = (const_1 / (const_1 + exp(-x))).raw(); - break; - case ActivationLayerInfo::ActivationFunction::RELU: - dst[i] = max(const_0, x).raw(); - break; - case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU: - dst[i] = min(a, max(const_0, x)).raw(); - break; - case ActivationLayerInfo::ActivationFunction::LEAKY_RELU: - dst[i] = (x > const_0) ? x.raw() : mul(a, x).raw(); - break; - case ActivationLayerInfo::ActivationFunction::SOFT_RELU: - dst[i] = log(const_1 + exp(x)).raw(); - break; - case ActivationLayerInfo::ActivationFunction::SQRT: - dst[i] = (const_1 / inv_sqrt(x)).raw(); - break; - case ActivationLayerInfo::ActivationFunction::SQUARE: - dst[i] = mul(x, x).raw(); - break; - case ActivationLayerInfo::ActivationFunction::TANH: - dst[i] = mul(a, tanh(mul(b, x))).raw(); - break; - default: - ARM_COMPUTE_ERROR("Unsupported activation function"); - } - } - - return dst; -} - -template SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); -template SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); -template SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); -template SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/ActivationLayer.h b/tests/validation_new/CPP/ActivationLayer.h deleted file mode 100644 index 3f10a2f360..0000000000 --- a/tests/validation_new/CPP/ActivationLayer.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_ACTIVATION_LAYER_H__ -#define __ARM_COMPUTE_TEST_ACTIVATION_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type = 0> -SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); - -template ::value, int>::type = 0> -SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_ACTIVATION_LAYER_H__ */ diff --git a/tests/validation_new/CPP/BitwiseAnd.cpp b/tests/validation_new/CPP/BitwiseAnd.cpp deleted file mode 100644 index 6fc46b402b..0000000000 --- a/tests/validation_new/CPP/BitwiseAnd.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "BitwiseAnd.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor bitwise_and(const SimpleTensor &src1, const SimpleTensor &src2) -{ - SimpleTensor dst(src1.shape(), src1.data_type()); - - for(int i = 0; i < src1.num_elements(); ++i) - { - dst[i] = src1[i] & src2[i]; - } - - return dst; -} - -template SimpleTensor bitwise_and(const SimpleTensor &src1, const SimpleTensor &src2); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/BitwiseAnd.h b/tests/validation_new/CPP/BitwiseAnd.h deleted file mode 100644 index eba2fd695f..0000000000 --- a/tests/validation_new/CPP/BitwiseAnd.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_BITWISE_AND_H__ -#define __ARM_COMPUTE_TEST_BITWISE_AND_H__ - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor bitwise_and(const SimpleTensor &src1, const SimpleTensor &src2); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_BITWISE_AND_H__ */ diff --git a/tests/validation_new/CPP/BitwiseNot.cpp b/tests/validation_new/CPP/BitwiseNot.cpp deleted file mode 100644 index 5a6a13b56c..0000000000 --- a/tests/validation_new/CPP/BitwiseNot.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "BitwiseNot.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor bitwise_not(const SimpleTensor &src) -{ - SimpleTensor dst(src.shape(), src.data_type()); - - for(int i = 0; i < src.num_elements(); ++i) - { - dst[i] = ~src[i]; - } - - return dst; -} - -template SimpleTensor bitwise_not(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/BitwiseNot.h b/tests/validation_new/CPP/BitwiseNot.h deleted file mode 100644 index b4206f9388..0000000000 --- a/tests/validation_new/CPP/BitwiseNot.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_BITWISE_NOT_H__ -#define __ARM_COMPUTE_TEST_BITWISE_NOT_H__ - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor bitwise_not(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_BITWISE_NOT_H__ */ diff --git a/tests/validation_new/CPP/BitwiseOr.cpp b/tests/validation_new/CPP/BitwiseOr.cpp deleted file mode 100644 index fc258d54f1..0000000000 --- a/tests/validation_new/CPP/BitwiseOr.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "BitwiseOr.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor bitwise_or(const SimpleTensor &src1, const SimpleTensor &src2) -{ - SimpleTensor dst(src1.shape(), src1.data_type()); - - for(int i = 0; i < src1.num_elements(); ++i) - { - dst[i] = src1[i] | src2[i]; - } - - return dst; -} - -template SimpleTensor bitwise_or(const SimpleTensor &src1, const SimpleTensor &src2); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/BitwiseOr.h b/tests/validation_new/CPP/BitwiseOr.h deleted file mode 100644 index 39158cb411..0000000000 --- a/tests/validation_new/CPP/BitwiseOr.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_BITWISE_OR_H__ -#define __ARM_COMPUTE_TEST_BITWISE_OR_H__ - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor bitwise_or(const SimpleTensor &src1, const SimpleTensor &src2); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_BITWISE_OR_H__ */ diff --git a/tests/validation_new/CPP/BitwiseXor.cpp b/tests/validation_new/CPP/BitwiseXor.cpp deleted file mode 100644 index b8d275d8b5..0000000000 --- a/tests/validation_new/CPP/BitwiseXor.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "BitwiseXor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor bitwise_xor(const SimpleTensor &src1, const SimpleTensor &src2) -{ - SimpleTensor dst(src1.shape(), src1.data_type()); - - for(int i = 0; i < src1.num_elements(); ++i) - { - dst[i] = src1[i] ^ src2[i]; - } - - return dst; -} - -template SimpleTensor bitwise_xor(const SimpleTensor &src1, const SimpleTensor &src2); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/BitwiseXor.h b/tests/validation_new/CPP/BitwiseXor.h deleted file mode 100644 index 3e7721e843..0000000000 --- a/tests/validation_new/CPP/BitwiseXor.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_BITWISE_XOR_H__ -#define __ARM_COMPUTE_TEST_BITWISE_XOR_H__ - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor bitwise_xor(const SimpleTensor &src1, const SimpleTensor &src2); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_BITWISE_XOR_H__ */ diff --git a/tests/validation_new/CPP/ConvolutionLayer.cpp b/tests/validation_new/CPP/ConvolutionLayer.cpp deleted file mode 100644 index a24621a3f2..0000000000 --- a/tests/validation_new/CPP/ConvolutionLayer.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "ConvolutionLayer.h" - -#include "tests/validation_new/FixedPoint.h" -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -inline bool is_valid_pixel(int i, int min, int max) -{ - return (i >= min && i < max); -} - -// 3D convolution for floating point type -template ::value, int>::type = 0> -void convolution3d(const T *in, const T *weights, const T *bias, T *out, int xi, int yi, int width_in, int height_in, int depth_in, int width_weights, int height_weights, int fixed_point_position) -{ - ARM_COMPUTE_UNUSED(fixed_point_position); - - const int half_width_weights = width_weights / 2; - const int half_height_weights = height_weights / 2; - - // Reset accumulator - T acc(0); - - // Compute a 2D convolution for each IFM and accumulate the result - for(int ifm = 0; ifm < depth_in; ++ifm) - { - // Compute the offset for the input slice - const int offset_slice_in = xi + yi * width_in + ifm * width_in * height_in; - - // Compute 2D convolution - for(int yk = -half_height_weights; yk <= half_height_weights; ++yk) - { - for(int xk = -half_width_weights; xk <= half_width_weights; ++xk) - { - // Check if the pixel is out-of-bound - if(is_valid_pixel(xi + xk, 0, width_in) && is_valid_pixel(yi + yk, 0, height_in)) - { - const int idx = xk + half_width_weights; - const int idy = yk + half_height_weights; - - const T i_value = in[offset_slice_in + xk + yk * width_in]; - const T w_value = weights[idx + idy * width_weights + ifm * width_weights * height_weights]; - - acc += i_value * w_value; - } - } - } - } - - // Accumulate the bias and store the result - *out = acc + (*bias); -} - -// 3D convolution for fixed point type -template ::value, int>::type = 0> -void convolution3d(const T *in, const T *weights, const T *bias, T *out, int xi, int yi, int width_in, int height_in, int depth_in, int width_weights, int height_weights, - int fixed_point_position) -{ - const int half_width_weights = width_weights / 2; - const int half_height_weights = height_weights / 2; - - using namespace fixed_point_arithmetic; - using promoted_type = fixed_point_arithmetic::traits::promote_t; - - // Reset accumulator - fixed_point acc(0, fixed_point_position); - - // Compute a 2D convolution for each IFM and accumulate the result - for(int ifm = 0; ifm < depth_in; ++ifm) - { - // Compute the offset for the input slice - const int offset_slice_in = xi + yi * width_in + ifm * width_in * height_in; - - // Compute 2D convolution - for(int yk = -half_height_weights; yk <= half_height_weights; ++yk) - { - for(int xk = -half_width_weights; xk <= half_width_weights; ++xk) - { - // Check if the pixel is out-of-bound - if(is_valid_pixel(xi + xk, 0, width_in) && is_valid_pixel(yi + yk, 0, height_in)) - { - const int idx = xk + half_width_weights; - const int idy = yk + half_height_weights; - - const fixed_point i_value(in[offset_slice_in + xk + yk * width_in], fixed_point_position, true); - const fixed_point w_value(weights[idx + idy * width_weights + ifm * width_weights * height_weights], fixed_point_position, true); - const fixed_point iw = i_value * w_value; - acc = iw + acc; - } - } - } - } - - // Get the bias - const fixed_point b(*bias, fixed_point_position, true); - - // Accumulate the bias and covert back - acc = acc + b; - fixed_point res(acc); - *out = res.raw(); -} -} // namespace - -template -SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, const PadStrideInfo &info) -{ - // Create reference - SimpleTensor dst{ output_shape, src.data_type(), 1, src.fixed_point_position() }; - - // Compute reference - const int width_in = src.shape().x(); - const int height_in = src.shape().y(); - const int depth_in = src.shape().z(); - const int width_out = dst.shape().x(); - const int height_out = dst.shape().y(); - const int depth_out = dst.shape().z(); - const int width_weights = weights.shape().x(); - const int height_weights = weights.shape().y(); - const int depth_weights = weights.shape().z(); - const int pad_xi = std::min(static_cast(info.pad().first), width_weights / 2); - const int pad_yi = std::min(static_cast(info.pad().second), height_weights / 2); - const int start_xi = width_weights / 2 - pad_xi; - const int start_yi = height_weights / 2 - pad_yi; - const int end_xi = width_in - start_xi; - const int end_yi = height_in - start_yi; - const int stride_xi = info.stride().first; - const int stride_yi = info.stride().second; - const int num_batches = src.shape().total_size() / (width_in * height_in * depth_in); - - for(int r = 0; r < num_batches; ++r) - { - for(int yi = start_yi; yi < end_yi; yi += stride_yi) - { - for(int xi = start_xi; xi < end_xi; xi += stride_xi) - { - for(int ofm = 0; ofm < depth_out; ++ofm) - { - // Compute input and output offsets - const int offset_in = r * width_in * height_in * depth_in; - const int xo = (xi - start_xi) / stride_xi; - const int yo = (yi - start_yi) / stride_yi; - const int offset_out = xo + yo * width_out + ofm * width_out * height_out + r * width_out * height_out * depth_out; - - // Compute 3D convolution - convolution3d(src.data() + offset_in, - weights.data() + ofm * width_weights * height_weights * depth_weights, - bias.data() + ofm, - dst.data() + offset_out, - xi, yi, - width_in, height_in, depth_in, - width_weights, height_weights, - src.fixed_point_position()); - } - } - } - } - - return dst; -} - -template SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, - const PadStrideInfo &info); -template SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, - const TensorShape &output_shape, const PadStrideInfo &info); -template SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, - const PadStrideInfo &info); -template SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, - const PadStrideInfo &info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/ConvolutionLayer.h b/tests/validation_new/CPP/ConvolutionLayer.h deleted file mode 100644 index a7c9e086a4..0000000000 --- a/tests/validation_new/CPP/ConvolutionLayer.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_CONVOLUTION_LAYER_H__ -#define __ARM_COMPUTE_TEST_CONVOLUTION_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, const PadStrideInfo &info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_CONVOLUTION_LAYER_H__ */ diff --git a/tests/validation_new/CPP/DepthConcatenateLayer.cpp b/tests/validation_new/CPP/DepthConcatenateLayer.cpp deleted file mode 100644 index c54c6c8568..0000000000 --- a/tests/validation_new/CPP/DepthConcatenateLayer.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "DepthConcatenateLayer.h" - -#include "tests/validation_new/FixedPoint.h" -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor depthconcatenate_layer(const std::vector> &srcs) -{ - // Create reference - std::vector shapes; - - for(const auto &src : srcs) - { - shapes.emplace_back(src.shape()); - } - - DataType dst_type = srcs.empty() ? DataType::UNKNOWN : srcs[0].data_type(); - TensorShape dst_shape = calculate_depth_concatenate_shape(shapes); - SimpleTensor dst(dst_shape, dst_type); - - // Compute reference - int depth_offset = 0; - const int width_out = dst.shape().x(); - const int height_out = dst.shape().y(); - const int depth_out = dst.shape().z(); - const int out_stride_z = width_out * height_out; - const int batches = dst.shape().total_size_upper(3); - - // Set output tensor to 0 - std::fill_n(dst.data(), dst.num_elements(), 0); - - for(const auto &src : srcs) - { - ARM_COMPUTE_ERROR_ON(depth_offset >= depth_out); - ARM_COMPUTE_ERROR_ON(batches != static_cast(src.shape().total_size_upper(3))); - - const int width = src.shape().x(); - const int height = src.shape().y(); - const int depth = src.shape().z(); - const int x_diff = (width_out - width) / 2; - const int y_diff = (height_out - height) / 2; - - const T *src_ptr = src.data(); - - for(int b = 0; b < batches; ++b) - { - const size_t offset_to_first_element = b * out_stride_z * depth_out + depth_offset * out_stride_z + y_diff * width_out + x_diff; - - for(int d = 0; d < depth; ++d) - { - for(int r = 0; r < height; ++r) - { - std::copy(src_ptr, src_ptr + width, dst.data() + offset_to_first_element + d * out_stride_z + r * width_out); - src_ptr += width; - } - } - } - - depth_offset += depth; - } - - return dst; -} - -template SimpleTensor depthconcatenate_layer(const std::vector> &srcs); -template SimpleTensor depthconcatenate_layer(const std::vector> &srcs); -template SimpleTensor depthconcatenate_layer(const std::vector> &srcs); -template SimpleTensor depthconcatenate_layer(const std::vector> &srcs); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/DepthConcatenateLayer.h b/tests/validation_new/CPP/DepthConcatenateLayer.h deleted file mode 100644 index 3c486a8015..0000000000 --- a/tests/validation_new/CPP/DepthConcatenateLayer.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_H__ -#define __ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_H__ - -#include "tests/SimpleTensor.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor depthconcatenate_layer(const std::vector> &srcs); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_H__ */ diff --git a/tests/validation_new/CPP/DepthwiseConvolution.cpp b/tests/validation_new/CPP/DepthwiseConvolution.cpp deleted file mode 100644 index 8c5cec596e..0000000000 --- a/tests/validation_new/CPP/DepthwiseConvolution.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "DepthwiseConvolution.h" - -#include "ConvolutionLayer.h" -#include "Utils.h" - -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -/** Perform a depthwise convolution - * - * - Three dimensions tensors - * - Third dimention is number of channels - * - Depths of input tensor and filter are equals - * - Padding, stride and output shape "match" - * - */ -template -SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const TensorShape &dst_shape, const PadStrideInfo &conv_info) -{ - // Create reference - SimpleTensor dst{ dst_shape, src.data_type(), 1, src.fixed_point_position() }; - - // Compute reference - const size_t filter_width = weights.shape().x(); - const size_t filter_height = weights.shape().y(); - const size_t filter_plane = filter_width * filter_height; - const size_t input_width = src.shape().x(); - const size_t input_height = src.shape().y(); - const size_t input_depth = src.shape().z(); - - const size_t filter_half_size = filter_width / 2; - const size_t pad_x = std::min(filter_half_size, static_cast(conv_info.pad().first)); - const size_t pad_y = std::min(filter_half_size, static_cast(conv_info.pad().second)); - const size_t minimum_x = -pad_x + filter_half_size; - const size_t minimum_y = -pad_y + filter_half_size; - - int out_pos = 0; - for(size_t z = 0; z < input_depth; ++z) - { - for(size_t y = minimum_y; y < input_height + pad_y - filter_half_size; y += conv_info.stride().second) - { - for(size_t x = minimum_x; x < input_width + pad_x - filter_half_size; x += conv_info.stride().first) - { - Coordinates coords(static_cast(x), static_cast(y), static_cast(z)); - size_t filter_offset = filter_plane * z; - - T val = 0; - for(int j = y - filter_half_size; j <= static_cast(y + filter_half_size); ++j) - { - for(int i = x - filter_half_size; i <= static_cast(x + filter_half_size); ++i) - { - coords.set(0, i); - coords.set(1, j); - val += *(weights.data() + filter_offset) * tensor_elem_at(src, coords, BorderMode::CONSTANT, 0.f); - ++filter_offset; - } - } - coords.set(0, x); - coords.set(1, y); - dst[out_pos++] = saturate_cast(val); - } - } - } - - return dst; -} - -template SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const TensorShape &dst_shape, const PadStrideInfo &conv_info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/DepthwiseConvolution.h b/tests/validation_new/CPP/DepthwiseConvolution.h deleted file mode 100644 index 4a92620880..0000000000 --- a/tests/validation_new/CPP/DepthwiseConvolution.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_H__ -#define __ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const TensorShape &dst_shape, const PadStrideInfo &conv_info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_H__ */ diff --git a/tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.cpp b/tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.cpp deleted file mode 100644 index eba0a19189..0000000000 --- a/tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "DepthwiseConvolution.h" - -#include "DepthwiseSeparableConvolutionLayer.h" - -#include "ConvolutionLayer.h" -#include "Utils.h" - -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -// Depthwise separable convolution layer -template -SimpleTensor depthwise_separable_convolution_layer(const SimpleTensor &src, const SimpleTensor &depthwise_weights, const TensorShape &depthwise_out_shape, - const SimpleTensor &pointwise_weights, - const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info) -{ - // Compute reference - SimpleTensor depthwise_out = depthwise_convolution(src, depthwise_weights, depthwise_out_shape, depthwise_conv_info); - SimpleTensor dst = convolution_layer(depthwise_out, pointwise_weights, biases, dst_shape, pointwise_conv_info); - - return dst; -} - -template SimpleTensor depthwise_separable_convolution_layer(const SimpleTensor &in, const SimpleTensor &depthwise_weights, const TensorShape &depthwise_out_shape, - const SimpleTensor &pointwise_weights, const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.h b/tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.h deleted file mode 100644 index 0c9f118b84..0000000000 --- a/tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_H__ -#define __ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor depthwise_separable_convolution_layer(const SimpleTensor &src, const SimpleTensor &depthwise_weights, const TensorShape &depthwise_out_shape, - const SimpleTensor &pointwise_weights, - const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_H__ */ diff --git a/tests/validation_new/CPP/DequantizationLayer.cpp b/tests/validation_new/CPP/DequantizationLayer.cpp deleted file mode 100644 index 1c7ec25255..0000000000 --- a/tests/validation_new/CPP/DequantizationLayer.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "DequantizationLayer.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type> -SimpleTensor dequantization_layer(const SimpleTensor &src, float min, float max) -{ - // Create reference - SimpleTensor dst{ src.shape(), DataType::F32 }; - - const float range = max - min; - const float scaling = range / 255.0f; - - for(int i = 0; i < src.num_elements(); ++i) - { - dst[i] = (static_cast(src[i]) * scaling) + min; - } - - return dst; -} - -template SimpleTensor dequantization_layer(const SimpleTensor &src, float min, float max); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/DequantizationLayer.h b/tests/validation_new/CPP/DequantizationLayer.h deleted file mode 100644 index 33592b89b8..0000000000 --- a/tests/validation_new/CPP/DequantizationLayer.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_H__ -#define __ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type = 0> -SimpleTensor dequantization_layer(const SimpleTensor &src, float min, float max); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_H__ */ diff --git a/tests/validation_new/CPP/Floor.cpp b/tests/validation_new/CPP/Floor.cpp deleted file mode 100644 index aed4fecd01..0000000000 --- a/tests/validation_new/CPP/Floor.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Floor.h" - -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor floor_layer(const SimpleTensor &src) -{ - // Create reference - SimpleTensor dst{ src.shape(), src.data_type() }; - - // Compute reference - for(int i = 0; i < src.num_elements(); ++i) - { - dst[i] = std::floor(src[i]); - } - - return dst; -} - -template SimpleTensor floor_layer(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/Floor.h b/tests/validation_new/CPP/Floor.h deleted file mode 100644 index 30b8118622..0000000000 --- a/tests/validation_new/CPP/Floor.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_FLOOR_H__ -#define __ARM_COMPUTE_TEST_FLOOR_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor floor_layer(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_FLOOR_H__ */ diff --git a/tests/validation_new/CPP/FullyConnectedLayer.cpp b/tests/validation_new/CPP/FullyConnectedLayer.cpp deleted file mode 100644 index 7852dab27b..0000000000 --- a/tests/validation_new/CPP/FullyConnectedLayer.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "FullyConnectedLayer.h" - -#include "tests/validation_new/FixedPoint.h" -#include "tests/validation_new/half.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -// Vector matrix multiply for floating point -template ::value, int>::type = 0> -void vector_matrix_multiply(const T *src, const T *weights, const T *bias, T *dst, int cols_weights, int rows_weights, uint8_t fixed_point_position) -{ - ARM_COMPUTE_UNUSED(fixed_point_position); - - for(int y = 0; y < rows_weights; ++y) - { - dst[y] = std::inner_product(src, src + cols_weights, weights, static_cast(0)) + bias[y]; - weights += cols_weights; - } -} - -// Vector matrix multiply for fixed point type -template ::value, int>::type = 0> -void vector_matrix_multiply(const T *src, const T *weights, const T *bias, T *dst, int cols_weights, int rows_weights, uint8_t fixed_point_position) -{ - using namespace fixed_point_arithmetic; - using promoted_type = fixed_point_arithmetic::traits::promote_t; - - for(int y = 0; y < rows_weights; ++y) - { - // Reset accumulator - fixed_point acc(0, fixed_point_position); - - for(int x = 0; x < cols_weights; ++x) - { - const fixed_point i_value(src[x], fixed_point_position, true); - const fixed_point w_value(weights[x], fixed_point_position, true); - acc = acc + i_value * w_value; - } - - // Get the bias - const fixed_point b(bias[y], fixed_point_position, true); - - // Convert back and accumulate the bias - fixed_point res(acc); - res = res + b; - - // Store the result - dst[y] = res.raw(); - - weights += cols_weights; - } -} -} // namespace - -template -SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &dst_shape) -{ - // Create reference - SimpleTensor dst{ TensorShape{ dst_shape }, src.data_type(), 1, src.fixed_point_position() }; - - // Sanity checks - const int num_batch_dimensions = std::max(0, static_cast(dst_shape.num_dimensions()) - 1); - const int num_input_dimensions = src.shape().num_dimensions() - num_batch_dimensions; - const unsigned int linear_input_size = src.shape().total_size_lower(num_input_dimensions); - - ARM_COMPUTE_UNUSED(num_batch_dimensions); - ARM_COMPUTE_UNUSED(num_input_dimensions); - ARM_COMPUTE_UNUSED(linear_input_size); - ARM_COMPUTE_ERROR_ON(weights.shape().x() != linear_input_size); - ARM_COMPUTE_ERROR_ON(weights.shape().y() != bias.shape().x()); - ARM_COMPUTE_ERROR_ON(weights.shape().y() != dst.shape().x()); - - // Compute reference - const int cols_weights = weights.shape().x(); - const int rows_weights = weights.shape().y(); - const int num_batches = dst_shape.total_size_upper(1); - - for(int k = 0; k < num_batches; ++k) - { - vector_matrix_multiply(src.data() + k * cols_weights, - weights.data(), - bias.data(), - dst.data() + k * rows_weights, - cols_weights, - rows_weights, - src.fixed_point_position()); - } - - return dst; -} - -template SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &dst_shape); -template SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, - const TensorShape &dst_shape); -template SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &dst_shape); -template SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &dst_shape); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/FullyConnectedLayer.h b/tests/validation_new/CPP/FullyConnectedLayer.h deleted file mode 100644 index 5d62179f57..0000000000 --- a/tests/validation_new/CPP/FullyConnectedLayer.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_H__ -#define __ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &dst_shape); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_H__ */ diff --git a/tests/validation_new/CPP/GEMM.cpp b/tests/validation_new/CPP/GEMM.cpp deleted file mode 100644 index 424633f8e7..0000000000 --- a/tests/validation_new/CPP/GEMM.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "GEMM.h" - -#include "tests/validation_new/FixedPoint.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type> -SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta) -{ - // Create reference - SimpleTensor dst{ c.shape(), c.data_type(), 1, c.fixed_point_position() }; - - // Compute reference - const int M = dst.shape().y(); - const int N = dst.shape().x(); - const int K = a.shape().x(); - - for(int row = 0; row < M; ++row) - { - for(int col = 0; col < N; ++col) - { - T acc(0); - - for(int k = 0; k < K; ++k) - { - acc += a[row * K + k] * b[k * N + col]; - } - - // Finalize the result: alpha * A * B + beta * C - dst[col + row * N] = alpha * acc + beta * c[col + row * N]; - } - } - - return dst; -} - -template ::value, int>::type> -SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta) -{ - using namespace fixed_point_arithmetic; - - // Create reference - SimpleTensor dst{ c.shape(), c.data_type(), 1, c.fixed_point_position() }; - - // Compute reference - using promoted_type = fixed_point_arithmetic::traits::promote_t; - - const int M = dst.shape().y(); - const int N = dst.shape().x(); - const int K = a.shape().x(); - const int fixed_point_position = a.fixed_point_position(); - - const fixed_point alpha_q(alpha, fixed_point_position); - const fixed_point beta_q(beta, fixed_point_position); - - for(int row = 0; row < M; ++row) - { - for(int col = 0; col < N; ++col) - { - fixed_point acc_q(0, fixed_point_position); - - for(int k = 0; k < K; ++k) - { - const fixed_point a0_q(a[row * K + k], fixed_point_position, true); - const fixed_point b0_q(b[k * N + col], fixed_point_position, true); - - acc_q = acc_q + (a0_q * b0_q); - } - - // Finalize the result: alpha * A * B + beta * C - const fixed_point c0_q(c[col + row * N], fixed_point_position, true); - - fixed_point res_q(acc_q); - res_q = alpha_q * res_q; - res_q = res_q + (beta_q * c0_q); - - // Store the result - dst[col + row * N] = res_q.raw(); - } - } - - return dst; -} - -template SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); -template SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); -template SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); -template SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/GEMM.h b/tests/validation_new/CPP/GEMM.h deleted file mode 100644 index 7fea2a9862..0000000000 --- a/tests/validation_new/CPP/GEMM.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_GEMM_H__ -#define __ARM_COMPUTE_TEST_GEMM_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type = 0> -SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); - -template ::value, int>::type = 0> -SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_GEMM_H__ */ diff --git a/tests/validation_new/CPP/L2Normalize.cpp b/tests/validation_new/CPP/L2Normalize.cpp deleted file mode 100644 index f423702819..0000000000 --- a/tests/validation_new/CPP/L2Normalize.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "L2Normalize.h" -#include "ReductionOperation.h" - -#include "tests/validation_new/Helpers.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -TensorShape get_output_shape(TensorShape shape, unsigned int axis) -{ - TensorShape output_shape(shape); - output_shape.set(axis, 1); - return output_shape; -} -} // namespace - -template -SimpleTensor l2_normalize(const SimpleTensor &src, unsigned int axis, float epsilon) -{ - // Create reference - SimpleTensor dst{ src.shape(), src.data_type() }; - - // Reduce across given axis - SimpleTensor sum = reduction_operation(src, get_output_shape(src.shape(), axis), axis, ReductionOperation::SUM_SQUARE); - - // Compute reference - const int elems = src.shape()[axis]; - const int upper_dims = src.shape().total_size_upper(axis + 1); - - for(int du = 0; du < upper_dims; ++du) - { - if(axis == 0) - { - const T *src_row_ptr = src.data() + du * elems; - T *dst_row_ptr = dst.data() + du * elems; - const T normalization_value = std::sqrt(std::max(sum[du], epsilon)); - std::transform(src_row_ptr, src_row_ptr + elems, dst_row_ptr, [normalization_value](T val) - { - return val / normalization_value; - }); - } - else - { - ARM_COMPUTE_ERROR("Unsupported normalization axis"); - } - } - - return dst; -} - -template SimpleTensor l2_normalize(const SimpleTensor &src, unsigned int axis, float epsilon); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/L2Normalize.h b/tests/validation_new/CPP/L2Normalize.h deleted file mode 100644 index da36a73bba..0000000000 --- a/tests/validation_new/CPP/L2Normalize.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_L2NORMALIZE_H__ -#define __ARM_COMPUTE_TEST_L2NORMALIZE_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor l2_normalize(const SimpleTensor &src, unsigned int axis, float epsilon); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_L2NORMALIZE_H__ */ diff --git a/tests/validation_new/CPP/MeanStdDev.cpp b/tests/validation_new/CPP/MeanStdDev.cpp deleted file mode 100644 index 4a39b13d56..0000000000 --- a/tests/validation_new/CPP/MeanStdDev.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "MeanStdDev.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::pair mean_and_standard_deviation(const SimpleTensor &in) -{ - const int num_elements = in.num_elements(); - - // Calculate mean - float mean = std::accumulate(in.data(), in.data() + num_elements, 0.f) / num_elements; - - // Calculate standard deviation - float std_dev = std::accumulate(in.data(), in.data() + num_elements, 0.f, [&mean](float a, float b) - { - return a + (mean - b) * (mean - b); - }); - - std_dev = std::sqrt(std_dev / num_elements); - - return std::make_pair(mean, std_dev); -} - -template std::pair mean_and_standard_deviation(const SimpleTensor &in); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/MeanStdDev.h b/tests/validation_new/CPP/MeanStdDev.h deleted file mode 100644 index 6b89ae0656..0000000000 --- a/tests/validation_new/CPP/MeanStdDev.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_STD_MEAN_DEV_H__ -#define __ARM_COMPUTE_TEST_STD_MEAN_DEV_H__ - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::pair mean_and_standard_deviation(const SimpleTensor &in); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_STD_MEAN_DEV_H__ */ diff --git a/tests/validation_new/CPP/NormalizationLayer.cpp b/tests/validation_new/CPP/NormalizationLayer.cpp deleted file mode 100644 index a8818d8b5c..0000000000 --- a/tests/validation_new/CPP/NormalizationLayer.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "NormalizationLayer.h" - -#include "tests/validation_new/FixedPoint.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type> -SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info) -{ - // Create reference - SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; - - // Compute reference - const uint32_t norm_size = info.norm_size(); - NormType type = info.type(); - float beta = info.beta(); - uint32_t kappa = info.kappa(); - - const int cols = src.shape()[0]; - const int rows = src.shape()[1]; - const int depth = src.shape()[2]; - int upper_dims = src.shape().total_size() / (cols * rows); - - float coeff = info.scale_coeff(); - int radius_cols = norm_size / 2; - - // IN_MAP_1D and CROSS_MAP normalize over a single axis only - int radius_rows = (NormType::IN_MAP_2D == type) ? norm_size / 2 : 0; - - if(type == NormType::CROSS_MAP) - { - // Remove also depth from upper dimensions since it is the dimension we - // want to use for normalization - upper_dims /= depth; - - for(int r = 0; r < upper_dims; ++r) - { - for(int i = 0; i < rows; ++i) - { - for(int k = 0; k < cols; ++k) - { - for(int l = 0; l < depth; ++l) - { - float accumulated_scale = 0.f; - - for(int j = -radius_cols; j <= radius_cols; ++j) - { - const int z = l + j; - - if(z >= 0 && z < depth) - { - const T value = src[k + i * cols + z * rows * cols + r * cols * rows * depth]; - accumulated_scale += value * value; - } - } - - dst[k + i * cols + l * rows * cols + r * cols * rows * depth] = kappa + accumulated_scale * coeff; - } - } - } - } - } - else - { - for(int r = 0; r < upper_dims; ++r) - { - for(int i = 0; i < rows; ++i) - { - for(int k = 0; k < cols; ++k) - { - float accumulated_scale = 0.f; - - for(int j = -radius_rows; j <= radius_rows; ++j) - { - const int y = i + j; - for(int l = -radius_cols; l <= radius_cols; ++l) - { - const int x = k + l; - - if((x >= 0 && y >= 0) && (x < cols && y < rows)) - { - const T value = src[x + y * cols + r * cols * rows]; - accumulated_scale += value * value; - } - } - } - - dst[k + i * cols + r * cols * rows] = kappa + accumulated_scale * coeff; - } - } - } - } - - if(beta == 1.f) - { - for(int i = 0; i < dst.num_elements(); ++i) - { - dst[i] = src[i] / dst[i]; - } - } - else if(beta == 0.5f) - { - for(int i = 0; i < dst.num_elements(); ++i) - { - dst[i] = src[i] / std::sqrt(dst[i]); - } - } - else - { - for(int i = 0; i < dst.num_elements(); ++i) - { - dst[i] = src[i] * std::exp(std::log(dst[i]) * -beta); - } - } - - return dst; -} - -template ::value, int>::type> -SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info) -{ - using namespace fixed_point_arithmetic; - - // Create reference - SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; - - // Compute reference - const int fixed_point_position = src.fixed_point_position(); - - const uint32_t norm_size = info.norm_size(); - NormType type = info.type(); - fixed_point beta(info.beta(), fixed_point_position); - fixed_point kappa(info.kappa(), fixed_point_position); - - const int cols = src.shape()[0]; - const int rows = src.shape()[1]; - const int depth = src.shape()[2]; - int upper_dims = src.shape().total_size() / (cols * rows); - - fixed_point coeff(info.scale_coeff(), fixed_point_position); - int radius_cols = norm_size / 2; - - // IN_MAP_1D and CROSS_MAP normalize over a single axis only - int radius_rows = (NormType::IN_MAP_2D == type) ? norm_size / 2 : 0; - - if(type == NormType::CROSS_MAP) - { - // Remove also depth from upper dimensions since it is the dimension we - // want to use for normalization - upper_dims /= depth; - - for(int r = 0; r < upper_dims; ++r) - { - for(int i = 0; i < rows; ++i) - { - for(int k = 0; k < cols; ++k) - { - for(int l = 0; l < depth; ++l) - { - fixed_point accumulated_scale(0.f, fixed_point_position); - - for(int j = -radius_cols; j <= radius_cols; ++j) - { - const int z = l + j; - - if(z >= 0 && z < depth) - { - const T value = src[k + i * cols + z * rows * cols + r * cols * rows * depth]; - const fixed_point fp_value(value, fixed_point_position, true); - accumulated_scale = add(accumulated_scale, mul(fp_value, fp_value)); - } - } - - accumulated_scale = add(kappa, mul(accumulated_scale, coeff)); - dst[k + i * cols + l * rows * cols + r * cols * rows * depth] = accumulated_scale.raw(); - } - } - } - } - } - else - { - for(int r = 0; r < upper_dims; ++r) - { - for(int i = 0; i < rows; ++i) - { - for(int k = 0; k < cols; ++k) - { - fixed_point accumulated_scale(0.f, fixed_point_position); - - for(int j = -radius_rows; j <= radius_rows; ++j) - { - const int y = i + j; - - for(int l = -radius_cols; l <= radius_cols; ++l) - { - const int x = k + l; - - if((x >= 0 && y >= 0) && (x < cols && y < rows)) - { - const T value = src[x + y * cols + r * cols * rows]; - const fixed_point fp_value(value, fixed_point_position, true); - accumulated_scale = add(accumulated_scale, mul(fp_value, fp_value)); - } - } - } - - accumulated_scale = add(kappa, mul(accumulated_scale, coeff)); - dst[k + i * cols + r * cols * rows] = accumulated_scale.raw(); - } - } - } - } - - if(info.beta() == 1.f) - { - for(int i = 0; i < dst.num_elements(); ++i) - { - fixed_point res = div(fixed_point(src[i], fixed_point_position, true), fixed_point(dst[i], fixed_point_position, true)); - dst[i] = res.raw(); - } - } - else - { - const fixed_point beta(info.beta(), fixed_point_position); - - for(int i = 0; i < dst.num_elements(); ++i) - { - fixed_point res = pow(fixed_point(dst[i], fixed_point_position, true), beta); - res = div(fixed_point(src[i], fixed_point_position, true), res); - dst[i] = res.raw(); - } - } - - return dst; -} - -template SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); -template SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); -template SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); -template SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/NormalizationLayer.h b/tests/validation_new/CPP/NormalizationLayer.h deleted file mode 100644 index bdd87545ca..0000000000 --- a/tests/validation_new/CPP/NormalizationLayer.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_NORMALIZATION_LAYER_H__ -#define __ARM_COMPUTE_TEST_NORMALIZATION_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type = 0> -SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); - -template ::value, int>::type = 0> -SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_NORMALIZATION_LAYER_H__ */ diff --git a/tests/validation_new/CPP/PoolingLayer.cpp b/tests/validation_new/CPP/PoolingLayer.cpp deleted file mode 100644 index 5464885dc4..0000000000 --- a/tests/validation_new/CPP/PoolingLayer.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "PoolingLayer.h" - -#include "tests/validation_new/FixedPoint.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -TensorShape calculate_output_shape(TensorShape shape, PoolingLayerInfo info) -{ - TensorShape dst_shape = shape; - const std::pair scaled_dims = arm_compute::scaled_dimensions(shape.x(), - shape.y(), - info.pool_size(), - info.pool_size(), - info.pad_stride_info()); - dst_shape.set(0, scaled_dims.first); - dst_shape.set(1, scaled_dims.second); - - return dst_shape; -} -} // namespace - -template ::value, int>::type> -SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info) -{ - const int pool_size = info.pool_size(); - PoolingType type = info.pool_type(); - int pool_stride_x = info.pad_stride_info().stride().first; - int pool_stride_y = info.pad_stride_info().stride().second; - int pad_x = info.pad_stride_info().pad().first; - int pad_y = info.pad_stride_info().pad().second; - - const auto w_src = static_cast(src.shape()[0]); - const auto h_src = static_cast(src.shape()[1]); - const int upper_dims = src.shape().total_size() / (w_src * h_src); - - // Create reference - SimpleTensor dst{ calculate_output_shape(src.shape(), info), src.data_type(), 1, src.fixed_point_position() }; - - const auto w_dst = static_cast(dst.shape()[0]); - const auto h_dst = static_cast(dst.shape()[1]); - - if(type == PoolingType::MAX) - { - for(int r = 0; r < upper_dims; ++r) - { - for(int h = 0; h < h_dst; ++h) - { - for(int w = 0; w < w_dst; ++w) - { - int wstart = w * pool_stride_x - pad_x; - int hstart = h * pool_stride_y - pad_y; - int wend = std::min(wstart + pool_size, w_src); - int hend = std::min(hstart + pool_size, h_src); - wstart = std::max(wstart, 0); - hstart = std::max(hstart, 0); - - T max_val = std::numeric_limits::lowest(); - for(int y = hstart; y < hend; ++y) - { - for(int x = wstart; x < wend; ++x) - { - const T val = src[r * h_src * w_src + y * w_src + x]; - if(val > max_val) - { - max_val = val; - } - } - } - - dst[r * h_dst * w_dst + h * w_dst + w] = max_val; - } - } - } - } - else // Average pooling - { - for(int r = 0; r < upper_dims; ++r) - { - for(int h = 0; h < h_dst; ++h) - { - for(int w = 0; w < w_dst; ++w) - { - T avg_val(0); - int wstart = w * pool_stride_x - pad_x; - int hstart = h * pool_stride_y - pad_y; - int wend = std::min(wstart + pool_size, w_src + pad_x); - int hend = std::min(hstart + pool_size, h_src + pad_y); - int pool = (hend - hstart) * (wend - wstart); - wstart = std::max(wstart, 0); - hstart = std::max(hstart, 0); - wend = std::min(wend, w_src); - hend = std::min(hend, h_src); - - for(int y = hstart; y < hend; ++y) - { - for(int x = wstart; x < wend; ++x) - { - avg_val += src[r * h_src * w_src + y * w_src + x]; - } - } - dst[r * h_dst * w_dst + h * w_dst + w] = avg_val / pool; - } - } - } - } - - return dst; -} - -template ::value, int>::type> -SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info) -{ - const int pool_size = info.pool_size(); - PoolingType type = info.pool_type(); - int pool_stride_x = info.pad_stride_info().stride().first; - int pool_stride_y = info.pad_stride_info().stride().second; - int pad_x = info.pad_stride_info().pad().first; - int pad_y = info.pad_stride_info().pad().second; - - const auto w_src = static_cast(src.shape()[0]); - const auto h_src = static_cast(src.shape()[1]); - const int upper_dims = src.shape().total_size() / (w_src * h_src); - - // Create reference - SimpleTensor dst{ calculate_output_shape(src.shape(), info), src.data_type(), 1, src.fixed_point_position() }; - - const auto w_dst = static_cast(dst.shape()[0]); - const auto h_dst = static_cast(dst.shape()[1]); - - if(type == PoolingType::MAX) - { - for(int r = 0; r < upper_dims; ++r) - { - for(int h = 0; h < h_dst; ++h) - { - for(int w = 0; w < w_dst; ++w) - { - int wstart = w * pool_stride_x - pad_x; - int hstart = h * pool_stride_y - pad_y; - int wend = std::min(wstart + pool_size, w_src); - int hend = std::min(hstart + pool_size, h_src); - wstart = std::max(wstart, 0); - hstart = std::max(hstart, 0); - - T max_val = std::numeric_limits::lowest(); - for(int y = hstart; y < hend; ++y) - { - for(int x = wstart; x < wend; ++x) - { - const T val = src[r * h_src * w_src + y * w_src + x]; - if(val > max_val) - { - max_val = val; - } - } - } - - dst[r * h_dst * w_dst + h * w_dst + w] = max_val; - } - } - } - } - else // Average pooling - { - for(int r = 0; r < upper_dims; ++r) - { - for(int h = 0; h < h_dst; ++h) - { - for(int w = 0; w < w_dst; ++w) - { - int wstart = w * pool_stride_x - pad_x; - int hstart = h * pool_stride_y - pad_y; - int wend = std::min(wstart + pool_size, w_src + pad_x); - int hend = std::min(hstart + pool_size, h_src + pad_y); - int pool = (hend - hstart) * (wend - wstart); - wstart = std::max(wstart, 0); - hstart = std::max(hstart, 0); - wend = std::min(wend, w_src); - hend = std::min(hend, h_src); - - using namespace fixed_point_arithmetic; - - const int fixed_point_position = src.fixed_point_position(); - const fixed_point invpool_fp(1.f / static_cast(pool), fixed_point_position); - fixed_point avg_val(0, fixed_point_position, true); - - for(int y = hstart; y < hend; ++y) - { - for(int x = wstart; x < wend; ++x) - { - const fixed_point in_fp(src[r * h_src * w_src + y * w_src + x], fixed_point_position, true); - avg_val = add(avg_val, in_fp); - } - } - dst[r * h_dst * w_dst + h * w_dst + w] = mul(avg_val, invpool_fp).raw(); - } - } - } - } - - return dst; -} - -template SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); -template SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); -template SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); -template SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/PoolingLayer.h b/tests/validation_new/CPP/PoolingLayer.h deleted file mode 100644 index 0935fb02f9..0000000000 --- a/tests/validation_new/CPP/PoolingLayer.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_POOLING_LAYER_H__ -#define __ARM_COMPUTE_TEST_POOLING_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type = 0> -SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); - -template ::value, int>::type = 0> -SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_POOLING_LAYER_H__ */ diff --git a/tests/validation_new/CPP/QuantizationLayer.cpp b/tests/validation_new/CPP/QuantizationLayer.cpp deleted file mode 100644 index d61e75a3a9..0000000000 --- a/tests/validation_new/CPP/QuantizationLayer.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "QuantizationLayer.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -void compute_min_max(const SimpleTensor &src, float *min, float *max) -{ - // Set min and max to first pixel - float tmp_min = src[0]; - float tmp_max = src[0]; - - // Look for min and max values - for(int i = 1; i < src.num_elements(); ++i) - { - if(src[i] < tmp_min) - { - tmp_min = src[i]; - } - if(src[i] > tmp_max) - { - tmp_max = src[i]; - } - } - - *min = tmp_min; - *max = tmp_max; -} - -template ::value, int>::type> -SimpleTensor quantization_layer(const SimpleTensor &src) -{ - // Create reference - SimpleTensor dst{ src.shape(), DataType::U8 }; - - // Compute min and max of the tensor using Min-Max layer - float min = 0.f; - float max = 0.f; - - compute_min_max(src, &min, &max); - - const float range = max - min; - - for(int i = 0; i < src.num_elements(); ++i) - { - // map values to range [0.0, 1.0] - const float normalized = (src[i] - min) / range; - dst[i] = static_cast(std::min(255.0f, normalized * 256.0f)); - } - - return dst; -} - -template SimpleTensor quantization_layer(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/QuantizationLayer.h b/tests/validation_new/CPP/QuantizationLayer.h deleted file mode 100644 index c696ab0c85..0000000000 --- a/tests/validation_new/CPP/QuantizationLayer.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_QUANTIZATION_LAYER_H__ -#define __ARM_COMPUTE_TEST_QUANTIZATION_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type = 0> -SimpleTensor quantization_layer(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_QUANTIZATION_LAYER_H__ */ diff --git a/tests/validation_new/CPP/ReductionOperation.cpp b/tests/validation_new/CPP/ReductionOperation.cpp deleted file mode 100644 index f4c5c21182..0000000000 --- a/tests/validation_new/CPP/ReductionOperation.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "ReductionOperation.h" - -#include "tests/validation_new/Helpers.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -template -struct square -{ - T operator()(const T &lhs, const T &rhs) const - { - return (lhs + rhs * rhs); - } -}; - -template -T reduce_operation(T *ptr, int reduce_elements, ReductionOperation op) -{ - switch(op) - { - case ReductionOperation::SUM_SQUARE: - return std::accumulate(ptr, ptr + reduce_elements, 0.f, square()); - default: - ARM_COMPUTE_ERROR("Unsupported reduction operation"); - } -} -} // namespace - -template -SimpleTensor reduction_operation(const SimpleTensor &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op) -{ - // Create reference - SimpleTensor dst{ dst_shape, src.data_type() }; - - // Compute reference - const int reduce_elems = src.shape()[axis]; - const int upper_dims = src.shape().total_size_upper(axis + 1); - - for(int du = 0; du < upper_dims; ++du) - { - if(axis == 0) - { - const T *src_row_ptr = src.data() + du * reduce_elems; - dst[du] = reduce_operation(src_row_ptr, reduce_elems, op); - } - else - { - ARM_COMPUTE_ERROR("Unsupported reduction axis"); - } - } - - return dst; -} - -template SimpleTensor reduction_operation(const SimpleTensor &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/ReductionOperation.h b/tests/validation_new/CPP/ReductionOperation.h deleted file mode 100644 index 500a8162fd..0000000000 --- a/tests/validation_new/CPP/ReductionOperation.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_REDUCTION_OPERATION_H__ -#define __ARM_COMPUTE_TEST_REDUCTION_OPERATION_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor reduction_operation(const SimpleTensor &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_FLOOR_H__ */ diff --git a/tests/validation_new/CPP/Scale.cpp b/tests/validation_new/CPP/Scale.cpp deleted file mode 100644 index a1119f33b9..0000000000 --- a/tests/validation_new/CPP/Scale.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "arm_compute/core/Helpers.h" - -#include "Scale.h" -#include "Utils.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor scale(const SimpleTensor &in, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) -{ - TensorShape shape_scaled(in.shape()); - shape_scaled.set(0, in.shape()[0] * scale_x); - shape_scaled.set(1, in.shape()[1] * scale_y); - SimpleTensor out(shape_scaled, in.data_type()); - - // Compute the ratio between source width/height and destination width/height - const auto wr = static_cast(in.shape()[0]) / static_cast(out.shape()[0]); - const auto hr = static_cast(in.shape()[1]) / static_cast(out.shape()[1]); - - const auto width = static_cast(in.shape().x()); - const auto height = static_cast(in.shape().y()); - - // Area interpolation behaves as Nearest Neighbour in case of up-sampling - if(policy == InterpolationPolicy::AREA && wr <= 1.f && hr <= 1.f) - { - policy = InterpolationPolicy::NEAREST_NEIGHBOR; - } - - for(int element_idx = 0, count = 0; element_idx < out.num_elements(); ++element_idx, ++count) - { - Coordinates id = index2coord(out.shape(), element_idx); - int idx = id.x(); - int idy = id.y(); - float x_src = (idx + 0.5f) * wr - 0.5f; - float y_src = (idy + 0.5f) * hr - 0.5f; - - switch(policy) - { - case InterpolationPolicy::NEAREST_NEIGHBOR: - { - //Calculate the source coords without -0.5f is equivalent to round the x_scr/y_src coords - x_src = (idx + 0.5f) * wr; - y_src = (idy + 0.5f) * hr; - id.set(0, x_src); - id.set(1, y_src); - - // If coordinates in range of tensor's width or height - if(x_src >= -1 || y_src >= -1 || x_src <= width || y_src <= height) - { - out[element_idx] = tensor_elem_at(in, id, border_mode, constant_border_value); - } - else - { - if(border_mode == BorderMode::CONSTANT) - { - out[element_idx] = constant_border_value; - } - else if(border_mode == BorderMode::REPLICATE) - { - id.set(0, clamp(static_cast(x_src), 0, width - 1)); - id.set(1, clamp(static_cast(y_src), 0, height - 1)); - out[element_idx] = in[coord2index(in.shape(), id)]; - } - } - break; - } - case InterpolationPolicy::BILINEAR: - { - id.set(0, std::floor(x_src)); - id.set(1, std::floor(y_src)); - if(x_src >= -1 || y_src >= -1 || x_src <= width || y_src <= height) - { - out[element_idx] = bilinear_policy(in, id, x_src, y_src, border_mode, constant_border_value); - } - else - { - if(border_mode == BorderMode::CONSTANT) - { - out[element_idx] = constant_border_value; - } - else if(border_mode == BorderMode::REPLICATE) - { - id.set(0, clamp(static_cast(x_src), 0, width - 1)); - id.set(1, clamp(static_cast(y_src), 0, height - 1)); - out[element_idx] = in[coord2index(in.shape(), id)]; - } - } - break; - } - case InterpolationPolicy::AREA: - { - int x_from = std::floor(idx * wr - 0.5f - x_src); - int y_from = std::floor(idy * hr - 0.5f - y_src); - int x_to = std::ceil((idx + 1) * wr - 0.5f - x_src); - int y_to = std::ceil((idy + 1) * hr - 0.5f - y_src); - const int xi = std::floor(x_src); - const int yi = std::floor(y_src); - - // Clamp position to borders - x_src = std::max(-1.f, std::min(x_src, static_cast(width))); - y_src = std::max(-1.f, std::min(y_src, static_cast(height))); - - // Clamp bounding box offsets to borders - x_from = ((x_src + x_from) < -1) ? -1 : x_from; - y_from = ((y_src + y_from) < -1) ? -1 : y_from; - x_to = ((x_src + x_to) > width) ? (width - x_src) : x_to; - y_to = ((y_src + y_to) > height) ? (height - y_src) : y_to; - ARM_COMPUTE_ERROR_ON((x_to - x_from + 1) == 0 || (y_to - y_from + 1) == 0); - - float sum = 0; - for(int j = yi + y_from, je = yi + y_to; j <= je; ++j) - { - for(int i = xi + x_from, ie = xi + x_to; i <= ie; ++i) - { - id.set(0, static_cast(i)); - id.set(1, static_cast(j)); - sum += tensor_elem_at(in, id, border_mode, constant_border_value); - } - } - out[element_idx] = sum / ((x_to - x_from + 1) * (y_to - y_from + 1)); - - break; - } - default: - ARM_COMPUTE_ERROR("Unsupported interpolation mode"); - } - } - - return out; -} - -template SimpleTensor scale(const SimpleTensor &src, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute \ No newline at end of file diff --git a/tests/validation_new/CPP/Scale.h b/tests/validation_new/CPP/Scale.h deleted file mode 100644 index b882915946..0000000000 --- a/tests/validation_new/CPP/Scale.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_SCALE_H__ -#define __ARM_COMPUTE_TEST_SCALE_H__ - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor scale(const SimpleTensor &in, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value = 0); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_SCALE_H__ */ diff --git a/tests/validation_new/CPP/SoftmaxLayer.cpp b/tests/validation_new/CPP/SoftmaxLayer.cpp deleted file mode 100644 index 8c2cda8296..0000000000 --- a/tests/validation_new/CPP/SoftmaxLayer.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "SoftmaxLayer.h" - -#include "tests/validation_new/FixedPoint.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type> -SimpleTensor softmax_layer(const SimpleTensor &src) -{ - // Create reference - SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; - - // Compute reference - const int cols = src.shape()[0]; - const int upper_dims = src.num_elements() / cols; - - for(int r = 0; r < upper_dims; ++r) - { - const T *src_row_ptr = src.data() + r * cols; - T *dst_row_ptr = dst.data() + r * cols; - - // Find max - const T max = *std::max_element(src_row_ptr, src_row_ptr + cols); - - // Regularize - T sum(0.f); - std::transform(src_row_ptr, src_row_ptr + cols, dst_row_ptr, [&sum, max](T val) - { - const T res(std::exp(val - max)); - sum += res; - return res; - }); - - // Normalize - std::transform(dst_row_ptr, dst_row_ptr + cols, dst_row_ptr, [sum](T val) - { - return val / sum; - }); - } - - return dst; -} - -template ::value, int>::type> -SimpleTensor softmax_layer(const SimpleTensor &src) -{ - using namespace fixed_point_arithmetic; - - // Create reference - SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; - - // Compute reference - const int cols = src.shape()[0]; - const int upper_dims = src.num_elements() / cols; - - for(int r = 0; r < upper_dims; ++r) - { - const T *src_row_ptr = src.data() + r * cols; - T *dst_row_ptr = dst.data() + r * cols; - - // Find max - const fixed_point max(*std::max_element(src_row_ptr, src_row_ptr + cols), src.fixed_point_position(), true); - - // Regularize - using promoted_type = fixed_point_arithmetic::traits::promote_t; - fixed_point sum(0, src.fixed_point_position(), true); - std::transform(src_row_ptr, src_row_ptr + cols, dst_row_ptr, [&](T val) - { - const fixed_point res = exp(fixed_point(val, src.fixed_point_position(), true) - max); - sum = add(sum, fixed_point(res.raw(), src.fixed_point_position(), true)); - return res.raw(); - }); - - // Normalize - fixed_point saturated_sum(sum); - std::transform(dst_row_ptr, dst_row_ptr + cols, dst_row_ptr, [&](T val) - { - return div(fixed_point(val, src.fixed_point_position(), true), saturated_sum).raw(); - }); - } - - return dst; -} - -template SimpleTensor softmax_layer(const SimpleTensor &src); -template SimpleTensor softmax_layer(const SimpleTensor &src); -template SimpleTensor softmax_layer(const SimpleTensor &src); -template SimpleTensor softmax_layer(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/SoftmaxLayer.h b/tests/validation_new/CPP/SoftmaxLayer.h deleted file mode 100644 index cc52f3cf51..0000000000 --- a/tests/validation_new/CPP/SoftmaxLayer.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_SOFTMAX_LAYER_H__ -#define __ARM_COMPUTE_TEST_SOFTMAX_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type = 0> -SimpleTensor softmax_layer(const SimpleTensor &src); - -template ::value, int>::type = 0> -SimpleTensor softmax_layer(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_SOFTMAX_LAYER_H__ */ diff --git a/tests/validation_new/CPP/Utils.cpp b/tests/validation_new/CPP/Utils.cpp deleted file mode 100644 index c89807b69a..0000000000 --- a/tests/validation_new/CPP/Utils.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Utils.h" - -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -// Return a tensor element at a specified coordinate with different border modes -template -T tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, T constant_border_value) -{ - const int x = coord.x(); - const int y = coord.y(); - const auto width = static_cast(in.shape().x()); - const auto height = static_cast(in.shape().y()); - - // If coordinates beyond range of tensor's width or height - if(x < 0 || y < 0 || x >= width || y >= height) - { - if(border_mode == BorderMode::REPLICATE) - { - coord.set(0, std::max(0, std::min(x, width - 1))); - coord.set(1, std::max(0, std::min(y, height - 1))); - } - else - { - return constant_border_value; - } - } - return in[coord2index(in.shape(), coord)]; -} -template float tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, float constant_border_value); -template uint8_t tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, uint8_t constant_border_value); - -// Return the bilinear value at a specified coordinate with different border modes -template -T bilinear_policy(const SimpleTensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value) -{ - int idx = std::floor(xn); - int idy = std::floor(yn); - - const float dx = xn - idx; - const float dy = yn - idy; - const float dx_1 = 1.0f - dx; - const float dy_1 = 1.0f - dy; - - id.set(0, idx); - id.set(1, idy); - const T tl = tensor_elem_at(in, id, border_mode, constant_border_value); - id.set(0, idx + 1); - id.set(1, idy); - const T tr = tensor_elem_at(in, id, border_mode, constant_border_value); - id.set(0, idx); - id.set(1, idy + 1); - const T bl = tensor_elem_at(in, id, border_mode, constant_border_value); - id.set(0, idx + 1); - id.set(1, idy + 1); - const T br = tensor_elem_at(in, id, border_mode, constant_border_value); - - return tl * (dx_1 * dy_1) + tr * (dx * dy_1) + bl * (dx_1 * dy) + br * (dx * dy); -} -template uint8_t bilinear_policy(const SimpleTensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value); - -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/Utils.h b/tests/validation_new/CPP/Utils.h deleted file mode 100644 index 4e3deb4d86..0000000000 --- a/tests/validation_new/CPP/Utils.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_VALIDATION_UTILS_H__ -#define __ARM_COMPUTE_TEST_VALIDATION_UTILS_H__ - -#include "arm_compute/core/Types.h" -#include "tests/Globals.h" -#include "tests/ILutAccessor.h" -#include "tests/Types.h" -#include "tests/validation/ValidationUserConfiguration.h" -#include "tests/validation/half.h" - -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -T tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, T constant_border_value); - -template -T bilinear_policy(const SimpleTensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value); -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_VALIDATION_UTILS_H__ */ diff --git a/tests/validation_new/FixedPoint.h b/tests/validation_new/FixedPoint.h deleted file mode 100644 index 61d791c54c..0000000000 --- a/tests/validation_new/FixedPoint.h +++ /dev/null @@ -1,984 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_VALIDATION_FIXEDPOINT_H__ -#define __ARM_COMPUTE_TEST_VALIDATION_FIXEDPOINT_H__ - -#include "Utils.h" -#include "support/ToolchainSupport.h" - -#include -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace fixed_point_arithmetic -{ -namespace detail -{ -// Forward declare structs -struct functions; -template -struct constant_expr; -} - -/** Fixed point traits */ -namespace traits -{ -// Promote types -// *INDENT-OFF* -// clang-format off -template struct promote { }; -template <> struct promote { using type = uint16_t; }; -template <> struct promote { using type = int16_t; }; -template <> struct promote { using type = uint32_t; }; -template <> struct promote { using type = int32_t; }; -template <> struct promote { using type = uint64_t; }; -template <> struct promote { using type = int64_t; }; -template <> struct promote { using type = uint64_t; }; -template <> struct promote { using type = int64_t; }; -template -using promote_t = typename promote::type; -// clang-format on -// *INDENT-ON* -} - -/** Strongly typed enum class representing the overflow policy */ -enum class OverflowPolicy -{ - WRAP, /**< Wrap policy */ - SATURATE /**< Saturate policy */ -}; -/** Strongly typed enum class representing the rounding policy */ -enum class RoundingPolicy -{ - TO_ZERO, /**< Round to zero policy */ - TO_NEAREST_EVEN /**< Round to nearest even policy */ -}; - -/** Arbitrary fixed-point arithmetic class */ -template -class fixed_point -{ -public: - // Static Checks - static_assert(std::is_integral::value, "Type is not an integer"); - - /** Constructor (from different fixed point type) - * - * @param[in] val Fixed point - * @param[in] p Fixed point precision - */ - template - fixed_point(fixed_point val, uint8_t p) - : _value(0), _fixed_point_position(p) - { - assert(p > 0 && p < std::numeric_limits::digits); - T v = 0; - - if(std::numeric_limits::digits < std::numeric_limits::digits) - { - val.rescale(p); - v = detail::constant_expr::saturate_cast(val.raw()); - } - else - { - auto v_cast = static_cast>(val); - v_cast.rescale(p); - v = v_cast.raw(); - } - _value = static_cast(v); - } - /** Constructor (from integer) - * - * @param[in] val Integer value to be represented as fixed point - * @param[in] p Fixed point precision - * @param[in] is_raw If true val is a raw fixed point value else an integer - */ - template ::value>::type> - fixed_point(U val, uint8_t p, bool is_raw = false) - : _value(val << p), _fixed_point_position(p) - { - if(is_raw) - { - _value = val; - } - } - /** Constructor (from float) - * - * @param[in] val Float value to be represented as fixed point - * @param[in] p Fixed point precision - */ - fixed_point(float val, uint8_t p) - : _value(detail::constant_expr::to_fixed(val, p)), _fixed_point_position(p) - { - assert(p > 0 && p < std::numeric_limits::digits); - } - /** Constructor (from float string) - * - * @param[in] str Float string to be represented as fixed point - * @param[in] p Fixed point precision - */ - fixed_point(std::string str, uint8_t p) - : _value(detail::constant_expr::to_fixed(support::cpp11::stof(str), p)), _fixed_point_position(p) - { - assert(p > 0 && p < std::numeric_limits::digits); - } - /** Default copy constructor */ - fixed_point &operator=(const fixed_point &) = default; - /** Default move constructor */ - fixed_point &operator=(fixed_point &&) = default; - /** Default copy assignment operator */ - fixed_point(const fixed_point &) = default; - /** Default move assignment operator */ - fixed_point(fixed_point &&) = default; - - /** Float conversion operator - * - * @return Float representation of fixed point - */ - operator float() const - { - return detail::constant_expr::to_float(_value, _fixed_point_position); - } - /** Integer conversion operator - * - * @return Integer representation of fixed point - */ - template ::value>::type> - operator U() const - { - return detail::constant_expr::to_int(_value, _fixed_point_position); - } - /** Convert to different fixed point of different type but same precision - * - * @note Down-conversion might fail. - */ - template - operator fixed_point() - { - U val = static_cast(_value); - if(std::numeric_limits::digits < std::numeric_limits::digits) - { - val = detail::constant_expr::saturate_cast(_value); - } - return fixed_point(val, _fixed_point_position, true); - } - - /** Arithmetic += assignment operator - * - * @param[in] rhs Fixed point operand - * - * @return Reference to this fixed point - */ - template - fixed_point &operator+=(const fixed_point &rhs) - { - fixed_point val(rhs, _fixed_point_position); - _value += val.raw(); - return *this; - } - /** Arithmetic -= assignment operator - * - * @param[in] rhs Fixed point operand - * - * @return Reference to this fixed point - */ - template - fixed_point &operator-=(const fixed_point &rhs) - { - fixed_point val(rhs, _fixed_point_position); - _value -= val.raw(); - return *this; - } - - /** Raw value accessor - * - * @return Raw fixed point value - */ - T raw() const - { - return _value; - } - /** Precision accessor - * - * @return Precision of fixed point - */ - uint8_t precision() const - { - return _fixed_point_position; - } - /** Rescale a fixed point to a new precision - * - * @param[in] p New fixed point precision - */ - void rescale(uint8_t p) - { - assert(p > 0 && p < std::numeric_limits::digits); - - using promoted_T = typename traits::promote::type; - promoted_T val = _value; - if(p > _fixed_point_position) - { - val <<= (p - _fixed_point_position); - } - else if(p < _fixed_point_position) - { - uint8_t pbar = _fixed_point_position - p; - val += (pbar != 0) ? (1 << (pbar - 1)) : 0; - val >>= pbar; - } - - _value = detail::constant_expr::saturate_cast(val); - _fixed_point_position = p; - } - -private: - T _value; /**< Fixed point raw value */ - uint8_t _fixed_point_position; /**< Fixed point precision */ -}; - -namespace detail -{ -/** Count the number of leading zero bits in the given value. - * - * @param[in] value Input value. - * - * @return Number of leading zero bits. - */ -template -constexpr int clz(T value) -{ - using unsigned_T = typename std::make_unsigned::type; - // __builtin_clz is available for int. Need to correct reported number to - // match the original type. - return __builtin_clz(value) - (32 - std::numeric_limits::digits); -} - -template -struct constant_expr -{ - /** Calculate representation of 1 in fixed point given a fixed point precision - * - * @param[in] p Fixed point precision - * - * @return Representation of value 1 in fixed point. - */ - static constexpr T fixed_one(uint8_t p) - { - return (1 << p); - } - /** Calculate fixed point precision step given a fixed point precision - * - * @param[in] p Fixed point precision - * - * @return Fixed point precision step - */ - static constexpr float fixed_step(uint8_t p) - { - return (1.0f / static_cast(1 << p)); - } - - /** Convert a fixed point value to float given its precision. - * - * @param[in] val Fixed point value - * @param[in] p Fixed point precision - * - * @return Float representation of the fixed point number - */ - static constexpr float to_float(T val, uint8_t p) - { - return static_cast(val * fixed_step(p)); - } - /** Convert a fixed point value to integer given its precision. - * - * @param[in] val Fixed point value - * @param[in] p Fixed point precision - * - * @return Integer of the fixed point number - */ - static constexpr T to_int(T val, uint8_t p) - { - return val >> p; - } - /** Convert a single precision floating point value to a fixed point representation given its precision. - * - * @param[in] val Floating point value - * @param[in] p Fixed point precision - * - * @return The raw fixed point representation - */ - static constexpr T to_fixed(float val, uint8_t p) - { - return static_cast(saturate_cast(val * fixed_one(p) + ((val >= 0) ? 0.5 : -0.5))); - } - /** Clamp value between two ranges - * - * @param[in] val Value to clamp - * @param[in] min Minimum value to clamp to - * @param[in] max Maximum value to clamp to - * - * @return clamped value - */ - static constexpr T clamp(T val, T min, T max) - { - return std::min(std::max(val, min), max); - } - /** Saturate given number - * - * @param[in] val Value to saturate - * - * @return Saturated value - */ - template - static constexpr T saturate_cast(U val) - { - return static_cast(std::min(std::max(val, static_cast(std::numeric_limits::min())), static_cast(std::numeric_limits::max()))); - } -}; -struct functions -{ - /** Output stream operator - * - * @param[in] s Output stream - * @param[in] x Fixed point value - * - * @return Reference output to updated stream - */ - template - static std::basic_ostream &write(std::basic_ostream &s, fixed_point &x) - { - return s << static_cast(x); - } - /** Signbit of a fixed point number. - * - * @param[in] x Fixed point number - * - * @return True if negative else false. - */ - template - static bool signbit(fixed_point x) - { - return ((x.raw() >> std::numeric_limits::digits) != 0); - } - /** Checks if two fixed point numbers are equal - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return True if fixed points are equal else false - */ - template - static bool isequal(fixed_point x, fixed_point y) - { - uint8_t p = std::min(x.precision(), y.precision()); - x.rescale(p); - y.rescale(p); - return (x.raw() == y.raw()); - } - /** Checks if two fixed point number are not equal - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return True if fixed points are not equal else false - */ - template - static bool isnotequal(fixed_point x, fixed_point y) - { - return !isequal(x, y); - } - /** Checks if one fixed point is greater than the other - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return True if fixed point is greater than other - */ - template - static bool isgreater(fixed_point x, fixed_point y) - { - uint8_t p = std::min(x.precision(), y.precision()); - x.rescale(p); - y.rescale(p); - return (x.raw() > y.raw()); - } - /** Checks if one fixed point is greater or equal than the other - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return True if fixed point is greater or equal than other - */ - template - static bool isgreaterequal(fixed_point x, fixed_point y) - { - uint8_t p = std::min(x.precision(), y.precision()); - x.rescale(p); - y.rescale(p); - return (x.raw() >= y.raw()); - } - /** Checks if one fixed point is less than the other - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return True if fixed point is less than other - */ - template - static bool isless(fixed_point x, fixed_point y) - { - uint8_t p = std::min(x.precision(), y.precision()); - x.rescale(p); - y.rescale(p); - return (x.raw() < y.raw()); - } - /** Checks if one fixed point is less or equal than the other - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return True if fixed point is less or equal than other - */ - template - static bool islessequal(fixed_point x, fixed_point y) - { - uint8_t p = std::min(x.precision(), y.precision()); - x.rescale(p); - y.rescale(p); - return (x.raw() <= y.raw()); - } - /** Checks if one fixed point is less or greater than the other - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return True if fixed point is less or greater than other - */ - template - static bool islessgreater(fixed_point x, fixed_point y) - { - return isnotequal(x, y); - } - /** Clamp fixed point to specific range. - * - * @param[in] x Fixed point operand - * @param[in] min Minimum value to clamp to - * @param[in] max Maximum value to clamp to - * - * @return Clamped result - */ - template - static fixed_point clamp(fixed_point x, T min, T max) - { - return fixed_point(constant_expr::clamp(x.raw(), min, max), x.precision(), true); - } - /** Negate number - * - * @param[in] x Fixed point operand - * - * @return Negated fixed point result - */ - template - static fixed_point negate(fixed_point x) - { - using promoted_T = typename traits::promote::type; - promoted_T val = -x.raw(); - if(OP == OverflowPolicy::SATURATE) - { - val = constant_expr::saturate_cast(val); - } - return fixed_point(static_cast(val), x.precision(), true); - } - /** Perform addition among two fixed point numbers - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return Result fixed point with precision equal to minimum precision of both operands - */ - template - static fixed_point add(fixed_point x, fixed_point y) - { - uint8_t p = std::min(x.precision(), y.precision()); - x.rescale(p); - y.rescale(p); - if(OP == OverflowPolicy::SATURATE) - { - using type = typename traits::promote::type; - type val = static_cast(x.raw()) + static_cast(y.raw()); - val = constant_expr::saturate_cast(val); - return fixed_point(static_cast(val), p, true); - } - else - { - return fixed_point(x.raw() + y.raw(), p, true); - } - } - /** Perform subtraction among two fixed point numbers - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return Result fixed point with precision equal to minimum precision of both operands - */ - template - static fixed_point sub(fixed_point x, fixed_point y) - { - uint8_t p = std::min(x.precision(), y.precision()); - x.rescale(p); - y.rescale(p); - if(OP == OverflowPolicy::SATURATE) - { - using type = typename traits::promote::type; - type val = static_cast(x.raw()) - static_cast(y.raw()); - val = constant_expr::saturate_cast(val); - return fixed_point(static_cast(val), p, true); - } - else - { - return fixed_point(x.raw() - y.raw(), p, true); - } - } - /** Perform multiplication among two fixed point numbers - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return Result fixed point with precision equal to minimum precision of both operands - */ - template - static fixed_point mul(fixed_point x, fixed_point y) - { - using promoted_T = typename traits::promote::type; - uint8_t p_min = std::min(x.precision(), y.precision()); - uint8_t p_max = std::max(x.precision(), y.precision()); - promoted_T round_factor = (1 << (p_max - 1)); - promoted_T val = ((static_cast(x.raw()) * static_cast(y.raw())) + round_factor) >> p_max; - if(OP == OverflowPolicy::SATURATE) - { - val = constant_expr::saturate_cast(val); - } - return fixed_point(static_cast(val), p_min, true); - } - /** Perform division among two fixed point numbers - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return Result fixed point with precision equal to minimum precision of both operands - */ - template - static fixed_point div(fixed_point x, fixed_point y) - { - using promoted_T = typename traits::promote::type; - uint8_t p = std::min(x.precision(), y.precision()); - promoted_T denom = static_cast(y.raw()); - if(denom != 0) - { - promoted_T val = (static_cast(x.raw()) << std::max(x.precision(), y.precision())) / denom; - if(OP == OverflowPolicy::SATURATE) - { - val = constant_expr::saturate_cast(val); - } - return fixed_point(static_cast(val), p, true); - } - else - { - T val = (x.raw() < 0) ? std::numeric_limits::min() : std::numeric_limits::max(); - return fixed_point(val, p, true); - } - } - /** Shift left - * - * @param[in] x Fixed point operand - * @param[in] shift Shift value - * - * @return Shifted value - */ - template - static fixed_point shift_left(fixed_point x, size_t shift) - { - using promoted_T = typename traits::promote::type; - promoted_T val = static_cast(x.raw()) << shift; - if(OP == OverflowPolicy::SATURATE) - { - val = constant_expr::saturate_cast(val); - } - return fixed_point(static_cast(val), x.precision(), true); - } - /** Shift right - * - * @param[in] x Fixed point operand - * @param[in] shift Shift value - * - * @return Shifted value - */ - template - static fixed_point shift_right(fixed_point x, size_t shift) - { - return fixed_point(x.raw() >> shift, x.precision(), true); - } - /** Calculate absolute value - * - * @param[in] x Fixed point operand - * - * @return Absolute value of operand - */ - template - static fixed_point abs(fixed_point x) - { - using promoted_T = typename traits::promote::type; - T val = (x.raw() < 0) ? constant_expr::saturate_cast(-static_cast(x.raw())) : x.raw(); - return fixed_point(val, x.precision(), true); - } - /** Calculate the logarithm of a fixed point number - * - * @param[in] x Fixed point operand - * - * @return Logarithm value of operand - */ - template - static fixed_point log(fixed_point x) - { - uint8_t p = x.precision(); - auto const_one = fixed_point(static_cast(1), p); - - // Logarithm of 1 is zero and logarithm of negative values is not defined in R, so return 0. - // Also, log(x) == -log(1/x) for 0 < x < 1. - if(isequal(x, const_one) || islessequal(x, fixed_point(static_cast(0), p))) - { - return fixed_point(static_cast(0), p, true); - } - else if(isless(x, const_one)) - { - return mul(log(div(const_one, x)), fixed_point(-1, p)); - } - - // Remove even powers of 2 - T shift_val = 31 - __builtin_clz(x.raw() >> p); - x = shift_right(x, shift_val); - x = sub(x, const_one); - - // Constants - auto ln2 = fixed_point(0.6931471, p); - auto A = fixed_point(1.4384189, p); - auto B = fixed_point(-0.67719, p); - auto C = fixed_point(0.3218538, p); - auto D = fixed_point(-0.0832229, p); - - // Polynomial expansion - auto sum = add(mul(x, D), C); - sum = add(mul(x, sum), B); - sum = add(mul(x, sum), A); - sum = mul(x, sum); - - return mul(add(sum, fixed_point(static_cast(shift_val), p)), ln2); - } - /** Calculate the exponential of a fixed point number. - * - * exp(x) = exp(floor(x)) * exp(x - floor(x)) - * = pow(2, floor(x) / ln(2)) * exp(x - floor(x)) - * = exp(x - floor(x)) << (floor(x) / ln(2)) - * - * @param[in] x Fixed point operand - * - * @return Exponential value of operand - */ - template - static fixed_point exp(fixed_point x) - { - uint8_t p = x.precision(); - // Constants - auto const_one = fixed_point(1, p); - auto ln2 = fixed_point(0.6931471, p); - auto inv_ln2 = fixed_point(1.442695, p); - auto A = fixed_point(0.9978546, p); - auto B = fixed_point(0.4994721, p); - auto C = fixed_point(0.1763723, p); - auto D = fixed_point(0.0435108, p); - - T scaled_int_part = detail::constant_expr::to_int(mul(x, inv_ln2).raw(), p); - - // Polynomial expansion - auto frac_part = sub(x, mul(ln2, fixed_point(scaled_int_part, p))); - auto taylor = add(mul(frac_part, D), C); - taylor = add(mul(frac_part, taylor), B); - taylor = add(mul(frac_part, taylor), A); - taylor = mul(frac_part, taylor); - taylor = add(taylor, const_one); - - // Saturate value - if(static_cast(clz(taylor.raw())) <= scaled_int_part) - { - return fixed_point(std::numeric_limits::max(), p, true); - } - - return (scaled_int_part < 0) ? shift_right(taylor, -scaled_int_part) : shift_left(taylor, scaled_int_part); - } - /** Calculate the inverse square root of a fixed point number - * - * @param[in] x Fixed point operand - * - * @return Inverse square root value of operand - */ - template - static fixed_point inv_sqrt(fixed_point x) - { - const uint8_t p = x.precision(); - int8_t shift = std::numeric_limits::digits - (p + detail::clz(x.raw())); - - shift += std::numeric_limits::is_signed ? 1 : 0; - - // Use volatile to restrict compiler optimizations on shift as compiler reports maybe-uninitialized error on Android - volatile int8_t *shift_ptr = &shift; - - auto const_three = fixed_point(3, p); - auto a = (*shift_ptr < 0) ? shift_left(x, -(shift)) : shift_right(x, shift); - fixed_point x2 = a; - - // We need three iterations to find the result for QS8 and five for QS16 - constexpr int num_iterations = std::is_same::value ? 3 : 5; - for(int i = 0; i < num_iterations; ++i) - { - fixed_point three_minus_dx = sub(const_three, mul(a, mul(x2, x2))); - x2 = shift_right(mul(x2, three_minus_dx), 1); - } - - return (shift < 0) ? shift_left(x2, (-shift) >> 1) : shift_right(x2, shift >> 1); - } - /** Calculate the hyperbolic tangent of a fixed point number - * - * @param[in] x Fixed point operand - * - * @return Hyperbolic tangent of the operand - */ - template - static fixed_point tanh(fixed_point x) - { - uint8_t p = x.precision(); - // Constants - auto const_one = fixed_point(1, p); - auto const_two = fixed_point(2, p); - - auto exp2x = exp(const_two * x); - auto num = exp2x - const_one; - auto den = exp2x + const_one; - auto tanh = num / den; - - return tanh; - } - /** Calculate the a-th power of a fixed point number. - * - * The power is computed as x^a = e^(log(x) * a) - * - * @param[in] x Fixed point operand - * @param[in] a Fixed point exponent - * - * @return a-th power of the operand - */ - template - static fixed_point pow(fixed_point x, fixed_point a) - { - return exp(log(x) * a); - } -}; - -template -bool operator==(const fixed_point &lhs, const fixed_point &rhs) -{ - return functions::isequal(lhs, rhs); -} -template -bool operator!=(const fixed_point &lhs, const fixed_point &rhs) -{ - return !operator==(lhs, rhs); -} -template -bool operator<(const fixed_point &lhs, const fixed_point &rhs) -{ - return functions::isless(lhs, rhs); -} -template -bool operator>(const fixed_point &lhs, const fixed_point &rhs) -{ - return operator<(rhs, lhs); -} -template -bool operator<=(const fixed_point &lhs, const fixed_point &rhs) -{ - return !operator>(lhs, rhs); -} -template -bool operator>=(const fixed_point &lhs, const fixed_point &rhs) -{ - return !operator<(lhs, rhs); -} -template -fixed_point operator+(const fixed_point &lhs, const fixed_point &rhs) -{ - return functions::add(lhs, rhs); -} -template -fixed_point operator-(const fixed_point &lhs, const fixed_point &rhs) -{ - return functions::sub(lhs, rhs); -} -template -fixed_point operator-(const fixed_point &rhs) -{ - return functions::negate(rhs); -} -template -fixed_point operator*(fixed_point x, fixed_point y) -{ - return functions::mul(x, y); -} -template -fixed_point operator/(fixed_point x, fixed_point y) -{ - return functions::div(x, y); -} -template -fixed_point operator>>(fixed_point x, size_t shift) -{ - return functions::shift_right(x, shift); -} -template -fixed_point operator<<(fixed_point x, size_t shift) -{ - return functions::shift_left(x, shift); -} -template -std::basic_ostream &operator<<(std::basic_ostream &s, fixed_point x) -{ - return functions::write(s, x); -} -template -inline fixed_point min(fixed_point x, fixed_point y) -{ - return x > y ? y : x; -} -template -inline fixed_point max(fixed_point x, fixed_point y) -{ - return x > y ? x : y; -} -template -inline fixed_point add(fixed_point x, fixed_point y) -{ - return functions::add(x, y); -} -template -inline fixed_point sub(fixed_point x, fixed_point y) -{ - return functions::sub(x, y); -} -template -inline fixed_point mul(fixed_point x, fixed_point y) -{ - return functions::mul(x, y); -} -template -inline fixed_point div(fixed_point x, fixed_point y) -{ - return functions::div(x, y); -} -template -inline fixed_point abs(fixed_point x) -{ - return functions::abs(x); -} -template -inline fixed_point clamp(fixed_point x, T min, T max) -{ - return functions::clamp(x, min, max); -} -template -inline fixed_point exp(fixed_point x) -{ - return functions::exp(x); -} -template -inline fixed_point log(fixed_point x) -{ - return functions::log(x); -} -template -inline fixed_point inv_sqrt(fixed_point x) -{ - return functions::inv_sqrt(x); -} -template -inline fixed_point tanh(fixed_point x) -{ - return functions::tanh(x); -} -template -inline fixed_point pow(fixed_point x, fixed_point a) -{ - return functions::pow(x, a); -} -} // namespace detail - -// Expose operators -using detail::operator==; -using detail::operator!=; -using detail::operator<; -using detail::operator>; -using detail::operator<=; -using detail::operator>=; -using detail::operator+; -using detail::operator-; -using detail::operator*; -using detail::operator/; -using detail::operator>>; -using detail::operator<<; - -// Expose additional functions -using detail::min; -using detail::max; -using detail::add; -using detail::sub; -using detail::mul; -using detail::div; -using detail::abs; -using detail::clamp; -using detail::exp; -using detail::log; -using detail::inv_sqrt; -using detail::tanh; -using detail::pow; -// TODO: floor -// TODO: ceil -// TODO: sqrt -} // namespace fixed_point_arithmetic -} // namespace test -} // namespace arm_compute -#endif /*__ARM_COMPUTE_TEST_VALIDATION_FIXEDPOINT_H__ */ diff --git a/tests/validation_new/Helpers.cpp b/tests/validation_new/Helpers.cpp deleted file mode 100644 index c65966b06f..0000000000 --- a/tests/validation_new/Helpers.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TensorShape calculate_depth_concatenate_shape(const std::vector &input_shapes) -{ - ARM_COMPUTE_ERROR_ON(input_shapes.empty()); - - TensorShape out_shape = input_shapes[0]; - - size_t max_x = 0; - size_t max_y = 0; - size_t depth = 0; - - for(const auto &shape : input_shapes) - { - max_x = std::max(shape.x(), max_x); - max_y = std::max(shape.y(), max_y); - depth += shape.z(); - } - - out_shape.set(0, max_x); - out_shape.set(1, max_y); - out_shape.set(2, depth); - - return out_shape; -} -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/Helpers.h b/tests/validation_new/Helpers.h deleted file mode 100644 index 30959161bb..0000000000 --- a/tests/validation_new/Helpers.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_VALIDATION_HELPERS_H__ -#define __ARM_COMPUTE_TEST_VALIDATION_HELPERS_H__ - -#include "arm_compute/core/Types.h" -#include "arm_compute/core/Utils.h" -#include "tests/validation/half.h" - -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -struct is_floating_point : public std::is_floating_point -{ -}; - -template <> -struct is_floating_point : public std::true_type -{ -}; - -/** Helper function to get the testing range for each activation layer. - * - * @param[in] activation Activation function to test. - * @param[in] data_type Data type. - * @param[in] fixed_point_position Number of bits for the fractional part. Defaults to 1. - * - * @return A pair containing the lower upper testing bounds for a given function. - */ -template -std::pair get_activation_layer_test_bounds(ActivationLayerInfo::ActivationFunction activation, DataType data_type, int fixed_point_position = 0) -{ - std::pair bounds; - - switch(data_type) - { - case DataType::F16: - { - using namespace half_float::literal; - - switch(activation) - { - case ActivationLayerInfo::ActivationFunction::SQUARE: - case ActivationLayerInfo::ActivationFunction::LOGISTIC: - case ActivationLayerInfo::ActivationFunction::SOFT_RELU: - // Reduce range as exponent overflows - bounds = std::make_pair(-10._h, 10._h); - break; - case ActivationLayerInfo::ActivationFunction::SQRT: - // Reduce range as sqrt should take a non-negative number - bounds = std::make_pair(0._h, 255._h); - break; - default: - bounds = std::make_pair(-255._h, 255._h); - break; - } - break; - } - case DataType::F32: - switch(activation) - { - case ActivationLayerInfo::ActivationFunction::LOGISTIC: - case ActivationLayerInfo::ActivationFunction::SOFT_RELU: - // Reduce range as exponent overflows - bounds = std::make_pair(-40.f, 40.f); - break; - case ActivationLayerInfo::ActivationFunction::SQRT: - // Reduce range as sqrt should take a non-negative number - bounds = std::make_pair(0.f, 255.f); - break; - default: - bounds = std::make_pair(-255.f, 255.f); - break; - } - break; - case DataType::QS8: - case DataType::QS16: - switch(activation) - { - case ActivationLayerInfo::ActivationFunction::LOGISTIC: - case ActivationLayerInfo::ActivationFunction::SOFT_RELU: - case ActivationLayerInfo::ActivationFunction::TANH: - // Reduce range as exponent overflows - bounds = std::make_pair(-(1 << fixed_point_position), 1 << fixed_point_position); - break; - case ActivationLayerInfo::ActivationFunction::SQRT: - // Reduce range as sqrt should take a non-negative number - // Can't be zero either as inv_sqrt is used in NEON. - bounds = std::make_pair(1, std::numeric_limits::max()); - break; - default: - bounds = std::make_pair(std::numeric_limits::lowest(), std::numeric_limits::max()); - break; - } - break; - default: - ARM_COMPUTE_ERROR("Unsupported data type"); - } - - return bounds; -} - -/** Calculate output tensor shape give a vector of input tensor to concatenate - * - * @param[in] input_shapes Shapes of the tensors to concatenate across depth. - * - * @return The shape of output concatenated tensor. - */ -TensorShape calculate_depth_concatenate_shape(const std::vector &input_shapes); -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_VALIDATION_HELPERS_H__ */ diff --git a/tests/validation_new/NEON/ActivationLayer.cpp b/tests/validation_new/NEON/ActivationLayer.cpp deleted file mode 100644 index bc2fe603fd..0000000000 --- a/tests/validation_new/NEON/ActivationLayer.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ActivationFunctionsDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/ActivationLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Define tolerance of the activation layer. - * - * @param[in] data_type The data type used. - * @param[in] activation The activation function used. - * - * @return Tolerance depending on the activation function. - */ -AbsoluteTolerance tolerance(DataType data_type, ActivationLayerInfo::ActivationFunction activation) -{ - switch(activation) - { - case ActivationLayerInfo::ActivationFunction::LOGISTIC: - case ActivationLayerInfo::ActivationFunction::SOFT_RELU: - case ActivationLayerInfo::ActivationFunction::SQRT: - case ActivationLayerInfo::ActivationFunction::TANH: - switch(data_type) - { - case DataType::QS8: - return AbsoluteTolerance(5.f); - case DataType::QS16: - return AbsoluteTolerance(11.f); - case DataType::F16: - return AbsoluteTolerance(0.01f); - default: - return AbsoluteTolerance(0.00001f); - } - break; - default: - return AbsoluteTolerance(0.f); - } -} - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 - DataType::F16, -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - DataType::F32, - DataType::QS8, - DataType::QS16, -}); - -/** Input data sets. */ -const auto ActivationDataset = combine(combine(framework::dataset::make("InPlace", { false, true }), datasets::ActivationFunctions()), framework::dataset::make("AlphaBeta", { 0.5f, 1.f })); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(ActivationLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), CNNDataTypes), framework::dataset::make("InPlace", { false, true })), - shape, data_type, in_place) -{ - // Set fixed point position data type allowed - const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - // Create tensors - Tensor src = create_tensor(shape, data_type, 1, fixed_point_position); - Tensor dst = create_tensor(shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEActivationLayer act_layer; - - if(in_place) - { - act_layer.configure(&src, nullptr, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS)); - } - else - { - act_layer.configure(&src, &dst, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS)); - } - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - - if(!in_place) - { - validate(dst.info()->valid_region(), valid_region); - } - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - - if(!in_place) - { - validate(dst.info()->padding(), padding); - } -} - -template -using NEActivationLayerFixture = ActivationValidationFixture; - -TEST_SUITE(Float) -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance(_data_type, _function)); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance(_data_type, _function)); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ActivationDataset), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance(_data_type, _function)); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ActivationDataset), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance(_data_type, _function)); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using NEActivationLayerFixedPointFixture = ActivationValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// We test for fixed point precision [3,5] because [1,2] and [6,7] ranges cause -// overflowing issues in most of the transcendentals functions. -FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 3, 6))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance(_data_type, _function)); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEActivationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 3, 6))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance(_data_type, _function)); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 -FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance(_data_type, _function)); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEActivationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance(_data_type, _function)); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/BitwiseAnd.cpp b/tests/validation_new/NEON/BitwiseAnd.cpp deleted file mode 100644 index 5e6f9000e2..0000000000 --- a/tests/validation_new/NEON/BitwiseAnd.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEBitwiseAnd.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/BitwiseAndFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(NEON) -TEST_SUITE(BitwiseAnd) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - Tensor src1 = create_tensor(shape, data_type); - Tensor src2 = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEBitwiseAnd bitwise_and; - bitwise_and.configure(&src1, &src2, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using NEBitwiseAndFixture = BitwiseAndValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, NEBitwiseAndFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEBitwiseAndFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/BitwiseNot.cpp b/tests/validation_new/NEON/BitwiseNot.cpp deleted file mode 100644 index 3725379404..0000000000 --- a/tests/validation_new/NEON/BitwiseNot.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEBitwiseNot.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/BitwiseNotFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(NEON) -TEST_SUITE(BitwiseNot) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - Tensor src = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEBitwiseNot bitwise_not; - bitwise_not.configure(&src, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using NEBitwiseNotFixture = BitwiseNotValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, NEBitwiseNotFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEBitwiseNotFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/BitwiseOr.cpp b/tests/validation_new/NEON/BitwiseOr.cpp deleted file mode 100644 index 84ddf8ea47..0000000000 --- a/tests/validation_new/NEON/BitwiseOr.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEBitwiseOr.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/BitwiseOrFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(NEON) -TEST_SUITE(BitwiseOr) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - Tensor src1 = create_tensor(shape, data_type); - Tensor src2 = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEBitwiseOr bitwise_or; - bitwise_or.configure(&src1, &src2, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using NEBitwiseOrFixture = BitwiseOrValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, NEBitwiseOrFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEBitwiseOrFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/BitwiseXor.cpp b/tests/validation_new/NEON/BitwiseXor.cpp deleted file mode 100644 index 5a5a650295..0000000000 --- a/tests/validation_new/NEON/BitwiseXor.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEBitwiseXor.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/BitwiseXorFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(NEON) -TEST_SUITE(BitwiseXor) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - Tensor src1 = create_tensor(shape, data_type); - Tensor src2 = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEBitwiseXor bitwise_xor; - bitwise_xor.configure(&src1, &src2, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using NEBitwiseXorFixture = BitwiseXorValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, NEBitwiseXorFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEBitwiseXorFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/ConvolutionLayer.cpp b/tests/validation_new/NEON/ConvolutionLayer.cpp deleted file mode 100644 index 1efff02428..0000000000 --- a/tests/validation_new/NEON/ConvolutionLayer.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/LargeConvolutionLayerDataset.h" -#include "tests/datasets_new/SmallConvolutionLayerDataset.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/ConvolutionLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -const AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ -#ifdef ARM_COMPUTE_ENABLE_FP16 -const AbsoluteTolerance tolerance_f16(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F16 */ -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -const AbsoluteTolerance tolerance_q(1.0f); /**< Tolerance value for comparing reference's output against implementation's output for fixed point data types */ - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 - DataType::F16, -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - DataType::F32, - DataType::QS8, - DataType::QS16, -}); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(ConvolutionLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallConvolutionLayerDataset(), datasets::LargeConvolutionLayerDataset()), CNNDataTypes), - input_shape, weights_shape, bias_shape, output_shape, info, data_type) -{ - // Set fixed point position data type allowed - int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - // Create tensors - Tensor src = create_tensor(input_shape, data_type, 1, fixed_point_position); - Tensor weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); - Tensor bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); - Tensor dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEConvolutionLayer conv; - conv.configure(&src, &weights, &bias, &dst, info); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(input_shape); - const ValidRegion weights_valid_region = shape_to_valid_region(weights_shape); - const ValidRegion bias_valid_region = shape_to_valid_region(bias_shape); - const ValidRegion dst_valid_region = shape_to_valid_region(output_shape); - - validate(src.info()->valid_region(), src_valid_region); - validate(weights.info()->valid_region(), weights_valid_region); - validate(bias.info()->valid_region(), bias_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - //TODO(COMPMID-415) Need to validate padding? -} - -template -using NEConvolutionLayerFixture = ConvolutionValidationFixture; - -TEST_SUITE(Float) -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallConvolutionLayerDataset(), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeConvolutionLayerDataset(), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using NEConvolutionLayerFixedPointFixture = ConvolutionValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// We test for fixed point precision [4,6] -FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 4, 7))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_q); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 4, 7))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_q); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) -FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_q); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_q); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/DepthConcatenateLayer.cpp b/tests/validation_new/NEON/DepthConcatenateLayer.cpp deleted file mode 100644 index d6400d2df5..0000000000 --- a/tests/validation_new/NEON/DepthConcatenateLayer.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEDepthConcatenate.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/DepthConcatenateLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(NEON) -TEST_SUITE(DepthConcatenateLayer) - -//TODO(COMPMID-415): Add configuration test? - -template -using NEDepthConcatenateLayerFixture = DepthConcatenateValidationFixture; - -TEST_SUITE(Float) -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), - framework::dataset::make("DataType", - DataType::QS8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), - framework::dataset::make("DataType", - DataType::QS8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), - framework::dataset::make("DataType", - DataType::QS16))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), - framework::dataset::make("DataType", - DataType::QS16))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/DequantizationLayer.cpp b/tests/validation_new/NEON/DequantizationLayer.cpp deleted file mode 100644 index 8b67a14d12..0000000000 --- a/tests/validation_new/NEON/DequantizationLayer.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEDequantizationLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/DequantizationLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr AbsoluteTolerance tolerance_f32(0.001f); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(DequantizationLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - Tensor src = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, DataType::F32); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - float min = 0.f; - float max = 0.f; - NEDequantizationLayer dequant_layer; - dequant_layer.configure(&src, &dst, &min, &max); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 8).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using NEDequantizationLayerFixture = DequantizationValidationFixture; - -TEST_SUITE(Integer) -TEST_SUITE(U8) -FIXTURE_DATA_TEST_CASE(RunSmall, NEDequantizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEDequantizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/DirectConvolutionLayer.cpp b/tests/validation_new/NEON/DirectConvolutionLayer.cpp deleted file mode 100644 index 68cbe54b32..0000000000 --- a/tests/validation_new/NEON/DirectConvolutionLayer.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEDirectConvolutionLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/DirectConvolutionLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance tolerance_qs(1.f); /**< Tolerance for fixed point tests */ -#ifdef ARM_COMPUTE_ENABLE_FP16 -constexpr AbsoluteTolerance tolerance_fp16(0.01f); /**< Tolerance for half precision floating point tests */ -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -constexpr AbsoluteTolerance tolerance_fp32(0.001f); /**< Tolerance for floating point tests */ - -/** Direct convolution data set. */ -const auto data_pad_f32 = concat(concat(combine(framework::dataset::make("PadX", 0), - combine(framework::dataset::make("PadY", 0), - framework::dataset::make("KernelSize", 1))), - combine(framework::dataset::make("PadX", 0, 2), - combine(framework::dataset::make("PadY", 0, 2), - framework::dataset::make("KernelSize", 3)))), - combine(framework::dataset::make("PadX", 0, 3), - combine(framework::dataset::make("PadY", 0, 3), - framework::dataset::make("KernelSize", 5)))); - -const auto data_pad_qs8 = concat(combine(framework::dataset::make("PadX", 0), - combine(framework::dataset::make("PadY", 0), - framework::dataset::make("KernelSize", 1))), - combine(framework::dataset::make("PadX", 0, 2), - combine(framework::dataset::make("PadY", 0, 2), - framework::dataset::make("KernelSize", 3)))); - -const auto data_f32 = combine(datasets::SmallDirectConvolutionShapes(), - combine(framework::dataset::make("StrideX", 1, 3), - combine(framework::dataset::make("StrideY", 1, 3), - combine(data_pad_f32, - framework::dataset::make("NumKernels", { 1, 4, 8, 16 }))))); - -const auto data_qs8 = combine(datasets::SmallDirectConvolutionShapes(), - combine(framework::dataset::make("StrideX", 1, 3), - combine(framework::dataset::make("StrideY", 1, 3), - combine(data_pad_qs8, - framework::dataset::make("NumKernels", { 1, 4, 8, 16 }))))); - -/** Direct convolution QS16 data set. */ -const auto data_qs16 = combine(datasets::SmallDirectConvolutionShapes(), - combine(framework::dataset::make("StrideX", 1, 3), - combine(framework::dataset::make("StrideY", 1, 3), - combine(framework::dataset::make("PadX", 0), - combine(framework::dataset::make("PadY", 0), - combine(framework::dataset::make("KernelSize", 1), - framework::dataset::make("NumKernels", { 1, 4, 8, 16 }))))))); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(DirectConvolutionLayer) - -//TODO(COMPMID-415): Configuration tests? - -template -using NEDirectConvolutionLayerFixture = DirectConvolutionValidationFixture; - -TEST_SUITE(Float) -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(Run, NEDirectConvolutionLayerFixture, framework::DatasetMode::ALL, combine(data_f32, framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fp16); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(Run, NEDirectConvolutionLayerFixture, framework::DatasetMode::ALL, combine(data_f32, framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fp32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using NEDirectConvolutionLayerFixedPointFixture = DirectConvolutionValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// We test for fixed point precision [4,6] -FIXTURE_DATA_TEST_CASE(Run, NEDirectConvolutionLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(data_qs8, framework::dataset::make("DataType", DataType::QS8)), - framework::dataset::make("FractionalBits", 4, 7))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// We test for fixed point precision [4,13] -FIXTURE_DATA_TEST_CASE(Run, NEDirectConvolutionLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(data_qs16, framework::dataset::make("DataType", DataType::QS16)), - framework::dataset::make("FractionalBits", 4, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/Floor.cpp b/tests/validation_new/NEON/Floor.cpp deleted file mode 100644 index e100c3035b..0000000000 --- a/tests/validation_new/NEON/Floor.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEFloor.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/FloorFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(NEON) -TEST_SUITE(Floor) - -template -using NEFloorFixture = FloorValidationFixture; - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEFloorFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEFloorFixture, framework::DatasetMode::NIGHTLY, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/FullyConnectedLayer.cpp b/tests/validation_new/NEON/FullyConnectedLayer.cpp deleted file mode 100644 index e859fb3872..0000000000 --- a/tests/validation_new/NEON/FullyConnectedLayer.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/FullyConnectedLayerDataset.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/FullyConnectedLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr AbsoluteTolerance tolerance_f32(0.001f); -#ifdef ARM_COMPUTE_ENABLE_FP16 -constexpr AbsoluteTolerance tolerance_f16(0.01f); -#endif /* ARM_COMPUTE_ENABLE_FP16*/ -/** Tolerance for fixed point operations */ -constexpr AbsoluteTolerance tolerance_fixed_point(1.f); - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 - DataType::F16, -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - DataType::F32, - DataType::QS8, - DataType::QS16, -}); - -const auto FullyConnectedParameters = combine(framework::dataset::make("TransposeWeights", { false, true }), framework::dataset::make("ReshapeWeights", { false, true })); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(FullyConnectedLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(framework::dataset::concat(datasets::SmallFullyConnectedLayerDataset(), datasets::LargeFullyConnectedLayerDataset()), - FullyConnectedParameters), - CNNDataTypes), - src_shape, weights_shape, bias_shape, dst_shape, transpose_weights, reshape_weights, data_type) -{ - // Set fixed point position data type allowed - int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - TensorShape ws(weights_shape); - - // Transpose weights if not done in the function - if(!reshape_weights || !transpose_weights) - { - const size_t shape_x = ws.x(); - ws.set(0, ws.y()); - ws.set(1, shape_x); - - // Weights have to be passed reshaped - // Transpose 1xW for batched version - if(!reshape_weights && dst_shape.y() > 1) - { - const float transpose_width = 16.0f / data_size_from_type(data_type); - const size_t shape_x = ws.x(); - ws.set(0, ws.y() * static_cast(transpose_width)); - ws.set(1, static_cast(std::ceil(shape_x / transpose_width))); - } - } - - // Create tensors - Tensor src = create_tensor(src_shape, data_type, 1, fixed_point_position); - Tensor weights = create_tensor(ws, data_type, 1, fixed_point_position); - Tensor bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); - Tensor dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function. - NEFullyConnectedLayer fc; - fc.configure(&src, &weights, &bias, &dst, transpose_weights, !reshape_weights); - - // Validate valid region - const ValidRegion dst_valid_region = shape_to_valid_region(dst_shape); - validate(dst.info()->valid_region(), dst_valid_region); -} - -template -using NEFullyConnectedLayerFixture = FullyConnectedLayerValidationFixture; - -TEST_SUITE(Float) -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEFullyConnectedLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEFullyConnectedLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallFullyConnectedLayerDataset(), FullyConnectedParameters), - framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeFullyConnectedLayerDataset(), FullyConnectedParameters), - framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using NEFullyConnectedLayerFixedPointFixture = FullyConnectedLayerValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 -FIXTURE_DATA_TEST_CASE(RunSmall, NEFullyConnectedLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fixed_point); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEFullyConnectedLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fixed_point); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 -FIXTURE_DATA_TEST_CASE(RunSmall, NEFullyConnectedLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fixed_point); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEFullyConnectedLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fixed_point); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/GEMM.cpp b/tests/validation_new/NEON/GEMM.cpp deleted file mode 100644 index 453b183d1e..0000000000 --- a/tests/validation_new/NEON/GEMM.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEGEMM.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/LargeGEMMDataset.h" -#include "tests/datasets_new/SmallGEMMDataset.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/GEMMFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance tolerance_f(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for floating point data types */ -constexpr AbsoluteTolerance tolerance_q(1.0f); /**< Tolerance value for comparing reference's output against implementation's output for fixed point data types */ - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 - DataType::F16, -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - DataType::F32, - DataType::QS8, - DataType::QS16, -}); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(GEMM) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallGEMMDataset(), datasets::LargeGEMMDataset()), CNNDataTypes), - shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type) -{ - // Set fixed point position data type allowed - const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - // Create tensors - Tensor a = create_tensor(shape_a, data_type, 1, fixed_point_position); - Tensor b = create_tensor(shape_b, data_type, 1, fixed_point_position); - Tensor c = create_tensor(shape_c, data_type, 1, fixed_point_position); - Tensor dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(c.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEGEMM gemm; - gemm.configure(&a, &b, &c, &dst, alpha, beta); - - //TODO(COMPMID-415): Validate valid region -} - -template -using NEGEMMFixture = GEMMValidationFixture; - -TEST_SUITE(Float) -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallGEMMDataset(), framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMDataset(), framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallGEMMDataset(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMDataset(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using NEGEMMFixedPointFixture = GEMMValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 7))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_q); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeGEMMDataset(), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 7))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_q); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_q); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeGEMMDataset(), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_q); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/L2Normalize.cpp b/tests/validation_new/NEON/L2Normalize.cpp deleted file mode 100644 index 20804d2a94..0000000000 --- a/tests/validation_new/NEON/L2Normalize.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEL2Normalize.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/L2NormalizeFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr RelativeTolerance tolerance_f32(0.00001f); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(L2Normalize) - -template -using NEL2NormalizeFixture = L2NormalizeValidationFixture; - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEL2NormalizeFixture, framework::DatasetMode::PRECOMMIT, - combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), framework::dataset::make("Epsilon", { 1e-12 }))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} - -FIXTURE_DATA_TEST_CASE(RunLarge, NEL2NormalizeFixture, framework::DatasetMode::NIGHTLY, - combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), framework::dataset::make("Epsilon", { 1e-12 }))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/MeanStdDev.cpp b/tests/validation_new/NEON/MeanStdDev.cpp deleted file mode 100644 index 6214261afb..0000000000 --- a/tests/validation_new/NEON/MeanStdDev.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/runtime/NEON/functions/NEMeanStdDev.h" -#include "framework/Macros.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/MeanStdDevFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr RelativeTolerance tolerance_rel_high_error(0.05f); -constexpr RelativeTolerance tolerance_rel_low_error(0.0005f); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(MeanStdDev) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - Tensor src = create_tensor(shape, data_type); - - // Create output variables - float mean = 0.f; - float std_dev = 0.f; - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create configure function - NEMeanStdDev mean_std_dev_image; - mean_std_dev_image.configure(&src, &mean, &std_dev); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); -} - -template -using NEMeanStdDevFixture = MeanStdDevValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, NEMeanStdDevFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate mean output - validate(_target.first, _reference.first); - - // Validate std_dev output - validate(_target.second, _reference.second, tolerance_rel_high_error); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEMeanStdDevFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate mean output - validate(_target.first, _reference.first, tolerance_rel_low_error); - - // Validate std_dev output - validate(_target.second, _reference.second, tolerance_rel_high_error); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/NormalizationLayer.cpp b/tests/validation_new/NEON/NormalizationLayer.cpp deleted file mode 100644 index 1da2ed0874..0000000000 --- a/tests/validation_new/NEON/NormalizationLayer.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NENormalizationLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/NormalizationTypesDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/NormalizationLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -#ifdef ARM_COMPUTE_ENABLE_FP16 -constexpr AbsoluteTolerance tolerance_f16(0.001f); -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -constexpr AbsoluteTolerance tolerance_f32(0.00001f); -/** Tolerance for fixed point operations */ -constexpr AbsoluteTolerance tolerance_qs8(2); -constexpr AbsoluteTolerance tolerance_qs16(3); - -/** Input data set. */ -const auto NormalizationDataset = combine(combine(combine(datasets::SmallShapes(), datasets::NormalizationTypes()), framework::dataset::make("NormalizationSize", 3, 9, 2)), - framework::dataset::make("Beta", { 0.5f, 1.f, 2.f })); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(NormalizationLayer) - -//TODO(COMPMID-415): Missing configuration? - -template -using NENormalizationLayerFixture = NormalizationValidationFixture; - -TEST_SUITE(Float) -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, NENormalizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NENormalizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NENormalizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NENormalizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using NENormalizationLayerFixedPointFixture = NormalizationValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 -FIXTURE_DATA_TEST_CASE(RunSmall, NENormalizationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(NormalizationDataset, framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs8); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NENormalizationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(NormalizationDataset, framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs8); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 -FIXTURE_DATA_TEST_CASE(RunSmall, NENormalizationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(NormalizationDataset, framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NENormalizationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(NormalizationDataset, framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs16); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/PoolingLayer.cpp b/tests/validation_new/NEON/PoolingLayer.cpp deleted file mode 100644 index 20fce3d73a..0000000000 --- a/tests/validation_new/NEON/PoolingLayer.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/PoolingTypesDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/PoolingLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Input data set for float data types */ -const auto PoolingLayerDatasetFP = combine(combine(datasets::PoolingTypes(), framework::dataset::make("PoolingSize", { 2, 3, 7 })), - framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) })); - -/** Input data set for quantized data types */ -const auto PoolingLayerDatasetQS = combine(combine(datasets::PoolingTypes(), framework::dataset::make("PoolingSize", { 2, 3 })), - framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) })); - -constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for float types */ -#ifdef ARM_COMPUTE_ENABLE_FP16 -constexpr AbsoluteTolerance tolerance_f16(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for float types */ -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -constexpr AbsoluteTolerance tolerance_qs8(0); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */ -constexpr AbsoluteTolerance tolerance_qs16(0); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */ -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(PoolingLayer) - -//TODO(COMPMID-415): Configuration tests? - -template -using NEPoolingLayerFixture = PoolingLayerValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType", - DataType::F32)))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType", - DataType::F32)))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() - -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP, - framework::dataset::make("DataType", DataType::F16)))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP, - framework::dataset::make("DataType", DataType::F16)))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -TEST_SUITE_END() - -template -using NEPoolingLayerFixedPointFixture = PoolingLayerValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS, - framework::dataset::make("DataType", DataType::QS8))), - framework::dataset::make("FractionalBits", 1, 5))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs8); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS, - framework::dataset::make("DataType", DataType::QS8))), - framework::dataset::make("FractionalBits", 1, 5))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs8); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS, - framework::dataset::make("DataType", DataType::QS16))), - framework::dataset::make("FractionalBits", 1, 13))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS, - framework::dataset::make("DataType", DataType::QS16))), - framework::dataset::make("FractionalBits", 1, 13))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs16); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/QuantizationLayer.cpp b/tests/validation_new/NEON/QuantizationLayer.cpp deleted file mode 100644 index 8b2acd6331..0000000000 --- a/tests/validation_new/NEON/QuantizationLayer.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEQuantizationLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/QuantizationLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for quantization */ -constexpr AbsoluteTolerance tolerance_u8(1); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(QuantizationLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), framework::dataset::make("DataType", DataType::F32)), shape, data_type) -{ - // Create tensors - Tensor src = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, DataType::U8); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEQuantizationLayer quant_layer; - quant_layer.configure(&src, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 8).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using NEQuantizationLayerFixture = QuantizationValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEQuantizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_u8); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEQuantizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_u8); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/ReductionOperation.cpp b/tests/validation_new/NEON/ReductionOperation.cpp deleted file mode 100644 index 4048af09e7..0000000000 --- a/tests/validation_new/NEON/ReductionOperation.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEReductionOperation.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ReductionOperationDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/ReductionOperationFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr RelativeTolerance tolerance_f32(0.00001f); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(ReductionOperation) - -template -using NEReductionOperationFixture = ReductionOperationValidationFixture; - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEReductionOperationFixture, framework::DatasetMode::PRECOMMIT, - combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), datasets::ReductionOperations())) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEReductionOperationFixture, framework::DatasetMode::NIGHTLY, - combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), datasets::ReductionOperations())) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/Scale.cpp b/tests/validation_new/NEON/Scale.cpp deleted file mode 100644 index 1036f98c23..0000000000 --- a/tests/validation_new/NEON/Scale.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEScale.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/BorderModeDataset.h" -#include "tests/datasets_new/InterpolationPolicyDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/ScaleFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(NEON) -TEST_SUITE(Scale) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), - framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - datasets::BorderModes()), - shape, data_type, policy, border_mode) -{ - std::mt19937 generator(library->seed()); - std::uniform_real_distribution distribution_float(0.25, 2); - const float scale_x = distribution_float(generator); - const float scale_y = distribution_float(generator); - uint8_t constant_border_value = 0; - if(border_mode == BorderMode::CONSTANT) - { - std::uniform_int_distribution distribution_u8(0, 255); - constant_border_value = distribution_u8(generator); - } - - // Create tensors - Tensor src = create_tensor(shape, data_type); - TensorShape shape_scaled(shape); - shape_scaled.set(0, shape[0] * scale_x); - shape_scaled.set(1, shape[1] * scale_y); - Tensor dst = create_tensor(shape_scaled, data_type); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEScale nescale; - nescale.configure(&src, &dst, policy, border_mode, constant_border_value); - - // Validate valid region - const ValidRegion dst_valid_region = calculate_valid_region_scale(*(src.info()), shape_scaled, policy, BorderSize(1), (border_mode == BorderMode::UNDEFINED)); - - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape_scaled.x(), 16); - calculator.set_border_mode(border_mode); - - const PaddingSize read_padding(1); - const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER); - validate(src.info()->padding(), read_padding); - validate(dst.info()->padding(), write_padding); -} - -template -using NEScaleFixture = ScaleValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8)), - framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - datasets::BorderModes())) -{ - //Create valid region - TensorInfo src_info(_shape, 1, _data_type); - ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED)); - - // Validate output - validate(Accessor(_target), _reference, valid_region); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8)), - framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - datasets::BorderModes())) -{ - //Create valid region - TensorInfo src_info(_shape, 1, _data_type); - ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED)); - - // Validate output - validate(Accessor(_target), _reference, valid_region); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/SoftmaxLayer.cpp b/tests/validation_new/NEON/SoftmaxLayer.cpp deleted file mode 100644 index 337ee29986..0000000000 --- a/tests/validation_new/NEON/SoftmaxLayer.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NESoftmaxLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/SoftmaxLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr AbsoluteTolerance tolerance_f32(0.000001f); -#ifdef ARM_COMPUTE_ENABLE_FP16 -constexpr AbsoluteTolerance tolerance_f16(0.0001f); -#endif /* ARM_COMPUTE_ENABLE_FP16*/ -/** Tolerance for fixed point operations */ -constexpr AbsoluteTolerance tolerance_fixed_point(2); - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 - DataType::F16, -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - DataType::F32, - DataType::QS8, - DataType::QS16, -}); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(SoftmaxLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), CNNDataTypes), shape, data_type) -{ - // Set fixed point position data type allowed - const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - // Create tensors - Tensor src = create_tensor(shape, data_type, 1, fixed_point_position); - Tensor dst = create_tensor(shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NESoftmaxLayer smx_layer; - smx_layer.configure(&src, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const int step = 16 / data_size_from_type(data_type); - const PaddingSize padding = PaddingCalculator(shape.x(), step).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using NESoftmaxLayerFixture = SoftmaxValidationFixture; - -TEST_SUITE(Float) -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, NESoftmaxLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NESoftmaxLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NESoftmaxLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NESoftmaxLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using NESoftmaxLayerFixedPointFixture = SoftmaxValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 -FIXTURE_DATA_TEST_CASE(RunSmall, NESoftmaxLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fixed_point); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NESoftmaxLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fixed_point); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 -FIXTURE_DATA_TEST_CASE(RunSmall, NESoftmaxLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fixed_point); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NESoftmaxLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fixed_point); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/Validation.cpp b/tests/validation_new/Validation.cpp deleted file mode 100644 index fec7c10939..0000000000 --- a/tests/validation_new/Validation.cpp +++ /dev/null @@ -1,307 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "Validation.h" - -#include "arm_compute/core/Coordinates.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/runtime/Tensor.h" -#include "tests/validation/half.h" - -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Get the data from *ptr after casting according to @p data_type and then convert the data to double. - * - * @param[in] ptr Pointer to value. - * @param[in] data_type Data type of both values. - * - * @return The data from the ptr after converted to double. - */ -double get_double_data(const void *ptr, DataType data_type) -{ - if(ptr == nullptr) - { - ARM_COMPUTE_ERROR("Can't dereference a null pointer!"); - } - - switch(data_type) - { - case DataType::U8: - return *reinterpret_cast(ptr); - case DataType::S8: - return *reinterpret_cast(ptr); - case DataType::QS8: - return *reinterpret_cast(ptr); - case DataType::U16: - return *reinterpret_cast(ptr); - case DataType::S16: - return *reinterpret_cast(ptr); - case DataType::QS16: - return *reinterpret_cast(ptr); - case DataType::U32: - return *reinterpret_cast(ptr); - case DataType::S32: - return *reinterpret_cast(ptr); - case DataType::U64: - return *reinterpret_cast(ptr); - case DataType::S64: - return *reinterpret_cast(ptr); - case DataType::F16: - return *reinterpret_cast(ptr); - case DataType::F32: - return *reinterpret_cast(ptr); - case DataType::F64: - return *reinterpret_cast(ptr); - case DataType::SIZET: - return *reinterpret_cast(ptr); - default: - ARM_COMPUTE_ERROR("NOT SUPPORTED!"); - } -} - -void check_border_element(const IAccessor &tensor, const Coordinates &id, - const BorderMode &border_mode, const void *border_value, - int64_t &num_elements, int64_t &num_mismatches) -{ - const size_t channel_size = element_size_from_data_type(tensor.data_type()); - const auto ptr = static_cast(tensor(id)); - - if(border_mode == BorderMode::REPLICATE) - { - Coordinates border_id{ id }; - - if(id.x() < 0) - { - border_id.set(0, 0); - } - else if(static_cast(id.x()) >= tensor.shape().x()) - { - border_id.set(0, tensor.shape().x() - 1); - } - - if(id.y() < 0) - { - border_id.set(1, 0); - } - else if(static_cast(id.y()) >= tensor.shape().y()) - { - border_id.set(1, tensor.shape().y() - 1); - } - - border_value = tensor(border_id); - } - - // Iterate over all channels within one element - for(int channel = 0; channel < tensor.num_channels(); ++channel) - { - const size_t channel_offset = channel * channel_size; - const double target = get_double_data(ptr + channel_offset, tensor.data_type()); - const double reference = get_double_data(static_cast(border_value) + channel_offset, tensor.data_type()); - - if(!compare, double>(target, reference)) - { - ARM_COMPUTE_TEST_INFO("id = " << id); - ARM_COMPUTE_TEST_INFO("channel = " << channel); - ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << target); - ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << reference); - ARM_COMPUTE_EXPECT_EQUAL(target, reference, framework::LogLevel::DEBUG); - - ++num_mismatches; - } - - ++num_elements; - } -} -} // namespace - -void validate(const arm_compute::ValidRegion ®ion, const arm_compute::ValidRegion &reference) -{ - ARM_COMPUTE_EXPECT_EQUAL(region.anchor.num_dimensions(), reference.anchor.num_dimensions(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT_EQUAL(region.shape.num_dimensions(), reference.shape.num_dimensions(), framework::LogLevel::ERRORS); - - for(unsigned int d = 0; d < region.anchor.num_dimensions(); ++d) - { - ARM_COMPUTE_EXPECT_EQUAL(region.anchor[d], reference.anchor[d], framework::LogLevel::ERRORS); - } - - for(unsigned int d = 0; d < region.shape.num_dimensions(); ++d) - { - ARM_COMPUTE_EXPECT_EQUAL(region.shape[d], reference.shape[d], framework::LogLevel::ERRORS); - } -} - -void validate(const arm_compute::PaddingSize &padding, const arm_compute::PaddingSize &reference) -{ - ARM_COMPUTE_EXPECT_EQUAL(padding.top, reference.top, framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT_EQUAL(padding.right, reference.right, framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT_EQUAL(padding.bottom, reference.bottom, framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT_EQUAL(padding.left, reference.left, framework::LogLevel::ERRORS); -} - -void validate(const IAccessor &tensor, const void *reference_value) -{ - ARM_COMPUTE_ASSERT(reference_value != nullptr); - - int64_t num_mismatches = 0; - int64_t num_elements = 0; - const size_t channel_size = element_size_from_data_type(tensor.data_type()); - - // Iterate over all elements, e.g. U8, S16, RGB888, ... - for(int element_idx = 0; element_idx < tensor.num_elements(); ++element_idx) - { - const Coordinates id = index2coord(tensor.shape(), element_idx); - - const auto ptr = static_cast(tensor(id)); - - // Iterate over all channels within one element - for(int channel = 0; channel < tensor.num_channels(); ++channel) - { - const size_t channel_offset = channel * channel_size; - const double target = get_double_data(ptr + channel_offset, tensor.data_type()); - const double reference = get_double_data(reference_value, tensor.data_type()); - - if(!compare, double>(target, reference)) - { - ARM_COMPUTE_TEST_INFO("id = " << id); - ARM_COMPUTE_TEST_INFO("channel = " << channel); - ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << target); - ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << reference); - ARM_COMPUTE_EXPECT_EQUAL(target, reference, framework::LogLevel::DEBUG); - - ++num_mismatches; - } - - ++num_elements; - } - } - - if(num_elements > 0) - { - const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; - - ARM_COMPUTE_TEST_INFO(num_mismatches << " values (" << std::fixed << std::setprecision(2) << percent_mismatches << "%) mismatched"); - ARM_COMPUTE_EXPECT_EQUAL(num_mismatches, 0, framework::LogLevel::ERRORS); - } -} - -void validate(const IAccessor &tensor, BorderSize border_size, const BorderMode &border_mode, const void *border_value) -{ - if(border_mode == BorderMode::UNDEFINED) - { - return; - } - else if(border_mode == BorderMode::CONSTANT) - { - ARM_COMPUTE_ASSERT(border_value != nullptr); - } - - int64_t num_mismatches = 0; - int64_t num_elements = 0; - const int slice_size = tensor.shape()[0] * tensor.shape()[1]; - - for(int element_idx = 0; element_idx < tensor.num_elements(); element_idx += slice_size) - { - Coordinates id = index2coord(tensor.shape(), element_idx); - - // Top border - for(int y = -border_size.top; y < 0; ++y) - { - id.set(1, y); - - for(int x = -border_size.left; x < static_cast(tensor.shape()[0]) + static_cast(border_size.right); ++x) - { - id.set(0, x); - - check_border_element(tensor, id, border_mode, border_value, num_elements, num_mismatches); - } - } - - // Bottom border - for(int y = tensor.shape()[1]; y < static_cast(tensor.shape()[1]) + static_cast(border_size.bottom); ++y) - { - id.set(1, y); - - for(int x = -border_size.left; x < static_cast(tensor.shape()[0]) + static_cast(border_size.right); ++x) - { - id.set(0, x); - - check_border_element(tensor, id, border_mode, border_value, num_elements, num_mismatches); - } - } - - // Left/right border - for(int y = 0; y < static_cast(tensor.shape()[1]); ++y) - { - id.set(1, y); - - // Left border - for(int x = -border_size.left; x < 0; ++x) - { - id.set(0, x); - - check_border_element(tensor, id, border_mode, border_value, num_elements, num_mismatches); - } - - // Right border - for(int x = tensor.shape()[0]; x < static_cast(tensor.shape()[0]) + static_cast(border_size.right); ++x) - { - id.set(0, x); - - check_border_element(tensor, id, border_mode, border_value, num_elements, num_mismatches); - } - } - } - - if(num_elements > 0) - { - const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; - - ARM_COMPUTE_TEST_INFO(num_mismatches << " values (" << std::fixed << std::setprecision(2) << percent_mismatches << "%) mismatched"); - ARM_COMPUTE_EXPECT_EQUAL(num_mismatches, 0, framework::LogLevel::ERRORS); - } -} - -void validate(std::vector classified_labels, std::vector expected_labels) -{ - ARM_COMPUTE_EXPECT_EQUAL(classified_labels.size(), expected_labels.size(), framework::LogLevel::ERRORS); - - for(unsigned int i = 0; i < expected_labels.size(); ++i) - { - ARM_COMPUTE_EXPECT_EQUAL(classified_labels[i], expected_labels[i], framework::LogLevel::ERRORS); - } -} -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/Validation.h b/tests/validation_new/Validation.h deleted file mode 100644 index d3c3541982..0000000000 --- a/tests/validation_new/Validation.h +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_VALIDATION_H__ -#define __ARM_COMPUTE_TEST_VALIDATION_H__ - -#include "SimpleTensor.h" -#include "arm_compute/core/FixedPoint.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Exceptions.h" -#include "tests/IAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/Utils.h" - -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -/** Class reprensenting an absolute tolerance value. */ -template -class AbsoluteTolerance -{ -public: - /** Underlying type. */ - using value_type = T; - - /* Default constructor. - * - * Initialises the tolerance to 0. - */ - AbsoluteTolerance() = default; - - /** Constructor. - * - * @param[in] value Absolute tolerance value. - */ - explicit constexpr AbsoluteTolerance(T value) - : _value{ value } - { - } - - /** Implicit conversion to the underlying type. */ - constexpr operator T() const - { - return _value; - } - -private: - T _value{ std::numeric_limits::epsilon() }; -}; - -/** Class reprensenting a relative tolerance value. */ -class RelativeTolerance -{ -public: - /** Underlying type. */ - using value_type = double; - - /* Default constructor. - * - * Initialises the tolerance to 0. - */ - RelativeTolerance() = default; - - /** Constructor. - * - * @param[in] value Relative tolerance value. - */ - explicit constexpr RelativeTolerance(value_type value) - : _value{ value } - { - } - - /** Implicit conversion to the underlying type. */ - constexpr operator value_type() const - { - return _value; - } - -private: - value_type _value{ 0 }; -}; - -/** Print AbsoluteTolerance type. */ -template -inline ::std::ostream &operator<<(::std::ostream &os, const AbsoluteTolerance &tolerance) -{ - os << static_cast::value_type>(tolerance); - - return os; -} - -/** Print RelativeTolerance type. */ -inline ::std::ostream &operator<<(::std::ostream &os, const RelativeTolerance &tolerance) -{ - os << static_cast(tolerance); - - return os; -} - -template -bool compare_dimensions(const Dimensions &dimensions1, const Dimensions &dimensions2) -{ - if(dimensions1.num_dimensions() != dimensions2.num_dimensions()) - { - return false; - } - - for(unsigned int i = 0; i < dimensions1.num_dimensions(); ++i) - { - if(dimensions1[i] != dimensions2[i]) - { - return false; - } - } - - return true; -} - -/** Validate valid regions. - * - * - Dimensionality has to be the same. - * - Anchors have to match. - * - Shapes have to match. - */ -void validate(const arm_compute::ValidRegion ®ion, const arm_compute::ValidRegion &reference); - -/** Validate padding. - * - * Padding on all sides has to be the same. - */ -void validate(const arm_compute::PaddingSize &padding, const arm_compute::PaddingSize &reference); - -/** Validate tensors. - * - * - Dimensionality has to be the same. - * - All values have to match. - * - * @note: wrap_range allows cases where reference tensor rounds up to the wrapping point, causing it to wrap around to - * zero while the test tensor stays at wrapping point to pass. This may permit true erroneous cases (difference between - * reference tensor and test tensor is multiple of wrap_range), but such errors would be detected by - * other test cases. - */ -template > -void validate(const IAccessor &tensor, const SimpleTensor &reference, U tolerance_value = U(), float tolerance_number = 0.f); - -/** Validate tensors with valid region. - * - * - Dimensionality has to be the same. - * - All values have to match. - * - * @note: wrap_range allows cases where reference tensor rounds up to the wrapping point, causing it to wrap around to - * zero while the test tensor stays at wrapping point to pass. This may permit true erroneous cases (difference between - * reference tensor and test tensor is multiple of wrap_range), but such errors would be detected by - * other test cases. - */ -template > -void validate(const IAccessor &tensor, const SimpleTensor &reference, const ValidRegion &valid_region, U tolerance_value = U(), float tolerance_number = 0.f); - -/** Validate tensors against constant value. - * - * - All values have to match. - */ -void validate(const IAccessor &tensor, const void *reference_value); - -/** Validate border against a constant value. - * - * - All border values have to match the specified value if mode is CONSTANT. - * - All border values have to be replicated if mode is REPLICATE. - * - Nothing is validated for mode UNDEFINED. - */ -void validate(const IAccessor &tensor, BorderSize border_size, const BorderMode &border_mode, const void *border_value); - -/** Validate classified labels against expected ones. - * - * - All values should match - */ -void validate(std::vector classified_labels, std::vector expected_labels); - -/** Validate float value. - * - * - All values should match - */ -template -void validate(T target, T reference, U tolerance = AbsoluteTolerance()); - -template -struct compare_base -{ - compare_base(typename T::value_type target, typename T::value_type reference, T tolerance = T(0)) - : _target{ target }, _reference{ reference }, _tolerance{ tolerance } - { - } - - typename T::value_type _target{}; - typename T::value_type _reference{}; - T _tolerance{}; -}; - -template -struct compare; - -template -struct compare, U> : public compare_base> -{ - using compare_base>::compare_base; - - operator bool() const - { - if(!std::isfinite(this->_target) || !std::isfinite(this->_reference)) - { - return false; - } - else if(this->_target == this->_reference) - { - return true; - } - - return static_cast(std::abs(this->_target - this->_reference)) <= static_cast(this->_tolerance); - } -}; - -template -struct compare : public compare_base -{ - using compare_base::compare_base; - - operator bool() const - { - if(!std::isfinite(_target) || !std::isfinite(_reference)) - { - return false; - } - else if(_target == _reference) - { - return true; - } - - const double relative_change = std::abs(static_cast(_target - _reference)) / _reference; - - return relative_change <= _tolerance; - } -}; - -template -void validate(const IAccessor &tensor, const SimpleTensor &reference, U tolerance_value, float tolerance_number) -{ - // Validate with valid region covering the entire shape - validate(tensor, reference, shape_to_valid_region(tensor.shape()), tolerance_value, tolerance_number); -} - -template -void validate(const IAccessor &tensor, const SimpleTensor &reference, const ValidRegion &valid_region, U tolerance_value, float tolerance_number) -{ - int64_t num_mismatches = 0; - int64_t num_elements = 0; - - ARM_COMPUTE_EXPECT_EQUAL(tensor.element_size(), reference.element_size(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT_EQUAL(tensor.data_type(), reference.data_type(), framework::LogLevel::ERRORS); - - if(reference.format() != Format::UNKNOWN) - { - ARM_COMPUTE_EXPECT_EQUAL(tensor.format(), reference.format(), framework::LogLevel::ERRORS); - } - - ARM_COMPUTE_EXPECT_EQUAL(tensor.num_channels(), reference.num_channels(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(compare_dimensions(tensor.shape(), reference.shape()), framework::LogLevel::ERRORS); - - const int min_elements = std::min(tensor.num_elements(), reference.num_elements()); - const int min_channels = std::min(tensor.num_channels(), reference.num_channels()); - - // Iterate over all elements within valid region, e.g. U8, S16, RGB888, ... - for(int element_idx = 0; element_idx < min_elements; ++element_idx) - { - const Coordinates id = index2coord(reference.shape(), element_idx); - - if(is_in_valid_region(valid_region, id)) - { - // Iterate over all channels within one element - for(int c = 0; c < min_channels; ++c) - { - const T &target_value = reinterpret_cast(tensor(id))[c]; - const T &reference_value = reinterpret_cast(reference(id))[c]; - - if(!compare(target_value, reference_value, tolerance_value)) - { - ARM_COMPUTE_TEST_INFO("id = " << id); - ARM_COMPUTE_TEST_INFO("channel = " << c); - ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target_value)); - ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference_value)); - ARM_COMPUTE_TEST_INFO("tolerance = " << std::setprecision(5) << framework::make_printable(static_cast(tolerance_value))); - ARM_COMPUTE_EXPECT_EQUAL(target_value, reference_value, framework::LogLevel::DEBUG); - - ++num_mismatches; - } - - ++num_elements; - } - } - } - - if(num_elements > 0) - { - const int64_t absolute_tolerance_number = tolerance_number * num_elements; - const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; - - ARM_COMPUTE_TEST_INFO(num_mismatches << " values (" << std::fixed << std::setprecision(2) << percent_mismatches - << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)"); - ARM_COMPUTE_EXPECT(num_mismatches <= absolute_tolerance_number, framework::LogLevel::ERRORS); - } -} - -template -void validate(T target, T reference, U tolerance) -{ - ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference)); - ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target)); - ARM_COMPUTE_TEST_INFO("tolerance = " << std::setprecision(5) << framework::make_printable(static_cast(tolerance))); - ARM_COMPUTE_EXPECT((compare(target, reference, tolerance)), framework::LogLevel::ERRORS); -} -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_H__ */ diff --git a/tests/validation_new/fixtures/ActivationLayerFixture.h b/tests/validation_new/fixtures/ActivationLayerFixture.h deleted file mode 100644 index bf0e7ba6ea..0000000000 --- a/tests/validation_new/fixtures/ActivationLayerFixture.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_ACTIVATION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_ACTIVATION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/ActivationLayer.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class ActivationValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, bool in_place, ActivationLayerInfo::ActivationFunction function, float alpha_beta, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - _data_type = data_type; - _function = function; - - ActivationLayerInfo info(function, alpha_beta, alpha_beta); - - _target = compute_target(shape, in_place, info, data_type, fractional_bits); - _reference = compute_reference(shape, info, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor) - { - if(is_data_type_float(_data_type)) - { - float min_bound = 0; - float max_bound = 0; - std::tie(min_bound, max_bound) = get_activation_layer_test_bounds(_function, _data_type); - std::uniform_real_distribution<> distribution(min_bound, max_bound); - library->fill(tensor, distribution, 0); - } - else - { - int min_bound = 0; - int max_bound = 0; - std::tie(min_bound, max_bound) = get_activation_layer_test_bounds(_function, _data_type, _fractional_bits); - std::uniform_int_distribution<> distribution(min_bound, max_bound); - library->fill(tensor, distribution, 0); - } - } - - TensorType compute_target(const TensorShape &shape, bool in_place, ActivationLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create tensors - TensorType src = create_tensor(shape, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(shape, data_type, 1, fixed_point_position); - - // Create and configure function - FunctionType act_layer; - - TensorType *dst_ptr = in_place ? &src : &dst; - - act_layer.configure(&src, dst_ptr, info); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - - if(!in_place) - { - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - } - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - act_layer.run(); - - if(in_place) - { - return src; - } - else - { - return dst; - } - } - - SimpleTensor compute_reference(const TensorShape &shape, ActivationLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create reference - SimpleTensor src{ shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src); - - return reference::activation_layer(src, info); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; - DataType _data_type{}; - ActivationLayerInfo::ActivationFunction _function{}; -}; - -template -class ActivationValidationFixture : public ActivationValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, bool in_place, ActivationLayerInfo::ActivationFunction function, float alpha_beta, DataType data_type) - { - ActivationValidationFixedPointFixture::setup(shape, in_place, function, alpha_beta, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ACTIVATION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/BitwiseAndFixture.h b/tests/validation_new/fixtures/BitwiseAndFixture.h deleted file mode 100644 index 1769ecdb1f..0000000000 --- a/tests/validation_new/fixtures/BitwiseAndFixture.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_BITWISE_AND_FIXTURE -#define ARM_COMPUTE_TEST_BITWISE_AND_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/BitwiseAnd.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class BitwiseAndValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor, int i) - { - library->fill_tensor_uniform(tensor, i); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src1 = create_tensor(shape, data_type); - TensorType src2 = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType bitwise_and; - - bitwise_and.configure(&src1, &src2, &dst); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src1), 0); - fill(AccessorType(src2), 1); - - // Compute function - bitwise_and.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src1{ shape, data_type }; - SimpleTensor src2{ shape, data_type }; - - // Fill reference - fill(src1, 0); - fill(src2, 1); - - return reference::bitwise_and(src1, src2); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_BITWISE_AND_FIXTURE */ diff --git a/tests/validation_new/fixtures/BitwiseNotFixture.h b/tests/validation_new/fixtures/BitwiseNotFixture.h deleted file mode 100644 index 5954c8639e..0000000000 --- a/tests/validation_new/fixtures/BitwiseNotFixture.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_BITWISE_NOT_FIXTURE -#define ARM_COMPUTE_TEST_BITWISE_NOT_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/BitwiseNot.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class BitwiseNotValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType bitwise_not; - - bitwise_not.configure(&src, &dst); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - bitwise_not.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - return reference::bitwise_not(src); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_BITWISE_NOT_FIXTURE */ diff --git a/tests/validation_new/fixtures/BitwiseOrFixture.h b/tests/validation_new/fixtures/BitwiseOrFixture.h deleted file mode 100644 index b39b46e813..0000000000 --- a/tests/validation_new/fixtures/BitwiseOrFixture.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_BITWISE_OR_FIXTURE -#define ARM_COMPUTE_TEST_BITWISE_OR_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/BitwiseOr.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class BitwiseOrValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor, int i) - { - library->fill_tensor_uniform(tensor, i); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src1 = create_tensor(shape, data_type); - TensorType src2 = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType bitwise_or; - - bitwise_or.configure(&src1, &src2, &dst); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src1), 0); - fill(AccessorType(src2), 1); - - // Compute function - bitwise_or.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src1{ shape, data_type }; - SimpleTensor src2{ shape, data_type }; - - // Fill reference - fill(src1, 0); - fill(src2, 1); - - return reference::bitwise_or(src1, src2); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_BITWISE_OR_FIXTURE */ diff --git a/tests/validation_new/fixtures/BitwiseXorFixture.h b/tests/validation_new/fixtures/BitwiseXorFixture.h deleted file mode 100644 index 1dfbf1f784..0000000000 --- a/tests/validation_new/fixtures/BitwiseXorFixture.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_BITWISE_XOR_FIXTURE -#define ARM_COMPUTE_TEST_BITWISE_XOR_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/BitwiseXor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class BitwiseXorValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor, int i) - { - library->fill_tensor_uniform(tensor, i); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src1 = create_tensor(shape, data_type); - TensorType src2 = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType bitwise_xor; - - bitwise_xor.configure(&src1, &src2, &dst); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src1), 0); - fill(AccessorType(src2), 1); - - // Compute function - bitwise_xor.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src1{ shape, data_type }; - SimpleTensor src2{ shape, data_type }; - - // Fill reference - fill(src1, 0); - fill(src2, 1); - - return reference::bitwise_xor(src1, src2); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_BITWISE_XOR_FIXTURE */ diff --git a/tests/validation_new/fixtures/ConvolutionLayerFixture.h b/tests/validation_new/fixtures/ConvolutionLayerFixture.h deleted file mode 100644 index 25a53d0c1d..0000000000 --- a/tests/validation_new/fixtures/ConvolutionLayerFixture.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_CONVOLUTION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_CONVOLUTION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/ConvolutionLayer.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class ConvolutionValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, PadStrideInfo info, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - _data_type = data_type; - - _target = compute_target(input_shape, weights_shape, bias_shape, output_shape, info, data_type, fractional_bits); - _reference = compute_reference(input_shape, weights_shape, bias_shape, output_shape, info, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor, int i) - { - switch(tensor.data_type()) - { - case DataType::F16: - case DataType::F32: - { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); - library->fill(tensor, distribution, i); - break; - } - default: - library->fill_tensor_uniform(tensor, i); - } - } - - TensorType compute_target(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, const PadStrideInfo &info, - DataType data_type, int fixed_point_position) - { - // Create tensors - TensorType src = create_tensor(input_shape, data_type, 1, fixed_point_position); - TensorType weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); - TensorType bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - // Create and configure function - FunctionType conv; - conv.configure(&src, &weights, &bias, &dst, info); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - weights.allocator()->allocate(); - bias.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src), 0); - fill(AccessorType(weights), 1); - fill(AccessorType(bias), 2); - - // Compute NEConvolutionLayer function - conv.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, const PadStrideInfo &info, - DataType data_type, int fixed_point_position) - { - // Create reference - SimpleTensor src{ input_shape, data_type, 1, fixed_point_position }; - SimpleTensor weights{ weights_shape, data_type, 1, fixed_point_position }; - SimpleTensor bias{ bias_shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src, 0); - fill(weights, 1); - fill(bias, 2); - - return reference::convolution_layer(src, weights, bias, output_shape, info); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; - DataType _data_type{}; -}; - -template -class ConvolutionValidationFixture : public ConvolutionValidationFixedPointFixture -{ -public: - template - void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, PadStrideInfo info, DataType data_type) - { - ConvolutionValidationFixedPointFixture::setup(input_shape, weights_shape, bias_shape, output_shape, info, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_CONVOLUTION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/DepthConcatenateLayerFixture.h b/tests/validation_new/fixtures/DepthConcatenateLayerFixture.h deleted file mode 100644 index 601758f80e..0000000000 --- a/tests/validation_new/fixtures/DepthConcatenateLayerFixture.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/DepthConcatenateLayer.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -class ITensor; -class Tensor; -class ICLTensor; -class CLTensor; - -namespace test -{ -namespace validation -{ -template -class DepthConcatenateValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - // Create input shapes - std::mt19937 gen(library->seed()); - std::uniform_int_distribution<> num_dis(2, 6); - const int num_tensors = num_dis(gen); - - std::vector shapes(num_tensors, shape); - std::uniform_int_distribution<> depth_dis(1, 7); - std::bernoulli_distribution mutate_dis(0.25f); - std::uniform_real_distribution<> change_dis(-0.25f, 0.f); - - // Generate more shapes based on the input - for(auto &s : shapes) - { - // Set the depth of the tensor - s.set(2, depth_dis(gen)); - - // Randomly change the first dimension - if(mutate_dis(gen)) - { - // Decrease the dimension by a small percentage. Don't increase - // as that could make tensor too large. Also the change must be - // an even number. Otherwise out depth concatenate fails. - s.set(0, s[0] + 2 * static_cast(s[0] * change_dis(gen))); - } - - // Repeat the same as above for the second dimension - if(mutate_dis(gen)) - { - s.set(1, s[1] + 2 * static_cast(s[1] * change_dis(gen))); - } - } - - _target = compute_target(shapes, data_type); - _reference = compute_reference(shapes, data_type); - } - -protected: - template - void fill(U &&tensor, int i) - { - library->fill_tensor_uniform(tensor, i); - } - - TensorType compute_target(std::vector shapes, DataType data_type) - { - using ITensorType = typename std::conditional::value, ITensor, ICLTensor>::type; - - std::vector srcs; - std::vector src_ptrs; - - // Create tensors - srcs.reserve(shapes.size()); - - for(const auto &shape : shapes) - { - srcs.emplace_back(create_tensor(shape, data_type, 1, _fractional_bits)); - src_ptrs.emplace_back(&srcs.back()); - } - - TensorShape dst_shape = calculate_depth_concatenate_shape(shapes); - TensorType dst = create_tensor(dst_shape, data_type, 1, _fractional_bits); - - // Create and configure function - FunctionType depth_concat; - depth_concat.configure(src_ptrs, &dst); - - for(auto &src : srcs) - { - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - } - - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - for(auto &src : srcs) - { - src.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - } - - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - int i = 0; - for(auto &src : srcs) - { - fill(AccessorType(src), i++); - } - - // Compute function - depth_concat.run(); - - return dst; - } - - SimpleTensor compute_reference(std::vector shapes, DataType data_type) - { - std::vector> srcs; - - // Create and fill tensors - int i = 0; - for(const auto &shape : shapes) - { - srcs.emplace_back(shape, data_type, 1, _fractional_bits); - fill(srcs.back(), i++); - } - - return reference::depthconcatenate_layer(srcs); - } - - TensorType _target{}; - SimpleTensor _reference{}; - -private: - int _fractional_bits{ 1 }; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/DepthwiseConvolutionFixture.h b/tests/validation_new/fixtures/DepthwiseConvolutionFixture.h deleted file mode 100644 index b745c7e53c..0000000000 --- a/tests/validation_new/fixtures/DepthwiseConvolutionFixture.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_FIXTURE -#define ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/DepthwiseConvolution.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class DepthwiseConvolutionValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape in_shape, TensorShape weights_shape, TensorShape out_shape, PadStrideInfo pad_stride_info) - { - _target = compute_target(in_shape, weights_shape, out_shape, pad_stride_info); - _reference = compute_reference(in_shape, weights_shape, out_shape, pad_stride_info); - } - -protected: - template - void fill(U &&tensor, int i) - { - switch(tensor.data_type()) - { - case DataType::F32: - { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); - library->fill(tensor, distribution, i); - break; - } - default: - library->fill_tensor_uniform(tensor, i); - } - } - - TensorType compute_target(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &output_shape, PadStrideInfo &pad_stride_info) - { - // Create tensors - TensorType src = create_tensor(input_shape, DataType::F32); - TensorType weights = create_tensor(weights_shape, DataType::F32); - TensorType dst = create_tensor(output_shape, DataType::F32); - - // Create Depthwise Convolution configure function - CLDepthwiseConvolution depthwise_convolution; - depthwise_convolution.configure(&src, &dst, &weights, pad_stride_info); - - // Allocate tensors - src.allocator()->allocate(); - weights.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src), 0); - fill(AccessorType(weights), 1); - - // Compute function - depthwise_convolution.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &in_shape, const TensorShape &weights_shape, const TensorShape &out_shape, const PadStrideInfo &pad_stride_info) - { - SimpleTensor src(in_shape, DataType::F32); - SimpleTensor weights(weights_shape, DataType::F32); - - fill(src, 0); - fill(weights, 1); - - return reference::depthwise_convolution(src, weights, out_shape, pad_stride_info); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_FIXTURE */ diff --git a/tests/validation_new/fixtures/DepthwiseSeparableConvolutionLayerFixture.h b/tests/validation_new/fixtures/DepthwiseSeparableConvolutionLayerFixture.h deleted file mode 100644 index c2578a9ce0..0000000000 --- a/tests/validation_new/fixtures/DepthwiseSeparableConvolutionLayerFixture.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class DepthwiseSeparableConvolutionValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape in_shape, TensorShape depthwise_weights_shape, TensorShape depthwise_out_shape, TensorShape pointwise_weights_shape, TensorShape biases_shape, TensorShape output_shape, - PadStrideInfo pad_stride_depthwise_info, PadStrideInfo pad_stride_pointwise_info) - { - _target = compute_target(in_shape, depthwise_weights_shape, depthwise_out_shape, pointwise_weights_shape, biases_shape, output_shape, pad_stride_depthwise_info, pad_stride_pointwise_info); - _reference = compute_reference(in_shape, depthwise_weights_shape, depthwise_out_shape, pointwise_weights_shape, biases_shape, output_shape, pad_stride_depthwise_info, pad_stride_pointwise_info); - } - -protected: - template - void fill(U &&tensor, int i) - { - switch(tensor.data_type()) - { - case DataType::F32: - { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); - library->fill(tensor, distribution, i); - break; - } - default: - library->fill_tensor_uniform(tensor, i); - } - } - - TensorType compute_target(const TensorShape &input_shape, const TensorShape &depthwise_weights_shape, const TensorShape &depthwise_out_shape, const TensorShape &pointwise_weights_shape, - const TensorShape &biases_shape, - const TensorShape &output_shape, const PadStrideInfo &pad_stride_depthwise_info, const PadStrideInfo &pad_stride_pointwise_info) - { - // Create tensors - TensorType src = create_tensor(input_shape, DataType::F32); - TensorType depthwise_weights = create_tensor(depthwise_weights_shape, DataType::F32); - TensorType depthwise_out = create_tensor(depthwise_out_shape, DataType::F32); - TensorType pointwise_weights = create_tensor(pointwise_weights_shape, DataType::F32); - TensorType biases = create_tensor(biases_shape, DataType::F32); - TensorType dst = create_tensor(output_shape, DataType::F32); - - // Create Depthwise Separable Convolution Layer configure function - CLDepthwiseSeparableConvolutionLayer depthwise_separable_convolution_layer; - depthwise_separable_convolution_layer.configure(&src, &depthwise_weights, &depthwise_out, &pointwise_weights, &biases, &dst, pad_stride_depthwise_info, pad_stride_pointwise_info); - - // Allocate tensors - src.allocator()->allocate(); - depthwise_weights.allocator()->allocate(); - depthwise_out.allocator()->allocate(); - pointwise_weights.allocator()->allocate(); - biases.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!depthwise_weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!depthwise_out.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!pointwise_weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!biases.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src), 0); - fill(AccessorType(depthwise_weights), 1); - fill(AccessorType(pointwise_weights), 2); - fill(AccessorType(biases), 3); - - // Compute function - depthwise_separable_convolution_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &in_shape, const TensorShape &depthwise_weights_shape, const TensorShape &depthwise_out_shape, const TensorShape &pointwise_weights_shape, - const TensorShape &biases_shape, const TensorShape &dst_shape, const PadStrideInfo &pad_stride_depthwise_info, const PadStrideInfo &pad_stride_pointwise_info) - { - SimpleTensor src(in_shape, DataType::F32); - SimpleTensor depthwise_weights(depthwise_weights_shape, DataType::F32); - SimpleTensor pointwise_weights(pointwise_weights_shape, DataType::F32); - SimpleTensor biases(biases_shape, DataType::F32); - - fill(src, 0); - fill(depthwise_weights, 1); - fill(pointwise_weights, 2); - fill(biases, 3); - - return reference::depthwise_separable_convolution_layer(src, depthwise_weights, depthwise_out_shape, pointwise_weights, biases, dst_shape, pad_stride_depthwise_info, pad_stride_pointwise_info); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/DequantizationLayerFixture.h b/tests/validation_new/fixtures/DequantizationLayerFixture.h deleted file mode 100644 index 35c536d6a0..0000000000 --- a/tests/validation_new/fixtures/DequantizationLayerFixture.h +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/DequantizationLayer.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class DequantizationValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - // Initialize random min and max values - rand_min_max(&_min, &_max); - - _target = compute_target(shape, data_type, _min, _max); - _reference = compute_reference(shape, data_type, _min, _max); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type, float min, float max) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, DataType::F32); - - // Create and configure function - FunctionType dequantization_layer; - dequantization_layer.configure(&src, &dst, &min, &max); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - dequantization_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type, float min, float max) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - return reference::dequantization_layer(src, min, max); - } - - /** Generate random constant values to be used as min and max for dequantization. - */ - void rand_min_max(float *min, float *max) - { - std::mt19937 gen(library->seed()); - std::uniform_real_distribution distribution(-10000.0, 10000.0); - - const float n1 = distribution(gen); - const float n2 = distribution(gen); - - if(n1 < n2) - { - *min = n1; - *max = n2; - } - else - { - *min = n2; - *max = n1; - } - } - - TensorType _target{}; - SimpleTensor _reference{}; - float _min = 0.f; - float _max = 0.f; -}; - -template -class DequantizationValidationFixture : public DequantizationValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - DequantizationValidationFixedPointFixture::setup(shape, data_type); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/DirectConvolutionLayerFixture.h b/tests/validation_new/fixtures/DirectConvolutionLayerFixture.h deleted file mode 100644 index 0d138b47d9..0000000000 --- a/tests/validation_new/fixtures/DirectConvolutionLayerFixture.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/ConvolutionLayer.h" -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/fixtures/ConvolutionLayerFixture.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class DirectConvolutionValidationFixedPointFixture : public ConvolutionValidationFixedPointFixture -{ -public: - template - void setup(TensorShape input_shape, int stride_x, int stride_y, int pad_x, int pad_y, unsigned int kernel_size, unsigned int num_kernels, DataType data_type, int fractional_bits) - { - const TensorShape weights_shape(kernel_size, kernel_size, input_shape.z(), num_kernels); - const TensorShape bias_shape(num_kernels); - const PadStrideInfo info(stride_x, stride_y, pad_x, pad_y, DimensionRoundingType::FLOOR); - const TensorShape output_shape = get_output_shape(input_shape, weights_shape, info); - - ConvolutionValidationFixedPointFixture::setup(input_shape, weights_shape, bias_shape, output_shape, info, data_type, fractional_bits); - } - -private: - TensorShape get_output_shape(TensorShape in_shape, TensorShape kernel_shape, const PadStrideInfo &info) - { - TensorShape out_shape(in_shape); - const std::pair scaled_dims = scaled_dimensions(in_shape.x(), - in_shape.y(), - kernel_shape.x(), - kernel_shape.y(), - info); - out_shape.set(0, scaled_dims.first); - out_shape.set(1, scaled_dims.second); - out_shape.set(2, kernel_shape[3]); - return out_shape; - } -}; - -template -class DirectConvolutionValidationFixture : public DirectConvolutionValidationFixedPointFixture -{ -public: - template - void setup(TensorShape input_shape, int stride_x, int stride_y, int pad_x, int pad_y, unsigned int kernel_size, unsigned int num_kernels, DataType data_type) - { - DirectConvolutionValidationFixedPointFixture::setup(input_shape, stride_x, stride_y, pad_x, pad_y, kernel_size, num_kernels, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/fixtures/FloorFixture.h b/tests/validation_new/fixtures/FloorFixture.h deleted file mode 100644 index ab4c5c7e1e..0000000000 --- a/tests/validation_new/fixtures/FloorFixture.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_FLOOR_FIXTURE -#define ARM_COMPUTE_TEST_FLOOR_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/Floor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class FloorValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType floor_func; - floor_func.configure(&src, &dst); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - floor_func.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - return reference::floor_layer(src); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_FLOOR_FIXTURE */ diff --git a/tests/validation_new/fixtures/FullyConnectedLayerFixture.h b/tests/validation_new/fixtures/FullyConnectedLayerFixture.h deleted file mode 100644 index 0953b0b67e..0000000000 --- a/tests/validation_new/fixtures/FullyConnectedLayerFixture.h +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/core/Utils.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/RawTensor.h" -#include "tests/validation_new/CPP/FullyConnectedLayer.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -RawTensor transpose(const RawTensor &src, int interleave = 1) -{ - // Create reference - TensorShape dst_shape(src.shape()); - dst_shape.set(0, src.shape().y() * interleave); - dst_shape.set(1, std::ceil(src.shape().x() / static_cast(interleave))); - - RawTensor dst{ dst_shape, src.data_type() }; - - // Compute reference - uint8_t *out_ptr = dst.data(); - - for(int i = 0; i < dst.num_elements(); i += interleave) - { - Coordinates coord = index2coord(dst.shape(), i); - size_t coord_x = coord.x(); - coord.set(0, coord.y() * interleave); - coord.set(1, coord_x / interleave); - - const int num_elements = std::min(interleave, src.shape().x() - coord.x()); - - std::copy_n(static_cast(src(coord)), num_elements * src.element_size(), out_ptr); - - out_ptr += interleave * dst.element_size(); - } - - return dst; -} -} // namespace - -template -class FullyConnectedLayerValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, bool transpose_weights, bool reshape_weights, DataType data_type, int fractional_bits) - { - ARM_COMPUTE_UNUSED(weights_shape); - ARM_COMPUTE_UNUSED(bias_shape); - - _fractional_bits = fractional_bits; - _data_type = data_type; - - _target = compute_target(input_shape, weights_shape, bias_shape, output_shape, transpose_weights, reshape_weights, data_type, fractional_bits); - _reference = compute_reference(input_shape, weights_shape, bias_shape, output_shape, transpose_weights, reshape_weights, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor, int i) - { - if(is_data_type_float(_data_type)) - { - std::uniform_real_distribution<> distribution(0.5f, 1.f); - library->fill(tensor, distribution, i); - } - else - { - library->fill_tensor_uniform(tensor, i); - } - } - - TensorType compute_target(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, bool transpose_weights, - bool reshape_weights, DataType data_type, int fixed_point_position) - { - TensorShape reshaped_weights_shape(weights_shape); - - // Test actions depending on the target settings - // - // | reshape | !reshape - // -----------+-----------+--------------------------- - // transpose | | *** - // -----------+-----------+--------------------------- - // !transpose | transpose | transpose & - // | | transpose1xW (if required) - // - // ***: That combination is invalid. But we can ignore the transpose flag and handle all !reshape the same - if(!reshape_weights || !transpose_weights) - { - const size_t shape_x = reshaped_weights_shape.x(); - reshaped_weights_shape.set(0, reshaped_weights_shape.y()); - reshaped_weights_shape.set(1, shape_x); - - // Weights have to be passed reshaped - // Transpose 1xW for batched version - if(!reshape_weights && output_shape.y() > 1 && run_interleave) - { - const int transpose_width = 16 / data_size_from_type(data_type); - const float shape_x = reshaped_weights_shape.x(); - reshaped_weights_shape.set(0, reshaped_weights_shape.y() * transpose_width); - reshaped_weights_shape.set(1, static_cast(std::ceil(shape_x / transpose_width))); - } - } - - // Create tensors - TensorType src = create_tensor(input_shape, data_type, 1, fixed_point_position); - TensorType weights = create_tensor(reshaped_weights_shape, data_type, 1, fixed_point_position); - TensorType bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - // Create and configure function. - FunctionType fc; - fc.configure(&src, &weights, &bias, &dst, transpose_weights, !reshape_weights); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - weights.allocator()->allocate(); - bias.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src), 0); - fill(AccessorType(bias), 2); - - if(!reshape_weights || !transpose_weights) - { - TensorShape tmp_shape(weights_shape); - RawTensor tmp(tmp_shape, data_type, 1, fixed_point_position); - - // Fill with original shape - fill(tmp, 1); - - // Transpose elementwise - tmp = transpose(tmp); - - // Reshape weights for batched runs - if(!reshape_weights && output_shape.y() > 1 && run_interleave) - { - // Transpose with interleave - const int interleave_size = 16 / tmp.element_size(); - tmp = transpose(tmp, interleave_size); - } - - AccessorType weights_accessor(weights); - - for(int i = 0; i < tmp.num_elements(); ++i) - { - Coordinates coord = index2coord(tmp.shape(), i); - std::copy_n(static_cast(tmp(coord)), - tmp.element_size(), - static_cast(weights_accessor(coord))); - } - } - else - { - fill(AccessorType(weights), 1); - } - - // Compute NEFullyConnectedLayer function - fc.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, bool transpose_weights, - bool reshape_weights, DataType data_type, int fixed_point_position = 0) - { - // Create reference - SimpleTensor src{ input_shape, data_type, 1, fixed_point_position }; - SimpleTensor weights{ weights_shape, data_type, 1, fixed_point_position }; - SimpleTensor bias{ bias_shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src, 0); - fill(weights, 1); - fill(bias, 2); - - return reference::fully_connected_layer(src, weights, bias, output_shape); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; - DataType _data_type{}; -}; - -template -class FullyConnectedLayerValidationFixture : public FullyConnectedLayerValidationFixedPointFixture -{ -public: - template - void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, bool transpose_weights, bool reshape_weights, DataType data_type) - { - FullyConnectedLayerValidationFixedPointFixture::setup(input_shape, weights_shape, bias_shape, output_shape, transpose_weights, - reshape_weights, data_type, - 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/GEMMFixture.h b/tests/validation_new/fixtures/GEMMFixture.h deleted file mode 100644 index a6ab518d74..0000000000 --- a/tests/validation_new/fixtures/GEMMFixture.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GEMM_FIXTURE -#define ARM_COMPUTE_TEST_GEMM_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/GEMM.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class GEMMValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape_a, TensorShape shape_b, TensorShape shape_c, TensorShape output_shape, float alpha, float beta, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - _data_type = data_type; - - _target = compute_target(shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type, fractional_bits); - _reference = compute_reference(shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor, int i) - { - switch(tensor.data_type()) - { - case DataType::F16: - case DataType::F32: - { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); - library->fill(tensor, distribution, i); - break; - } - default: - library->fill_tensor_uniform(tensor, i); - } - } - - TensorType compute_target(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_c, const TensorShape &output_shape, float alpha, float beta, - DataType data_type, int fixed_point_position) - { - // Create tensors - TensorType a = create_tensor(shape_a, data_type, 1, fixed_point_position); - TensorType b = create_tensor(shape_b, data_type, 1, fixed_point_position); - TensorType c = create_tensor(shape_c, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - // Create and configure function - FunctionType gemm; - gemm.configure(&a, &b, &c, &dst, alpha, beta); - - ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(c.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - a.allocator()->allocate(); - b.allocator()->allocate(); - c.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!a.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!b.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!c.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(a), 0); - fill(AccessorType(b), 1); - fill(AccessorType(c), 2); - - // Compute GEMM function - gemm.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_c, const TensorShape &output_shape, float alpha, float beta, - DataType data_type, int fixed_point_position) - { - // Create reference - SimpleTensor a{ shape_a, data_type, 1, fixed_point_position }; - SimpleTensor b{ shape_b, data_type, 1, fixed_point_position }; - SimpleTensor c{ shape_c, data_type, 1, fixed_point_position }; - - // Fill reference - fill(a, 0); - fill(b, 1); - fill(c, 2); - - return reference::gemm(a, b, c, alpha, beta); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; - DataType _data_type{}; -}; - -template -class GEMMValidationFixture : public GEMMValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape_a, TensorShape shape_b, TensorShape shape_c, TensorShape output_shape, float alpha, float beta, DataType data_type) - { - GEMMValidationFixedPointFixture::setup(shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GEMM_FIXTURE */ diff --git a/tests/validation_new/fixtures/L2NormalizeFixture.h b/tests/validation_new/fixtures/L2NormalizeFixture.h deleted file mode 100644 index 5102b93f51..0000000000 --- a/tests/validation_new/fixtures/L2NormalizeFixture.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_L2NORMALIZE_FIXTURE -#define ARM_COMPUTE_TEST_L2NORMALIZE_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/L2Normalize.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class L2NormalizeValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type, unsigned int axis, float epsilon) - { - _target = compute_target(shape, data_type, axis, epsilon); - _reference = compute_reference(shape, data_type, axis, epsilon); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type, unsigned int axis, float epsilon) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType l2_norm_func; - l2_norm_func.configure(&src, &dst, axis, epsilon); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - l2_norm_func.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type, unsigned int axis, float epsilon) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - return reference::l2_normalize(src, axis, epsilon); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_L2NORMALIZE_FIXTURE */ diff --git a/tests/validation_new/fixtures/MeanStdDevFixture.h b/tests/validation_new/fixtures/MeanStdDevFixture.h deleted file mode 100644 index 65622fca07..0000000000 --- a/tests/validation_new/fixtures/MeanStdDevFixture.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_MEAN_STD_DEV_FIXTURE -#define ARM_COMPUTE_TEST_MEAN_STD_DEV_FIXTURE - -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/Globals.h" -#include "tests/validation_new/CPP/MeanStdDev.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class MeanStdDevValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - std::pair compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - - // Create output variables - float mean = 0.0f; - float std_dev = 0.0f; - - // Create and configure function - FunctionType mean_std_dev; - mean_std_dev.configure(&src, &mean, &std_dev); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - mean_std_dev.run(); - - return std::make_pair(mean, std_dev); - } - - std::pair compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - // Compute reference - return reference::mean_and_standard_deviation(src); - } - - std::pair _target{}; - std::pair _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_MEAN_STD_DEV_FIXTURE */ diff --git a/tests/validation_new/fixtures/NormalizationLayerFixture.h b/tests/validation_new/fixtures/NormalizationLayerFixture.h deleted file mode 100644 index 044405473b..0000000000 --- a/tests/validation_new/fixtures/NormalizationLayerFixture.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_NORMALIZATION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_NORMALIZATION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/NormalizationLayer.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class NormalizationValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, NormType norm_type, int norm_size, float beta, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - NormalizationLayerInfo info(norm_type, norm_size, 5, beta); - - _target = compute_target(shape, info, data_type, fractional_bits); - _reference = compute_reference(shape, info, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor) - { - if(_fractional_bits == 0) - { - library->fill_tensor_uniform(tensor, 0); - } - else - { - const int one_fixed = 1 << _fractional_bits; - std::uniform_int_distribution<> distribution(-one_fixed, one_fixed); - library->fill(tensor, distribution, 0); - } - } - - TensorType compute_target(const TensorShape &shape, NormalizationLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create tensors - TensorType src = create_tensor(shape, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(shape, data_type, 1, fixed_point_position); - - // Create and configure function - FunctionType norm_layer; - norm_layer.configure(&src, &dst, info); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - norm_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, NormalizationLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create reference - SimpleTensor src{ shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src); - - return reference::normalization_layer(src, info); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; -}; - -template -class NormalizationValidationFixture : public NormalizationValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, NormType norm_type, int norm_size, float beta, DataType data_type) - { - NormalizationValidationFixedPointFixture::setup(shape, norm_type, norm_size, beta, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_NORMALIZATION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/PoolingLayerFixture.h b/tests/validation_new/fixtures/PoolingLayerFixture.h deleted file mode 100644 index c0c818f3a0..0000000000 --- a/tests/validation_new/fixtures/PoolingLayerFixture.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_POOLING_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_POOLING_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/PoolingLayer.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class PoolingLayerValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, PoolingType pool_type, int pool_size, PadStrideInfo pad_stride_info, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - PoolingLayerInfo info(pool_type, pool_size, pad_stride_info); - - _target = compute_target(shape, info, data_type, fractional_bits); - _reference = compute_reference(shape, info, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor) - { - if(_fractional_bits == 0) - { - std::uniform_real_distribution<> distribution(-1.f, 1.f); - library->fill(tensor, distribution, 0); - } - else - { - const int one_fixed = 1 << _fractional_bits; - std::uniform_int_distribution<> distribution(-one_fixed, one_fixed); - library->fill(tensor, distribution, 0); - } - } - - TensorType compute_target(const TensorShape &shape, PoolingLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create tensors - TensorType src = create_tensor(shape, data_type, 1, fixed_point_position); - TensorType dst; - - // Create and configure function - FunctionType pool_layer; - pool_layer.configure(&src, &dst, info); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - pool_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, PoolingLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create reference - SimpleTensor src{ shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src); - - return reference::pooling_layer(src, info); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; -}; - -template -class PoolingLayerValidationFixture : public PoolingLayerValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, PoolingType pool_type, int pool_size, PadStrideInfo pad_stride_info, DataType data_type) - { - PoolingLayerValidationFixedPointFixture::setup(shape, pool_type, pool_size, pad_stride_info, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_POOLING_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/QuantizationLayerFixture.h b/tests/validation_new/fixtures/QuantizationLayerFixture.h deleted file mode 100644 index 469fd5f231..0000000000 --- a/tests/validation_new/fixtures/QuantizationLayerFixture.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_QUANTIZATION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_QUANTIZATION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/QuantizationLayer.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class QuantizationValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, DataType::U8); - - // Create and configure function - FunctionType quantization_layer; - quantization_layer.configure(&src, &dst); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - quantization_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - return reference::quantization_layer(src); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; - -template -class QuantizationValidationFixture : public QuantizationValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - QuantizationValidationFixedPointFixture::setup(shape, data_type); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_QUANTIZATION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/ReductionOperationFixture.h b/tests/validation_new/fixtures/ReductionOperationFixture.h deleted file mode 100644 index 416aadf8d7..0000000000 --- a/tests/validation_new/fixtures/ReductionOperationFixture.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_REDUCTION_OPERATION_FIXTURE -#define ARM_COMPUTE_TEST_REDUCTION_OPERATION_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/ReductionOperation.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class ReductionOperationValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type, unsigned int axis, ReductionOperation op) - { - const TensorShape output_shape = get_output_shape(shape, axis); - _target = compute_target(shape, output_shape, data_type, axis, op); - _reference = compute_reference(shape, output_shape, data_type, axis, op); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &src_shape, const TensorShape &dst_shape, DataType data_type, unsigned int axis, ReductionOperation op) - { - // Create tensors - TensorType src = create_tensor(src_shape, data_type); - TensorType dst = create_tensor(dst_shape, data_type); - - // Create and configure function - FunctionType reduction_func; - reduction_func.configure(&src, &dst, axis, op); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - reduction_func.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &src_shape, const TensorShape &dst_shape, DataType data_type, unsigned int axis, ReductionOperation op) - { - // Create reference - SimpleTensor src{ src_shape, data_type }; - - // Fill reference - fill(src); - - return reference::reduction_operation(src, dst_shape, axis, op); - } - - TensorType _target{}; - SimpleTensor _reference{}; - -private: - TensorShape get_output_shape(TensorShape shape, unsigned int axis) - { - TensorShape output_shape(shape); - output_shape.set(axis, 1); - return output_shape; - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_REDUCTION_OPERATION_FIXTURE */ diff --git a/tests/validation_new/fixtures/ScaleFixture.h b/tests/validation_new/fixtures/ScaleFixture.h deleted file mode 100644 index 74dc0d6816..0000000000 --- a/tests/validation_new/fixtures/ScaleFixture.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_SCALE_FIXTURE -#define ARM_COMPUTE_TEST_SCALE_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/Scale.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class ScaleValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type, InterpolationPolicy policy, BorderMode border_mode) - { - _shape = shape; - _policy = policy; - _border_mode = border_mode; - _data_type = data_type; - - std::mt19937 generator(library->seed()); - std::uniform_real_distribution distribution_float(0.25, 4); - const float scale_x = distribution_float(generator); - const float scale_y = distribution_float(generator); - std::uniform_int_distribution distribution_u8(0, 255); - uint8_t constant_border_value = distribution_u8(generator); - - _target = compute_target(shape, scale_x, scale_y, policy, border_mode, constant_border_value); - _reference = compute_reference(shape, scale_x, scale_y, policy, border_mode, constant_border_value); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, const float scale_x, const float scale_y, - InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) - { - // Create tensors - TensorType src = create_tensor(shape, _data_type); - TensorShape shape_scaled(shape); - shape_scaled.set(0, shape[0] * scale_x); - shape_scaled.set(1, shape[1] * scale_y); - TensorType dst = create_tensor(shape_scaled, _data_type); - - // Create and configure function - FunctionType scale; - - scale.configure(&src, &dst, policy, border_mode, constant_border_value); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - scale.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, const float scale_x, const float scale_y, - InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) - { - // Create reference - SimpleTensor src{ shape, _data_type }; - - // Fill reference - fill(src); - - return reference::scale(src, scale_x, scale_y, policy, border_mode, constant_border_value); - } - - TensorType _target{}; - SimpleTensor _reference{}; - TensorShape _shape{}; - InterpolationPolicy _policy{}; - BorderMode _border_mode{}; - DataType _data_type{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_SCALE_FIXTURE */ \ No newline at end of file diff --git a/tests/validation_new/fixtures/SoftmaxLayerFixture.h b/tests/validation_new/fixtures/SoftmaxLayerFixture.h deleted file mode 100644 index c6f3d2216f..0000000000 --- a/tests/validation_new/fixtures/SoftmaxLayerFixture.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_SOFTMAX_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_SOFTMAX_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/SoftmaxLayer.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class SoftmaxValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - - _target = compute_target(shape, data_type, fractional_bits); - _reference = compute_reference(shape, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor) - { - if(_fractional_bits == 0) - { - std::uniform_real_distribution<> distribution(-1000.f, 1000.f); - library->fill(tensor, distribution, 0); - } - else - { - const int one_fixed = 1 << _fractional_bits; - std::uniform_int_distribution<> distribution(-one_fixed, one_fixed); - library->fill(tensor, distribution, 0); - } - } - - TensorType compute_target(const TensorShape &shape, DataType data_type, int fixed_point_position = 0) - { - // Create tensors - TensorType src = create_tensor(shape, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(shape, data_type, 1, fixed_point_position); - - // Create and configure function - FunctionType smx_layer; - smx_layer.configure(&src, &dst); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - smx_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type, int fixed_point_position = 0) - { - // Create reference - SimpleTensor src{ shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src); - - return reference::softmax_layer(src); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; -}; - -template -class SoftmaxValidationFixture : public SoftmaxValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - SoftmaxValidationFixedPointFixture::setup(shape, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_SOFTMAX_LAYER_FIXTURE */ diff --git a/tests/validation_new/half.h b/tests/validation_new/half.h deleted file mode 100644 index 0ca620cf57..0000000000 --- a/tests/validation_new/half.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef __ARM_COMPUTE_TEST_HALF_H__ -#define __ARM_COMPUTE_TEST_HALF_H__ - -#ifdef __ANDROID__ -// Android toolchain is broken and doesn't support all CPP11 math functions. -#define HALF_ENABLE_CPP11_CMATH 0 -#endif /* __ANDROID__ */ - -// Set style to round to nearest -#define HALF_ROUND_STYLE 1 -#define HALF_ROUND_TIES_TO_EVEN 1 - -#include "half/half.hpp" - -#endif /* __ARM_COMPUTE_TEST_HALF_H__ */ diff --git a/tests/validation_old/AssetsLibrary.cpp b/tests/validation_old/AssetsLibrary.cpp new file mode 100644 index 0000000000..d7c881d9a8 --- /dev/null +++ b/tests/validation_old/AssetsLibrary.cpp @@ -0,0 +1,447 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "tests/AssetsLibrary.h" + +#include "TypePrinter.h" +#include "Utils.h" + +#include "arm_compute/core/ITensor.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace +{ +template ::value, int>::type = 0> +void rgb_to_luminance(const RawTensor &src, RawTensor &dst) +{ + const size_t min_size = std::min(src.size(), dst.size()); + + for(size_t i = 0, j = 0; i < min_size; i += 3, ++j) + { + reinterpret_cast(dst.data())[j] = 0.2126f * src.data()[i + 0] + 0.7152f * src.data()[i + 1] + 0.0722f * src.data()[i + 2]; + } +} + +void extract_r_from_rgb(const RawTensor &src, RawTensor &dst) +{ + const size_t min_size = std::min(src.size(), dst.size()); + + for(size_t i = 0, j = 0; i < min_size; i += 3, ++j) + { + dst.data()[j] = src.data()[i]; + } +} + +void extract_g_from_rgb(const RawTensor &src, RawTensor &dst) +{ + const size_t min_size = std::min(src.size(), dst.size()); + + for(size_t i = 1, j = 0; i < min_size; i += 3, ++j) + { + dst.data()[j] = src.data()[i]; + } +} + +void discard_comments(std::ifstream &fs) +{ + while(fs.peek() == '#') + { + fs.ignore(std::numeric_limits::max(), '\n'); + } +} + +void discard_comments_and_spaces(std::ifstream &fs) +{ + while(true) + { + discard_comments(fs); + + if(isspace(fs.peek()) == 0) + { + break; + } + + fs.ignore(1); + } +} + +std::tuple parse_ppm_header(std::ifstream &fs) +{ + // Check the PPM magic number is valid + std::array magic_number{ { 0 } }; + fs >> magic_number[0] >> magic_number[1]; + + if(magic_number[0] != 'P' || magic_number[1] != '6') + { + throw std::runtime_error("Only raw PPM format is suported"); + } + + discard_comments_and_spaces(fs); + + unsigned int width = 0; + fs >> width; + + discard_comments_and_spaces(fs); + + unsigned int height = 0; + fs >> height; + + discard_comments_and_spaces(fs); + + int max_value = 0; + fs >> max_value; + + if(!fs.good()) + { + throw std::runtime_error("Cannot read image dimensions"); + } + + if(max_value != 255) + { + throw std::runtime_error("RawTensor doesn't have 8-bit values"); + } + + discard_comments(fs); + + if(isspace(fs.peek()) == 0) + { + throw std::runtime_error("Invalid PPM header"); + } + + fs.ignore(1); + + return std::make_tuple(width, height, max_value); +} + +RawTensor load_ppm(const std::string &path) +{ + std::ifstream file(path, std::ios::in | std::ios::binary); + + if(!file.good()) + { + throw std::runtime_error("Could not load PPM image: " + path); + } + + unsigned int width = 0; + unsigned int height = 0; + + std::tie(width, height, std::ignore) = parse_ppm_header(file); + + RawTensor raw(TensorShape(width, height), Format::RGB888); + + // Check if the file is large enough to fill the image + const size_t current_position = file.tellg(); + file.seekg(0, std::ios_base::end); + const size_t end_position = file.tellg(); + file.seekg(current_position, std::ios_base::beg); + + if((end_position - current_position) < raw.size()) + { + throw std::runtime_error("Not enough data in file"); + } + + file.read(reinterpret_cast(raw.data()), raw.size()); + + if(!file.good()) + { + throw std::runtime_error("Failure while reading image buffer"); + } + + return raw; +} +} // namespace + +AssetsLibrary::AssetsLibrary(std::string path, std::random_device::result_type seed) //NOLINT + : _library_path(std::move(path)), + _seed{ seed } +{ +} + +std::random_device::result_type AssetsLibrary::seed() const +{ + return _seed; +} + +void AssetsLibrary::fill(RawTensor &raw, const std::string &name, Format format) const +{ + //FIXME: Should be done by swapping cached buffers + const RawTensor &src = get(name, format); + std::copy_n(src.data(), raw.size(), raw.data()); +} + +void AssetsLibrary::fill(RawTensor &raw, const std::string &name, Channel channel) const +{ + fill(raw, name, get_format_for_channel(channel), channel); +} + +void AssetsLibrary::fill(RawTensor &raw, const std::string &name, Format format, Channel channel) const +{ + const RawTensor &src = get(name, format, channel); + std::copy_n(src.data(), raw.size(), raw.data()); +} + +const AssetsLibrary::Loader &AssetsLibrary::get_loader(const std::string &extension) const +{ + static std::unordered_map loaders = + { + { "ppm", load_ppm } + }; + + const auto it = loaders.find(extension); + + if(it != loaders.end()) + { + return it->second; + } + else + { + throw std::invalid_argument("Cannot load image with extension '" + extension + "'"); + } +} + +const AssetsLibrary::Converter &AssetsLibrary::get_converter(Format src, Format dst) const +{ + static std::map, Converter> converters = + { + { std::make_pair(Format::RGB888, Format::U8), rgb_to_luminance }, + { std::make_pair(Format::RGB888, Format::U16), rgb_to_luminance }, + { std::make_pair(Format::RGB888, Format::S16), rgb_to_luminance }, + { std::make_pair(Format::RGB888, Format::U32), rgb_to_luminance } + }; + + const auto it = converters.find(std::make_pair(src, dst)); + + if(it != converters.end()) + { + return it->second; + } + else + { + std::stringstream msg; + msg << "Cannot convert from format '" << src << "' to format '" << dst << "'\n"; + throw std::invalid_argument(msg.str()); + } +} + +const AssetsLibrary::Converter &AssetsLibrary::get_converter(DataType src, Format dst) const +{ + static std::map, Converter> converters = {}; + + const auto it = converters.find(std::make_pair(src, dst)); + + if(it != converters.end()) + { + return it->second; + } + else + { + std::stringstream msg; + msg << "Cannot convert from data type '" << src << "' to format '" << dst << "'\n"; + throw std::invalid_argument(msg.str()); + } +} + +const AssetsLibrary::Converter &AssetsLibrary::get_converter(DataType src, DataType dst) const +{ + static std::map, Converter> converters = {}; + + const auto it = converters.find(std::make_pair(src, dst)); + + if(it != converters.end()) + { + return it->second; + } + else + { + std::stringstream msg; + msg << "Cannot convert from data type '" << src << "' to data type '" << dst << "'\n"; + throw std::invalid_argument(msg.str()); + } +} + +const AssetsLibrary::Converter &AssetsLibrary::get_converter(Format src, DataType dst) const +{ + static std::map, Converter> converters = {}; + + const auto it = converters.find(std::make_pair(src, dst)); + + if(it != converters.end()) + { + return it->second; + } + else + { + std::stringstream msg; + msg << "Cannot convert from format '" << src << "' to data type '" << dst << "'\n"; + throw std::invalid_argument(msg.str()); + } +} + +const AssetsLibrary::Extractor &AssetsLibrary::get_extractor(Format format, Channel channel) const +{ + static std::map, Extractor> extractors = + { + { std::make_pair(Format::RGB888, Channel::R), extract_r_from_rgb }, + { std::make_pair(Format::RGB888, Channel::G), extract_g_from_rgb } + }; + + const auto it = extractors.find(std::make_pair(format, channel)); + + if(it != extractors.end()) + { + return it->second; + } + else + { + std::stringstream msg; + msg << "Cannot extract channel '" << channel << "' from format '" << format << "'\n"; + throw std::invalid_argument(msg.str()); + } +} + +RawTensor AssetsLibrary::load_image(const std::string &name) const +{ +#ifdef _WIN32 + const std::string image_path = ("\\images\\"); +#else /* _WIN32 */ + const std::string image_path = ("/images/"); +#endif /* _WIN32 */ + + const std::string path = _library_path + image_path + name; + const std::string extension = path.substr(path.find_last_of('.') + 1); + return (*get_loader(extension))(path); +} + +const RawTensor &AssetsLibrary::find_or_create_raw_tensor(const std::string &name, Format format) const +{ + std::lock_guard guard(_format_lock); + + const RawTensor *ptr = _cache.find(std::make_tuple(name, format)); + + if(ptr != nullptr) + { + return *ptr; + } + + RawTensor raw = load_image(name); + + if(raw.format() != format) + { + //FIXME: Remove unnecessary copy + RawTensor dst(raw.shape(), format); + (*get_converter(raw.format(), format))(raw, dst); + raw = std::move(dst); + } + + return _cache.add(std::make_tuple(name, format), std::move(raw)); +} + +const RawTensor &AssetsLibrary::find_or_create_raw_tensor(const std::string &name, Format format, Channel channel) const +{ + std::lock_guard guard(_channel_lock); + + const RawTensor *ptr = _cache.find(std::make_tuple(name, format, channel)); + + if(ptr != nullptr) + { + return *ptr; + } + + const RawTensor &src = get(name, format); + //FIXME: Need to change shape to match channel + RawTensor dst(src.shape(), get_channel_format(channel)); + + (*get_extractor(format, channel))(src, dst); + + return _cache.add(std::make_tuple(name, format, channel), std::move(dst)); +} + +TensorShape AssetsLibrary::get_image_shape(const std::string &name) +{ + return load_image(name).shape(); +} + +const RawTensor &AssetsLibrary::get(const std::string &name) const +{ + //FIXME: Format should be derived from the image name. Not be fixed to RGB. + return find_or_create_raw_tensor(name, Format::RGB888); +} + +RawTensor AssetsLibrary::get(const std::string &name) +{ + //FIXME: Format should be derived from the image name. Not be fixed to RGB. + return RawTensor(find_or_create_raw_tensor(name, Format::RGB888)); +} + +RawTensor AssetsLibrary::get(const std::string &name, DataType data_type, int num_channels) const +{ + const RawTensor &raw = get(name); + + return RawTensor(raw.shape(), data_type, num_channels); +} + +const RawTensor &AssetsLibrary::get(const std::string &name, Format format) const +{ + return find_or_create_raw_tensor(name, format); +} + +RawTensor AssetsLibrary::get(const std::string &name, Format format) +{ + return RawTensor(find_or_create_raw_tensor(name, format)); +} + +const RawTensor &AssetsLibrary::get(const std::string &name, Channel channel) const +{ + return get(name, get_format_for_channel(channel), channel); +} + +RawTensor AssetsLibrary::get(const std::string &name, Channel channel) +{ + return RawTensor(get(name, get_format_for_channel(channel), channel)); +} + +const RawTensor &AssetsLibrary::get(const std::string &name, Format format, Channel channel) const +{ + return find_or_create_raw_tensor(name, format, channel); +} + +RawTensor AssetsLibrary::get(const std::string &name, Format format, Channel channel) +{ + return RawTensor(find_or_create_raw_tensor(name, format, channel)); +} +} // namespace test +} // namespace arm_compute diff --git a/tests/validation_old/AssetsLibrary.h b/tests/validation_old/AssetsLibrary.h new file mode 100644 index 0000000000..6945aa6fe1 --- /dev/null +++ b/tests/validation_old/AssetsLibrary.h @@ -0,0 +1,674 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_TENSOR_LIBRARY_H__ +#define __ARM_COMPUTE_TEST_TENSOR_LIBRARY_H__ + +#include "arm_compute/core/Coordinates.h" +#include "arm_compute/core/Error.h" +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/TensorInfo.h" +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/core/Window.h" +#include "tests/RawTensor.h" +#include "tests/TensorCache.h" +#include "tests/Utils.h" +#include "tests/validation_old/half.h" + +#include +#include +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +/** Factory class to create and fill tensors. + * + * Allows to initialise tensors from loaded images or by specifying the shape + * explicitly. Furthermore, provides methods to fill tensors with the content of + * loaded images or with random values. + */ +class AssetsLibrary final +{ +public: + /** Initialises the library with a @p path to the image directory. + * Furthermore, sets the seed for the random generator to @p seed. + * + * @param[in] path Path to load images from. + * @param[in] seed Seed used to initialise the random number generator. + */ + AssetsLibrary(std::string path, std::random_device::result_type seed); + + /** Seed that is used to fill tensors with random values. */ + std::random_device::result_type seed() const; + + /** Provides a tensor shape for the specified image. + * + * @param[in] name Image file used to look up the raw tensor. + */ + TensorShape get_image_shape(const std::string &name); + + /** Provides a contant raw tensor for the specified image. + * + * @param[in] name Image file used to look up the raw tensor. + */ + const RawTensor &get(const std::string &name) const; + + /** Provides a raw tensor for the specified image. + * + * @param[in] name Image file used to look up the raw tensor. + */ + RawTensor get(const std::string &name); + + /** Creates an uninitialised raw tensor with the given @p data_type and @p + * num_channels. The shape is derived from the specified image. + * + * @param[in] name Image file used to initialise the tensor. + * @param[in] data_type Data type used to initialise the tensor. + * @param[in] num_channels Number of channels used to initialise the tensor. + */ + RawTensor get(const std::string &name, DataType data_type, int num_channels = 1) const; + + /** Provides a contant raw tensor for the specified image after it has been + * converted to @p format. + * + * @param[in] name Image file used to look up the raw tensor. + * @param[in] format Format used to look up the raw tensor. + */ + const RawTensor &get(const std::string &name, Format format) const; + + /** Provides a raw tensor for the specified image after it has been + * converted to @p format. + * + * @param[in] name Image file used to look up the raw tensor. + * @param[in] format Format used to look up the raw tensor. + */ + RawTensor get(const std::string &name, Format format); + + /** Provides a contant raw tensor for the specified channel after it has + * been extracted form the given image. + * + * @param[in] name Image file used to look up the raw tensor. + * @param[in] channel Channel used to look up the raw tensor. + * + * @note The channel has to be unambiguous so that the format can be + * inferred automatically. + */ + const RawTensor &get(const std::string &name, Channel channel) const; + + /** Provides a raw tensor for the specified channel after it has been + * extracted form the given image. + * + * @param[in] name Image file used to look up the raw tensor. + * @param[in] channel Channel used to look up the raw tensor. + * + * @note The channel has to be unambiguous so that the format can be + * inferred automatically. + */ + RawTensor get(const std::string &name, Channel channel); + + /** Provides a constant raw tensor for the specified channel after it has + * been extracted form the given image formatted to @p format. + * + * @param[in] name Image file used to look up the raw tensor. + * @param[in] format Format used to look up the raw tensor. + * @param[in] channel Channel used to look up the raw tensor. + */ + const RawTensor &get(const std::string &name, Format format, Channel channel) const; + + /** Provides a raw tensor for the specified channel after it has been + * extracted form the given image formatted to @p format. + * + * @param[in] name Image file used to look up the raw tensor. + * @param[in] format Format used to look up the raw tensor. + * @param[in] channel Channel used to look up the raw tensor. + */ + RawTensor get(const std::string &name, Format format, Channel channel); + + /** Puts garbage values all around the tensor for testing purposes + * + * @param[in, out] tensor To be filled tensor. + * @param[in] distribution Distribution used to fill the tensor's surroundings. + * @param[in] seed_offset The offset will be added to the global seed before initialising the random generator. + */ + template + void fill_borders_with_garbage(T &&tensor, D &&distribution, std::random_device::result_type seed_offset) const; + + /** Fills the specified @p tensor with random values drawn from @p + * distribution. + * + * @param[in, out] tensor To be filled tensor. + * @param[in] distribution Distribution used to fill the tensor. + * @param[in] seed_offset The offset will be added to the global seed before initialising the random generator. + * + * @note The @p distribution has to provide operator(Generator &) which + * will be used to draw samples. + */ + template + void fill(T &&tensor, D &&distribution, std::random_device::result_type seed_offset) const; + + /** Fills the specified @p raw tensor with random values drawn from @p + * distribution. + * + * @param[in, out] raw To be filled raw. + * @param[in] distribution Distribution used to fill the tensor. + * @param[in] seed_offset The offset will be added to the global seed before initialising the random generator. + * + * @note The @p distribution has to provide operator(Generator &) which + * will be used to draw samples. + */ + template + void fill(RawTensor &raw, D &&distribution, std::random_device::result_type seed_offset) const; + + /** Fills the specified @p tensor with the content of the specified image + * converted to the given format. + * + * @param[in, out] tensor To be filled tensor. + * @param[in] name Image file used to fill the tensor. + * @param[in] format Format of the image used to fill the tensor. + * + * @warning No check is performed that the specified format actually + * matches the format of the tensor. + */ + template + void fill(T &&tensor, const std::string &name, Format format) const; + + /** Fills the raw tensor with the content of the specified image + * converted to the given format. + * + * @param[in, out] raw To be filled raw tensor. + * @param[in] name Image file used to fill the tensor. + * @param[in] format Format of the image used to fill the tensor. + * + * @warning No check is performed that the specified format actually + * matches the format of the tensor. + */ + void fill(RawTensor &raw, const std::string &name, Format format) const; + + /** Fills the specified @p tensor with the content of the specified channel + * extracted from the given image. + * + * @param[in, out] tensor To be filled tensor. + * @param[in] name Image file used to fill the tensor. + * @param[in] channel Channel of the image used to fill the tensor. + * + * @note The channel has to be unambiguous so that the format can be + * inferred automatically. + * + * @warning No check is performed that the specified format actually + * matches the format of the tensor. + */ + template + void fill(T &&tensor, const std::string &name, Channel channel) const; + + /** Fills the raw tensor with the content of the specified channel + * extracted from the given image. + * + * @param[in, out] raw To be filled raw tensor. + * @param[in] name Image file used to fill the tensor. + * @param[in] channel Channel of the image used to fill the tensor. + * + * @note The channel has to be unambiguous so that the format can be + * inferred automatically. + * + * @warning No check is performed that the specified format actually + * matches the format of the tensor. + */ + void fill(RawTensor &raw, const std::string &name, Channel channel) const; + + /** Fills the specified @p tensor with the content of the specified channel + * extracted from the given image after it has been converted to the given + * format. + * + * @param[in, out] tensor To be filled tensor. + * @param[in] name Image file used to fill the tensor. + * @param[in] format Format of the image used to fill the tensor. + * @param[in] channel Channel of the image used to fill the tensor. + * + * @warning No check is performed that the specified format actually + * matches the format of the tensor. + */ + template + void fill(T &&tensor, const std::string &name, Format format, Channel channel) const; + + /** Fills the raw tensor with the content of the specified channel + * extracted from the given image after it has been converted to the given + * format. + * + * @param[in, out] raw To be filled raw tensor. + * @param[in] name Image file used to fill the tensor. + * @param[in] format Format of the image used to fill the tensor. + * @param[in] channel Channel of the image used to fill the tensor. + * + * @warning No check is performed that the specified format actually + * matches the format of the tensor. + */ + void fill(RawTensor &raw, const std::string &name, Format format, Channel channel) const; + + /** Fill a tensor with uniform distribution across the range of its type + * + * @param[in, out] tensor To be filled tensor. + * @param[in] seed_offset The offset will be added to the global seed before initialising the random generator. + */ + template + void fill_tensor_uniform(T &&tensor, std::random_device::result_type seed_offset) const; + + /** Fill a tensor with uniform distribution across the a specified range + * + * @param[in, out] tensor To be filled tensor. + * @param[in] seed_offset The offset will be added to the global seed before initialising the random generator. + * @param[in] low lowest value in the range (inclusive) + * @param[in] high highest value in the range (inclusive) + * + * @note @p low and @p high must be of the same type as the data type of @p tensor + */ + template + void fill_tensor_uniform(T &&tensor, std::random_device::result_type seed_offset, D low, D high) const; + + /** Fills the specified @p tensor with data loaded from binary in specified path. + * + * @param[in, out] tensor To be filled tensor. + * @param[in] name Data file. + */ + template + void fill_layer_data(T &&tensor, std::string name) const; + +private: + // Function prototype to convert between image formats. + using Converter = void (*)(const RawTensor &src, RawTensor &dst); + // Function prototype to extract a channel from an image. + using Extractor = void (*)(const RawTensor &src, RawTensor &dst); + // Function prototype to load an image file. + using Loader = RawTensor (*)(const std::string &path); + + const Converter &get_converter(Format src, Format dst) const; + const Converter &get_converter(DataType src, Format dst) const; + const Converter &get_converter(Format src, DataType dst) const; + const Converter &get_converter(DataType src, DataType dst) const; + const Extractor &get_extractor(Format format, Channel) const; + const Loader &get_loader(const std::string &extension) const; + + /** Creates a raw tensor from the specified image. + * + * @param[in] name To be loaded image file. + * + * @note If use_single_image is true @p name is ignored and the user image + * is loaded instead. + */ + RawTensor load_image(const std::string &name) const; + + /** Provides a raw tensor for the specified image and format. + * + * @param[in] name Image file used to look up the raw tensor. + * @param[in] format Format used to look up the raw tensor. + * + * If the tensor has already been requested before the cached version will + * be returned. Otherwise the tensor will be added to the cache. + * + * @note If use_single_image is true @p name is ignored and the user image + * is loaded instead. + */ + const RawTensor &find_or_create_raw_tensor(const std::string &name, Format format) const; + + /** Provides a raw tensor for the specified image, format and channel. + * + * @param[in] name Image file used to look up the raw tensor. + * @param[in] format Format used to look up the raw tensor. + * @param[in] channel Channel used to look up the raw tensor. + * + * If the tensor has already been requested before the cached version will + * be returned. Otherwise the tensor will be added to the cache. + * + * @note If use_single_image is true @p name is ignored and the user image + * is loaded instead. + */ + const RawTensor &find_or_create_raw_tensor(const std::string &name, Format format, Channel channel) const; + + mutable TensorCache _cache{}; + mutable std::mutex _format_lock{}; + mutable std::mutex _channel_lock{}; + const std::string _library_path; + std::random_device::result_type _seed; +}; + +template +void AssetsLibrary::fill_borders_with_garbage(T &&tensor, D &&distribution, std::random_device::result_type seed_offset) const +{ + const PaddingSize padding_size = tensor.padding(); + + Window window; + window.set(0, Window::Dimension(-padding_size.left, tensor.shape()[0] + padding_size.right, 1)); + window.set(1, Window::Dimension(-padding_size.top, tensor.shape()[1] + padding_size.bottom, 1)); + + std::mt19937 gen(_seed); + + execute_window_loop(window, [&](const Coordinates & id) + { + TensorShape shape = tensor.shape(); + + // If outside of valid region + if(id.x() < 0 || id.x() >= static_cast(shape.x()) || id.y() < 0 || id.y() >= static_cast(shape.y())) + { + using ResultType = typename std::remove_reference::type::result_type; + const ResultType value = distribution(gen); + void *const out_ptr = tensor(id); + store_value_with_data_type(out_ptr, value, tensor.data_type()); + } + }); +} + +template +void AssetsLibrary::fill(T &&tensor, D &&distribution, std::random_device::result_type seed_offset) const +{ + Window window; + for(unsigned int d = 0; d < tensor.shape().num_dimensions(); ++d) + { + window.set(d, Window::Dimension(0, tensor.shape()[d], 1)); + } + + std::mt19937 gen(_seed + seed_offset); + + //FIXME: Replace with normal loop + execute_window_loop(window, [&](const Coordinates & id) + { + using ResultType = typename std::remove_reference::type::result_type; + const ResultType value = distribution(gen); + void *const out_ptr = tensor(id); + store_value_with_data_type(out_ptr, value, tensor.data_type()); + }); + + fill_borders_with_garbage(tensor, distribution, seed_offset); +} + +template +void AssetsLibrary::fill(RawTensor &raw, D &&distribution, std::random_device::result_type seed_offset) const +{ + std::mt19937 gen(_seed + seed_offset); + + for(size_t offset = 0; offset < raw.size(); offset += raw.element_size()) + { + using ResultType = typename std::remove_reference::type::result_type; + const ResultType value = distribution(gen); + store_value_with_data_type(raw.data() + offset, value, raw.data_type()); + } +} + +template +void AssetsLibrary::fill(T &&tensor, const std::string &name, Format format) const +{ + const RawTensor &raw = get(name, format); + + for(size_t offset = 0; offset < raw.size(); offset += raw.element_size()) + { + const Coordinates id = index2coord(raw.shape(), offset / raw.element_size()); + + const RawTensor::value_type *const raw_ptr = raw.data() + offset; + const auto out_ptr = static_cast(tensor(id)); + std::copy_n(raw_ptr, raw.element_size(), out_ptr); + } +} + +template +void AssetsLibrary::fill(T &&tensor, const std::string &name, Channel channel) const +{ + fill(std::forward(tensor), name, get_format_for_channel(channel), channel); +} + +template +void AssetsLibrary::fill(T &&tensor, const std::string &name, Format format, Channel channel) const +{ + const RawTensor &raw = get(name, format, channel); + + for(size_t offset = 0; offset < raw.size(); offset += raw.element_size()) + { + const Coordinates id = index2coord(raw.shape(), offset / raw.element_size()); + + const RawTensor::value_type *const raw_ptr = raw.data() + offset; + const auto out_ptr = static_cast(tensor(id)); + std::copy_n(raw_ptr, raw.element_size(), out_ptr); + } +} + +template +void AssetsLibrary::fill_tensor_uniform(T &&tensor, std::random_device::result_type seed_offset) const +{ + switch(tensor.data_type()) + { + case DataType::U8: + { + std::uniform_int_distribution distribution_u8(std::numeric_limits::lowest(), std::numeric_limits::max()); + fill(tensor, distribution_u8, seed_offset); + break; + } + case DataType::S8: + case DataType::QS8: + { + std::uniform_int_distribution distribution_s8(std::numeric_limits::lowest(), std::numeric_limits::max()); + fill(tensor, distribution_s8, seed_offset); + break; + } + case DataType::U16: + { + std::uniform_int_distribution distribution_u16(std::numeric_limits::lowest(), std::numeric_limits::max()); + fill(tensor, distribution_u16, seed_offset); + break; + } + case DataType::S16: + case DataType::QS16: + { + std::uniform_int_distribution distribution_s16(std::numeric_limits::lowest(), std::numeric_limits::max()); + fill(tensor, distribution_s16, seed_offset); + break; + } + case DataType::U32: + { + std::uniform_int_distribution distribution_u32(std::numeric_limits::lowest(), std::numeric_limits::max()); + fill(tensor, distribution_u32, seed_offset); + break; + } + case DataType::S32: + { + std::uniform_int_distribution distribution_s32(std::numeric_limits::lowest(), std::numeric_limits::max()); + fill(tensor, distribution_s32, seed_offset); + break; + } + case DataType::U64: + { + std::uniform_int_distribution distribution_u64(std::numeric_limits::lowest(), std::numeric_limits::max()); + fill(tensor, distribution_u64, seed_offset); + break; + } + case DataType::S64: + { + std::uniform_int_distribution distribution_s64(std::numeric_limits::lowest(), std::numeric_limits::max()); + fill(tensor, distribution_s64, seed_offset); + break; + } + case DataType::F16: + { + // It doesn't make sense to check [-inf, inf], so hard code it to a big number + std::uniform_real_distribution distribution_f16(-100.f, 100.f); + fill(tensor, distribution_f16, seed_offset); + break; + } + case DataType::F32: + { + // It doesn't make sense to check [-inf, inf], so hard code it to a big number + std::uniform_real_distribution distribution_f32(-1000.f, 1000.f); + fill(tensor, distribution_f32, seed_offset); + break; + } + case DataType::F64: + { + // It doesn't make sense to check [-inf, inf], so hard code it to a big number + std::uniform_real_distribution distribution_f64(-1000.f, 1000.f); + fill(tensor, distribution_f64, seed_offset); + break; + } + case DataType::SIZET: + { + std::uniform_int_distribution distribution_sizet(std::numeric_limits::lowest(), std::numeric_limits::max()); + fill(tensor, distribution_sizet, seed_offset); + break; + } + default: + ARM_COMPUTE_ERROR("NOT SUPPORTED!"); + } +} + +template +void AssetsLibrary::fill_tensor_uniform(T &&tensor, std::random_device::result_type seed_offset, D low, D high) const +{ + switch(tensor.data_type()) + { + case DataType::U8: + { + ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); + std::uniform_int_distribution distribution_u8(low, high); + fill(tensor, distribution_u8, seed_offset); + break; + } + case DataType::S8: + case DataType::QS8: + { + ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); + std::uniform_int_distribution distribution_s8(low, high); + fill(tensor, distribution_s8, seed_offset); + break; + } + case DataType::U16: + { + ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); + std::uniform_int_distribution distribution_u16(low, high); + fill(tensor, distribution_u16, seed_offset); + break; + } + case DataType::S16: + case DataType::QS16: + { + ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); + std::uniform_int_distribution distribution_s16(low, high); + fill(tensor, distribution_s16, seed_offset); + break; + } + case DataType::U32: + { + ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); + std::uniform_int_distribution distribution_u32(low, high); + fill(tensor, distribution_u32, seed_offset); + break; + } + case DataType::S32: + { + ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); + std::uniform_int_distribution distribution_s32(low, high); + fill(tensor, distribution_s32, seed_offset); + break; + } + case DataType::U64: + { + ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); + std::uniform_int_distribution distribution_u64(low, high); + fill(tensor, distribution_u64, seed_offset); + break; + } + case DataType::S64: + { + ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); + std::uniform_int_distribution distribution_s64(low, high); + fill(tensor, distribution_s64, seed_offset); + break; + } + case DataType::F16: + { + std::uniform_real_distribution distribution_f16(low, high); + fill(tensor, distribution_f16, seed_offset); + break; + } + case DataType::F32: + { + ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); + std::uniform_real_distribution distribution_f32(low, high); + fill(tensor, distribution_f32, seed_offset); + break; + } + case DataType::F64: + { + ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); + std::uniform_real_distribution distribution_f64(low, high); + fill(tensor, distribution_f64, seed_offset); + break; + } + case DataType::SIZET: + { + ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); + std::uniform_int_distribution distribution_sizet(low, high); + fill(tensor, distribution_sizet, seed_offset); + break; + } + default: + ARM_COMPUTE_ERROR("NOT SUPPORTED!"); + } +} + +template +void AssetsLibrary::fill_layer_data(T &&tensor, std::string name) const +{ +#ifdef _WIN32 + const std::string path_separator("\\"); +#else /* _WIN32 */ + const std::string path_separator("/"); +#endif /* _WIN32 */ + + const std::string path = _library_path + path_separator + name; + + // Open file + std::ifstream file(path, std::ios::in | std::ios::binary); + if(!file.good()) + { + throw std::runtime_error("Could not load binary data: " + path); + } + + Window window; + for(unsigned int d = 0; d < tensor.shape().num_dimensions(); ++d) + { + window.set(d, Window::Dimension(0, tensor.shape()[d], 1)); + } + + //FIXME : Replace with normal loop + execute_window_loop(window, [&](const Coordinates & id) + { + float val; + file.read(reinterpret_cast(&val), sizeof(float)); + void *const out_ptr = tensor(id); + store_value_with_data_type(out_ptr, val, tensor.data_type()); + }); +} +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_TENSOR_LIBRARY_H__ */ diff --git a/tests/validation_old/CL/ArithmeticAddition.cpp b/tests/validation_old/CL/ArithmeticAddition.cpp new file mode 100644 index 0000000000..8e67bf3a26 --- /dev/null +++ b/tests/validation_old/CL/ArithmeticAddition.cpp @@ -0,0 +1,302 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/functions/CLArithmeticAddition.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Neon arithmetic addition function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in0 Data type of first input tensor. + * @param[in] dt_in1 Data type of second input tensor. + * @param[in] dt_out Data type of the output tensor. + * @param[in] policy Overflow policy of the operation. + * @param[in] fixed_point_position (Optional) Fixed point position that expresses the number of bits for the fractional part of the number when the tensor's data type is QS8 or QS16 (default = 0). + * + * @return Computed output tensor. + */ +CLTensor compute_arithmetic_addition(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy policy, int fixed_point_position = 0) +{ + // Create tensors + CLTensor src1 = create_tensor(shape, dt_in0, 1, fixed_point_position); + CLTensor src2 = create_tensor(shape, dt_in1, 1, fixed_point_position); + CLTensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); + + // Create and configure function + CLArithmeticAddition add; + add.configure(&src1, &src2, &dst, policy); + + // Allocate tensors + src1.allocator()->allocate(); + src2.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src1.info()->is_resizable()); + BOOST_TEST(!src2.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(CLAccessor(src1), 0); + library->fill_tensor_uniform(CLAccessor(src2), 1); + + // Compute function + add.run(); + + return dst; +} + +void validate_configuration(const CLTensor &src1, const CLTensor &src2, CLTensor &dst, TensorShape shape, ConvertPolicy policy) +{ + BOOST_TEST(src1.info()->is_resizable()); + BOOST_TEST(src2.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + CLArithmeticAddition add; + add.configure(&src1, &src2, &dst, policy); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src1.info()->valid_region(), valid_region); + validate(src2.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src1.info()->padding(), padding); + validate(src2.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(ArithmeticAddition) + +BOOST_AUTO_TEST_SUITE(U8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, policy) +{ + // Create tensors + CLTensor src1 = create_tensor(shape, DataType::U8); + CLTensor src2 = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, DataType::U8); + + validate_configuration(src1, src2, dst, shape, policy); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, policy) +{ + // Compute function + CLTensor dst = compute_arithmetic_addition(shape, DataType::U8, DataType::U8, DataType::U8, policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::U8, DataType::U8, DataType::U8, policy); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(S16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, dt, policy) +{ + // Create tensors + CLTensor src1 = create_tensor(shape, dt); + CLTensor src2 = create_tensor(shape, DataType::S16); + CLTensor dst = create_tensor(shape, DataType::S16); + + validate_configuration(src1, src2, dst, shape, policy); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, dt, policy) +{ + // Compute function + CLTensor dst = compute_arithmetic_addition(shape, dt, DataType::S16, DataType::S16, policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, dt, DataType::S16, DataType::S16, policy); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, dt, policy) +{ + // Compute function + CLTensor dst = compute_arithmetic_addition(shape, dt, DataType::S16, DataType::S16, policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, dt, DataType::S16, DataType::S16, policy); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(Quantized) +BOOST_AUTO_TEST_SUITE(QS8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 7), + shape, policy, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_arithmetic_addition(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 7), + shape, policy, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_arithmetic_addition(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(QS16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 15), + shape, policy, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_arithmetic_addition(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 15), + shape, policy, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_arithmetic_addition(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(F16) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) +{ + // Compute function + CLTensor dst = compute_arithmetic_addition(shape, DataType::F16, DataType::F16, DataType::F16, ConvertPolicy::WRAP); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::F16, DataType::F16, DataType::F16, ConvertPolicy::WRAP); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(F32) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, policy) +{ + // Create tensors + CLTensor src1 = create_tensor(shape, DataType::F32); + CLTensor src2 = create_tensor(shape, DataType::F32); + CLTensor dst = create_tensor(shape, DataType::F32); + + validate_configuration(src1, src2, dst, shape, policy); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) +{ + // Compute function + CLTensor dst = compute_arithmetic_addition(shape, DataType::F32, DataType::F32, DataType::F32, ConvertPolicy::WRAP); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::F32, DataType::F32, DataType::F32, ConvertPolicy::WRAP); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, policy) +{ + // Compute function + CLTensor dst = compute_arithmetic_addition(shape, DataType::F32, DataType::F32, DataType::F32, policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::F32, DataType::F32, DataType::F32, policy); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/ArithmeticSubtraction.cpp b/tests/validation_old/CL/ArithmeticSubtraction.cpp new file mode 100644 index 0000000000..522ee7b1e8 --- /dev/null +++ b/tests/validation_old/CL/ArithmeticSubtraction.cpp @@ -0,0 +1,288 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/functions/CLArithmeticSubtraction.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Neon arithmetic subtraction function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in0 Data type of first input tensor. + * @param[in] dt_in1 Data type of second input tensor. + * @param[in] dt_out Data type of the output tensor. + * @param[in] policy Overflow policy of the operation. + * @param[in] fixed_point_position (Optional) Fixed point position that expresses the number of bits for the fractional part of the number when the tensor's data type is QS8 or QS16 (default = 0). + * + * @return Computed output tensor. + */ +CLTensor compute_arithmetic_subtraction(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy policy, int fixed_point_position = 0) +{ + // Create tensors + CLTensor src1 = create_tensor(shape, dt_in0, 1, fixed_point_position); + CLTensor src2 = create_tensor(shape, dt_in1, 1, fixed_point_position); + CLTensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); + + // Create and configure function + CLArithmeticSubtraction sub; + sub.configure(&src1, &src2, &dst, policy); + + // Allocate tensors + src1.allocator()->allocate(); + src2.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src1.info()->is_resizable()); + BOOST_TEST(!src2.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(CLAccessor(src1), 0); + library->fill_tensor_uniform(CLAccessor(src2), 1); + + // Compute function + sub.run(); + + return dst; +} + +void validate_configuration(const CLTensor &src1, const CLTensor &src2, CLTensor &dst, TensorShape shape, ConvertPolicy policy) +{ + BOOST_TEST(src1.info()->is_resizable()); + BOOST_TEST(src2.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + CLArithmeticSubtraction sub; + sub.configure(&src1, &src2, &dst, policy); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src1.info()->valid_region(), valid_region); + validate(src2.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src1.info()->padding(), padding); + validate(src2.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(ArithmeticSubtraction) + +BOOST_AUTO_TEST_SUITE(U8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, policy) +{ + // Create tensors + CLTensor src1 = create_tensor(shape, DataType::U8); + CLTensor src2 = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, DataType::U8); + + validate_configuration(src1, src2, dst, shape, policy); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, policy) +{ + // Compute function + CLTensor dst = compute_arithmetic_subtraction(shape, DataType::U8, DataType::U8, DataType::U8, policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::U8, DataType::U8, DataType::U8, policy); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(S16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, dt, policy) +{ + // Create tensors + CLTensor src1 = create_tensor(shape, dt); + CLTensor src2 = create_tensor(shape, DataType::S16); + CLTensor dst = create_tensor(shape, DataType::S16); + + validate_configuration(src1, src2, dst, shape, policy); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, dt, policy) +{ + // Compute function + CLTensor dst = compute_arithmetic_subtraction(shape, dt, DataType::S16, DataType::S16, policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, dt, DataType::S16, DataType::S16, policy); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, dt, policy) +{ + // Compute function + CLTensor dst = compute_arithmetic_subtraction(shape, dt, DataType::S16, DataType::S16, policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, dt, DataType::S16, DataType::S16, policy); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(Quantized) +BOOST_AUTO_TEST_SUITE(QS8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 7), + shape, policy, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_arithmetic_subtraction(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 7), + shape, policy, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_arithmetic_subtraction(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(QS16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 15), + shape, policy, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_arithmetic_subtraction(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 15), + shape, policy, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_arithmetic_subtraction(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(Float) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, policy) +{ + // Create tensors + CLTensor src1 = create_tensor(shape, DataType::F32); + CLTensor src2 = create_tensor(shape, DataType::F32); + CLTensor dst = create_tensor(shape, DataType::F32); + + validate_configuration(src1, src2, dst, shape, policy); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) +{ + // Compute function + CLTensor dst = compute_arithmetic_subtraction(shape, DataType::F32, DataType::F32, DataType::F32, ConvertPolicy::WRAP); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::F32, DataType::F32, DataType::F32, ConvertPolicy::WRAP); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, policy) +{ + // Compute function + CLTensor dst = compute_arithmetic_subtraction(shape, DataType::F32, DataType::F32, DataType::F32, policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::F32, DataType::F32, DataType::F32, policy); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/BatchNormalizationLayer.cpp b/tests/validation_old/CL/BatchNormalizationLayer.cpp new file mode 100644 index 0000000000..75c9a580ea --- /dev/null +++ b/tests/validation_old/CL/BatchNormalizationLayer.cpp @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Helpers.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/dataset/BatchNormalizationLayerDataset.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/functions/CLBatchNormalizationLayer.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +const float tolerance_f = 1e-05; /**< Tolerance value for comparing reference's output against floating point implementation's output */ +const float tolerance_qs8 = 3; /**< Tolerance value for comparing reference's output against quantized implementation's output */ +const float tolerance_qs16 = 6; /**< Tolerance value for comparing reference's output against quantized implementation's output */ + +/** Compute Neon batch normalization function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt Data type of input and output tensors. + * @param[in] norm_info Normalization Layer information. + * + * @return Computed output tensor. + */ +CLTensor compute_reference_batch_normalization_layer(const TensorShape &shape0, const TensorShape &shape1, DataType dt, float epsilon, int fixed_point_position = 0) +{ + // Create tensors + CLTensor src = create_tensor(shape0, dt, 1, fixed_point_position); + CLTensor dst = create_tensor(shape0, dt, 1, fixed_point_position); + CLTensor mean = create_tensor(shape1, dt, 1, fixed_point_position); + CLTensor var = create_tensor(shape1, dt, 1, fixed_point_position); + CLTensor beta = create_tensor(shape1, dt, 1, fixed_point_position); + CLTensor gamma = create_tensor(shape1, dt, 1, fixed_point_position); + + // Create and configure function + CLBatchNormalizationLayer norm; + norm.configure(&src, &dst, &mean, &var, &beta, &gamma, epsilon); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + mean.allocator()->allocate(); + var.allocator()->allocate(); + beta.allocator()->allocate(); + gamma.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + BOOST_TEST(!mean.info()->is_resizable()); + BOOST_TEST(!var.info()->is_resizable()); + BOOST_TEST(!beta.info()->is_resizable()); + BOOST_TEST(!gamma.info()->is_resizable()); + + // Fill tensors + if(dt == DataType::F32) + { + float min_bound = 0.f; + float max_bound = 0.f; + std::tie(min_bound, max_bound) = get_batchnormalization_layer_test_bounds(); + std::uniform_real_distribution<> distribution(min_bound, max_bound); + std::uniform_real_distribution<> distribution_var(0, max_bound); + library->fill(CLAccessor(src), distribution, 0); + library->fill(CLAccessor(mean), distribution, 1); + library->fill(CLAccessor(var), distribution_var, 0); + library->fill(CLAccessor(beta), distribution, 3); + library->fill(CLAccessor(gamma), distribution, 4); + } + else + { + int min_bound = 0; + int max_bound = 0; + if(dt == DataType::QS8) + { + std::tie(min_bound, max_bound) = get_batchnormalization_layer_test_bounds(fixed_point_position); + } + else + { + std::tie(min_bound, max_bound) = get_batchnormalization_layer_test_bounds(fixed_point_position); + } + std::uniform_int_distribution<> distribution(min_bound, max_bound); + std::uniform_int_distribution<> distribution_var(0, max_bound); + library->fill(CLAccessor(src), distribution, 0); + library->fill(CLAccessor(mean), distribution, 1); + library->fill(CLAccessor(var), distribution_var, 0); + library->fill(CLAccessor(beta), distribution, 3); + library->fill(CLAccessor(gamma), distribution, 4); + } + + // Compute function + norm.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(BatchNormalizationLayer) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make({ DataType::QS8, DataType::QS16, DataType::F32 }), obj, dt) +{ + // Set fixed point position data type allowed + int fixed_point_position = (arm_compute::is_data_type_fixed_point(dt)) ? 3 : 0; + + // Create tensors + CLTensor src = create_tensor(obj.shape0, dt, 1, fixed_point_position); + CLTensor dst = create_tensor(obj.shape0, dt, 1, fixed_point_position); + CLTensor mean = create_tensor(obj.shape1, dt, 1, fixed_point_position); + CLTensor var = create_tensor(obj.shape1, dt, 1, fixed_point_position); + CLTensor beta = create_tensor(obj.shape1, dt, 1, fixed_point_position); + CLTensor gamma = create_tensor(obj.shape1, dt, 1, fixed_point_position); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + BOOST_TEST(mean.info()->is_resizable()); + BOOST_TEST(var.info()->is_resizable()); + BOOST_TEST(beta.info()->is_resizable()); + BOOST_TEST(gamma.info()->is_resizable()); + + // Create and configure function + CLBatchNormalizationLayer norm; + norm.configure(&src, &dst, &mean, &var, &beta, &gamma, obj.epsilon); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(obj.shape0); + const ValidRegion valid_region_vec = shape_to_valid_region(obj.shape1); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + validate(mean.info()->valid_region(), valid_region_vec); + validate(var.info()->valid_region(), valid_region_vec); + validate(beta.info()->valid_region(), valid_region_vec); + validate(gamma.info()->valid_region(), valid_region_vec); +} + +BOOST_AUTO_TEST_SUITE(Float) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(Random, + RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::F32), + obj, dt) +{ + // Compute function + CLTensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon); + + // Validate output + validate(CLAccessor(dst), ref_dst, tolerance_f, 0); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(Quantized) + +BOOST_AUTO_TEST_SUITE(QS8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(Random, + RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::QS8) * boost::unit_test::data::xrange(1, 6), + obj, dt, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst, tolerance_qs8, 0); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(QS16) +BOOST_DATA_TEST_CASE(Random, + RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::QS16) * boost::unit_test::data::xrange(1, 14), + obj, dt, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst, tolerance_qs16, 0); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/Box3x3.cpp b/tests/validation_old/CL/Box3x3.cpp new file mode 100644 index 0000000000..3eacb484b2 --- /dev/null +++ b/tests/validation_old/CL/Box3x3.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLBox3x3.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +constexpr unsigned int filter_size = 3; /** Size of the kernel/filter in number of elements. */ +constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ + +/** Compute CL box3x3 filter. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] border_mode BorderMode used by the input tensor. + * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. + * + * @return Computed output tensor. + */ +CLTensor compute_box3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, DataType::U8); + + // Create and configure function + CLBox3x3 box3x3; + box3x3.configure(&src, &dst, border_mode, constant_border_value); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(CLAccessor(src), 0); + + // Compute function + box3x3.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(Box3x3) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, DataType::U8); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + CLBox3x3 box3x3; + box3x3.configure(&src, &dst, border_mode); + + // Validate valid region + const ValidRegion src_valid_region = shape_to_valid_region(shape); + const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + validate(src.info()->valid_region(), src_valid_region); + validate(dst.info()->valid_region(), dst_valid_region); + + // Validate padding + PaddingCalculator calculator(shape.x(), 8); + calculator.set_border_size(1); + calculator.set_border_mode(border_mode); + + const PaddingSize dst_padding = calculator.required_padding(); + + calculator.set_accessed_elements(16); + calculator.set_access_offset(-1); + + const PaddingSize src_padding = calculator.required_padding(); + + validate(src.info()->padding(), src_padding); + validate(dst.info()->padding(), dst_padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) +{ + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + const uint8_t border_value = distribution(gen); + + // Compute function + CLTensor dst = compute_box3x3(shape, border_mode, border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_box3x3(shape, border_mode, border_value); + + // Validate output + validate(CLAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) +{ + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + const uint8_t border_value = distribution(gen); + + // Compute function + CLTensor dst = compute_box3x3(shape, border_mode, border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_box3x3(shape, border_mode, border_value); + + // Validate output + validate(CLAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/CLFixture.cpp b/tests/validation_old/CL/CLFixture.cpp new file mode 100644 index 0000000000..aacaeb35b7 --- /dev/null +++ b/tests/validation_old/CL/CLFixture.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "tests/validation_old/CL/CLFixture.h" + +#include "tests/validation_old/boost_wrapper.h" + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +BOOST_GLOBAL_FIXTURE(CLFixture); diff --git a/tests/validation_old/CL/CLFixture.h b/tests/validation_old/CL/CLFixture.h new file mode 100644 index 0000000000..77538be8f4 --- /dev/null +++ b/tests/validation_old/CL/CLFixture.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_VALIDATION_CL_CLFIXTURE_H__ +#define __ARM_COMPUTE_TEST_VALIDATION_CL_CLFIXTURE_H__ + +#include "arm_compute/runtime/CL/CLScheduler.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +struct CLFixture +{ + CLFixture() + { + CLScheduler::get().default_init(); + } +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_VALIDATION_CL_CLFIXTURE_H__ */ diff --git a/tests/validation_old/CL/DepthConvert.cpp b/tests/validation_old/CL/DepthConvert.cpp new file mode 100644 index 0000000000..994a0327bf --- /dev/null +++ b/tests/validation_old/CL/DepthConvert.cpp @@ -0,0 +1,495 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/functions/CLDepthConvert.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute CL depth convert function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in Data type of input tensor. + * @param[in] dt_out Data type of the output tensor. + * @param[in] policy Conversion policy. + * @param[in] shift Value for down/up conversions. Must be 0 <= shift < 8. + * + * @return Computed output CLtensor. + */ +CLTensor compute_depth_convert(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, uint32_t shift, uint32_t fixed_point_position = 0) +{ + // Create tensors + CLTensor src = create_tensor(shape, dt_in, 1, fixed_point_position); + CLTensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); + + // Create and configure function + CLDepthConvert depth_convert; + depth_convert.configure(&src, &dst, policy, shift); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(CLAccessor(src), 0); + + // Compute function + depth_convert.run(); + + return dst; +} +/** Configure and validate region/padding function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in Data type of input tensor. + * @param[in] dt_out Data type of the output tensor. + * @param[in] policy Conversion policy. + * @param[in] shift Value for down/up conversions. Must be 0 <= shift < 8. + * @param[in] fixed_point_position Fixed point position. + * + */ +void compute_configure_validate(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, uint32_t shift, uint32_t fixed_point_position = 0) +{ + // Create tensors + CLTensor src = create_tensor(shape, dt_in, 1, fixed_point_position); + CLTensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + CLDepthConvert depth_convert; + depth_convert.configure(&src, &dst, policy, shift); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(DepthConvert) + +BOOST_AUTO_TEST_SUITE(U8_to_U16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::U8, DataType::U16, policy, shift); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, DataType::U8, DataType::U16, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::U16, policy, shift, 0); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, DataType::U8, DataType::U16, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::U16, policy, shift, 0); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(U8_to_S16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::U8, DataType::S16, policy, shift); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, DataType::U8, DataType::S16, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S16, policy, shift, 0); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, DataType::U8, DataType::S16, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S16, policy, shift, 0); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(U8_to_S32) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::U8, DataType::S32, policy, shift); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, DataType::U8, DataType::S32, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S32, policy, shift, 0); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, DataType::U8, DataType::S32, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S32, policy, shift, 0); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(U16_to_U8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::U16, DataType::U8, policy, shift); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, DataType::U16, DataType::U8, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U8, policy, shift, 0); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, DataType::U16, DataType::U8, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U8, policy, shift, 0); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(U16_to_U32) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::U16, DataType::U32, policy, shift); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, DataType::U16, DataType::U32, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U32, policy, shift, 0); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, DataType::U16, DataType::U32, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U32, policy, shift, 0); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(S16_to_U8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::S16, DataType::U8, policy, shift); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, DataType::S16, DataType::U8, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::U8, policy, shift, 0); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, DataType::S16, DataType::U8, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::U8, policy, shift, 0); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(S16_to_S32) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::S16, DataType::S32, policy, shift); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, DataType::S16, DataType::S32, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::S32, policy, shift, 0); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, DataType::S16, DataType::S32, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::S32, policy, shift, 0); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(Quantized_to_F32) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::QS8, DataType::QS16 }) + * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) * boost::unit_test::data::xrange(1, 7, 1), + shape, dt, policy, fixed_point_position) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, dt, DataType::F32, policy, 0, fixed_point_position); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * boost::unit_test::data::make({ DataType::QS8, DataType::QS16 }) * boost::unit_test::data::xrange(1, 7, 1), + shape, policy, dt, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, dt, DataType::F32, policy, 0, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, dt, DataType::F32, policy, 0, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::QS8, DataType::QS16 }) + * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) * boost::unit_test::data::xrange(1, 7, 1), + shape, dt, policy, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, dt, DataType::F32, policy, 0, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, dt, DataType::F32, policy, 0, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(F32_to_Quantized) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::QS8, DataType::QS16 }) + * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) * boost::unit_test::data::xrange(1, 7, 1), + shape, dt, policy, fixed_point_position) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::F32, dt, policy, 0, fixed_point_position); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::QS8, DataType::QS16 }) + * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) * boost::unit_test::data::xrange(1, 7, 1), + shape, dt, policy, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, DataType::F32, dt, policy, 0, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::F32, dt, policy, 0, fixed_point_position, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::QS8, DataType::QS16 }) + * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) * boost::unit_test::data::xrange(1, 7, 1), + shape, dt, policy, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_depth_convert(shape, DataType::F32, dt, policy, 0, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::F32, dt, policy, 0, fixed_point_position, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/FillBorder.cpp b/tests/validation_old/CL/FillBorder.cpp new file mode 100644 index 0000000000..ed47a1eeb3 --- /dev/null +++ b/tests/validation_old/CL/FillBorder.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/CL/kernels/CLFillBorderKernel.h" +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLScheduler.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(FillBorder, BorderModes() * boost::unit_test::data::make({ PaddingSize{ 0 }, PaddingSize{ 1, 0, 1, 2 }, PaddingSize{ 10 } }), border_mode, padding) +{ + constexpr uint8_t border_value = 42U; + constexpr uint8_t tensor_value = 89U; + BorderSize border_size{ 5 }; + + // Create tensors + CLTensor src = create_tensor(TensorShape{ 10U, 10U, 2U }, DataType::U8); + + src.info()->extend_padding(padding); + + // Allocate tensor + src.allocator()->allocate(); + + // Check padding is as required + validate(src.info()->padding(), padding); + + // Fill tensor with constant value + std::uniform_int_distribution distribution{ tensor_value, tensor_value }; + library->fill(CLAccessor(src), distribution, 0); + + // Create and configure kernel + CLFillBorderKernel fill_border; + fill_border.configure(&src, border_size, border_mode, border_value); + + // Run kernel + fill_border.run(fill_border.window(), CLScheduler::get().queue()); + + // Validate border + border_size.limit(padding); + validate(CLAccessor(src), border_size, border_mode, &border_value); + + // Validate tensor + validate(CLAccessor(src), &tensor_value); +} + +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/FixedPoint/FixedPoint_QS8.cpp b/tests/validation_old/CL/FixedPoint/FixedPoint_QS8.cpp new file mode 100644 index 0000000000..3721fb51d7 --- /dev/null +++ b/tests/validation_old/CL/FixedPoint/FixedPoint_QS8.cpp @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/CL/CLKernelLibrary.h" +#include "arm_compute/core/CL/ICLKernel.h" +#include "arm_compute/core/CL/OpenCL.h" +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/core/Window.h" +#include "arm_compute/runtime/CL/CLScheduler.h" +#include "arm_compute/runtime/CL/CLSubTensor.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" + +#include "arm_compute/core/CL/ICLTensor.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +const float tolerance_exp = 1.0f; /**< Tolerance value for comparing reference's output against implementation's output (exponential)*/ +const float tolerance_invsqrt = 4.0f; /**< Tolerance value for comparing reference's output against implementation's output (inverse square-root) */ +const float tolerance_log = 5.0f; /**< Tolerance value for comparing reference's output against implementation's output (logarithm) */ + +/** Compute Neon fixed point operation for signed 8bit fixed point. + * + * @param[in] shape Shape of the input and output tensors. + * + * @return Computed output tensor. + */ +CLTensor compute_fixed_point_op(const TensorShape &shape, int fixed_point_position, FixedPointOp op) +{ + std::string fixed_point_operation_kernel; +#ifndef EMBEDDED_KERNELS + fixed_point_operation_kernel += "#include \"fixed_point.h\"\n"; +#endif /* EMBEDDED_KERNELS */ + fixed_point_operation_kernel += + "__kernel void fixed_point_operation_qs8( \n" + " __global char* src, \n" + " __global char* dst) \n" + "{ \n" + " char16 in = vload16(0, src + get_global_id(0) * 16); \n" + " if(FIXED_POINT_OP == 0) \n" + " { \n" + " vstore16(EXP_OP_EXPAND(in, DATA_TYPE, 16, FIXED_POINT_POS), 0, dst + get_global_id(0) * 16); \n" + " } \n" + " else if(FIXED_POINT_OP == 1) \n" + " { \n" + " vstore16(INVSQRT_OP_EXPAND(in, DATA_TYPE, 16, FIXED_POINT_POS), 0, dst + get_global_id(0) * 16); \n" + " } \n" + " else \n" + " { \n" + " vstore16(LOG_OP_EXPAND(in, DATA_TYPE, 16, FIXED_POINT_POS), 0, dst + get_global_id(0) * 16); \n" + " } \n" + "} \n" + "\n"; + + // Create tensors + CLTensor src = create_tensor(shape, DataType::QS8, 1, fixed_point_position); + CLTensor dst = create_tensor(shape, DataType::QS8, 1, fixed_point_position); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Set build options + std::string build_opts = "-DFIXED_POINT_POS=" + support::cpp11::to_string(fixed_point_position); + build_opts += " -DDATA_TYPE=qs8"; + + // Fill tensors. + int min = 0; + int max = 0; + switch(op) + { + case FixedPointOp::EXP: + min = -(1 << (fixed_point_position - 1)); + max = (1 << (fixed_point_position - 1)); + build_opts += " -DFIXED_POINT_OP=0"; + break; + case FixedPointOp::INV_SQRT: + min = 1; + max = 0x7F; + build_opts += " -DFIXED_POINT_OP=1"; + break; + case FixedPointOp::LOG: + min = (1 << (fixed_point_position - 1)); + max = 0x3F; + build_opts += " -DFIXED_POINT_OP=2"; + break; + default: + ARM_COMPUTE_ERROR("Operation not supported"); + } + + std::uniform_int_distribution<> distribution(min, max); + library->fill(CLAccessor(src), distribution, 0); + + std::vector sources; + +#ifndef EMBEDDED_KERNELS + build_opts += " -I" + CLKernelLibrary::get().get_kernel_path(); +#else /* EMBEDDED_KERNELS */ + sources.push_back(CLKernelLibrary::get().get_program_source("fixed_point.h")); +#endif /* EMBEDDED_KERNELS */ + + sources.push_back(fixed_point_operation_kernel); + + // Create program + ::cl::Program program(sources); + + // Build program + program.build(build_opts.c_str()); + + ::cl::Kernel kernel(program, "fixed_point_operation_qs8", nullptr); + + unsigned int idx = 0; + kernel.setArg(idx++, src.cl_buffer()); + kernel.setArg(idx++, dst.cl_buffer()); + + ::cl::NDRange gws(shape[0] / 16, 1, 1); + CLScheduler::get().queue().enqueueNDRangeKernel(kernel, 0, gws); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(FixedPoint) +BOOST_AUTO_TEST_SUITE(QS8) + +BOOST_AUTO_TEST_SUITE(Exp) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(1, 6), shape, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_fixed_point_op(shape, fixed_point_position, FixedPointOp::EXP); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS8, DataType::QS8, FixedPointOp::EXP, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst, tolerance_exp); +} + +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(Log) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(3, 6), shape, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_fixed_point_op(shape, fixed_point_position, FixedPointOp::LOG); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS8, DataType::QS8, FixedPointOp::LOG, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst, tolerance_log); +} + +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(Invsqrt) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(1, 6), shape, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_fixed_point_op(shape, fixed_point_position, FixedPointOp::INV_SQRT); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS8, DataType::QS8, FixedPointOp::INV_SQRT, fixed_point_position); + + // Validate output + validate(CLAccessor(dst), ref_dst, tolerance_invsqrt); +} + +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/Gaussian3x3.cpp b/tests/validation_old/CL/Gaussian3x3.cpp new file mode 100644 index 0000000000..27f4833289 --- /dev/null +++ b/tests/validation_old/CL/Gaussian3x3.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLGaussian3x3.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +constexpr unsigned int filter_size = 3; /** Size of the kernel/filter in number of elements. */ +constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ + +/** Compute CL gaussian3x3 filter. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] border_mode BorderMode used by the input tensor. + * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. + * + * @return Computed output tensor. + */ +CLTensor compute_gaussian3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, DataType::U8); + + // Create and configure function + CLGaussian3x3 gaussian3x3; + gaussian3x3.configure(&src, &dst, border_mode, constant_border_value); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(CLAccessor(src), 0); + + // Compute function + gaussian3x3.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(Gaussian3x3) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, DataType::U8); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + CLGaussian3x3 gaussian3x3; + gaussian3x3.configure(&src, &dst, border_mode); + + // Validate valid region + const ValidRegion src_valid_region = shape_to_valid_region(shape); + const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + validate(src.info()->valid_region(), src_valid_region); + validate(dst.info()->valid_region(), dst_valid_region); + + // Validate padding + PaddingCalculator calculator(shape.x(), 8); + calculator.set_border_size(1); + calculator.set_border_mode(border_mode); + + const PaddingSize dst_padding = calculator.required_padding(); + + calculator.set_accessed_elements(16); + calculator.set_access_offset(-1); + + const PaddingSize src_padding = calculator.required_padding(); + + validate(src.info()->padding(), src_padding); + validate(dst.info()->padding(), dst_padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) +{ + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + const uint8_t border_value = distribution(gen); + + // Compute function + CLTensor dst = compute_gaussian3x3(shape, border_mode, border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_gaussian3x3(shape, border_mode, border_value); + + // Validate output + validate(CLAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) +{ + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + const uint8_t border_value = distribution(gen); + + // Compute function + CLTensor dst = compute_gaussian3x3(shape, border_mode, border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_gaussian3x3(shape, border_mode, border_value); + + // Validate output + validate(CLAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/Gaussian5x5.cpp b/tests/validation_old/CL/Gaussian5x5.cpp new file mode 100644 index 0000000000..c187426f4c --- /dev/null +++ b/tests/validation_old/CL/Gaussian5x5.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLGaussian5x5.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +constexpr unsigned int filter_size = 5; /** Size of the kernel/filter in number of elements. */ +constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ + +/** Compute CL gaussian5x5 filter. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] border_mode BorderMode used by the input tensor. + * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. + * + * @return Computed output tensor. + */ +CLTensor compute_gaussian5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, DataType::U8); + + // Create and configure function + CLGaussian5x5 gaussian5x5; + gaussian5x5.configure(&src, &dst, border_mode, constant_border_value); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(CLAccessor(src), 0); + + // Compute function + gaussian5x5.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(Gaussian5x5) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, DataType::U8); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + CLGaussian5x5 gaussian5x5; + gaussian5x5.configure(&src, &dst, border_mode); + + // Validate valid region + const ValidRegion src_valid_region = shape_to_valid_region(shape); + const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + validate(src.info()->valid_region(), src_valid_region); + validate(dst.info()->valid_region(), dst_valid_region); + + // Validate padding + PaddingCalculator calculator(shape.x(), 8); + calculator.set_border_size(2); + calculator.set_border_mode(border_mode); + + const PaddingSize dst_padding = calculator.required_padding(); + + calculator.set_accessed_elements(16); + calculator.set_access_offset(-2); + + const PaddingSize src_padding = calculator.required_padding(); + + validate(src.info()->padding(), src_padding); + validate(dst.info()->padding(), dst_padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) +{ + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + const uint8_t border_value = distribution(gen); + + // Compute function + CLTensor dst = compute_gaussian5x5(shape, border_mode, border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_gaussian5x5(shape, border_mode, border_value); + + // Validate output + validate(CLAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) +{ + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + const uint8_t border_value = distribution(gen); + + // Compute function + CLTensor dst = compute_gaussian5x5(shape, border_mode, border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_gaussian5x5(shape, border_mode, border_value); + + // Validate output + validate(CLAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/HarrisCorners.cpp b/tests/validation_old/CL/HarrisCorners.cpp new file mode 100644 index 0000000000..2c73679058 --- /dev/null +++ b/tests/validation_old/CL/HarrisCorners.cpp @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLArray.h" +#include "arm_compute/runtime/CL/functions/CLHarrisCorners.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "PaddingCalculator.h" +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute CL Harris corners function. + * + * @param[in] shape Shape of input tensor + * @param[in] threshold Minimum threshold with which to eliminate Harris Corner scores (computed using the normalized Sobel kernel). + * @param[in] min_dist Radial Euclidean distance for the euclidean distance stage + * @param[in] sensitivity Sensitivity threshold k from the Harris-Stephens equation + * @param[in] gradient_size The gradient window size to use on the input. The implementation supports 3, 5, and 7 + * @param[in] block_size The block window size used to compute the Harris Corner score. The implementation supports 3, 5, and 7. + * @param[in] border_mode Border mode to use + * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. + * + * @return Computed corners' keypoints. + */ +void compute_harris_corners(const TensorShape &shape, CLKeyPointArray &corners, float threshold, float min_dist, float sensitivity, + int32_t gradient_size, int32_t block_size, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + src.info()->set_format(Format::U8); + + // Create harris corners configure function + CLHarrisCorners harris_corners; + harris_corners.configure(&src, threshold, min_dist, sensitivity, gradient_size, block_size, &corners, border_mode, constant_border_value); + + // Allocate tensors + src.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(CLAccessor(src), 0); + + // Compute function + harris_corners.run(); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(HarrisCorners) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (Small2DShapes() + Large2DShapes()) * BorderModes() + * boost::unit_test::data::make({ 3, 5, 7 }) * boost::unit_test::data::make({ 3, 5, 7 }), + shape, border_mode, gradient, block) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + src.info()->set_format(Format::U8); + + CLKeyPointArray corners(shape.total_size()); + + uint8_t constant_border_value = 0; + + std::mt19937 gen(user_config.seed.get()); + std::uniform_real_distribution real_dist(0.01, std::numeric_limits::min()); + + const float threshold = real_dist(gen); + const float sensitivity = real_dist(gen); + const float max_euclidean_distance = 30.f; + + real_dist = std::uniform_real_distribution(0.f, max_euclidean_distance); + float min_dist = real_dist(gen); + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::uniform_int_distribution int_dist(0, 255); + constant_border_value = int_dist(gen); + } + + BOOST_TEST(src.info()->is_resizable()); + + // Create harris corners configure function + CLHarrisCorners harris_corners; + harris_corners.configure(&src, threshold, min_dist, sensitivity, gradient, block, &corners, border_mode, constant_border_value); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + + validate(src.info()->valid_region(), valid_region); + + // Validate padding + PaddingCalculator calculator(shape.x(), 8); + + calculator.set_border_mode(border_mode); + calculator.set_border_size(gradient / 2); + calculator.set_access_offset(-gradient / 2); + calculator.set_accessed_elements(16); + + const PaddingSize padding = calculator.required_padding(); + + validate(src.info()->padding(), padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, Small2DShapes() * BorderModes() * boost::unit_test::data::make({ 3, 5, 7 }) * boost::unit_test::data::make({ 3, 5, 7 }), shape, border_mode, gradient, block) +{ + uint8_t constant_border_value = 0; + + std::mt19937 gen(user_config.seed.get()); + std::uniform_real_distribution real_dist(0.01, std::numeric_limits::min()); + + const float threshold = real_dist(gen); + const float sensitivity = real_dist(gen); + const float max_euclidean_distance = 30.f; + + real_dist = std::uniform_real_distribution(0.f, max_euclidean_distance); + const float min_dist = real_dist(gen); + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::uniform_int_distribution int_dist(0, 255); + constant_border_value = int_dist(gen); + } + + // Create array of keypoints + CLKeyPointArray dst(shape.total_size()); + + // Compute function + compute_harris_corners(shape, dst, threshold, min_dist, sensitivity, gradient, block, border_mode, constant_border_value); + + // Compute reference + KeyPointArray ref_dst = Reference::compute_reference_harris_corners(shape, threshold, min_dist, sensitivity, gradient, block, border_mode, constant_border_value); + + // Validate output + dst.map(); + validate(dst, ref_dst, 1); + dst.unmap(); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, Large2DShapes() * BorderModes() * boost::unit_test::data::make({ 3, 5, 7 }) * boost::unit_test::data::make({ 3, 5, 7 }), shape, border_mode, gradient, block) +{ + uint8_t constant_border_value = 0; + + std::mt19937 gen(user_config.seed.get()); + std::uniform_real_distribution real_dist(0.01, std::numeric_limits::min()); + + const float threshold = real_dist(gen); + const float sensitivity = real_dist(gen); + const float max_euclidean_distance = 30.f; + + real_dist = std::uniform_real_distribution(0.f, max_euclidean_distance); + const float min_dist = real_dist(gen); + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::uniform_int_distribution int_dist(0, 255); + constant_border_value = int_dist(gen); + } + + // Create array of keypoints + CLKeyPointArray dst(shape.total_size()); + + // Compute function + compute_harris_corners(shape, dst, threshold, min_dist, sensitivity, gradient, block, border_mode, constant_border_value); + + // Compute reference + KeyPointArray ref_dst = Reference::compute_reference_harris_corners(shape, threshold, min_dist, sensitivity, gradient, block, border_mode, constant_border_value); + + // Validate output + dst.map(); + validate(dst, ref_dst); + dst.unmap(); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/IntegralImage.cpp b/tests/validation_old/CL/IntegralImage.cpp new file mode 100644 index 0000000000..ea15b90b2a --- /dev/null +++ b/tests/validation_old/CL/IntegralImage.cpp @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "CL/CLAccessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/functions/CLIntegralImage.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute CL integral image function. + * + * @param[in] shape Shape of the input and output tensors. + * + * @return Computed output tensor. + */ +CLTensor compute_integral_image(const TensorShape &shape) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, DataType::U32); + + // Create integral image configure function + CLIntegralImage integral_image; + integral_image.configure(&src, &dst); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(CLAccessor(src), 0); + + // Compute function + integral_image.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(IntegralImage) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, SmallShapes() + LargeShapes(), shape) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, DataType::U32); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create integral image configure function + CLIntegralImage integral_image; + integral_image.configure(&src, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) +{ + // Compute function + CLTensor dst = compute_integral_image(shape); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_integral_image(shape); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes(), shape) +{ + // Compute function + CLTensor dst = compute_integral_image(shape); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_integral_image(shape); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/MinMaxLocation.cpp b/tests/validation_old/CL/MinMaxLocation.cpp new file mode 100644 index 0000000000..8824215223 --- /dev/null +++ b/tests/validation_old/CL/MinMaxLocation.cpp @@ -0,0 +1,397 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "CL/CLAccessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/functions/CLMinMaxLocation.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "PaddingCalculator.h" +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute CL MinMaxLocation function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in Data type of first input tensor. + * @param[out] min Minimum value of tensor + * @param[out] max Maximum value of tensor + * @param[out] min_loc Array with locations of minimum values + * @param[out] max_loc Array with locations of maximum values + * @param[out] min_count Number of minimum values found + * @param[out] max_count Number of maximum values found + * + * @return Computed output tensor. + */ +void compute_min_max_location(const TensorShape &shape, DataType dt_in, void *min, void *max, + CLCoordinates2DArray &min_loc, CLCoordinates2DArray &max_loc, uint32_t &min_count, uint32_t &max_count) +{ + // Create tensor + CLTensor src = create_tensor(shape, dt_in); + + // Create and configure min_max_location configure function + CLMinMaxLocation min_max_loc; + min_max_loc.configure(&src, min, max, &min_loc, &max_loc, &min_count, &max_count); + + // Allocate tensors + src.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(CLAccessor(src), 0); + + // Compute function + min_max_loc.run(); +} + +void validate_configuration(const CLTensor &src, TensorShape shape) +{ + BOOST_TEST(src.info()->is_resizable()); + + // Create output storage + int32_t min; + int32_t max; + CLCoordinates2DArray min_loc(shape.total_size()); + CLCoordinates2DArray max_loc(shape.total_size()); + uint32_t min_count; + uint32_t max_count; + + // Create and configure function + CLMinMaxLocation min_max_loc; + min_max_loc.configure(&src, &min, &max, &min_loc, &max_loc, &min_count, &max_count); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), src.info()->dimension(0)).required_padding(); + validate(src.info()->padding(), padding); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(MinMaxLocation) +BOOST_AUTO_TEST_SUITE(U8) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (Small2DShapes() + Large2DShapes()), + shape) +{ + // Create tensor + CLTensor src = create_tensor(shape, DataType::U8); + src.info()->set_format(Format::U8); + + validate_configuration(src, shape); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, Small2DShapes(), + shape) +{ + // Create output storage + int32_t min; + int32_t max; + CLCoordinates2DArray min_loc(shape.total_size()); + CLCoordinates2DArray max_loc(shape.total_size()); + uint32_t min_count; + uint32_t max_count; + + int32_t ref_min; + int32_t ref_max; + CLCoordinates2DArray ref_min_loc(shape.total_size()); + CLCoordinates2DArray ref_max_loc(shape.total_size()); + uint32_t ref_min_count; + uint32_t ref_max_count; + + // Compute function + compute_min_max_location(shape, DataType::U8, &min, &max, min_loc, max_loc, min_count, max_count); + + // Compute reference + ref_min_loc.map(); + ref_max_loc.map(); + + Reference::compute_reference_min_max_location(shape, DataType::U8, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); + + min_loc.map(); + max_loc.map(); + + // Validate output + validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); + + ref_min_loc.unmap(); + ref_max_loc.unmap(); + min_loc.unmap(); + max_loc.unmap(); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, Large2DShapes(), + shape) +{ + // Create output storage + int32_t min; + int32_t max; + CLCoordinates2DArray min_loc(shape.total_size()); + CLCoordinates2DArray max_loc(shape.total_size()); + uint32_t min_count; + uint32_t max_count; + + int32_t ref_min; + int32_t ref_max; + CLCoordinates2DArray ref_min_loc(shape.total_size()); + CLCoordinates2DArray ref_max_loc(shape.total_size()); + uint32_t ref_min_count; + uint32_t ref_max_count; + + // Compute function + compute_min_max_location(shape, DataType::U8, &min, &max, min_loc, max_loc, min_count, max_count); + + // Compute reference + ref_min_loc.map(); + ref_max_loc.map(); + + Reference::compute_reference_min_max_location(shape, DataType::U8, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); + + min_loc.map(); + max_loc.map(); + + // Validate output + validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); + + ref_min_loc.unmap(); + ref_max_loc.unmap(); + min_loc.unmap(); + max_loc.unmap(); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(S16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (Small2DShapes() + Large2DShapes()), + shape) +{ + // Create tensor + CLTensor src = create_tensor(shape, DataType::S16); + src.info()->set_format(Format::S16); + + validate_configuration(src, shape); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, Small2DShapes(), + shape) +{ + // Create output storage + int32_t min; + int32_t max; + CLCoordinates2DArray min_loc(shape.total_size()); + CLCoordinates2DArray max_loc(shape.total_size()); + uint32_t min_count; + uint32_t max_count; + + int32_t ref_min; + int32_t ref_max; + CLCoordinates2DArray ref_min_loc(shape.total_size()); + CLCoordinates2DArray ref_max_loc(shape.total_size()); + uint32_t ref_min_count; + uint32_t ref_max_count; + + // Compute function + compute_min_max_location(shape, DataType::S16, &min, &max, min_loc, max_loc, min_count, max_count); + + // Compute reference + ref_min_loc.map(); + ref_max_loc.map(); + + Reference::compute_reference_min_max_location(shape, DataType::S16, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); + + min_loc.map(); + max_loc.map(); + + // Validate output + validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); + + ref_min_loc.unmap(); + ref_max_loc.unmap(); + min_loc.unmap(); + max_loc.unmap(); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, Large2DShapes(), + shape) +{ + // Create output storage + int32_t min; + int32_t max; + CLCoordinates2DArray min_loc(shape.total_size()); + CLCoordinates2DArray max_loc(shape.total_size()); + uint32_t min_count; + uint32_t max_count; + + int32_t ref_min; + int32_t ref_max; + CLCoordinates2DArray ref_min_loc(shape.total_size()); + CLCoordinates2DArray ref_max_loc(shape.total_size()); + uint32_t ref_min_count; + uint32_t ref_max_count; + + // Compute function + compute_min_max_location(shape, DataType::S16, &min, &max, min_loc, max_loc, min_count, max_count); + + // Compute reference + ref_min_loc.map(); + ref_max_loc.map(); + + Reference::compute_reference_min_max_location(shape, DataType::S16, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); + + min_loc.map(); + max_loc.map(); + + // Validate output + validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); + + ref_min_loc.unmap(); + ref_max_loc.unmap(); + min_loc.unmap(); + max_loc.unmap(); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(Float) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (Small2DShapes() + Large2DShapes()), + shape) +{ + // Create tensor + CLTensor src = create_tensor(shape, DataType::F32); + + validate_configuration(src, shape); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, Small2DShapes(), + shape) +{ + // Create output storage + float min; + float max; + CLCoordinates2DArray min_loc(shape.total_size()); + CLCoordinates2DArray max_loc(shape.total_size()); + uint32_t min_count; + uint32_t max_count; + + float ref_min; + float ref_max; + CLCoordinates2DArray ref_min_loc(shape.total_size()); + CLCoordinates2DArray ref_max_loc(shape.total_size()); + uint32_t ref_min_count; + uint32_t ref_max_count; + + // Compute function + compute_min_max_location(shape, DataType::F32, &min, &max, min_loc, max_loc, min_count, max_count); + + // Compute reference + ref_min_loc.map(); + ref_max_loc.map(); + + Reference::compute_reference_min_max_location(shape, DataType::F32, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); + + min_loc.map(); + max_loc.map(); + + // Validate output + validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); + + ref_min_loc.unmap(); + ref_max_loc.unmap(); + min_loc.unmap(); + max_loc.unmap(); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, Large2DShapes(), + shape) +{ + // Create output storage + float min; + float max; + CLCoordinates2DArray min_loc(shape.total_size()); + CLCoordinates2DArray max_loc(shape.total_size()); + uint32_t min_count; + uint32_t max_count; + + float ref_min; + float ref_max; + CLCoordinates2DArray ref_min_loc(shape.total_size()); + CLCoordinates2DArray ref_max_loc(shape.total_size()); + uint32_t ref_min_count; + uint32_t ref_max_count; + + // Compute function + compute_min_max_location(shape, DataType::F32, &min, &max, min_loc, max_loc, min_count, max_count); + + // Compute reference + ref_min_loc.map(); + ref_max_loc.map(); + + Reference::compute_reference_min_max_location(shape, DataType::F32, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); + + min_loc.map(); + max_loc.map(); + + // Validate output + validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); + + ref_min_loc.unmap(); + ref_max_loc.unmap(); + min_loc.unmap(); + max_loc.unmap(); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/NonLinearFilter.cpp b/tests/validation_old/CL/NonLinearFilter.cpp new file mode 100644 index 0000000000..0132f7db8c --- /dev/null +++ b/tests/validation_old/CL/NonLinearFilter.cpp @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Helpers.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/functions/CLNonLinearFilter.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute NonLinearFilter function. + * + * @param[in] input Shape of the input and output tensors. + * @param[in] function Non linear function to perform + * @param[in] mask_size Mask size. Supported sizes: 3, 5 + * @param[in] pattern Mask pattern + * @param[in] mask The given mask. Will be used only if pattern is specified to PATTERN_OTHER + * @param[in] border_mode Strategy to use for borders. + * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT. + * + * @return Computed output CL tensor. + */ +CLTensor compute_non_linear_filter(const TensorShape &shape, NonLinearFilterFunction function, unsigned int mask_size, + MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, + uint8_t constant_border_value) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, DataType::U8); + + // Create and configure function + CLNonLinearFilter filter; + filter.configure(&src, &dst, function, mask_size, pattern, mask, border_mode, constant_border_value); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(CLAccessor(src), 0); + + // Compute function + filter.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(NonLinearFilter) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) + * NonLinearFilterFunctions() * boost::unit_test::data::make({ 3U, 5U }) + * boost::unit_test::data::make({ MatrixPattern::BOX, MatrixPattern::CROSS, MatrixPattern::DISK }) * BorderModes(), + shape, function, mask_size, pattern, border_mode) +{ + std::mt19937 generator(user_config.seed.get()); + std::uniform_int_distribution distribution_u8(0, 255); + const uint8_t constant_border_value = distribution_u8(generator); + + // Create the mask + uint8_t mask[mask_size * mask_size]; + fill_mask_from_pattern(mask, mask_size, mask_size, pattern); + const auto half_mask_size = static_cast(mask_size / 2); + + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, DataType::U8); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + CLNonLinearFilter filter; + filter.configure(&src, &dst, function, mask_size, pattern, mask, border_mode, constant_border_value); + + // Validate valid region + const ValidRegion src_valid_region = shape_to_valid_region(shape); + const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, BorderSize(half_mask_size)); + + validate(src.info()->valid_region(), src_valid_region); + validate(dst.info()->valid_region(), dst_valid_region); + + // Validate padding + PaddingCalculator calculator(shape.x(), ((MatrixPattern::OTHER == pattern) ? 1 : 8)); + calculator.set_border_mode(border_mode); + calculator.set_border_size(half_mask_size); + + const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER); + + calculator.set_accessed_elements(16); + calculator.set_access_offset(-half_mask_size); + + const PaddingSize read_padding = calculator.required_padding(PaddingCalculator::Option::INCLUDE_BORDER); + + validate(src.info()->padding(), read_padding); + validate(dst.info()->padding(), write_padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() + * NonLinearFilterFunctions() * boost::unit_test::data::make({ 3U, 5U }) + * boost::unit_test::data::make({ MatrixPattern::BOX, MatrixPattern::CROSS, MatrixPattern::DISK }) * BorderModes(), + shape, function, mask_size, pattern, border_mode) +{ + std::mt19937 generator(user_config.seed.get()); + std::uniform_int_distribution distribution_u8(0, 255); + const uint8_t constant_border_value = distribution_u8(generator); + + // Create the mask + uint8_t mask[mask_size * mask_size]; + fill_mask_from_pattern(mask, mask_size, mask_size, pattern); + + // Compute function + CLTensor dst = compute_non_linear_filter(shape, function, mask_size, pattern, mask, border_mode, constant_border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_non_linear_filter(shape, function, mask_size, pattern, mask, border_mode, constant_border_value); + + // Calculate valid region + const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, BorderSize(static_cast(mask_size / 2))); + + // Validate output + validate(CLAccessor(dst), ref_dst, valid_region); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() + * NonLinearFilterFunctions() * boost::unit_test::data::make({ 3U, 5U }) + * boost::unit_test::data::make({ MatrixPattern::BOX, MatrixPattern::CROSS, MatrixPattern::DISK }) * BorderModes(), + shape, function, mask_size, pattern, border_mode) +{ + std::mt19937 generator(user_config.seed.get()); + std::uniform_int_distribution distribution_u8(0, 255); + const uint8_t constant_border_value = distribution_u8(generator); + + // Create the mask + uint8_t mask[mask_size * mask_size]; + fill_mask_from_pattern(mask, mask_size, mask_size, pattern); + + // Compute function + CLTensor dst = compute_non_linear_filter(shape, function, mask_size, pattern, mask, border_mode, constant_border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_non_linear_filter(shape, function, mask_size, pattern, mask, border_mode, constant_border_value); + + // Calculate valid region + const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, BorderSize(static_cast(mask_size / 2))); + + // Validate output + validate(CLAccessor(dst), ref_dst, valid_region); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/PixelWiseMultiplication.cpp b/tests/validation_old/CL/PixelWiseMultiplication.cpp new file mode 100644 index 0000000000..f003298a23 --- /dev/null +++ b/tests/validation_old/CL/PixelWiseMultiplication.cpp @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "TypePrinter.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/runtime/CL/functions/CLPixelWiseMultiplication.h" + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +const float tolerance_f32 = 1.f; /**< Tolerance value for comparing reference's output against implementation's output for float input */ +const float tolerance_f16 = 1.f; /**< Tolerance value for comparing reference's output against implementation's output for float input */ + +/** Compute CL pixel-wise multiplication function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in0 Data type of first input tensor. + * @param[in] dt_in1 Data type of second input tensor. + * @param[in] dt_out Data type of the output tensor. + * @param[in] scale Non-negative scale. + * @param[in] convert_policy Overflow policy of the operation. + * @param[in] rounding_policy Rounding policy of the operation. + * @param[in] fixed_point_position (Optional) Fixed point position that expresses the number of bits for the fractional part of the number. + * + * @return Computed output tensor. + */ +CLTensor compute_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy, + int fixed_point_position = 0) +{ + // Create tensors + CLTensor src1 = create_tensor(shape, dt_in0, 1, fixed_point_position); + CLTensor src2 = create_tensor(shape, dt_in1, 1, fixed_point_position); + CLTensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); + + // Create and configure function + CLPixelWiseMultiplication multiply; + multiply.configure(&src1, &src2, &dst, scale, convert_policy, rounding_policy); + + // Allocate tensors + src1.allocator()->allocate(); + src2.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src1.info()->is_resizable()); + BOOST_TEST(!src2.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(CLAccessor(src1), 0); + library->fill_tensor_uniform(CLAccessor(src2), 1); + + // Compute function + multiply.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(PixelWiseMultiplication) + +BOOST_AUTO_TEST_SUITE(Float16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::F16 *ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP, + shape, dt, convert_policy, rounding_policy) +{ + constexpr float scale = 1.f / 255.f; + + // Compute function + CLTensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy); + + // Validate output + validate(CLAccessor(dst), ref_dst, tolerance_f16); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(Float) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::F32 *ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP, + shape, dt, convert_policy, rounding_policy) +{ + constexpr float scale = 1.f / 255.f; + + // Compute function + CLTensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy); + + // Validate output + validate(CLAccessor(dst), ref_dst, tolerance_f32); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(Quantized) +BOOST_AUTO_TEST_SUITE(QS8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 7), + shape, dt, convert_policy, rounding_policy, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, fixed_point_position, convert_policy, rounding_policy); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(QS16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::QS16 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 15), + shape, dt, convert_policy, rounding_policy, fixed_point_position) +{ + // Compute function + CLTensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, fixed_point_position, convert_policy, rounding_policy); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif // DOXYGEN_SKIP_THIS diff --git a/tests/validation_old/CL/ROIPoolingLayer.cpp b/tests/validation_old/CL/ROIPoolingLayer.cpp new file mode 100644 index 0000000000..edd1cccf2a --- /dev/null +++ b/tests/validation_old/CL/ROIPoolingLayer.cpp @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "CL/CLArrayAccessor.h" +#include "TypePrinter.h" +#include "arm_compute/runtime/CL/CLArray.h" +#include "arm_compute/runtime/CL/functions/CLROIPoolingLayer.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +CLTensor compute_roi_pooling_layer(const TensorShape &shape, DataType dt, const std::vector &rois, ROIPoolingLayerInfo pool_info) +{ + TensorShape shape_dst; + shape_dst.set(0, pool_info.pooled_width()); + shape_dst.set(1, pool_info.pooled_height()); + shape_dst.set(2, shape.z()); + shape_dst.set(3, rois.size()); + + // Create tensors + CLTensor src = create_tensor(shape, dt); + CLTensor dst = create_tensor(shape_dst, dt); + + // Create ROI array + CLArray rois_array(rois.size()); + fill_array(CLArrayAccessor(rois_array), rois); + + // Create and configure function + CLROIPoolingLayer roi_pool; + roi_pool.configure(&src, &rois_array, &dst, pool_info); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + std::uniform_real_distribution<> distribution(-1, 1); + library->fill(CLAccessor(src), distribution, 0); + + // Compute function + roi_pool.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(ROIPoolingLayer) + +BOOST_AUTO_TEST_SUITE(Float) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, boost::unit_test::data::make({ DataType::F16, DataType::F32 }) * boost::unit_test::data::make({ 10, 20, 40 }) * boost::unit_test::data::make({ 7, 9 }) * + boost::unit_test::data::make({ 1.f / 8.f, 1.f / 16.f }), + dt, num_rois, roi_pool_size, roi_scale) +{ + TensorShape shape(50U, 47U, 2U, 3U); + ROIPoolingLayerInfo pool_info(roi_pool_size, roi_pool_size, roi_scale); + + // Construct ROI vector + std::vector rois = generate_random_rois(shape, pool_info, num_rois, user_config.seed); + + // Compute function + CLTensor dst = compute_roi_pooling_layer(shape, dt, rois, pool_info); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_roi_pooling_layer(shape, dt, rois, pool_info); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/Sobel3x3.cpp b/tests/validation_old/CL/Sobel3x3.cpp new file mode 100644 index 0000000000..a4c779cd5c --- /dev/null +++ b/tests/validation_old/CL/Sobel3x3.cpp @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "CL/CLAccessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLSubTensor.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLSobel3x3.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +constexpr unsigned int filter_size = 3; /** Size of the kernel/filter in number of elements. */ +constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ + +/** Compute CL Sobel 3x3 function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] border_mode BorderMode used by the input tensor + * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT + * + * @return Computed output tensor. + */ +std::pair compute_sobel_3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst_x = create_tensor(shape, DataType::S16); + CLTensor dst_y = create_tensor(shape, DataType::S16); + + src.info()->set_format(Format::U8); + dst_x.info()->set_format(Format::S16); + dst_y.info()->set_format(Format::S16); + + // Create sobel image configure function + CLSobel3x3 sobel_3x3; + sobel_3x3.configure(&src, &dst_x, &dst_y, border_mode, constant_border_value); + + // Allocate tensors + src.allocator()->allocate(); + dst_x.allocator()->allocate(); + dst_y.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst_x.info()->is_resizable()); + BOOST_TEST(!dst_y.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(CLAccessor(src), 0); + + // Compute function + sobel_3x3.run(); + + return std::make_pair(std::move(dst_x), std::move(dst_y)); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(Sobel3x3) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst_x = create_tensor(shape, DataType::S16); + CLTensor dst_y = create_tensor(shape, DataType::S16); + + src.info()->set_format(Format::U8); + dst_x.info()->set_format(Format::S16); + dst_y.info()->set_format(Format::S16); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst_x.info()->is_resizable()); + BOOST_TEST(dst_y.info()->is_resizable()); + + // Create sobel 3x3 configure function + CLSobel3x3 sobel_3x3; + sobel_3x3.configure(&src, &dst_x, &dst_y, border_mode); + + // Validate valid region + const ValidRegion src_valid_region = shape_to_valid_region(shape); + const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + + validate(src.info()->valid_region(), src_valid_region); + validate(dst_x.info()->valid_region(), dst_valid_region); + validate(dst_y.info()->valid_region(), dst_valid_region); + + // Validate padding + PaddingCalculator calculator(shape.x(), 8); + + calculator.set_border_mode(border_mode); + calculator.set_border_size(1); + + const PaddingSize dst_padding = calculator.required_padding(); + + calculator.set_accessed_elements(16); + calculator.set_access_offset(-1); + + const PaddingSize src_padding = calculator.required_padding(); + + validate(src.info()->padding(), src_padding); + validate(dst_x.info()->padding(), dst_padding); + validate(dst_y.info()->padding(), dst_padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) +{ + uint8_t constant_border_value = 0; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + constant_border_value = distribution(gen); + } + + // Compute function + std::pair dst = compute_sobel_3x3(shape, border_mode, constant_border_value); + + // Compute reference + std::pair ref_dst = Reference::compute_reference_sobel_3x3(shape, border_mode, constant_border_value); + + // Calculate valid region + const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + + // Validate output + validate(CLAccessor(dst.first), ref_dst.first, valid_region); + validate(CLAccessor(dst.second), ref_dst.second, valid_region); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) +{ + uint8_t constant_border_value = 0; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + constant_border_value = distribution(gen); + } + + // Compute function + std::pair dst = compute_sobel_3x3(shape, border_mode, constant_border_value); + + // Compute reference + std::pair ref_dst = Reference::compute_reference_sobel_3x3(shape, border_mode, constant_border_value); + + // Calculate valid region + const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + + // Validate output + validate(CLAccessor(dst.first), ref_dst.first, valid_region); + validate(CLAccessor(dst.second), ref_dst.second, valid_region); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/Sobel5x5.cpp b/tests/validation_old/CL/Sobel5x5.cpp new file mode 100644 index 0000000000..7e5dec1209 --- /dev/null +++ b/tests/validation_old/CL/Sobel5x5.cpp @@ -0,0 +1,204 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "CL/CLAccessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLSubTensor.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLSobel5x5.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +constexpr unsigned int filter_size = 5; /** Size of the kernel/filter in number of elements. */ +constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ + +/** Compute CL Sobel 5x5 function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] border_mode BorderMode used by the input tensor + * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT + * + * @return Computed output tensor. + */ +std::pair compute_sobel_5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst_x = create_tensor(shape, DataType::S16); + CLTensor dst_y = create_tensor(shape, DataType::S16); + + src.info()->set_format(Format::U8); + dst_x.info()->set_format(Format::S16); + dst_y.info()->set_format(Format::S16); + + // Create sobel image configure function + CLSobel5x5 sobel_5x5; + sobel_5x5.configure(&src, &dst_x, &dst_y, border_mode, constant_border_value); + + // Allocate tensors + src.allocator()->allocate(); + dst_x.allocator()->allocate(); + dst_y.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst_x.info()->is_resizable()); + BOOST_TEST(!dst_y.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(CLAccessor(src), 0); + + // Compute function + sobel_5x5.run(); + + return std::make_pair(std::move(dst_x), std::move(dst_y)); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(Sobel5x5) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst_x = create_tensor(shape, DataType::S16); + CLTensor dst_y = create_tensor(shape, DataType::S16); + + src.info()->set_format(Format::U8); + dst_x.info()->set_format(Format::S16); + dst_y.info()->set_format(Format::S16); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst_x.info()->is_resizable()); + BOOST_TEST(dst_y.info()->is_resizable()); + + // Create sobel 5x5 configure function + CLSobel5x5 sobel_5x5; + sobel_5x5.configure(&src, &dst_x, &dst_y, border_mode); + + // Validate valid region + const ValidRegion src_valid_region = shape_to_valid_region(shape); + const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + + validate(src.info()->valid_region(), src_valid_region); + validate(dst_x.info()->valid_region(), dst_valid_region); + validate(dst_y.info()->valid_region(), dst_valid_region); + + // Validate padding + PaddingCalculator calculator(shape.x(), 8); + calculator.set_border_mode(border_mode); + calculator.set_border_size(2); + + const PaddingSize dst_padding = calculator.required_padding(); + + calculator.set_accessed_elements(16); + calculator.set_access_offset(-2); + + const PaddingSize src_padding = calculator.required_padding(); + + validate(src.info()->padding(), src_padding); + validate(dst_x.info()->padding(), dst_padding); + validate(dst_y.info()->padding(), dst_padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) +{ + uint8_t constant_border_value = 0; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + constant_border_value = distribution(gen); + } + + // Compute function + std::pair dst = compute_sobel_5x5(shape, border_mode, constant_border_value); + + // Compute reference + std::pair ref_dst = Reference::compute_reference_sobel_5x5(shape, border_mode, constant_border_value); + + // Calculate valid region + const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + + // Validate output + validate(CLAccessor(dst.first), ref_dst.first, valid_region); + validate(CLAccessor(dst.second), ref_dst.second, valid_region); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) +{ + uint8_t constant_border_value = 0; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + constant_border_value = distribution(gen); + } + + // Compute function + std::pair dst = compute_sobel_5x5(shape, border_mode, constant_border_value); + + // Compute reference + std::pair ref_dst = Reference::compute_reference_sobel_5x5(shape, border_mode, constant_border_value); + + // Calculate valid region + const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + + // Validate output + validate(CLAccessor(dst.first), ref_dst.first, valid_region); + validate(CLAccessor(dst.second), ref_dst.second, valid_region); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/TableLookup.cpp b/tests/validation_old/CL/TableLookup.cpp new file mode 100644 index 0000000000..26c38689f0 --- /dev/null +++ b/tests/validation_old/CL/TableLookup.cpp @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "CL/CLLutAccessor.h" +#include "PaddingCalculator.h" +#include "RawLutAccessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Helpers.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLTableLookup.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Table Lookup function. + * + * @param[in] shape Shape of the input tensors + * @param[in] data_type Type of the input/output tensor + * @param[in] lut The input LUT. + * + * @return Computed output cl tensor. + */ +CLTensor compute_table_lookup(const TensorShape &shape, DataType data_type, CLLut &lut) +{ + // Create tensors + CLTensor src = create_tensor(shape, data_type); + CLTensor dst = create_tensor(shape, data_type); + + // Create and configure function + CLTableLookup table_lookup; + table_lookup.configure(&src, &lut, &dst); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(CLAccessor(src), 0); + + // Compute function + table_lookup.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(TableLookup) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), + shape, data_type) +{ + //Create Lut + const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; + CLLut cllut(num_elem, data_type); + + if(data_type == DataType::U8) + { + fill_lookuptable(CLLutAccessor(cllut)); + } + else + { + fill_lookuptable(CLLutAccessor(cllut)); + } + + // Create tensors + CLTensor src = create_tensor(shape, data_type); + CLTensor dst = create_tensor(shape, data_type); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + CLTableLookup table_lookup; + table_lookup.configure(&src, &cllut, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 8).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, + SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), + shape, data_type) +{ + //Create Lut + const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; + CLLut cllut(num_elem, data_type); + + if(data_type == DataType::U8) + { + //Create rawLut + std::map rawlut; + + //Fill the Lut + fill_lookuptable(CLLutAccessor(cllut)); + fill_lookuptable(RawLutAccessor(rawlut)); + + // Compute function + CLTensor dst = compute_table_lookup(shape, data_type, cllut); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); + + // Validate output + validate(CLAccessor(dst), ref_dst); + } + else + { + //Create rawLut + std::map rawlut; + + //Fill the Lut + fill_lookuptable(CLLutAccessor(cllut)); + fill_lookuptable(RawLutAccessor(rawlut)); + + // Compute function + CLTensor dst = compute_table_lookup(shape, data_type, cllut); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); + + // Validate output + validate(CLAccessor(dst), ref_dst); + } +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, + LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), + shape, data_type) +{ + //Create Lut + const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; + CLLut cllut(num_elem, data_type); + + if(data_type == DataType::U8) + { + //Create rawLut + std::map rawlut; + + //Fill the Lut + fill_lookuptable(CLLutAccessor(cllut)); + fill_lookuptable(RawLutAccessor(rawlut)); + + // Compute function + CLTensor dst = compute_table_lookup(shape, data_type, cllut); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); + + // Validate output + validate(CLAccessor(dst), ref_dst); + } + else + { + //Create rawLut + std::map rawlut; + + //Fill the Lut + fill_lookuptable(CLLutAccessor(cllut)); + fill_lookuptable(RawLutAccessor(rawlut)); + + // Compute function + CLTensor dst = compute_table_lookup(shape, data_type, cllut); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); + + // Validate output + validate(CLAccessor(dst), ref_dst); + } +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/Threshold.cpp b/tests/validation_old/CL/Threshold.cpp new file mode 100644 index 0000000000..74ddd6873e --- /dev/null +++ b/tests/validation_old/CL/Threshold.cpp @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/dataset/ThresholdDataset.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/CLTensor.h" +#include "arm_compute/runtime/CL/CLTensorAllocator.h" +#include "arm_compute/runtime/CL/functions/CLThreshold.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Threshold function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] threshold Threshold. When the threshold type is RANGE, this is used as the lower threshold. + * @param[in] false_value value to set when the condition is not respected. + * @param[in] true_value value to set when the condition is respected. + * @param[in] type Thresholding type. Either RANGE or BINARY. + * @param[in] upper Upper threshold. Only used when the thresholding type is RANGE. + * + * @return Computed output tensor. + */ +CLTensor compute_threshold(const TensorShape &shape, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, DataType::U8); + + // Create and configure function + CLThreshold thrsh; + thrsh.configure(&src, &dst, threshold, false_value, true_value, type, upper); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(CLAccessor(src), 0); + + // Compute function + thrsh.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(Threshold) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, + (SmallShapes() + LargeShapes()) * ThresholdDataset(), + shape, threshold_conf) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, DataType::U8); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + CLThreshold cl_threshold; + cl_threshold.configure(&src, &dst, threshold_conf.threshold, threshold_conf.false_value, threshold_conf.true_value, threshold_conf.type, threshold_conf.upper); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, + SmallShapes() * ThresholdDataset(), + shape, threshold_conf) +{ + // Compute function + CLTensor dst = compute_threshold(shape, threshold_conf.threshold, threshold_conf.false_value, threshold_conf.true_value, threshold_conf.type, threshold_conf.upper); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_threshold(shape, threshold_conf.threshold, threshold_conf.false_value, threshold_conf.true_value, threshold_conf.type, threshold_conf.upper); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, + LargeShapes() * ThresholdDataset(), + shape, threshold_conf) +{ + // Compute function + CLTensor dst = compute_threshold(shape, threshold_conf.threshold, threshold_conf.false_value, threshold_conf.true_value, threshold_conf.type, threshold_conf.upper); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_threshold(shape, threshold_conf.threshold, threshold_conf.false_value, threshold_conf.true_value, threshold_conf.type, threshold_conf.upper); + + // Validate output + validate(CLAccessor(dst), ref_dst); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/WarpPerspective.cpp b/tests/validation_old/CL/WarpPerspective.cpp new file mode 100644 index 0000000000..6252361003 --- /dev/null +++ b/tests/validation_old/CL/WarpPerspective.cpp @@ -0,0 +1,208 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Helpers.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/CL/functions/CLWarpPerspective.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Warp Perspective function. + * + * @param[in] input Shape of the input and output tensors. + * @param[in] matrix The perspective matrix. Must be 3x3 of type float. + * @param[in] policy The interpolation type. + * @param[in] border_mode Strategy to use for borders. + * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. + * + * @return Computed output tensor. + */ +CLTensor compute_warp_perspective(const TensorShape &shape, const float *matrix, InterpolationPolicy policy, + BorderMode border_mode, uint8_t constant_border_value) +{ + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, DataType::U8); + + // Create and configure function + CLWarpPerspective warp_perspective; + warp_perspective.configure(&src, &dst, matrix, policy, border_mode, constant_border_value); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(CLAccessor(src), 0); + + // Compute function + warp_perspective.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(CL) +BOOST_AUTO_TEST_SUITE(WarpPerspective) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) + * boost::unit_test::data::make({ InterpolationPolicy::BILINEAR, InterpolationPolicy::NEAREST_NEIGHBOR }) * BorderModes(), + shape, policy, border_mode) +{ + uint8_t constant_border_value = 0; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution_u8(0, 255); + constant_border_value = distribution_u8(gen); + } + + std::array matrix; + fill_warp_matrix<9>(matrix, 3, 3); + + // Create tensors + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, DataType::U8); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + CLWarpPerspective warp_perspective; + warp_perspective.configure(&src, &dst, matrix.data(), policy, border_mode, constant_border_value); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + PaddingCalculator calculator(shape.x(), 4); + calculator.set_border_mode(border_mode); + + const PaddingSize read_padding(1); + const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER); + + validate(src.info()->padding(), read_padding); + validate(dst.info()->padding(), write_padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() + * boost::unit_test::data::make({ InterpolationPolicy::BILINEAR, InterpolationPolicy::NEAREST_NEIGHBOR }) + * BorderModes(), + shape, policy, border_mode) +{ + uint8_t constant_border_value = 0; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution_u8(0, 255); + constant_border_value = distribution_u8(gen); + } + + // Create the valid mask Tensor + RawTensor valid_mask(shape, DataType::U8); + + // Create the matrix + std::array matrix; + fill_warp_matrix<9>(matrix, 3, 3); + + // Compute function + CLTensor dst = compute_warp_perspective(shape, matrix.data(), policy, border_mode, constant_border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_warp_perspective(shape, valid_mask, matrix.data(), policy, border_mode, constant_border_value); + + // Validate output + validate(CLAccessor(dst), ref_dst, valid_mask, 1, 0.2f); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() + * boost::unit_test::data::make({ InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR }) * BorderModes(), + shape, policy, border_mode) +{ + uint8_t constant_border_value = 0; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution_u8(0, 255); + constant_border_value = distribution_u8(gen); + } + + // Create the valid mask Tensor + RawTensor valid_mask(shape, DataType::U8); + + // Create the matrix + std::array matrix; + fill_warp_matrix<9>(matrix, 3, 3); + + // Compute function + CLTensor dst = compute_warp_perspective(shape, matrix.data(), policy, border_mode, constant_border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_warp_perspective(shape, valid_mask, matrix.data(), policy, border_mode, constant_border_value); + + // Validate output + validate(CLAccessor(dst), ref_dst, valid_mask, 1, 0.2f); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/Datasets.h b/tests/validation_old/Datasets.h new file mode 100644 index 0000000000..464fffd1cf --- /dev/null +++ b/tests/validation_old/Datasets.h @@ -0,0 +1,264 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_VALIDATION_DATASETS_H__ +#define __ARM_COMPUTE_TEST_VALIDATION_DATASETS_H__ + +#include "tests/validation_old/dataset/ActivationFunctionDataset.h" +#include "tests/validation_old/dataset/BatchNormalizationLayerDataset.h" +#include "tests/validation_old/dataset/BorderModeDataset.h" +#include "tests/validation_old/dataset/ConvertPolicyDataset.h" +#include "tests/validation_old/dataset/ConvolutionLayerDataset.h" +#include "tests/validation_old/dataset/DataTypeDatasets.h" +#include "tests/validation_old/dataset/FullyConnectedLayerDataset.h" +#include "tests/validation_old/dataset/GEMMDataset.h" +#include "tests/validation_old/dataset/ImageDatasets.h" +#include "tests/validation_old/dataset/InterpolationPolicyDataset.h" +#include "tests/validation_old/dataset/MatrixPatternDataset.h" +#include "tests/validation_old/dataset/NonLinearFilterFunctionDataset.h" +#include "tests/validation_old/dataset/NormalizationTypeDataset.h" +#include "tests/validation_old/dataset/PoolingTypesDataset.h" +#include "tests/validation_old/dataset/RoundingPolicyDataset.h" +#include "tests/validation_old/dataset/ShapeDatasets.h" +#include "tests/validation_old/dataset/ThresholdDataset.h" + +#include "tests/validation_old/boost_wrapper.h" + +using namespace boost::unit_test::data::monomorphic; + +namespace boost +{ +namespace unit_test +{ +namespace data +{ +namespace monomorphic +{ +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; + +/// Register the data set with Boost +template <> +struct is_dataset : boost::mpl::true_ +{ +}; +} +} +} +} +#endif /* __ARM_COMPUTE_TEST_VALIDATION_DATASETS_H__ */ diff --git a/tests/validation_old/FixedPoint.h b/tests/validation_old/FixedPoint.h new file mode 100644 index 0000000000..12ffcdfc3d --- /dev/null +++ b/tests/validation_old/FixedPoint.h @@ -0,0 +1,986 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_VALIDATION_FIXEDPOINT_H__ +#define __ARM_COMPUTE_TEST_VALIDATION_FIXEDPOINT_H__ + +#include "Utils.h" +#include "support/ToolchainSupport.h" + +#include +#include +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace fixed_point_arithmetic +{ +namespace detail +{ +// Forward declare structs +struct functions; +template +struct constant_expr; +} + +/** Fixed point traits */ +namespace traits +{ +// Promote types +// *INDENT-OFF* +// clang-format off +template struct promote { }; +template <> struct promote { using type = uint16_t; }; +template <> struct promote { using type = int16_t; }; +template <> struct promote { using type = uint32_t; }; +template <> struct promote { using type = int32_t; }; +template <> struct promote { using type = uint64_t; }; +template <> struct promote { using type = int64_t; }; +template <> struct promote { using type = uint64_t; }; +template <> struct promote { using type = int64_t; }; +// clang-format on +// *INDENT-ON* +} + +/** Strongly typed enum class representing the overflow policy */ +enum class OverflowPolicy +{ + WRAP, /**< Wrap policy */ + SATURATE /**< Saturate policy */ +}; +/** Strongly typed enum class representing the rounding policy */ +enum class RoundingPolicy +{ + TO_ZERO, /**< Round to zero policy */ + TO_NEAREST_EVEN /**< Round to nearest even policy */ +}; + +/** Arbitrary fixed-point arithmetic class */ +template +class fixed_point +{ +public: + // Static Checks + static_assert(std::is_integral::value, "Type is not an integer"); + + // Friends + friend struct detail::functions; + friend struct detail::constant_expr; + + /** Constructor (from different fixed point type) + * + * @param[in] val Fixed point + * @param[in] p Fixed point precision + */ + template + fixed_point(fixed_point val, uint8_t p) + : _value(0), _fixed_point_position(p) + { + assert(p > 0 && p < std::numeric_limits::digits); + T v = 0; + + if(std::numeric_limits::digits < std::numeric_limits::digits) + { + val.rescale(p); + v = detail::constant_expr::saturate_cast(val.raw()); + } + else + { + auto v_cast = static_cast>(val); + v_cast.rescale(p); + v = v_cast.raw(); + } + _value = static_cast(v); + } + /** Constructor (from integer) + * + * @param[in] val Integer value to be represented as fixed point + * @param[in] p Fixed point precision + * @param[in] is_raw If true val is a raw fixed point value else an integer + */ + template ::value>::type> + fixed_point(U val, uint8_t p, bool is_raw = false) + : _value(val << p), _fixed_point_position(p) + { + if(is_raw) + { + _value = val; + } + } + /** Constructor (from float) + * + * @param[in] val Float value to be represented as fixed point + * @param[in] p Fixed point precision + */ + fixed_point(float val, uint8_t p) + : _value(detail::constant_expr::to_fixed(val, p)), _fixed_point_position(p) + { + assert(p > 0 && p < std::numeric_limits::digits); + } + /** Constructor (from float string) + * + * @param[in] str Float string to be represented as fixed point + * @param[in] p Fixed point precision + */ + fixed_point(std::string str, uint8_t p) + : _value(detail::constant_expr::to_fixed(support::cpp11::stof(str), p)), _fixed_point_position(p) + { + assert(p > 0 && p < std::numeric_limits::digits); + } + /** Default copy constructor */ + fixed_point &operator=(const fixed_point &) = default; + /** Default move constructor */ + fixed_point &operator=(fixed_point &&) = default; + /** Default copy assignment operator */ + fixed_point(const fixed_point &) = default; + /** Default move assignment operator */ + fixed_point(fixed_point &&) = default; + + /** Float conversion operator + * + * @return Float representation of fixed point + */ + operator float() const + { + return detail::constant_expr::to_float(_value, _fixed_point_position); + } + /** Integer conversion operator + * + * @return Integer representation of fixed point + */ + template ::value>::type> + operator U() const + { + return detail::constant_expr::to_int(_value, _fixed_point_position); + } + /** Convert to different fixed point of different type but same precision + * + * @note Down-conversion might fail. + */ + template + operator fixed_point() + { + U val = static_cast(_value); + if(std::numeric_limits::digits < std::numeric_limits::digits) + { + val = detail::constant_expr::saturate_cast(_value); + } + return fixed_point(val, _fixed_point_position, true); + } + + /** Arithmetic += assignment operator + * + * @param[in] rhs Fixed point operand + * + * @return Reference to this fixed point + */ + template + fixed_point &operator+=(const fixed_point &rhs) + { + fixed_point val(rhs, _fixed_point_position); + _value += val.raw(); + return *this; + } + /** Arithmetic -= assignment operator + * + * @param[in] rhs Fixed point operand + * + * @return Reference to this fixed point + */ + template + fixed_point &operator-=(const fixed_point &rhs) + { + fixed_point val(rhs, _fixed_point_position); + _value -= val.raw(); + return *this; + } + + /** Raw value accessor + * + * @return Raw fixed point value + */ + T raw() const + { + return _value; + } + /** Precision accessor + * + * @return Precision of fixed point + */ + uint8_t precision() const + { + return _fixed_point_position; + } + /** Rescale a fixed point to a new precision + * + * @param[in] p New fixed point precision + */ + void rescale(uint8_t p) + { + assert(p > 0 && p < std::numeric_limits::digits); + + using promoted_T = typename traits::promote::type; + promoted_T val = _value; + if(p > _fixed_point_position) + { + val <<= (p - _fixed_point_position); + } + else if(p < _fixed_point_position) + { + uint8_t pbar = _fixed_point_position - p; + val += (pbar != 0) ? (1 << (pbar - 1)) : 0; + val >>= pbar; + } + + _value = detail::constant_expr::saturate_cast(val); + _fixed_point_position = p; + } + +private: + T _value; /**< Fixed point raw value */ + uint8_t _fixed_point_position; /**< Fixed point precision */ +}; + +namespace detail +{ +/** Count the number of leading zero bits in the given value. + * + * @param[in] value Input value. + * + * @return Number of leading zero bits. + */ +template +constexpr int clz(T value) +{ + using unsigned_T = typename std::make_unsigned::type; + // __builtin_clz is available for int. Need to correct reported number to + // match the original type. + return __builtin_clz(value) - (32 - std::numeric_limits::digits); +} + +template +struct constant_expr +{ + /** Calculate representation of 1 in fixed point given a fixed point precision + * + * @param[in] p Fixed point precision + * + * @return Representation of value 1 in fixed point. + */ + static constexpr T fixed_one(uint8_t p) + { + return (1 << p); + } + /** Calculate fixed point precision step given a fixed point precision + * + * @param[in] p Fixed point precision + * + * @return Fixed point precision step + */ + static constexpr float fixed_step(uint8_t p) + { + return (1.0f / static_cast(1 << p)); + } + + /** Convert a fixed point value to float given its precision. + * + * @param[in] val Fixed point value + * @param[in] p Fixed point precision + * + * @return Float representation of the fixed point number + */ + static constexpr float to_float(T val, uint8_t p) + { + return static_cast(val * fixed_step(p)); + } + /** Convert a fixed point value to integer given its precision. + * + * @param[in] val Fixed point value + * @param[in] p Fixed point precision + * + * @return Integer of the fixed point number + */ + static constexpr T to_int(T val, uint8_t p) + { + return val >> p; + } + /** Convert a single precision floating point value to a fixed point representation given its precision. + * + * @param[in] val Floating point value + * @param[in] p Fixed point precision + * + * @return The raw fixed point representation + */ + static constexpr T to_fixed(float val, uint8_t p) + { + return static_cast(saturate_cast(val * fixed_one(p) + ((val >= 0) ? 0.5 : -0.5))); + } + /** Clamp value between two ranges + * + * @param[in] val Value to clamp + * @param[in] min Minimum value to clamp to + * @param[in] max Maximum value to clamp to + * + * @return clamped value + */ + static constexpr T clamp(T val, T min, T max) + { + return std::min(std::max(val, min), max); + } + /** Saturate given number + * + * @param[in] val Value to saturate + * + * @return Saturated value + */ + template + static constexpr T saturate_cast(U val) + { + return static_cast(std::min(std::max(val, static_cast(std::numeric_limits::min())), static_cast(std::numeric_limits::max()))); + } +}; +struct functions +{ + /** Output stream operator + * + * @param[in] s Output stream + * @param[in] x Fixed point value + * + * @return Reference output to updated stream + */ + template + static std::basic_ostream &write(std::basic_ostream &s, fixed_point &x) + { + return s << static_cast(x); + } + /** Signbit of a fixed point number. + * + * @param[in] x Fixed point number + * + * @return True if negative else false. + */ + template + static bool signbit(fixed_point x) + { + return ((x._value >> std::numeric_limits::digits) != 0); + } + /** Checks if two fixed point numbers are equal + * + * @param[in] x First fixed point operand + * @param[in] y Second fixed point operand + * + * @return True if fixed points are equal else false + */ + template + static bool isequal(fixed_point x, fixed_point y) + { + uint8_t p = std::min(x._fixed_point_position, y._fixed_point_position); + x.rescale(p); + y.rescale(p); + return (x._value == y._value); + } + /** Checks if two fixed point number are not equal + * + * @param[in] x First fixed point operand + * @param[in] y Second fixed point operand + * + * @return True if fixed points are not equal else false + */ + template + static bool isnotequal(fixed_point x, fixed_point y) + { + return !isequal(x, y); + } + /** Checks if one fixed point is greater than the other + * + * @param[in] x First fixed point operand + * @param[in] y Second fixed point operand + * + * @return True if fixed point is greater than other + */ + template + static bool isgreater(fixed_point x, fixed_point y) + { + uint8_t p = std::min(x._fixed_point_position, y._fixed_point_position); + x.rescale(p); + y.rescale(p); + return (x._value > y._value); + } + /** Checks if one fixed point is greater or equal than the other + * + * @param[in] x First fixed point operand + * @param[in] y Second fixed point operand + * + * @return True if fixed point is greater or equal than other + */ + template + static bool isgreaterequal(fixed_point x, fixed_point y) + { + uint8_t p = std::min(x._fixed_point_position, y._fixed_point_position); + x.rescale(p); + y.rescale(p); + return (x._value >= y._value); + } + /** Checks if one fixed point is less than the other + * + * @param[in] x First fixed point operand + * @param[in] y Second fixed point operand + * + * @return True if fixed point is less than other + */ + template + static bool isless(fixed_point x, fixed_point y) + { + uint8_t p = std::min(x._fixed_point_position, y._fixed_point_position); + x.rescale(p); + y.rescale(p); + return (x._value < y._value); + } + /** Checks if one fixed point is less or equal than the other + * + * @param[in] x First fixed point operand + * @param[in] y Second fixed point operand + * + * @return True if fixed point is less or equal than other + */ + template + static bool islessequal(fixed_point x, fixed_point y) + { + uint8_t p = std::min(x._fixed_point_position, y._fixed_point_position); + x.rescale(p); + y.rescale(p); + return (x._value <= y._value); + } + /** Checks if one fixed point is less or greater than the other + * + * @param[in] x First fixed point operand + * @param[in] y Second fixed point operand + * + * @return True if fixed point is less or greater than other + */ + template + static bool islessgreater(fixed_point x, fixed_point y) + { + return isnotequal(x, y); + } + /** Clamp fixed point to specific range. + * + * @param[in] x Fixed point operand + * @param[in] min Minimum value to clamp to + * @param[in] max Maximum value to clamp to + * + * @return Clamped result + */ + template + static fixed_point clamp(fixed_point x, T min, T max) + { + return fixed_point(constant_expr::clamp(x._value, min, max), x._fixed_point_position, true); + } + /** Negate number + * + * @param[in] x Fixed point operand + * + * @return Negated fixed point result + */ + template + static fixed_point negate(fixed_point x) + { + using promoted_T = typename traits::promote::type; + promoted_T val = -x._value; + if(OP == OverflowPolicy::SATURATE) + { + val = constant_expr::saturate_cast(val); + } + return fixed_point(static_cast(val), x._fixed_point_position, true); + } + /** Perform addition among two fixed point numbers + * + * @param[in] x First fixed point operand + * @param[in] y Second fixed point operand + * + * @return Result fixed point with precision equal to minimum precision of both operands + */ + template + static fixed_point add(fixed_point x, fixed_point y) + { + uint8_t p = std::min(x._fixed_point_position, y._fixed_point_position); + x.rescale(p); + y.rescale(p); + if(OP == OverflowPolicy::SATURATE) + { + using type = typename traits::promote::type; + type val = static_cast(x._value) + static_cast(y._value); + val = constant_expr::saturate_cast(val); + return fixed_point(static_cast(val), p, true); + } + else + { + return fixed_point(x._value + y._value, p, true); + } + } + /** Perform subtraction among two fixed point numbers + * + * @param[in] x First fixed point operand + * @param[in] y Second fixed point operand + * + * @return Result fixed point with precision equal to minimum precision of both operands + */ + template + static fixed_point sub(fixed_point x, fixed_point y) + { + uint8_t p = std::min(x._fixed_point_position, y._fixed_point_position); + x.rescale(p); + y.rescale(p); + if(OP == OverflowPolicy::SATURATE) + { + using type = typename traits::promote::type; + type val = static_cast(x._value) - static_cast(y._value); + val = constant_expr::saturate_cast(val); + return fixed_point(static_cast(val), p, true); + } + else + { + return fixed_point(x._value - y._value, p, true); + } + } + /** Perform multiplication among two fixed point numbers + * + * @param[in] x First fixed point operand + * @param[in] y Second fixed point operand + * + * @return Result fixed point with precision equal to minimum precision of both operands + */ + template + static fixed_point mul(fixed_point x, fixed_point y) + { + using promoted_T = typename traits::promote::type; + uint8_t p_min = std::min(x._fixed_point_position, y._fixed_point_position); + uint8_t p_max = std::max(x._fixed_point_position, y._fixed_point_position); + promoted_T round_factor = (1 << (p_max - 1)); + promoted_T val = ((static_cast(x._value) * static_cast(y._value)) + round_factor) >> p_max; + if(OP == OverflowPolicy::SATURATE) + { + val = constant_expr::saturate_cast(val); + } + return fixed_point(static_cast(val), p_min, true); + } + /** Perform division among two fixed point numbers + * + * @param[in] x First fixed point operand + * @param[in] y Second fixed point operand + * + * @return Result fixed point with precision equal to minimum precision of both operands + */ + template + static fixed_point div(fixed_point x, fixed_point y) + { + using promoted_T = typename traits::promote::type; + uint8_t p = std::min(x._fixed_point_position, y._fixed_point_position); + promoted_T denom = static_cast(y._value); + if(denom != 0) + { + promoted_T val = (static_cast(x._value) << std::max(x._fixed_point_position, y._fixed_point_position)) / denom; + if(OP == OverflowPolicy::SATURATE) + { + val = constant_expr::saturate_cast(val); + } + return fixed_point(static_cast(val), p, true); + } + else + { + T val = (x._value < 0) ? std::numeric_limits::min() : std::numeric_limits::max(); + return fixed_point(val, p, true); + } + } + /** Shift left + * + * @param[in] x Fixed point operand + * @param[in] shift Shift value + * + * @return Shifted value + */ + template + static fixed_point shift_left(fixed_point x, size_t shift) + { + using promoted_T = typename traits::promote::type; + promoted_T val = static_cast(x._value) << shift; + if(OP == OverflowPolicy::SATURATE) + { + val = constant_expr::saturate_cast(val); + } + return fixed_point(static_cast(val), x._fixed_point_position, true); + } + /** Shift right + * + * @param[in] x Fixed point operand + * @param[in] shift Shift value + * + * @return Shifted value + */ + template + static fixed_point shift_right(fixed_point x, size_t shift) + { + return fixed_point(x._value >> shift, x._fixed_point_position, true); + } + /** Calculate absolute value + * + * @param[in] x Fixed point operand + * + * @return Absolute value of operand + */ + template + static fixed_point abs(fixed_point x) + { + using promoted_T = typename traits::promote::type; + T val = (x._value < 0) ? constant_expr::saturate_cast(-static_cast(x._value)) : x._value; + return fixed_point(val, x._fixed_point_position, true); + } + /** Calculate the logarithm of a fixed point number + * + * @param[in] x Fixed point operand + * + * @return Logarithm value of operand + */ + template + static fixed_point log(fixed_point x) + { + uint8_t p = x._fixed_point_position; + auto const_one = fixed_point(static_cast(1), p); + + // Logarithm of 1 is zero and logarithm of negative values is not defined in R, so return 0. + // Also, log(x) == -log(1/x) for 0 < x < 1. + if(isequal(x, const_one) || islessequal(x, fixed_point(static_cast(0), p))) + { + return fixed_point(static_cast(0), p, true); + } + else if(isless(x, const_one)) + { + return mul(log(div(const_one, x)), fixed_point(-1, p)); + } + + // Remove even powers of 2 + T shift_val = 31 - __builtin_clz(x._value >> p); + x = shift_right(x, shift_val); + x = sub(x, const_one); + + // Constants + auto ln2 = fixed_point(0.6931471, p); + auto A = fixed_point(1.4384189, p); + auto B = fixed_point(-0.67719, p); + auto C = fixed_point(0.3218538, p); + auto D = fixed_point(-0.0832229, p); + + // Polynomial expansion + auto sum = add(mul(x, D), C); + sum = add(mul(x, sum), B); + sum = add(mul(x, sum), A); + sum = mul(x, sum); + + return mul(add(sum, fixed_point(static_cast(shift_val), p)), ln2); + } + /** Calculate the exponential of a fixed point number. + * + * exp(x) = exp(floor(x)) * exp(x - floor(x)) + * = pow(2, floor(x) / ln(2)) * exp(x - floor(x)) + * = exp(x - floor(x)) << (floor(x) / ln(2)) + * + * @param[in] x Fixed point operand + * + * @return Exponential value of operand + */ + template + static fixed_point exp(fixed_point x) + { + uint8_t p = x._fixed_point_position; + // Constants + auto const_one = fixed_point(1, p); + auto ln2 = fixed_point(0.6931471, p); + auto inv_ln2 = fixed_point(1.442695, p); + auto A = fixed_point(0.9978546, p); + auto B = fixed_point(0.4994721, p); + auto C = fixed_point(0.1763723, p); + auto D = fixed_point(0.0435108, p); + + T scaled_int_part = detail::constant_expr::to_int(mul(x, inv_ln2)._value, p); + + // Polynomial expansion + auto frac_part = sub(x, mul(ln2, fixed_point(scaled_int_part, p))); + auto taylor = add(mul(frac_part, D), C); + taylor = add(mul(frac_part, taylor), B); + taylor = add(mul(frac_part, taylor), A); + taylor = mul(frac_part, taylor); + taylor = add(taylor, const_one); + + // Saturate value + if(static_cast(clz(taylor.raw())) <= scaled_int_part) + { + return fixed_point(std::numeric_limits::max(), p, true); + } + + return (scaled_int_part < 0) ? shift_right(taylor, -scaled_int_part) : shift_left(taylor, scaled_int_part); + } + /** Calculate the inverse square root of a fixed point number + * + * @param[in] x Fixed point operand + * + * @return Inverse square root value of operand + */ + template + static fixed_point inv_sqrt(fixed_point x) + { + const uint8_t p = x._fixed_point_position; + int8_t shift = std::numeric_limits::digits - (p + detail::clz(x._value)); + + shift += std::numeric_limits::is_signed ? 1 : 0; + + // Use volatile to restrict compiler optimizations on shift as compiler reports maybe-uninitialized error on Android + volatile int8_t *shift_ptr = &shift; + + auto const_three = fixed_point(3, p); + auto a = (*shift_ptr < 0) ? shift_left(x, -(shift)) : shift_right(x, shift); + fixed_point x2 = a; + + // We need three iterations to find the result for QS8 and five for QS16 + constexpr int num_iterations = std::is_same::value ? 3 : 5; + for(int i = 0; i < num_iterations; ++i) + { + fixed_point three_minus_dx = sub(const_three, mul(a, mul(x2, x2))); + x2 = shift_right(mul(x2, three_minus_dx), 1); + } + + return (shift < 0) ? shift_left(x2, (-shift) >> 1) : shift_right(x2, shift >> 1); + } + /** Calculate the hyperbolic tangent of a fixed point number + * + * @param[in] x Fixed point operand + * + * @return Hyperbolic tangent of the operand + */ + template + static fixed_point tanh(fixed_point x) + { + uint8_t p = x._fixed_point_position; + // Constants + auto const_one = fixed_point(1, p); + auto const_two = fixed_point(2, p); + + auto exp2x = exp(const_two * x); + auto num = exp2x - const_one; + auto den = exp2x + const_one; + auto tanh = num / den; + + return tanh; + } + /** Calculate the a-th power of a fixed point number. + * + * The power is computed as x^a = e^(log(x) * a) + * + * @param[in] x Fixed point operand + * @param[in] a Fixed point exponent + * + * @return a-th power of the operand + */ + template + static fixed_point pow(fixed_point x, fixed_point a) + { + return exp(log(x) * a); + } +}; + +template +bool operator==(const fixed_point &lhs, const fixed_point &rhs) +{ + return functions::isequal(lhs, rhs); +} +template +bool operator!=(const fixed_point &lhs, const fixed_point &rhs) +{ + return !operator==(lhs, rhs); +} +template +bool operator<(const fixed_point &lhs, const fixed_point &rhs) +{ + return functions::isless(lhs, rhs); +} +template +bool operator>(const fixed_point &lhs, const fixed_point &rhs) +{ + return operator<(rhs, lhs); +} +template +bool operator<=(const fixed_point &lhs, const fixed_point &rhs) +{ + return !operator>(lhs, rhs); +} +template +bool operator>=(const fixed_point &lhs, const fixed_point &rhs) +{ + return !operator<(lhs, rhs); +} +template +fixed_point operator+(const fixed_point &lhs, const fixed_point &rhs) +{ + return functions::add(lhs, rhs); +} +template +fixed_point operator-(const fixed_point &lhs, const fixed_point &rhs) +{ + return functions::sub(lhs, rhs); +} +template +fixed_point operator-(const fixed_point &rhs) +{ + return functions::negate(rhs); +} +template +fixed_point operator*(fixed_point x, fixed_point y) +{ + return functions::mul(x, y); +} +template +fixed_point operator/(fixed_point x, fixed_point y) +{ + return functions::div(x, y); +} +template +fixed_point operator>>(fixed_point x, size_t shift) +{ + return functions::shift_right(x, shift); +} +template +fixed_point operator<<(fixed_point x, size_t shift) +{ + return functions::shift_left(x, shift); +} +template +std::basic_ostream &operator<<(std::basic_ostream &s, fixed_point x) +{ + return functions::write(s, x); +} +template +inline fixed_point min(fixed_point x, fixed_point y) +{ + return x > y ? y : x; +} +template +inline fixed_point max(fixed_point x, fixed_point y) +{ + return x > y ? x : y; +} +template +inline fixed_point add(fixed_point x, fixed_point y) +{ + return functions::add(x, y); +} +template +inline fixed_point sub(fixed_point x, fixed_point y) +{ + return functions::sub(x, y); +} +template +inline fixed_point mul(fixed_point x, fixed_point y) +{ + return functions::mul(x, y); +} +template +inline fixed_point div(fixed_point x, fixed_point y) +{ + return functions::div(x, y); +} +template +inline fixed_point abs(fixed_point x) +{ + return functions::abs(x); +} +template +inline fixed_point clamp(fixed_point x, T min, T max) +{ + return functions::clamp(x, min, max); +} +template +inline fixed_point exp(fixed_point x) +{ + return functions::exp(x); +} +template +inline fixed_point log(fixed_point x) +{ + return functions::log(x); +} +template +inline fixed_point inv_sqrt(fixed_point x) +{ + return functions::inv_sqrt(x); +} +template +inline fixed_point tanh(fixed_point x) +{ + return functions::tanh(x); +} +template +inline fixed_point pow(fixed_point x, fixed_point a) +{ + return functions::pow(x, a); +} +} // namespace detail + +// Expose operators +using detail::operator==; +using detail::operator!=; +using detail::operator<; +using detail::operator>; +using detail::operator<=; +using detail::operator>=; +using detail::operator+; +using detail::operator-; +using detail::operator*; +using detail::operator/; +using detail::operator>>; +using detail::operator<<; + +// Expose additional functions +using detail::min; +using detail::max; +using detail::add; +using detail::sub; +using detail::mul; +using detail::div; +using detail::abs; +using detail::clamp; +using detail::exp; +using detail::log; +using detail::inv_sqrt; +using detail::tanh; +using detail::pow; +// TODO: floor +// TODO: ceil +// TODO: sqrt +} // namespace fixed_point_arithmetic +} // namespace test +} // namespace arm_compute +#endif /*__ARM_COMPUTE_TEST_VALIDATION_FIXEDPOINT_H__ */ diff --git a/tests/validation_old/Helpers.h b/tests/validation_old/Helpers.h new file mode 100644 index 0000000000..e109edee2a --- /dev/null +++ b/tests/validation_old/Helpers.h @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_VALIDATION_HELPERS_H__ +#define __ARM_COMPUTE_TEST_VALIDATION_HELPERS_H__ + +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/ILutAccessor.h" +#include "tests/Types.h" +#include "tests/validation_old/ValidationUserConfiguration.h" +#include "tests/validation_old/half.h" + +#include +#include +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +/** Helper function to fill one or more tensors with the uniform distribution with int values. + * + * @param[in] dist Distribution to be used to get the values for the tensor. + * @param[in] seeds List of seeds to be used to fill each tensor. + * @param[in,out] tensor Tensor to be initialized with the values of the distribution. + * @param[in,out] other_tensors (Optional) One or more tensors to be filled. + * + */ +template +void fill_tensors(D &&dist, std::initializer_list seeds, T &&tensor, Ts &&... other_tensors) +{ + const std::array < T, 1 + sizeof...(Ts) > tensors{ { std::forward(tensor), std::forward(other_tensors)... } }; + std::vector vs(seeds); + ARM_COMPUTE_ERROR_ON(vs.size() != tensors.size()); + int k = 0; + for(auto tp : tensors) + { + library->fill(*tp, std::forward(dist), vs[k++]); + } +} + +/** Helper function to get the testing range for each activation layer. + * + * @param[in] activation Activation function to test. + * @param[in] fixed_point_position (Optional) Number of bits for the fractional part. Defaults to 1. + * + * @return A pair containing the lower upper testing bounds for a given function. + */ +template +inline std::pair get_activation_layer_test_bounds(ActivationLayerInfo::ActivationFunction activation, int fixed_point_position = 1) +{ + bool is_float = std::is_same::value; + is_float = is_float || std::is_same::value; + + std::pair bounds; + + // Set initial values + if(is_float) + { + bounds = std::make_pair(-255.f, 255.f); + } + else + { + bounds = std::make_pair(std::numeric_limits::lowest(), std::numeric_limits::max()); + } + + // Reduce testing ranges + switch(activation) + { + case ActivationLayerInfo::ActivationFunction::LOGISTIC: + case ActivationLayerInfo::ActivationFunction::SOFT_RELU: + // Reduce range as exponent overflows + if(is_float) + { + bounds.first = -40.f; + bounds.second = 40.f; + } + else + { + bounds.first = -(1 << (fixed_point_position)); + bounds.second = 1 << (fixed_point_position); + } + break; + case ActivationLayerInfo::ActivationFunction::TANH: + // Reduce range as exponent overflows + if(!is_float) + { + bounds.first = -(1 << (fixed_point_position)); + bounds.second = 1 << (fixed_point_position); + } + break; + case ActivationLayerInfo::ActivationFunction::SQRT: + // Reduce range as sqrt should take a non-negative number + bounds.first = (is_float) ? 0 : 1; + break; + default: + break; + } + return bounds; +} +/** Helper function to get the testing range for batch normalization layer. + * + * @param[in] fixed_point_position (Optional) Number of bits for the fractional part. Defaults to 1. + * + * @return A pair containing the lower upper testing bounds. + */ +template +std::pair get_batchnormalization_layer_test_bounds(int fixed_point_position = 1) +{ + bool is_float = std::is_floating_point::value; + std::pair bounds; + + // Set initial values + if(is_float) + { + bounds = std::make_pair(-1.f, 1.f); + } + else + { + bounds = std::make_pair(1, 1 << (fixed_point_position)); + } + + return bounds; +} + +/** Fill mask with the corresponding given pattern. + * + * @param[in,out] mask Mask to be filled according to pattern + * @param[in] cols Columns (width) of mask + * @param[in] rows Rows (height) of mask + * @param[in] pattern Pattern to fill the mask according to + */ +inline void fill_mask_from_pattern(uint8_t *mask, int cols, int rows, MatrixPattern pattern) +{ + unsigned int v = 0; + std::mt19937 gen(user_config.seed.get()); + std::bernoulli_distribution dist(0.5); + + for(int r = 0; r < rows; ++r) + { + for(int c = 0; c < cols; ++c, ++v) + { + uint8_t val = 0; + + switch(pattern) + { + case MatrixPattern::BOX: + val = 255; + break; + case MatrixPattern::CROSS: + val = ((r == (rows / 2)) || (c == (cols / 2))) ? 255 : 0; + break; + case MatrixPattern::DISK: + val = (((r - rows / 2.0f + 0.5f) * (r - rows / 2.0f + 0.5f)) / ((rows / 2.0f) * (rows / 2.0f)) + ((c - cols / 2.0f + 0.5f) * (c - cols / 2.0f + 0.5f)) / ((cols / 2.0f) * + (cols / 2.0f))) <= 1.0f ? 255 : 0; + break; + case MatrixPattern::OTHER: + val = (dist(gen) ? 0 : 255); + break; + default: + return; + } + + mask[v] = val; + } + } + + if(pattern == MatrixPattern::OTHER) + { + std::uniform_int_distribution distribution_u8(0, ((cols * rows) - 1)); + mask[distribution_u8(gen)] = 255; + } +} + +/** Calculate output tensor shape give a vector of input tensor to concatenate + * + * @param[in] input_shapes Shapes of the tensors to concatenate across depth. + * + * @return The shape of output concatenated tensor. + */ +inline TensorShape calculate_depth_concatenate_shape(std::vector input_shapes) +{ + TensorShape out_shape = input_shapes.at(0); + + unsigned int max_x = 0; + unsigned int max_y = 0; + unsigned int depth = 0; + + for(auto const &shape : input_shapes) + { + max_x = std::max(shape.x(), max_x); + max_y = std::max(shape.y(), max_y); + depth += shape.z(); + } + + out_shape.set(0, max_x); + out_shape.set(1, max_y); + out_shape.set(2, depth); + + return out_shape; +} + +/** Fill matrix random. + * + * @param[in,out] matrix Matrix + * @param[in] cols Columns (width) of matrix + * @param[in] rows Rows (height) of matrix + */ +template +inline void fill_warp_matrix(std::array &matrix, int cols, int rows) +{ + std::mt19937 gen(user_config.seed.get()); + std::uniform_real_distribution dist(-1, 1); + + for(int v = 0, r = 0; r < rows; ++r) + { + for(int c = 0; c < cols; ++c, ++v) + { + matrix[v] = dist(gen); + } + } + if(SIZE == 9) + { + matrix[(cols * rows) - 1] = 1; + } +} + +/** Helper function to fill the Lut random by a ILutAccessor. + * + * @param[in,out] table Accessor at the Lut. + * + */ +template +void fill_lookuptable(T &&table) +{ + std::mt19937 generator(user_config.seed.get()); + std::uniform_int_distribution distribution(std::numeric_limits::min(), std::numeric_limits::max()); + + for(int i = std::numeric_limits::min(); i <= std::numeric_limits::max(); i++) + { + table[i] = distribution(generator); + } +} +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_VALIDATION_HELPERS_H__ */ diff --git a/tests/validation_old/NEON/AbsoluteDifference.cpp b/tests/validation_old/NEON/AbsoluteDifference.cpp new file mode 100644 index 0000000000..aa866fff49 --- /dev/null +++ b/tests/validation_old/NEON/AbsoluteDifference.cpp @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEAbsoluteDifference.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Neon absolute difference function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in0 Data type of first input tensor. + * @param[in] dt_in1 Data type of second input tensor. + * @param[in] dt_out Data type of the output tensor. + * + * @return Computed output tensor. + */ +Tensor compute_absolute_difference(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out) +{ + // Create tensors + Tensor src1 = create_tensor(shape, dt_in0); + Tensor src2 = create_tensor(shape, dt_in1); + Tensor dst = create_tensor(shape, dt_out); + + // Create and configure function + NEAbsoluteDifference abs_d; + abs_d.configure(&src1, &src2, &dst); + + // Allocate tensors + src1.allocator()->allocate(); + src2.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src1.info()->is_resizable()); + BOOST_TEST(!src2.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src1), 0); + library->fill_tensor_uniform(Accessor(src2), 1); + + // Compute function + abs_d.run(); + + return dst; +} + +void validate_configuration(const Tensor &src1, const Tensor &src2, Tensor &dst, TensorShape shape) +{ + BOOST_TEST(src1.info()->is_resizable()); + BOOST_TEST(src2.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + NEAbsoluteDifference abs_d; + abs_d.configure(&src1, &src2, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src1.info()->valid_region(), valid_region); + validate(src2.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src1.info()->padding(), padding); + validate(src2.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(AbsoluteDifference) + +BOOST_AUTO_TEST_SUITE(U8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()), + shape) +{ + // Create tensors + Tensor src1 = create_tensor(shape, DataType::U8); + Tensor src2 = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + validate_configuration(src1, src2, dst, shape); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), + shape) +{ + // Compute function + Tensor dst = compute_absolute_difference(shape, DataType::U8, DataType::U8, DataType::U8); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_absolute_difference(shape, DataType::U8, DataType::U8, DataType::U8); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes(), + shape) +{ + // Compute function + Tensor dst = compute_absolute_difference(shape, DataType::U8, DataType::U8, DataType::U8); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_absolute_difference(shape, DataType::U8, DataType::U8, DataType::U8); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(S16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), + shape, dt) +{ + // Create tensors + Tensor src1 = create_tensor(shape, dt); + Tensor src2 = create_tensor(shape, DataType::S16); + Tensor dst = create_tensor(shape, DataType::S16); + + validate_configuration(src1, src2, dst, shape); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), + shape, dt) +{ + // Compute function + Tensor dst = compute_absolute_difference(shape, dt, DataType::S16, DataType::S16); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_absolute_difference(shape, dt, DataType::S16, DataType::S16); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), + shape, dt) +{ + // Compute function + Tensor dst = compute_absolute_difference(shape, dt, DataType::S16, DataType::S16); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_absolute_difference(shape, dt, DataType::S16, DataType::S16); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Accumulate.cpp b/tests/validation_old/NEON/Accumulate.cpp new file mode 100644 index 0000000000..eb680a383d --- /dev/null +++ b/tests/validation_old/NEON/Accumulate.cpp @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEAccumulate.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Neon accumulate function. + * + * @param[in] shape Shape of the input and output tensors. + * + * @return Computed output tensor. + */ +Tensor compute_accumulate(const TensorShape &shape) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::S16); + + // Create and configure function + NEAccumulate acc; + acc.configure(&src, &dst); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + library->fill_tensor_uniform(Accessor(dst), 1); + + // Compute function + acc.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(Accumulate) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()), + shape) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::S16); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + NEAccumulate acc; + acc.configure(&src, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), + shape) +{ + // Compute function + Tensor dst = compute_accumulate(shape); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_accumulate(shape); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes(), + shape) +{ + // Compute function + Tensor dst = compute_accumulate(shape); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_accumulate(shape); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/AccumulateSquared.cpp b/tests/validation_old/NEON/AccumulateSquared.cpp new file mode 100644 index 0000000000..29b5edf41b --- /dev/null +++ b/tests/validation_old/NEON/AccumulateSquared.cpp @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEAccumulate.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Neon accumulate squared function. + * + * @param[in] shape Shape of the input and output tensors. + * + * @return Computed output tensor. + */ +Tensor compute_accumulate_squared(const TensorShape &shape, uint32_t shift) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::S16); + + // Create and configure function + NEAccumulateSquared acc; + acc.configure(&src, shift, &dst); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + // dst tensor filled with non-negative values + library->fill_tensor_uniform(Accessor(src), 0); + library->fill_tensor_uniform(Accessor(dst), 1, static_cast(0), std::numeric_limits::max()); + + // Compute function + acc.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(AccumulateSquared) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::xrange(0U, 16U), + shape, shift) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::S16); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + NEAccumulateSquared acc; + acc.configure(&src, shift, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::xrange(0U, 16U), + shape, shift) +{ + // Compute function + Tensor dst = compute_accumulate_squared(shape, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_accumulate_squared(shape, shift); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ 0U, 1U, 15U }), + shape, shift) +{ + // Compute function + Tensor dst = compute_accumulate_squared(shape, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_accumulate_squared(shape, shift); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/AccumulateWeighted.cpp b/tests/validation_old/NEON/AccumulateWeighted.cpp new file mode 100644 index 0000000000..c59c1edbc8 --- /dev/null +++ b/tests/validation_old/NEON/AccumulateWeighted.cpp @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEAccumulate.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Neon accumulate weighted function. + * + * @param[in] shape Shape of the input and output tensors. + * + * @return Computed output tensor. + */ +Tensor compute_accumulate_weighted(const TensorShape &shape, float alpha) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + // Create and configure function + NEAccumulateWeighted acc; + acc.configure(&src, alpha, &dst); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + library->fill_tensor_uniform(Accessor(dst), 1); + + // Compute function + acc.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(AccumulateWeighted) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ 0.f, 0.5f, 1.f }), + shape, alpha) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + NEAccumulateWeighted acc; + acc.configure(&src, alpha, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ 0.f, 0.5f, 1.f }), + shape, alpha) +{ + // Compute function + Tensor dst = compute_accumulate_weighted(shape, alpha); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_accumulate_weighted(shape, alpha); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ 0.f, 0.5f, 1.f }), + shape, alpha) +{ + // Compute function + Tensor dst = compute_accumulate_weighted(shape, alpha); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_accumulate_weighted(shape, alpha); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/ArithmeticAddition.cpp b/tests/validation_old/NEON/ArithmeticAddition.cpp new file mode 100644 index 0000000000..490f124422 --- /dev/null +++ b/tests/validation_old/NEON/ArithmeticAddition.cpp @@ -0,0 +1,304 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEArithmeticAddition.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Neon arithmetic addition function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in0 Data type of first input tensor. + * @param[in] dt_in1 Data type of second input tensor. + * @param[in] dt_out Data type of the output tensor. + * @param[in] policy Overflow policy of the operation. + * @param[in] fixed_point_position (Optional) Fixed point position that expresses the number of bits for the fractional part of the number when the tensor's data type is QS8 or QS16 (default = 0). + * + * @return Computed output tensor. + */ +Tensor compute_arithmetic_addition(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy policy, int fixed_point_position = 0) +{ + // Create tensors + Tensor src1 = create_tensor(shape, dt_in0, 1, fixed_point_position); + Tensor src2 = create_tensor(shape, dt_in1, 1, fixed_point_position); + Tensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); + + // Create and configure function + NEArithmeticAddition add; + add.configure(&src1, &src2, &dst, policy); + + // Allocate tensors + src1.allocator()->allocate(); + src2.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src1.info()->is_resizable()); + BOOST_TEST(!src2.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src1), 0); + library->fill_tensor_uniform(Accessor(src2), 1); + + // Compute function + add.run(); + + return dst; +} + +void validate_configuration(const Tensor &src1, const Tensor &src2, Tensor &dst, TensorShape shape, ConvertPolicy policy) +{ + BOOST_TEST(src1.info()->is_resizable()); + BOOST_TEST(src2.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + NEArithmeticAddition add; + add.configure(&src1, &src2, &dst, policy); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src1.info()->valid_region(), valid_region); + validate(src2.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src1.info()->padding(), padding); + validate(src2.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(ArithmeticAddition) + +BOOST_AUTO_TEST_SUITE(U8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, policy) +{ + // Create tensors + Tensor src1 = create_tensor(shape, DataType::U8); + Tensor src2 = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + validate_configuration(src1, src2, dst, shape, policy); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, policy) +{ + // Compute function + Tensor dst = compute_arithmetic_addition(shape, DataType::U8, DataType::U8, DataType::U8, policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::U8, DataType::U8, DataType::U8, policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(S16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, dt, policy) +{ + // Create tensors + Tensor src1 = create_tensor(shape, dt); + Tensor src2 = create_tensor(shape, DataType::S16); + Tensor dst = create_tensor(shape, DataType::S16); + + validate_configuration(src1, src2, dst, shape, policy); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, dt, policy) +{ + // Compute function + Tensor dst = compute_arithmetic_addition(shape, dt, DataType::S16, DataType::S16, policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, dt, DataType::S16, DataType::S16, policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, dt, policy) +{ + // Compute function + Tensor dst = compute_arithmetic_addition(shape, dt, DataType::S16, DataType::S16, policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, dt, DataType::S16, DataType::S16, policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(Quantized) +BOOST_AUTO_TEST_SUITE(QS8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 7), + shape, policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_arithmetic_addition(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 7), + shape, policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_arithmetic_addition(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(QS16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 15), + shape, policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_arithmetic_addition(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 15), + shape, policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_arithmetic_addition(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() + +#ifdef ARM_COMPUTE_ENABLE_FP16 +BOOST_AUTO_TEST_SUITE(F16) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) +{ + // Compute function + Tensor dst = compute_arithmetic_addition(shape, DataType::F16, DataType::F16, DataType::F16, ConvertPolicy::WRAP); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::F16, DataType::F16, DataType::F16, ConvertPolicy::WRAP); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + +BOOST_AUTO_TEST_SUITE(F32) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, policy) +{ + // Create tensors + Tensor src1 = create_tensor(shape, DataType::F32); + Tensor src2 = create_tensor(shape, DataType::F32); + Tensor dst = create_tensor(shape, DataType::F32); + + validate_configuration(src1, src2, dst, shape, policy); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) +{ + // Compute function + Tensor dst = compute_arithmetic_addition(shape, DataType::F32, DataType::F32, DataType::F32, ConvertPolicy::WRAP); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::F32, DataType::F32, DataType::F32, ConvertPolicy::WRAP); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, policy) +{ + // Compute function + Tensor dst = compute_arithmetic_addition(shape, DataType::F32, DataType::F32, DataType::F32, policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_addition(shape, DataType::F32, DataType::F32, DataType::F32, policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/ArithmeticSubtraction.cpp b/tests/validation_old/NEON/ArithmeticSubtraction.cpp new file mode 100644 index 0000000000..86aa124f00 --- /dev/null +++ b/tests/validation_old/NEON/ArithmeticSubtraction.cpp @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEArithmeticSubtraction.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Neon arithmetic subtraction function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in0 Data type of first input tensor. + * @param[in] dt_in1 Data type of second input tensor. + * @param[in] dt_out Data type of the output tensor. + * @param[in] policy Overflow policy of the operation. + * @param[in] fixed_point_position (Optional) Fixed point position that expresses the number of bits for the fractional part of the number when the tensor's data type is QS8 or QS16 (default = 0). + * + * @return Computed output tensor. + */ +Tensor compute_arithmetic_subtraction(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy policy, int fixed_point_position = 0) +{ + // Create tensors + Tensor src1 = create_tensor(shape, dt_in0, 1, fixed_point_position); + Tensor src2 = create_tensor(shape, dt_in1, 1, fixed_point_position); + Tensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); + + // Create and configure function + NEArithmeticSubtraction sub; + sub.configure(&src1, &src2, &dst, policy); + + // Allocate tensors + src1.allocator()->allocate(); + src2.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src1.info()->is_resizable()); + BOOST_TEST(!src2.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src1), 0); + library->fill_tensor_uniform(Accessor(src2), 1); + + // Compute function + sub.run(); + + return dst; +} + +void validate_configuration(const Tensor &src1, const Tensor &src2, Tensor &dst, TensorShape shape, ConvertPolicy policy) +{ + BOOST_TEST(src1.info()->is_resizable()); + BOOST_TEST(src2.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + NEArithmeticSubtraction sub; + sub.configure(&src1, &src2, &dst, policy); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src1.info()->valid_region(), valid_region); + validate(src2.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src1.info()->padding(), padding); + validate(src2.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(ArithmeticSubtraction) + +BOOST_AUTO_TEST_SUITE(U8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, policy) +{ + // Create tensors + Tensor src1 = create_tensor(shape, DataType::U8); + Tensor src2 = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + validate_configuration(src1, src2, dst, shape, policy); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, policy) +{ + // Compute function + Tensor dst = compute_arithmetic_subtraction(shape, DataType::U8, DataType::U8, DataType::U8, policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::U8, DataType::U8, DataType::U8, policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(S16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, dt, policy) +{ + // Create tensors + Tensor src1 = create_tensor(shape, dt); + Tensor src2 = create_tensor(shape, DataType::S16); + Tensor dst = create_tensor(shape, DataType::S16); + + validate_configuration(src1, src2, dst, shape, policy); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, dt, policy) +{ + // Compute function + Tensor dst = compute_arithmetic_subtraction(shape, dt, DataType::S16, DataType::S16, policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, dt, DataType::S16, DataType::S16, policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, dt, policy) +{ + // Compute function + Tensor dst = compute_arithmetic_subtraction(shape, dt, DataType::S16, DataType::S16, policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, dt, DataType::S16, DataType::S16, policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(Quantized) +BOOST_AUTO_TEST_SUITE(QS8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 7), + shape, policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_arithmetic_subtraction(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 7), + shape, policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_arithmetic_subtraction(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::QS8, DataType::QS8, DataType::QS8, policy, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(QS16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 15), + shape, policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_arithmetic_subtraction(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * ConvertPolicies() * boost::unit_test::data::xrange(1, 15), + shape, policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_arithmetic_subtraction(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::QS16, DataType::QS16, DataType::QS16, policy, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() + +#ifdef ARM_COMPUTE_ENABLE_FP16 +BOOST_AUTO_TEST_SUITE(Float16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) +{ + // Compute function + Tensor dst = compute_arithmetic_subtraction(shape, DataType::F16, DataType::F16, DataType::F16, ConvertPolicy::WRAP); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::F16, DataType::F16, DataType::F16, ConvertPolicy::WRAP); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + +BOOST_AUTO_TEST_SUITE(Float) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, policy) +{ + // Create tensors + Tensor src1 = create_tensor(shape, DataType::F32); + Tensor src2 = create_tensor(shape, DataType::F32); + Tensor dst = create_tensor(shape, DataType::F32); + + validate_configuration(src1, src2, dst, shape, policy); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) +{ + // Compute function + Tensor dst = compute_arithmetic_subtraction(shape, DataType::F32, DataType::F32, DataType::F32, ConvertPolicy::WRAP); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::F32, DataType::F32, DataType::F32, ConvertPolicy::WRAP); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }), + shape, policy) +{ + // Compute function + Tensor dst = compute_arithmetic_subtraction(shape, DataType::F32, DataType::F32, DataType::F32, policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_arithmetic_subtraction(shape, DataType::F32, DataType::F32, DataType::F32, policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/BatchNormalizationLayer.cpp b/tests/validation_old/NEON/BatchNormalizationLayer.cpp new file mode 100644 index 0000000000..d98f99a63c --- /dev/null +++ b/tests/validation_old/NEON/BatchNormalizationLayer.cpp @@ -0,0 +1,258 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "TypePrinter.h" +#include "tests/Globals.h" +#include "tests/NEON/Helper.h" +#include "tests/Utils.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Helpers.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/dataset/BatchNormalizationLayerDataset.h" + +#include "arm_compute/runtime/NEON/functions/NEBatchNormalizationLayer.h" + +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +const float tolerance_qs8 = 6; /**< Tolerance value for comparing reference's output against quantized implementation's output */ +const float tolerance_qs16 = 6; /**< Tolerance value for comparing reference's output against quantized implementation's output */ +const float tolerance_f32 = 1e-05f; /**< Tolerance value for comparing reference's output against floating point implementation's output */ +#ifdef ARM_COMPUTE_ENABLE_FP16 +const float tolerance_f16 = 0.01f; /**< Tolerance value for comparing reference's output against half precision floating point implementation's output */ +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + +/** Compute Neon batch normalization function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt Data type of input and output tensors. + * @param[in] norm_info Normalization Layer information. + * + * @return Computed output tensor. + */ +Tensor compute_reference_batch_normalization_layer(const TensorShape &shape0, const TensorShape &shape1, DataType dt, float epsilon, int fixed_point_position = 0) +{ + // Create tensors + Tensor src = create_tensor(shape0, dt, 1, fixed_point_position); + Tensor dst = create_tensor(shape0, dt, 1, fixed_point_position); + Tensor mean = create_tensor(shape1, dt, 1, fixed_point_position); + Tensor var = create_tensor(shape1, dt, 1, fixed_point_position); + Tensor beta = create_tensor(shape1, dt, 1, fixed_point_position); + Tensor gamma = create_tensor(shape1, dt, 1, fixed_point_position); + + // Create and configure function + NEBatchNormalizationLayer norm; + norm.configure(&src, &dst, &mean, &var, &beta, &gamma, epsilon); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + mean.allocator()->allocate(); + var.allocator()->allocate(); + beta.allocator()->allocate(); + gamma.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + BOOST_TEST(!mean.info()->is_resizable()); + BOOST_TEST(!var.info()->is_resizable()); + BOOST_TEST(!beta.info()->is_resizable()); + BOOST_TEST(!gamma.info()->is_resizable()); + + // Fill tensors + switch(dt) + { + case DataType::QS8: + { + const std::pair bounds = get_batchnormalization_layer_test_bounds(fixed_point_position); + std::uniform_int_distribution<> distribution(bounds.first, bounds.second); + std::uniform_int_distribution<> distribution_var(0, bounds.second); + test::fill_tensors(distribution, { 0, 1, 3, 4 }, &src, &mean, &beta, &gamma); + test::fill_tensors(distribution_var, { 0 }, &var); + break; + } + case DataType::QS16: + { + const std::pair bounds = get_batchnormalization_layer_test_bounds(fixed_point_position); + std::uniform_int_distribution<> distribution(bounds.first, bounds.second); + std::uniform_int_distribution<> distribution_var(0, bounds.second); + test::fill_tensors(distribution, { 0, 1, 3, 4 }, &src, &mean, &beta, &gamma); + test::fill_tensors(distribution_var, { 0 }, &var); + break; + } +#ifdef ARM_COMPUTE_ENABLE_FP16 + case DataType::F16: + { + const std::pair bounds = get_batchnormalization_layer_test_bounds(); + std::uniform_real_distribution<> distribution(bounds.first, bounds.second); + std::uniform_real_distribution<> distribution_var(0, bounds.second); + test::fill_tensors(distribution, { 0, 1, 3, 4 }, &src, &mean, &beta, &gamma); + test::fill_tensors(distribution_var, { 0 }, &var); + break; + } +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + case DataType::F32: + { + const std::pair bounds = get_batchnormalization_layer_test_bounds(); + std::uniform_real_distribution<> distribution(bounds.first, bounds.second); + std::uniform_real_distribution<> distribution_var(0, bounds.second); + test::fill_tensors(distribution, { 0, 1, 3, 4 }, &src, &mean, &beta, &gamma); + test::fill_tensors(distribution_var, { 0 }, &var); + break; + } + default: + { + ARM_COMPUTE_ERROR("Not supported"); + break; + } + } + + // Compute function + norm.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(BatchNormalizationLayer) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make({ DataType::QS8, DataType::QS16, DataType::F32 }), obj, dt) +{ + // Set fixed point position data type allowed + int fixed_point_position = (arm_compute::is_data_type_fixed_point(dt)) ? 3 : 0; + + // Create tensors + Tensor src = create_tensor(obj.shape0, dt, 1, fixed_point_position); + Tensor dst = create_tensor(obj.shape0, dt, 1, fixed_point_position); + Tensor mean = create_tensor(obj.shape1, dt, 1, fixed_point_position); + Tensor var = create_tensor(obj.shape1, dt, 1, fixed_point_position); + Tensor beta = create_tensor(obj.shape1, dt, 1, fixed_point_position); + Tensor gamma = create_tensor(obj.shape1, dt, 1, fixed_point_position); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + BOOST_TEST(mean.info()->is_resizable()); + BOOST_TEST(var.info()->is_resizable()); + BOOST_TEST(beta.info()->is_resizable()); + BOOST_TEST(gamma.info()->is_resizable()); + + // Create and configure function + NEBatchNormalizationLayer norm; + norm.configure(&src, &dst, &mean, &var, &beta, &gamma, obj.epsilon); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(obj.shape0); + const ValidRegion valid_region_vec = shape_to_valid_region(obj.shape1); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + validate(mean.info()->valid_region(), valid_region_vec); + validate(var.info()->valid_region(), valid_region_vec); + validate(beta.info()->valid_region(), valid_region_vec); + validate(gamma.info()->valid_region(), valid_region_vec); +} + +BOOST_AUTO_TEST_SUITE(Float) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(Random, + RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::F32), + obj, dt) +{ + // Compute function + Tensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon); + + // Validate output + validate(Accessor(dst), ref_dst, tolerance_f32, 0); +} +BOOST_AUTO_TEST_SUITE_END() + +#ifdef ARM_COMPUTE_ENABLE_FP16 +BOOST_AUTO_TEST_SUITE(Float16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(Random, + RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::F16), + obj, dt) +{ + // Compute function + Tensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon); + + // Validate output + validate(Accessor(dst), ref_dst, tolerance_f16, 0); +} +BOOST_AUTO_TEST_SUITE_END() +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + +BOOST_AUTO_TEST_SUITE(Quantized) +BOOST_AUTO_TEST_SUITE(QS8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(Random, + RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::QS8) * boost::unit_test::data::xrange(1, 6), + obj, dt, fixed_point_position) +{ + // Compute function + Tensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst, tolerance_qs8); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(QS16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(Random, + RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::QS16) * boost::unit_test::data::xrange(1, 14), + obj, dt, fixed_point_position) +{ + // Compute function + Tensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst, tolerance_qs16); +} +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Box3x3.cpp b/tests/validation_old/NEON/Box3x3.cpp new file mode 100644 index 0000000000..708b7de204 --- /dev/null +++ b/tests/validation_old/NEON/Box3x3.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEBox3x3.h" +#include "arm_compute/runtime/SubTensor.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +constexpr unsigned int filter_size = 3; /** Size of the kernel/filter in number of elements. */ +constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ + +/** Compute Neon box3x3 filter. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] border_mode BorderMode used by the input tensor. + * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. + * + * @return Computed output tensor. + */ +Tensor compute_box3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + // Create and configure function + NEBox3x3 box3x3; + box3x3.configure(&src, &dst, border_mode, constant_border_value); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + + // Compute function + box3x3.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(Box3x3) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + NEBox3x3 box3x3; + box3x3.configure(&src, &dst, border_mode); + + // Validate valid region + const ValidRegion src_valid_region = shape_to_valid_region(shape); + const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + validate(src.info()->valid_region(), src_valid_region); + validate(dst.info()->valid_region(), dst_valid_region); + + // Validate padding + PaddingCalculator calculator(shape.x(), 8); + calculator.set_border_size(1); + calculator.set_border_mode(border_mode); + + const PaddingSize dst_padding = calculator.required_padding(); + + calculator.set_accessed_elements(16); + calculator.set_access_offset(-1); + + const PaddingSize src_padding = calculator.required_padding(); + + validate(src.info()->padding(), src_padding); + validate(dst.info()->padding(), dst_padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) +{ + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + const uint8_t border_value = distribution(gen); + + // Compute function + Tensor dst = compute_box3x3(shape, border_mode, border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_box3x3(shape, border_mode, border_value); + + // Validate output + validate(Accessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) +{ + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + const uint8_t border_value = distribution(gen); + + // Compute function + Tensor dst = compute_box3x3(shape, border_mode, border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_box3x3(shape, border_mode, border_value); + + // Validate output + validate(Accessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/DepthConvert.cpp b/tests/validation_old/NEON/DepthConvert.cpp new file mode 100644 index 0000000000..48a2b6d3f0 --- /dev/null +++ b/tests/validation_old/NEON/DepthConvert.cpp @@ -0,0 +1,637 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEDepthConvert.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Neon depth convert function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in Data type of input tensor. + * @param[in] dt_out Data type of the output tensor. + * @param[in] policy Conversion policy. + * @param[in] shift Value for down/up conversions. Must be 0 <= shift < 8. + * @param[in] fixed_point_position_in (Optional) Fixed point position for the input tensor. + * @param[in] fixed_point_position_out (Optional) Fixed point position for the output tensor. + * + * @return Computed output tensor. + */ +Tensor compute_depth_convert(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, + uint32_t shift, uint32_t fixed_point_position_in = 0, uint32_t fixed_point_position_out = 0) +{ + // Create tensors + Tensor src = create_tensor(shape, dt_in, 1, fixed_point_position_in); + Tensor dst = create_tensor(shape, dt_out, 1, fixed_point_position_out); + + // Create and configure function + NEDepthConvert depth_convert; + depth_convert.configure(&src, &dst, policy, shift); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + + // Compute function + depth_convert.run(); + + return dst; +} +/** Configure and validate region/padding function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in Data type of input tensor. + * @param[in] dt_out Data type of the output tensor. + * @param[in] policy Conversion policy. + * @param[in] shift Value for down/up conversions. Must be 0 <= shift < 8. + * @param[in] fixed_point_position_in (Optional) Fixed point position for the input tensor. + * @param[in] fixed_point_position_out (Optional) Fixed point position for the output tensor. + * + */ + +void compute_configure_validate(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, + uint32_t shift, uint32_t fixed_point_position_in = 0, uint32_t fixed_point_position_out = 0) +{ + // Create tensors + Tensor src = create_tensor(shape, dt_in, 1, fixed_point_position_in); + Tensor dst = create_tensor(shape, dt_out, 1, fixed_point_position_out); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + NEDepthConvert depth_convert; + depth_convert.configure(&src, &dst, policy, shift); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(DepthConvert) + +BOOST_AUTO_TEST_SUITE(QS8_to_QS8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * (boost::unit_test::data::make({ 1, 3, 5, 6 }) ^ boost::unit_test::data::make({ 6, 5, 1, 3 })), + shape, policy, fixed_point_position_in, fixed_point_position_out) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::QS8, DataType::QS8, policy, 0, fixed_point_position_in, fixed_point_position_out); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * (boost::unit_test::data::make({ 1, 3, 5, 6 }) ^ boost::unit_test::data::make({ 6, 5, 1, 3 })), + shape, policy, fixed_point_position_in, fixed_point_position_out) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::QS8, DataType::QS8, policy, 0, fixed_point_position_in, fixed_point_position_out); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::QS8, DataType::QS8, policy, 0, fixed_point_position_in, fixed_point_position_out); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(QS8_to_F32) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * boost::unit_test::data::xrange(1, 7, 1), + shape, policy, fixed_point_position) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::QS8, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * boost::unit_test::data::xrange(1, 7, 1), + shape, policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::QS8, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::QS8, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * boost::unit_test::data::xrange(1, 7, 1), + shape, policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::QS8, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::QS8, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(F32_to_QS8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * boost::unit_test::data::xrange(1, 7, 1), + shape, policy, fixed_point_position) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::F32, DataType::QS8, policy, 0, fixed_point_position, fixed_point_position); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * boost::unit_test::data::xrange(1, 7, 1), + shape, policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::F32, DataType::QS8, policy, 0, fixed_point_position, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::F32, DataType::QS8, policy, 0, fixed_point_position, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * boost::unit_test::data::xrange(1, 7, 1), + shape, policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::F32, DataType::QS8, policy, 0, fixed_point_position, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::F32, DataType::QS8, policy, 0, fixed_point_position, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(QS16_to_QS16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * (boost::unit_test::data::make({ 3, 6, 7, 13, 14 }) ^ boost::unit_test::data::make({ 5, 10, 14, 4, 7 })), + shape, policy, fixed_point_position_in, fixed_point_position_out) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::QS16, DataType::QS16, policy, 0, fixed_point_position_in, fixed_point_position_out); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * (boost::unit_test::data::make({ 3, 6, 7, 13, 14 }) ^ boost::unit_test::data::make({ 5, 10, 14, 4, 7 })), + shape, policy, fixed_point_position_in, fixed_point_position_out) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::QS16, DataType::QS16, policy, 0, fixed_point_position_in, fixed_point_position_out); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::QS16, DataType::QS16, policy, 0, fixed_point_position_in, fixed_point_position_out); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(QS16_to_F32) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * boost::unit_test::data::xrange(1, 15, 1), + shape, policy, fixed_point_position) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::QS16, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * boost::unit_test::data::xrange(1, 15, 1), + shape, policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::QS16, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::QS16, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * boost::unit_test::data::xrange(1, 15, 1), + shape, policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::QS16, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::QS16, DataType::F32, policy, 0, fixed_point_position, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(F32_to_QS16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * boost::unit_test::data::xrange(1, 7, 1), + shape, policy, fixed_point_position) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::F32, DataType::QS16, policy, 0, fixed_point_position, fixed_point_position); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * boost::unit_test::data::xrange(1, 15, 1), + shape, policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::F32, DataType::QS16, policy, 0, fixed_point_position, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::F32, DataType::QS16, policy, 0, fixed_point_position, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) + * boost::unit_test::data::xrange(1, 15, 1), + shape, policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::F32, DataType::QS16, policy, 0, fixed_point_position, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::F32, DataType::QS16, policy, 0, fixed_point_position, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(U8_to_U16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) + +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::U8, DataType::U16, policy, shift, 0); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::U16, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::U16, policy, shift); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::U16, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::U16, policy, shift); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(U8_to_S16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::U8, DataType::S16, policy, shift); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::S16, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S16, policy, shift); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::S16, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S16, policy, shift); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(U8_to_S32) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::U8, DataType::S32, policy, shift); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::S32, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S32, policy, shift); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::S32, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S32, policy, shift); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(U16_to_U8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::U16, DataType::U8, policy, shift); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::U16, DataType::U8, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U8, policy, shift); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::U16, DataType::U8, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U8, policy, shift); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(U16_to_U32) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::U16, DataType::U32, policy, shift); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::U16, DataType::U32, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U32, policy, shift); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::U16, DataType::U32, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U32, policy, shift); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(S16_to_U8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::S16, DataType::U8, policy, shift); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::S16, DataType::U8, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::U8, policy, shift); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::S16, DataType::U8, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::U8, policy, shift); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(S16_to_S32) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute configure and validate region/padding + compute_configure_validate(shape, DataType::S16, DataType::S32, policy, shift); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::S16, DataType::S32, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::S32, policy, shift); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) + * boost::unit_test::data::xrange(0, 7, 1), + shape, policy, shift) +{ + // Compute function + Tensor dst = compute_depth_convert(shape, DataType::S16, DataType::S32, policy, shift); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::S32, policy, shift); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/FillBorder.cpp b/tests/validation_old/NEON/FillBorder.cpp new file mode 100644 index 0000000000..ad703d97fb --- /dev/null +++ b/tests/validation_old/NEON/FillBorder.cpp @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/NEON/kernels/NEFillBorderKernel.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(FillBorder, BorderModes() * boost::unit_test::data::make({ PaddingSize{ 0 }, PaddingSize{ 1, 0, 1, 2 }, PaddingSize{ 10 } }), border_mode, padding) +{ + constexpr uint8_t border_value = 42U; + constexpr uint8_t tensor_value = 89U; + BorderSize border_size{ 5 }; + + // Create tensors + Tensor src = create_tensor(TensorShape{ 10U, 10U, 2U }, DataType::U8); + + src.info()->extend_padding(padding); + + // Allocate tensor + src.allocator()->allocate(); + + // Check padding is as required + validate(src.info()->padding(), padding); + + // Fill tensor with constant value + std::uniform_int_distribution distribution{ tensor_value, tensor_value }; + library->fill(Accessor(src), distribution, 0); + + // Create and configure kernel + NEFillBorderKernel fill_border; + fill_border.configure(&src, border_size, border_mode, border_value); + + // Run kernel + fill_border.run(fill_border.window()); + + // Validate border + border_size.limit(padding); + validate(Accessor(src), border_size, border_mode, &border_value); + + // Validate tensor + validate(Accessor(src), &tensor_value); +} + +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Fixedpoint/Exp_QS16.cpp b/tests/validation_old/NEON/Fixedpoint/Exp_QS16.cpp new file mode 100644 index 0000000000..66115879aa --- /dev/null +++ b/tests/validation_old/NEON/Fixedpoint/Exp_QS16.cpp @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/ReferenceCPP.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/NEON/NEFixedPoint.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +const float tolerance = 1.0f; /**< Tolerance value for comparing reference's output against implementation's output */ + +/** Compute Neon exponential function for signed 16 bit fixed point. + * + * @param[in] shape Shape of the input and output tensors. + * + * @return Computed output tensor. + */ +Tensor compute_exp_qs16(const TensorShape &shape, int fixed_point_position) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::QS16, 1, fixed_point_position); + Tensor dst = create_tensor(shape, DataType::QS16, 1, fixed_point_position); + + constexpr unsigned int num_elems_processed_per_iteration = 8; + Window window = calculate_max_window(*src.info(), Steps(num_elems_processed_per_iteration)); + AccessWindowHorizontal input_access(src.info(), 0, num_elems_processed_per_iteration); + AccessWindowHorizontal output_access(dst.info(), 0, num_elems_processed_per_iteration); + + update_window_and_padding(window, input_access, output_access); + output_access.set_valid_region(window, src.info()->valid_region()); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors. Keep the range between [-1.0, 1.0) so the result won't + // overflow. + std::uniform_int_distribution<> distribution(-(1 << (fixed_point_position - 1)), (1 << (fixed_point_position - 1))); + library->fill(Accessor(src), distribution, 0); + + Iterator input(&src, window); + Iterator output(&dst, window); + + execute_window_loop(window, [&](const Coordinates & id) + { + qint16x8_t in = vld1q_qs16(reinterpret_cast(input.ptr())); + // Use saturated exp + vst1q_qs16(reinterpret_cast(output.ptr()), vqexpq_qs16(in, fixed_point_position)); + }, + input, output); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(FixedPoint) +BOOST_AUTO_TEST_SUITE(QS16) +BOOST_AUTO_TEST_SUITE(Exp) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(1, 15), shape, fixed_point_position) +{ + // Compute function + Tensor dst = compute_exp_qs16(shape, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS16, DataType::QS16, FixedPointOp::EXP, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst, tolerance, 0); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Fixedpoint/Exp_QS8.cpp b/tests/validation_old/NEON/Fixedpoint/Exp_QS8.cpp new file mode 100644 index 0000000000..9e8096fa75 --- /dev/null +++ b/tests/validation_old/NEON/Fixedpoint/Exp_QS8.cpp @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/ReferenceCPP.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/NEON/NEFixedPoint.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +const float tolerance = 0.0f; /**< Tolerance value for comparing reference's output against implementation's output */ + +/** Compute Neon exponential function for signed 8bit fixed point. + * + * @param[in] shape Shape of the input and output tensors. + * + * @return Computed output tensor. + */ +Tensor compute_exp_qs8(const TensorShape &shape, int fixed_point_position) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::QS8, 1, fixed_point_position); + Tensor dst = create_tensor(shape, DataType::QS8, 1, fixed_point_position); + + constexpr unsigned int num_elems_processed_per_iteration = 16; + Window window = calculate_max_window(*src.info(), Steps(num_elems_processed_per_iteration)); + AccessWindowHorizontal input_access(src.info(), 0, num_elems_processed_per_iteration); + AccessWindowHorizontal output_access(dst.info(), 0, num_elems_processed_per_iteration); + + update_window_and_padding(window, input_access, output_access); + output_access.set_valid_region(window, src.info()->valid_region()); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors. Keep the range between [-1.0, 1.0) so the result won't + // overflow. E.g. e^7 = 1096, which cannot be represented in QS8 + std::uniform_int_distribution<> distribution(-(1 << (fixed_point_position - 1)), (1 << (fixed_point_position - 1))); + library->fill(Accessor(src), distribution, 0); + + Iterator input(&src, window); + Iterator output(&dst, window); + + execute_window_loop(window, [&](const Coordinates & id) + { + qint8x16_t in = vld1q_s8(reinterpret_cast(input.ptr())); + // Use saturated exp + vst1q_s8(reinterpret_cast(output.ptr()), vqexpq_qs8(in, fixed_point_position)); + }, + input, output); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(FixedPoint) +BOOST_AUTO_TEST_SUITE(QS8) +BOOST_AUTO_TEST_SUITE(Exp) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(1, 7), shape, fixed_point_position) +{ + // Compute function + Tensor dst = compute_exp_qs8(shape, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS8, DataType::QS8, FixedPointOp::EXP, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst, tolerance, 0); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Fixedpoint/Invsqrt_QS16.cpp b/tests/validation_old/NEON/Fixedpoint/Invsqrt_QS16.cpp new file mode 100644 index 0000000000..f56707a93d --- /dev/null +++ b/tests/validation_old/NEON/Fixedpoint/Invsqrt_QS16.cpp @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/ReferenceCPP.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/NEON/NEFixedPoint.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +const float tolerance = 5.0f; /**< Tolerance value for comparing reference's output against implementation's output */ + +/** Compute Neon inverse square root function for signed 16 bit fixed point. + * + * @param[in] shape Shape of the input and output tensors. + * + * @return Computed output tensor. + */ +Tensor compute_invsqrt_qs16(const TensorShape &shape, int fixed_point_position) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::QS16, 1, fixed_point_position); + Tensor dst = create_tensor(shape, DataType::QS16, 1, fixed_point_position); + + constexpr unsigned int num_elems_processed_per_iteration = 8; + Window window = calculate_max_window(*src.info(), Steps(num_elems_processed_per_iteration)); + AccessWindowHorizontal input_access(src.info(), 0, num_elems_processed_per_iteration); + AccessWindowHorizontal output_access(dst.info(), 0, num_elems_processed_per_iteration); + + update_window_and_padding(window, input_access, output_access); + output_access.set_valid_region(window, src.info()->valid_region()); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors. Keep the range between [1, 0x7FFF) + std::uniform_int_distribution<> distribution(1, 0x7FFF); + library->fill(Accessor(src), distribution, 0); + + Iterator input(&src, window); + Iterator output(&dst, window); + + execute_window_loop(window, [&](const Coordinates & id) + { + qint16x8_t in = vld1q_qs16(reinterpret_cast(input.ptr())); + vst1q_qs16(reinterpret_cast(output.ptr()), vqinvsqrtq_qs16(in, fixed_point_position)); + }, + input, output); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(FixedPoint) +BOOST_AUTO_TEST_SUITE(QS16) +BOOST_AUTO_TEST_SUITE(Invsqrt) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunSmall, boost::unit_test::data::xrange(1, 14), fixed_point_position) +{ + TensorShape shape(8192U); + + // Compute function + Tensor dst = compute_invsqrt_qs16(shape, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS16, DataType::QS16, FixedPointOp::INV_SQRT, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst, tolerance, 0); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Fixedpoint/Invsqrt_QS8.cpp b/tests/validation_old/NEON/Fixedpoint/Invsqrt_QS8.cpp new file mode 100644 index 0000000000..fb33fd4632 --- /dev/null +++ b/tests/validation_old/NEON/Fixedpoint/Invsqrt_QS8.cpp @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/ReferenceCPP.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/NEON/NEFixedPoint.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +const float tolerance = 4.0f; /**< Tolerance value for comparing reference's output against implementation's output */ + +/** Compute Neon inverse square root function for signed 8bit fixed point. + * + * @param[in] shape Shape of the input and output tensors. + * + * @return Computed output tensor. + */ +Tensor compute_invsqrt_qs8(const TensorShape &shape, int fixed_point_position) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::QS8, 1, fixed_point_position); + Tensor dst = create_tensor(shape, DataType::QS8, 1, fixed_point_position); + + constexpr unsigned int num_elems_processed_per_iteration = 16; + Window window = calculate_max_window(*src.info(), Steps(num_elems_processed_per_iteration)); + AccessWindowHorizontal input_access(src.info(), 0, num_elems_processed_per_iteration); + AccessWindowHorizontal output_access(dst.info(), 0, num_elems_processed_per_iteration); + + update_window_and_padding(window, input_access, output_access); + output_access.set_valid_region(window, src.info()->valid_region()); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors. Keep the range between [1, 127). + std::uniform_int_distribution<> distribution(1, 127); + library->fill(Accessor(src), distribution, 0); + + Iterator input(&src, window); + Iterator output(&dst, window); + + execute_window_loop(window, [&](const Coordinates & id) + { + qint8x16_t in = vld1q_s8(reinterpret_cast(input.ptr())); + vst1q_s8(reinterpret_cast(output.ptr()), vqinvsqrtq_qs8(in, fixed_point_position)); + }, + input, output); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(FixedPoint) +BOOST_AUTO_TEST_SUITE(QS8) +BOOST_AUTO_TEST_SUITE(Invsqrt) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Small1DShape, SmallShapes() * boost::unit_test::data::xrange(1, 6), shape, fixed_point_position) +{ + // Compute function + Tensor dst = compute_invsqrt_qs8(shape, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS8, DataType::QS8, FixedPointOp::INV_SQRT, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst, tolerance, 0); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Fixedpoint/Log_QS16.cpp b/tests/validation_old/NEON/Fixedpoint/Log_QS16.cpp new file mode 100644 index 0000000000..6485b2031c --- /dev/null +++ b/tests/validation_old/NEON/Fixedpoint/Log_QS16.cpp @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/ReferenceCPP.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/NEON/NEFixedPoint.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +const float tolerance = 7.0f; /**< Tolerance value for comparing reference's output against implementation's output */ + +/** Compute Neon logarithm function for signed 16 bit fixed point. + * + * @param[in] shape Shape of the input and output tensors. + * + * @return Computed output tensor. + */ +Tensor compute_log_qs16(const TensorShape &shape, int fixed_point_position) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::QS16, 1, fixed_point_position); + Tensor dst = create_tensor(shape, DataType::QS16, 1, fixed_point_position); + + constexpr unsigned int num_elems_processed_per_iteration = 8; + Window window = calculate_max_window(*src.info(), Steps(num_elems_processed_per_iteration)); + AccessWindowHorizontal input_access(src.info(), 0, num_elems_processed_per_iteration); + AccessWindowHorizontal output_access(dst.info(), 0, num_elems_processed_per_iteration); + + update_window_and_padding(window, input_access, output_access); + output_access.set_valid_region(window, src.info()->valid_region()); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors. Keep the range between [(1 << (fixed_point_position - 1), 0x3FFF) so the result won't + // overflow. + std::uniform_int_distribution<> distribution((1 << (fixed_point_position - 1)), 0x3FFF); + library->fill(Accessor(src), distribution, 0); + + Iterator input(&src, window); + Iterator output(&dst, window); + + execute_window_loop(window, [&](const Coordinates & id) + { + qint16x8_t in = vld1q_qs16(reinterpret_cast(input.ptr())); + vst1q_qs16(reinterpret_cast(output.ptr()), vlogq_qs16(in, fixed_point_position)); + }, + input, output); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(FixedPoint) +BOOST_AUTO_TEST_SUITE(QS16) +BOOST_AUTO_TEST_SUITE(Log) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(4, 14), shape, fixed_point_position) +{ + // Compute function + Tensor dst = compute_log_qs16(shape, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS16, DataType::QS16, FixedPointOp::LOG, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst, tolerance, 0); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Fixedpoint/Log_QS8.cpp b/tests/validation_old/NEON/Fixedpoint/Log_QS8.cpp new file mode 100644 index 0000000000..21012c52b0 --- /dev/null +++ b/tests/validation_old/NEON/Fixedpoint/Log_QS8.cpp @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/ReferenceCPP.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/NEON/NEFixedPoint.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +const float tolerance = 5; /**< Tolerance value for comparing reference's output against implementation's output */ + +/** Compute Neon logarithm function for signed 8bit fixed point. + * + * @param[in] shape Shape of the input and output tensors. + * + * @return Computed output tensor. + */ +Tensor compute_log_qs8(const TensorShape &shape, int fixed_point_position) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::QS8, 1, fixed_point_position); + Tensor dst = create_tensor(shape, DataType::QS8, 1, fixed_point_position); + + constexpr unsigned int num_elems_processed_per_iteration = 16; + Window window = calculate_max_window(*src.info(), Steps(num_elems_processed_per_iteration)); + AccessWindowHorizontal input_access(src.info(), 0, num_elems_processed_per_iteration); + AccessWindowHorizontal output_access(dst.info(), 0, num_elems_processed_per_iteration); + + update_window_and_padding(window, input_access, output_access); + output_access.set_valid_region(window, src.info()->valid_region()); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors. Keep the range between [(1 << (fixed_point_position - 1), 63) so the result won't + // overflow. E.g. for Q2.5 ln(0.001) = -6.9, which cannot be represented. + std::uniform_int_distribution<> distribution((1 << (fixed_point_position - 1)), 0x3F); + library->fill(Accessor(src), distribution, 0); + + Iterator input(&src, window); + Iterator output(&dst, window); + + execute_window_loop(window, [&](const Coordinates & id) + { + qint8x16_t in = vld1q_s8(reinterpret_cast(input.ptr())); + vst1q_s8(reinterpret_cast(output.ptr()), vlogq_qs8(in, fixed_point_position)); + }, + input, output); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(FixedPoint) +BOOST_AUTO_TEST_SUITE(QS8) +BOOST_AUTO_TEST_SUITE(Log) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(3, 6), shape, fixed_point_position) +{ + // Compute function + Tensor dst = compute_log_qs8(shape, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS8, DataType::QS8, FixedPointOp::LOG, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst, tolerance, 0); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Fixedpoint/Reciprocal_QS16.cpp b/tests/validation_old/NEON/Fixedpoint/Reciprocal_QS16.cpp new file mode 100644 index 0000000000..5630a3391a --- /dev/null +++ b/tests/validation_old/NEON/Fixedpoint/Reciprocal_QS16.cpp @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/ReferenceCPP.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/NEON/NEFixedPoint.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +const float tolerance = 11.0f; /**< Tolerance value for comparing reference's output against implementation's output. */ + +/** Compute Neon reciprocal function for signed 16 bit fixed point. + * + * @param[in] shape Shape of the input and output tensors. + * + * @return Computed output tensor. + */ +Tensor compute_reciprocal_qs16(const TensorShape &shape, int fixed_point_position) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::QS16, 1, fixed_point_position); + Tensor dst = create_tensor(shape, DataType::QS16, 1, fixed_point_position); + + constexpr unsigned int num_elems_processed_per_iteration = 8; + Window window = calculate_max_window(*src.info(), Steps(num_elems_processed_per_iteration)); + AccessWindowHorizontal input_access(src.info(), 0, num_elems_processed_per_iteration); + AccessWindowHorizontal output_access(dst.info(), 0, num_elems_processed_per_iteration); + + update_window_and_padding(window, input_access, output_access); + output_access.set_valid_region(window, src.info()->valid_region()); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors. Keep the range between [15, 0x7FFF) so the result won't + // overflow. + std::uniform_int_distribution<> distribution(15, 0x7FFF); + library->fill(Accessor(src), distribution, 0); + + Iterator input(&src, window); + Iterator output(&dst, window); + + execute_window_loop(window, [&](const Coordinates & id) + { + qint16x8_t in = vld1q_qs16(reinterpret_cast(input.ptr())); + vst1q_qs16(reinterpret_cast(output.ptr()), vqrecipq_qs16(in, fixed_point_position)); + }, + input, output); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(FixedPoint) +BOOST_AUTO_TEST_SUITE(QS16) +BOOST_AUTO_TEST_SUITE(Reciprocal) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(1, 14), shape, fixed_point_position) +{ + // Compute function + Tensor dst = compute_reciprocal_qs16(shape, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS16, DataType::QS16, FixedPointOp::RECIPROCAL, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst, tolerance, 0); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Fixedpoint/Reciprocal_QS8.cpp b/tests/validation_old/NEON/Fixedpoint/Reciprocal_QS8.cpp new file mode 100644 index 0000000000..23f98acc40 --- /dev/null +++ b/tests/validation_old/NEON/Fixedpoint/Reciprocal_QS8.cpp @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/ReferenceCPP.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/NEON/NEFixedPoint.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +const float tolerance = 3; /**< Tolerance value for comparing reference's output against implementation's output */ + +/** Compute Neon reciprocal function for signed 8bit fixed point. + * + * @param[in] shape Shape of the input and output tensors. + * + * @return Computed output tensor. + */ +Tensor compute_reciprocal_qs8(const TensorShape &shape, int fixed_point_position) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::QS8, 1, fixed_point_position); + Tensor dst = create_tensor(shape, DataType::QS8, 1, fixed_point_position); + + constexpr unsigned int num_elems_processed_per_iteration = 16; + Window window = calculate_max_window(*src.info(), Steps(num_elems_processed_per_iteration)); + AccessWindowHorizontal input_access(src.info(), 0, num_elems_processed_per_iteration); + AccessWindowHorizontal output_access(dst.info(), 0, num_elems_processed_per_iteration); + + update_window_and_padding(window, input_access, output_access); + output_access.set_valid_region(window, src.info()->valid_region()); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors. Keep the range between [15, 100) so the result won't + // overflow. E.g. for Q2.5 reciprocal(0.001) = 1000, which cannot be represented. + std::uniform_int_distribution<> distribution(15, 0x7F); + library->fill(Accessor(src), distribution, 0); + + Iterator input(&src, window); + Iterator output(&dst, window); + + execute_window_loop(window, [&](const Coordinates & id) + { + qint8x16_t in = vld1q_s8(reinterpret_cast(input.ptr())); + vst1q_s8(reinterpret_cast(output.ptr()), vrecipq_qs8(in, fixed_point_position)); + }, + input, output); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(FixedPoint) +BOOST_AUTO_TEST_SUITE(QS8) +BOOST_AUTO_TEST_SUITE(Reciprocal) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunSmall, Small1DShape() * boost::unit_test::data::xrange(1, 6), shape, fixed_point_position) +{ + // Compute function + Tensor dst = compute_reciprocal_qs8(shape, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_operation(shape, DataType::QS8, DataType::QS8, FixedPointOp::RECIPROCAL, fixed_point_position); + + // Validate output + validate(Accessor(dst), ref_dst, tolerance, 0); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Gaussian3x3.cpp b/tests/validation_old/NEON/Gaussian3x3.cpp new file mode 100644 index 0000000000..becd9196ea --- /dev/null +++ b/tests/validation_old/NEON/Gaussian3x3.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEGaussian3x3.h" +#include "arm_compute/runtime/SubTensor.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +constexpr unsigned int filter_size = 3; /** Size of the kernel/filter in number of elements. */ +constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ + +/** Compute Neon gaussian3x3 filter. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] border_mode BorderMode used by the input tensor. + * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. + * + * @return Computed output tensor. + */ +Tensor compute_gaussian3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + // Create and configure function + NEGaussian3x3 gaussian3x3; + gaussian3x3.configure(&src, &dst, border_mode, constant_border_value); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + + // Compute function + gaussian3x3.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(Gaussian3x3) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + NEGaussian3x3 gaussian3x3; + gaussian3x3.configure(&src, &dst, border_mode); + + // Validate valid region + const ValidRegion src_valid_region = shape_to_valid_region(shape); + const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + validate(src.info()->valid_region(), src_valid_region); + validate(dst.info()->valid_region(), dst_valid_region); + + // Validate padding + PaddingCalculator calculator(shape.x(), 8); + calculator.set_border_size(1); + calculator.set_border_mode(border_mode); + + const PaddingSize dst_padding = calculator.required_padding(); + + calculator.set_accessed_elements(16); + calculator.set_access_offset(-1); + + const PaddingSize src_padding = calculator.required_padding(); + + validate(src.info()->padding(), src_padding); + validate(dst.info()->padding(), dst_padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) +{ + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + const uint8_t border_value = distribution(gen); + + // Compute function + Tensor dst = compute_gaussian3x3(shape, border_mode, border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_gaussian3x3(shape, border_mode, border_value); + + // Validate output + validate(Accessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) +{ + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + const uint8_t border_value = distribution(gen); + + // Compute function + Tensor dst = compute_gaussian3x3(shape, border_mode, border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_gaussian3x3(shape, border_mode, border_value); + + // Validate output + validate(Accessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Gaussian5x5.cpp b/tests/validation_old/NEON/Gaussian5x5.cpp new file mode 100644 index 0000000000..240285afb6 --- /dev/null +++ b/tests/validation_old/NEON/Gaussian5x5.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEGaussian5x5.h" +#include "arm_compute/runtime/SubTensor.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +constexpr unsigned int filter_size = 5; /** Size of the kernel/filter in number of elements. */ +constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ + +/** Compute Neon gaussian5x5 filter. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] border_mode BorderMode used by the input tensor. + * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. + * + * @return Computed output tensor. + */ +Tensor compute_gaussian5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + // Create and configure function + NEGaussian5x5 gaussian5x5; + gaussian5x5.configure(&src, &dst, border_mode, constant_border_value); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + + // Compute function + gaussian5x5.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(Gaussian5x5) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + NEGaussian5x5 gaussian5x5; + gaussian5x5.configure(&src, &dst, border_mode); + + // Validate valid region + const ValidRegion src_valid_region = shape_to_valid_region(shape); + const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + validate(src.info()->valid_region(), src_valid_region); + validate(dst.info()->valid_region(), dst_valid_region); + + // Validate padding + PaddingCalculator calculator(shape.x(), 16); + calculator.set_border_size(2); + calculator.set_border_mode(border_mode); + + const PaddingSize dst_padding = calculator.required_padding(); + + calculator.set_processed_elements(8); + calculator.set_access_offset(-2); + + const PaddingSize src_padding = calculator.required_padding(); + + validate(src.info()->padding(), src_padding); + validate(dst.info()->padding(), dst_padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) +{ + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + const uint8_t border_value = distribution(gen); + + // Compute function + Tensor dst = compute_gaussian5x5(shape, border_mode, border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_gaussian5x5(shape, border_mode, border_value); + + // Validate output + validate(Accessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) +{ + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + const uint8_t border_value = distribution(gen); + + // Compute function + Tensor dst = compute_gaussian5x5(shape, border_mode, border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_gaussian5x5(shape, border_mode, border_value); + + // Validate output + validate(Accessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/HarrisCorners.cpp b/tests/validation_old/NEON/HarrisCorners.cpp new file mode 100644 index 0000000000..809e61c053 --- /dev/null +++ b/tests/validation_old/NEON/HarrisCorners.cpp @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "NEON/Helper.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEHarrisCorners.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "PaddingCalculator.h" +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Neon Harris corners function. + * + * @param[in] shape Shape of input tensor + * @param[in] threshold Minimum threshold with which to eliminate Harris Corner scores (computed using the normalized Sobel kernel). + * @param[in] min_dist Radial Euclidean distance for the euclidean distance stage + * @param[in] sensitivity Sensitivity threshold k from the Harris-Stephens equation + * @param[in] gradient_size The gradient window size to use on the input. The implementation supports 3, 5, and 7 + * @param[in] block_size The block window size used to compute the Harris Corner score. The implementation supports 3, 5, and 7. + * @param[in] border_mode Border mode to use + * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. + * @param[in] use_fp16 If true the FP16 kernels will be used. If false F32 kernels are used. + * + * @return Computed corners' keypoints. + */ +KeyPointArray compute_harris_corners(const TensorShape &shape, float threshold, float min_dist, float sensitivity, + int32_t gradient_size, int32_t block_size, BorderMode border_mode, uint8_t constant_border_value, bool use_fp16) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + src.info()->set_format(Format::U8); + + // Create array of keypoints + KeyPointArray corners(shape.total_size()); + + // Create harris corners configure function + NEHarrisCorners harris_corners; + harris_corners.configure(&src, threshold, min_dist, sensitivity, gradient_size, block_size, &corners, border_mode, constant_border_value, use_fp16); + + // Allocate tensors + src.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + + // Compute function + harris_corners.run(); + + return corners; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(HarrisCorners) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (Small2DShapes() + Large2DShapes()) * BorderModes() + * boost::unit_test::data::make({ 3, 5, 7 }) * boost::unit_test::data::make({ 3, 5, 7 }), + shape, border_mode, gradient, block) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + src.info()->set_format(Format::U8); + + KeyPointArray corners; + + uint8_t constant_border_value = 0; + + std::mt19937 gen(user_config.seed.get()); + std::uniform_real_distribution real_dist(0.01, std::numeric_limits::min()); + + const float threshold = real_dist(gen); + const float sensitivity = real_dist(gen); + const float max_euclidean_distance = 30.f; + + real_dist = std::uniform_real_distribution(0.f, max_euclidean_distance); + const float min_dist = real_dist(gen); + + // 50% chance to use fp16 + bool use_fp16 = real_dist(gen) < max_euclidean_distance / 2 ? true : false; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::uniform_int_distribution int_dist(0, 255); + constant_border_value = int_dist(gen); + } + + BOOST_TEST(src.info()->is_resizable()); + + // Create harris corners configure function + NEHarrisCorners harris_corners; + harris_corners.configure(&src, threshold, min_dist, sensitivity, gradient, block, &corners, border_mode, constant_border_value, use_fp16); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + + validate(src.info()->valid_region(), valid_region); + + // Validate padding + PaddingCalculator calculator(shape.x(), 8); + + calculator.set_border_mode(border_mode); + calculator.set_border_size(gradient / 2); + calculator.set_access_offset(-gradient / 2); + calculator.set_accessed_elements(16); + + const PaddingSize padding = calculator.required_padding(); + + validate(src.info()->padding(), padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, Small2DShapes() * BorderModes() * boost::unit_test::data::make({ 3, 5, 7 }) * boost::unit_test::data::make({ 3, 5, 7 }), shape, border_mode, gradient, block) +{ + uint8_t constant_border_value = 0; + + std::mt19937 gen(user_config.seed.get()); + std::uniform_real_distribution real_dist(0.01, std::numeric_limits::min()); + + const float threshold = real_dist(gen); + const float sensitivity = real_dist(gen); + const float max_euclidean_distance = 30.f; + + real_dist = std::uniform_real_distribution(0.f, max_euclidean_distance); + const float min_dist = real_dist(gen); + + // 50% chance to use fp16 + bool use_fp16 = real_dist(gen) < max_euclidean_distance / 2 ? true : false; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::uniform_int_distribution int_dist(0, 255); + constant_border_value = int_dist(gen); + } + + // Compute function + KeyPointArray dst = compute_harris_corners(shape, threshold, min_dist, sensitivity, gradient, block, border_mode, constant_border_value, use_fp16); + + // Compute reference + KeyPointArray ref_dst = Reference::compute_reference_harris_corners(shape, threshold, min_dist, sensitivity, gradient, block, border_mode, constant_border_value); + + // Validate output + validate(dst, ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, Large2DShapes() * BorderModes() * boost::unit_test::data::make({ 3, 5, 7 }) * boost::unit_test::data::make({ 3, 5, 7 }), shape, border_mode, gradient, block) +{ + uint8_t constant_border_value = 0; + + std::mt19937 gen(user_config.seed.get()); + std::uniform_real_distribution real_dist(0.01, std::numeric_limits::min()); + + const float threshold = real_dist(gen); + const float sensitivity = real_dist(gen); + const float max_euclidean_distance = 30.f; + + real_dist = std::uniform_real_distribution(0.f, max_euclidean_distance); + float min_dist = real_dist(gen); + + // 50% chance to use fp16 + bool use_fp16 = real_dist(gen) < max_euclidean_distance / 2 ? true : false; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::uniform_int_distribution int_dist(0, 255); + constant_border_value = int_dist(gen); + } + + // Compute function + KeyPointArray dst = compute_harris_corners(shape, threshold, min_dist, sensitivity, gradient, block, border_mode, constant_border_value, use_fp16); + + // Compute reference + KeyPointArray ref_dst = Reference::compute_reference_harris_corners(shape, threshold, min_dist, sensitivity, gradient, block, border_mode, constant_border_value); + + // Validate output + validate(dst, ref_dst); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/IntegralImage.cpp b/tests/validation_old/NEON/IntegralImage.cpp new file mode 100644 index 0000000000..69654b2585 --- /dev/null +++ b/tests/validation_old/NEON/IntegralImage.cpp @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "NEON/Accessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEIntegralImage.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Neon integral image function. + * + * @param[in] shape Shape of the input and output tensors. + * + * @return Computed output tensor. + */ +Tensor compute_integral_image(const TensorShape &shape) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U32); + + // Create integral image configure function + NEIntegralImage integral_image; + integral_image.configure(&src, &dst); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + + // Compute function + integral_image.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(IntegralImage) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, SmallShapes() + LargeShapes(), shape) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U32); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create integral image configure function + NEIntegralImage integral_image; + integral_image.configure(&src, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize src_padding = PaddingCalculator(shape.x(), 16).required_padding(); + const PaddingSize dst_padding(1, src_padding.right, 0, 1); + + validate(src.info()->padding(), src_padding); + validate(dst.info()->padding(), dst_padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) +{ + // Compute function + Tensor dst = compute_integral_image(shape); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_integral_image(shape); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes(), shape) +{ + // Compute function + Tensor dst = compute_integral_image(shape); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_integral_image(shape); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/MinMaxLocation.cpp b/tests/validation_old/NEON/MinMaxLocation.cpp new file mode 100644 index 0000000000..c41745a636 --- /dev/null +++ b/tests/validation_old/NEON/MinMaxLocation.cpp @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "NEON/Accessor.h" +#include "NEON/Helper.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEMinMaxLocation.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Neon MinMaxLocation function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in Data type of first input tensor. + * @param[out] min Minimum value of tensor + * @param[out] max Maximum value of tensor + * @param[out] min_loc Array with locations of minimum values + * @param[out] max_loc Array with locations of maximum values + * @param[out] min_count Number of minimum values found + * @param[out] max_count Number of maximum values found + * + * @return Computed output tensor. + */ + +void compute_min_max_location(const TensorShape &shape, DataType dt_in, void *min, void *max, + Coordinates2DArray &min_loc, Coordinates2DArray &max_loc, uint32_t &min_count, uint32_t &max_count) +{ + // Create tensor + Tensor src = create_tensor(shape, dt_in); + + // Create and configure min_max_location configure function + NEMinMaxLocation min_max_loc; + min_max_loc.configure(&src, min, max, &min_loc, &max_loc, &min_count, &max_count); + + // Allocate tensors + src.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + + // Compute function + min_max_loc.run(); +} + +void validate_configuration(const Tensor &src, TensorShape shape) +{ + BOOST_TEST(src.info()->is_resizable()); + + // Create output storage + int32_t min; + int32_t max; + Coordinates2DArray min_loc; + Coordinates2DArray max_loc; + uint32_t min_count; + uint32_t max_count; + + // Create and configure function + NEMinMaxLocation min_max_loc; + min_max_loc.configure(&src, &min, &max, &min_loc, &max_loc, &min_count, &max_count); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 1).required_padding(); + validate(src.info()->padding(), padding); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(MinMaxLocation) + +BOOST_AUTO_TEST_SUITE(Integer) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (Small2DShapes() + Large2DShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), + shape, dt) +{ + // Create tensor + Tensor src = create_tensor(shape, dt); + src.info()->set_format(dt == DataType::U8 ? Format::U8 : Format::S16); + + validate_configuration(src, shape); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, Small2DShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), + shape, dt) +{ + // Create output storage + int32_t min; + int32_t max; + Coordinates2DArray min_loc(shape.total_size()); + Coordinates2DArray max_loc(shape.total_size()); + uint32_t min_count; + uint32_t max_count; + + int32_t ref_min; + int32_t ref_max; + Coordinates2DArray ref_min_loc(shape.total_size()); + Coordinates2DArray ref_max_loc(shape.total_size()); + uint32_t ref_min_count; + uint32_t ref_max_count; + + // Compute function + compute_min_max_location(shape, dt, &min, &max, min_loc, max_loc, min_count, max_count); + + // Compute reference + Reference::compute_reference_min_max_location(shape, dt, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); + + // Validate output + validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, Large2DShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), + shape, dt) +{ + // Create output storage + int32_t min; + int32_t max; + Coordinates2DArray min_loc(shape.total_size()); + Coordinates2DArray max_loc(shape.total_size()); + uint32_t min_count; + uint32_t max_count; + + int32_t ref_min; + int32_t ref_max; + Coordinates2DArray ref_min_loc(shape.total_size()); + Coordinates2DArray ref_max_loc(shape.total_size()); + uint32_t ref_min_count; + uint32_t ref_max_count; + + // Compute function + compute_min_max_location(shape, dt, &min, &max, min_loc, max_loc, min_count, max_count); + + // Compute reference + Reference::compute_reference_min_max_location(shape, dt, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); + + // Validate output + validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(Float) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, Small2DShapes() * DataType::F32, + shape, dt) +{ + // Create output storage + float min; + float max; + Coordinates2DArray min_loc(shape.total_size()); + Coordinates2DArray max_loc(shape.total_size()); + uint32_t min_count; + uint32_t max_count; + + float ref_min; + float ref_max; + Coordinates2DArray ref_min_loc(shape.total_size()); + Coordinates2DArray ref_max_loc(shape.total_size()); + uint32_t ref_min_count; + uint32_t ref_max_count; + + // Compute function + compute_min_max_location(shape, dt, &min, &max, min_loc, max_loc, min_count, max_count); + + // Compute reference + Reference::compute_reference_min_max_location(shape, dt, &ref_min, &ref_max, ref_min_loc, ref_max_loc, ref_min_count, ref_max_count); + + // Validate output + validate_min_max_loc(min, ref_min, max, ref_max, min_loc, ref_min_loc, max_loc, ref_max_loc, min_count, ref_min_count, max_count, ref_max_count); +} + +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/NonLinearFilter.cpp b/tests/validation_old/NEON/NonLinearFilter.cpp new file mode 100644 index 0000000000..acc90a436a --- /dev/null +++ b/tests/validation_old/NEON/NonLinearFilter.cpp @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Helpers.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NENonLinearFilter.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute NonLinearFilter function. + * + * @param[in] input Shape of the input and output tensors. + * @param[in] function Non linear function to perform + * @param[in] mask_size Mask size. Supported sizes: 3, 5 + * @param[in] pattern Mask pattern + * @param[in] mask The given mask. Will be used only if pattern is specified to PATTERN_OTHER + * @param[in] border_mode Strategy to use for borders. + * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT. + * + * @return Computed output tensor. + */ +Tensor compute_non_linear_filter(const TensorShape &shape, NonLinearFilterFunction function, unsigned int mask_size, + MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, + uint8_t constant_border_value) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + // Create and configure function + NENonLinearFilter filter; + filter.configure(&src, &dst, function, mask_size, pattern, mask, border_mode, constant_border_value); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + + // Compute function + filter.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(NonLinearFilter) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) + * NonLinearFilterFunctions() * boost::unit_test::data::make({ 3U, 5U }) + * MatrixPatterns() * BorderModes(), + shape, function, mask_size, pattern, border_mode) +{ + std::mt19937 generator(user_config.seed.get()); + std::uniform_int_distribution distribution_u8(0, 255); + const uint8_t constant_border_value = distribution_u8(generator); + + // Create the mask + uint8_t mask[mask_size * mask_size]; + fill_mask_from_pattern(mask, mask_size, mask_size, pattern); + const auto half_mask_size = static_cast(mask_size / 2); + + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + NENonLinearFilter filter; + filter.configure(&src, &dst, function, mask_size, pattern, mask, border_mode, constant_border_value); + + // Validate valid region + const ValidRegion src_valid_region = shape_to_valid_region(shape); + const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, BorderSize(half_mask_size)); + + validate(src.info()->valid_region(), src_valid_region); + validate(dst.info()->valid_region(), dst_valid_region); + + // Validate padding + PaddingCalculator calculator(shape.x(), ((MatrixPattern::OTHER == pattern) ? 1 : 8)); + calculator.set_border_mode(border_mode); + calculator.set_border_size(half_mask_size); + + const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER); + + calculator.set_accessed_elements(16); + calculator.set_access_offset(-half_mask_size); + + const PaddingSize read_padding = calculator.required_padding(PaddingCalculator::Option::INCLUDE_BORDER); + + validate(src.info()->padding(), read_padding); + validate(dst.info()->padding(), write_padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() + * NonLinearFilterFunctions() * boost::unit_test::data::make({ 3U, 5U }) + * MatrixPatterns() * BorderModes(), + shape, function, mask_size, pattern, border_mode) +{ + std::mt19937 generator(user_config.seed.get()); + std::uniform_int_distribution distribution_u8(0, 255); + const uint8_t constant_border_value = distribution_u8(generator); + + // Create the mask + uint8_t mask[mask_size * mask_size]; + fill_mask_from_pattern(mask, mask_size, mask_size, pattern); + + // Compute function + Tensor dst = compute_non_linear_filter(shape, function, mask_size, pattern, mask, border_mode, constant_border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_non_linear_filter(shape, function, mask_size, pattern, mask, border_mode, constant_border_value); + + // Calculate valid region + const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, BorderSize(static_cast(mask_size / 2))); + + // Validate output + validate(Accessor(dst), ref_dst, valid_region); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() + * NonLinearFilterFunctions() * boost::unit_test::data::make({ 3U, 5U }) + * MatrixPatterns() * BorderModes(), + shape, function, mask_size, pattern, border_mode) +{ + std::mt19937 generator(user_config.seed.get()); + std::uniform_int_distribution distribution_u8(0, 255); + const uint8_t constant_border_value = distribution_u8(generator); + + // Create the mask + uint8_t mask[mask_size * mask_size]; + fill_mask_from_pattern(mask, mask_size, mask_size, pattern); + + // Compute function + Tensor dst = compute_non_linear_filter(shape, function, mask_size, pattern, mask, border_mode, constant_border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_non_linear_filter(shape, function, mask_size, pattern, mask, border_mode, constant_border_value); + + // Calculate valid region + const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, BorderSize(static_cast(mask_size / 2))); + + // Validate output + validate(Accessor(dst), ref_dst, valid_region); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/PixelWiseMultiplication.cpp b/tests/validation_old/NEON/PixelWiseMultiplication.cpp new file mode 100644 index 0000000000..60eb82ef84 --- /dev/null +++ b/tests/validation_old/NEON/PixelWiseMultiplication.cpp @@ -0,0 +1,583 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEPixelWiseMultiplication.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Neon pixel-wise multiplication function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in0 Data type of first input tensor. + * @param[in] dt_in1 Data type of second input tensor. + * @param[in] dt_out Data type of the output tensor. + * @param[in] scale Non-negative scale. + * @param[in] convert_policy Overflow policy of the operation. + * @param[in] rounding_policy Rounding policy of the operation. + * @param[in] fixed_point_position (Optional) Fixed point position that expresses the number of bits for the fractional part of the number. + * + * @return Computed output tensor. + */ +Tensor compute_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy, + int fixed_point_position = 0) +{ + // Create tensors + Tensor src1 = create_tensor(shape, dt_in0, 1, fixed_point_position); + Tensor src2 = create_tensor(shape, dt_in1, 1, fixed_point_position); + Tensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); + + // Create and configure function + NEPixelWiseMultiplication multiply; + multiply.configure(&src1, &src2, &dst, scale, convert_policy, rounding_policy); + + // Allocate tensors + src1.allocator()->allocate(); + src2.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src1.info()->is_resizable()); + BOOST_TEST(!src2.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src1), 0); + library->fill_tensor_uniform(Accessor(src2), 1); + + // Compute function + multiply.run(); + + return dst; +} + +void validate_configuration(const Tensor &src1, const Tensor &src2, Tensor &dst, TensorShape shape, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) +{ + BOOST_TEST(src1.info()->is_resizable()); + BOOST_TEST(src2.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + NEPixelWiseMultiplication multiply; + multiply.configure(&src1, &src2, &dst, scale, convert_policy, rounding_policy); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src1.info()->valid_region(), valid_region); + validate(src2.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src1.info()->padding(), padding); + validate(src2.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(PixelWiseMultiplication) + +BOOST_AUTO_TEST_SUITE(U8) +BOOST_AUTO_TEST_SUITE(Scale255) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * (1.f / 255.f) * ConvertPolicies() + * RoundingPolicy::TO_NEAREST_UP, + shape, scale, convert_policy, rounding_policy) +{ + // Create tensors + Tensor src1 = create_tensor(shape, DataType::U8); + Tensor src2 = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP, + shape, scale, convert_policy, rounding_policy) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy, + rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, + DataType::U8, scale, convert_policy, rounding_policy); + + // Validate output + // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion + validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits::max()); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP, + shape, scale, convert_policy, rounding_policy) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy, + rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, + DataType::U8, scale, convert_policy, rounding_policy); + + // Validate output + // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion + validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits::max()); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(ScaleOther) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) + * ConvertPolicies() + * RoundingPolicy::TO_ZERO, + shape, scale, convert_policy, rounding_policy) +{ + // Create tensors + Tensor src1 = create_tensor(shape, DataType::U8); + Tensor src2 = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() + * RoundingPolicy::TO_ZERO, + shape, scale, convert_policy, rounding_policy) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy, + rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, + DataType::U8, scale, convert_policy, rounding_policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() + * RoundingPolicy::TO_ZERO, + shape, scale, convert_policy, rounding_policy) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy, + rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, + DataType::U8, scale, convert_policy, rounding_policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(S16) +BOOST_AUTO_TEST_SUITE(Scale255) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * (1.f / 255.f) * ConvertPolicies() + * RoundingPolicy::TO_NEAREST_UP, + shape, dt, scale, convert_policy, rounding_policy) +{ + // Create tensors + Tensor src1 = create_tensor(shape, dt); + Tensor src2 = create_tensor(shape, DataType::S16); + Tensor dst = create_tensor(shape, DataType::S16); + + validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * (1.f / 255.f) * ConvertPolicies() + * RoundingPolicy::TO_NEAREST_UP, + shape, dt, scale, convert_policy, rounding_policy) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); + + // Validate output + // Allow tolerance value of 2.f to counteract imprecision due to 32-bit float conversion + validate(Accessor(dst), ref_dst, 2.f, 0.f, std::numeric_limits::max()); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * (1.f / 255.f) * ConvertPolicies() + * RoundingPolicy::TO_NEAREST_UP, + shape, dt, scale, convert_policy, rounding_policy) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, + scale, convert_policy, rounding_policy); + + // Validate output + // Allow tolerance value of 2.f to counteract imprecision due to 32-bit float conversion + validate(Accessor(dst), ref_dst, 2.f, 0.f, std::numeric_limits::max()); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(ScaleOther) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) + * ConvertPolicies() + * RoundingPolicy::TO_ZERO, + shape, dt, scale, convert_policy, rounding_policy) +{ + // Create tensors + Tensor src1 = create_tensor(shape, dt); + Tensor src2 = create_tensor(shape, DataType::S16); + Tensor dst = create_tensor(shape, DataType::S16); + + validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() + * RoundingPolicy::TO_ZERO, + shape, dt, scale, convert_policy, rounding_policy) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() + * RoundingPolicy::TO_ZERO, + shape, dt, scale, convert_policy, rounding_policy) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, + scale, convert_policy, rounding_policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() + +#ifdef ARM_COMPUTE_ENABLE_FP16 +BOOST_AUTO_TEST_SUITE(F16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) + +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP, + shape, scale, convert_policy, rounding_policy) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F16, DataType::F16, DataType::F16, scale, convert_policy, rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F16, DataType::F16, DataType::F16, scale, convert_policy, rounding_policy); + + // Validate output + // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion + validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits::max()); +} + +BOOST_AUTO_TEST_SUITE_END() +#endif /* ARM_COMPUTE_ENABLE_FP16 */ + +BOOST_AUTO_TEST_SUITE(F32) +BOOST_AUTO_TEST_SUITE(Scale255) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * (1.f / 255.f) * ConvertPolicies() + * RoundingPolicy::TO_NEAREST_UP, + shape, scale, convert_policy, rounding_policy) +{ + // Create tensors + Tensor src1 = create_tensor(shape, DataType::F32); + Tensor src2 = create_tensor(shape, DataType::F32); + Tensor dst = create_tensor(shape, DataType::F32); + + validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * (1.f / 255.f) * ConvertPolicies() + * RoundingPolicy::TO_NEAREST_UP, + shape, scale, convert_policy, rounding_policy) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); + + // Validate output + // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion + validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits::max()); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * (1.f / 255.f) * ConvertPolicies() + * RoundingPolicy::TO_NEAREST_UP, + shape, scale, convert_policy, rounding_policy) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, + scale, convert_policy, rounding_policy); + + // Validate output + // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion + validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits::max()); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(ScaleOther) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) + * ConvertPolicies() + * RoundingPolicy::TO_ZERO, + shape, scale, convert_policy, rounding_policy) +{ + // Create tensors + Tensor src1 = create_tensor(shape, DataType::F32); + Tensor src2 = create_tensor(shape, DataType::F32); + Tensor dst = create_tensor(shape, DataType::F32); + + validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() + * RoundingPolicy::TO_ZERO, + shape, scale, convert_policy, rounding_policy) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies() + * RoundingPolicy::TO_ZERO, + shape, scale, convert_policy, rounding_policy) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, + scale, convert_policy, rounding_policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(Quantized) +BOOST_AUTO_TEST_SUITE(QS8) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 7), + shape, dt, convert_policy, rounding_policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, fixed_point_position, convert_policy, rounding_policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmallScale255, SmallShapes() * DataType::QS8 * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP * boost::unit_test::data::xrange(1, 7), + shape, dt, scale, convert_policy, rounding_policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmallScaleOther, SmallShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 7), + shape, dt, convert_policy, rounding_policy, fixed_point_position) +{ + const float scale = 1.f / static_cast(1 << fixed_point_position); + + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); + + // Validate output + validate(Accessor(dst), ref_dst, 1.f); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 7), + shape, dt, convert_policy, rounding_policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLargeScale255, LargeShapes() * DataType::QS8 * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 7), + shape, dt, scale, convert_policy, rounding_policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLargeScaleOther, LargeShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 7), + shape, dt, convert_policy, rounding_policy, fixed_point_position) +{ + const float scale = 1.f / static_cast(1 << fixed_point_position); + + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); + + // Validate output + validate(Accessor(dst), ref_dst, 1.f); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(QS16) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::QS16 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 15), + shape, dt, convert_policy, rounding_policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, fixed_point_position, convert_policy, rounding_policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmallScale255, SmallShapes() * DataType::QS16 * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP * boost::unit_test::data::xrange(1, 15), + shape, dt, scale, convert_policy, rounding_policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmallScaleOther, SmallShapes() * DataType::QS16 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 15), + shape, dt, convert_policy, rounding_policy, fixed_point_position) +{ + const float scale = 1.f / static_cast(1 << fixed_point_position); + + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, scale, convert_policy, rounding_policy, fixed_point_position); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, scale, fixed_point_position, convert_policy, rounding_policy); + + // Validate output + validate(Accessor(dst), ref_dst, 1.f); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * DataType::QS16 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange(1, 15), + shape, dt, convert_policy, rounding_policy, fixed_point_position) +{ + // Compute function + Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/ROIPoolingLayer.cpp b/tests/validation_old/NEON/ROIPoolingLayer.cpp new file mode 100644 index 0000000000..2046beb196 --- /dev/null +++ b/tests/validation_old/NEON/ROIPoolingLayer.cpp @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "NEON/ArrayAccessor.h" +#include "TypePrinter.h" +#include "arm_compute/runtime/NEON/functions/NEROIPoolingLayer.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +Tensor compute_roi_pooling_layer(const TensorShape &shape, DataType dt, const std::vector &rois, ROIPoolingLayerInfo pool_info) +{ + TensorShape shape_dst; + shape_dst.set(0, pool_info.pooled_width()); + shape_dst.set(1, pool_info.pooled_height()); + shape_dst.set(2, shape.z()); + shape_dst.set(3, rois.size()); + + // Create tensors + Tensor src = create_tensor(shape, dt); + Tensor dst = create_tensor(shape_dst, dt); + + // Create ROI array + Array rois_array(rois.size()); + fill_array(ArrayAccessor(rois_array), rois); + + // Create and configure function + NEROIPoolingLayer roi_pool; + roi_pool.configure(&src, &rois_array, &dst, pool_info); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + std::uniform_real_distribution<> distribution(-1, 1); + library->fill(Accessor(src), distribution, 0); + + // Compute function + roi_pool.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(ROIPoolingLayer) + +BOOST_AUTO_TEST_SUITE(Float) +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, CNNFloatDataTypes() * boost::unit_test::data::make({ 10, 20, 40 }) * boost::unit_test::data::make({ 7, 9 }) * boost::unit_test::data::make({ 1.f / 8.f, 1.f / 16.f }), + dt, num_rois, roi_pool_size, roi_scale) +{ + TensorShape shape(50U, 47U, 2U, 3U); + ROIPoolingLayerInfo pool_info(roi_pool_size, roi_pool_size, roi_scale); + + // Construct ROI vector + std::vector rois = generate_random_rois(shape, pool_info, num_rois, user_config.seed); + + // Compute function + Tensor dst = compute_roi_pooling_layer(shape, dt, rois, pool_info); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_roi_pooling_layer(shape, dt, rois, pool_info); + + // Validate output + validate(Accessor(dst), ref_dst); +} +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Sobel3x3.cpp b/tests/validation_old/NEON/Sobel3x3.cpp new file mode 100644 index 0000000000..cb249e1a58 --- /dev/null +++ b/tests/validation_old/NEON/Sobel3x3.cpp @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NESobel3x3.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "PaddingCalculator.h" +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +constexpr unsigned int filter_size = 3; /** Size of the kernel/filter in number of elements. */ +constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ + +/** Compute Neon Sobel 3x3 function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] border_mode BorderMode used by the input tensor + * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT + * + * @return Computed output tensor. + */ +std::pair compute_sobel_3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst_x = create_tensor(shape, DataType::S16); + Tensor dst_y = create_tensor(shape, DataType::S16); + + src.info()->set_format(Format::U8); + dst_x.info()->set_format(Format::S16); + dst_y.info()->set_format(Format::S16); + + // Create sobel image configure function + NESobel3x3 sobel_3x3; + sobel_3x3.configure(&src, &dst_x, &dst_y, border_mode, constant_border_value); + + // Allocate tensors + src.allocator()->allocate(); + dst_x.allocator()->allocate(); + dst_y.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst_x.info()->is_resizable()); + BOOST_TEST(!dst_y.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + + // Compute function + sobel_3x3.run(); + + return std::make_pair(std::move(dst_x), std::move(dst_y)); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(Sobel3x3) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst_x = create_tensor(shape, DataType::S16); + Tensor dst_y = create_tensor(shape, DataType::S16); + + src.info()->set_format(Format::U8); + dst_x.info()->set_format(Format::S16); + dst_y.info()->set_format(Format::S16); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst_x.info()->is_resizable()); + BOOST_TEST(dst_y.info()->is_resizable()); + + // Create sobel 3x3 configure function + NESobel3x3 sobel_3x3; + sobel_3x3.configure(&src, &dst_x, &dst_y, border_mode); + + // Validate valid region + const ValidRegion src_valid_region = shape_to_valid_region(shape); + const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + + validate(src.info()->valid_region(), src_valid_region); + validate(dst_x.info()->valid_region(), dst_valid_region); + validate(dst_y.info()->valid_region(), dst_valid_region); + + // Validate padding + PaddingCalculator calculator(shape.x(), 8); + + calculator.set_border_mode(border_mode); + calculator.set_border_size(1); + + const PaddingSize dst_padding = calculator.required_padding(); + + calculator.set_accessed_elements(16); + calculator.set_access_offset(-1); + + const PaddingSize src_padding = calculator.required_padding(); + + validate(src.info()->padding(), src_padding); + validate(dst_x.info()->padding(), dst_padding); + validate(dst_y.info()->padding(), dst_padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) +{ + uint8_t constant_border_value = 0; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + constant_border_value = distribution(gen); + } + + // Compute function + std::pair dst = compute_sobel_3x3(shape, border_mode, constant_border_value); + + // Compute reference + std::pair ref_dst = Reference::compute_reference_sobel_3x3(shape, border_mode, constant_border_value); + + // Calculate valid region + const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + + // Validate output + validate(Accessor(dst.first), ref_dst.first, valid_region); + validate(Accessor(dst.second), ref_dst.second, valid_region); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) +{ + uint8_t constant_border_value = 0; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + constant_border_value = distribution(gen); + } + + // Compute function + std::pair dst = compute_sobel_3x3(shape, border_mode, constant_border_value); + + // Compute reference + std::pair ref_dst = Reference::compute_reference_sobel_3x3(shape, border_mode, constant_border_value); + + // Calculate valid region + const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + + // Validate output + validate(Accessor(dst.first), ref_dst.first, valid_region); + validate(Accessor(dst.second), ref_dst.second, valid_region); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Sobel5x5.cpp b/tests/validation_old/NEON/Sobel5x5.cpp new file mode 100644 index 0000000000..2f26e62e83 --- /dev/null +++ b/tests/validation_old/NEON/Sobel5x5.cpp @@ -0,0 +1,204 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "NEON/Accessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NESobel5x5.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +constexpr unsigned int filter_size = 5; /** Size of the kernel/filter in number of elements. */ +constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ + +/** Compute Neon Sobel 5x5 function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] border_mode BorderMode used by the input tensor + * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT + * + * @return Computed output tensor. + */ +std::pair compute_sobel_5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst_x = create_tensor(shape, DataType::S16); + Tensor dst_y = create_tensor(shape, DataType::S16); + + src.info()->set_format(Format::U8); + dst_x.info()->set_format(Format::S16); + dst_y.info()->set_format(Format::S16); + + // Create sobel image configure function + NESobel5x5 sobel_5x5; + sobel_5x5.configure(&src, &dst_x, &dst_y, border_mode, constant_border_value); + + // Allocate tensors + src.allocator()->allocate(); + dst_x.allocator()->allocate(); + dst_y.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst_x.info()->is_resizable()); + BOOST_TEST(!dst_y.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + + // Compute function + sobel_5x5.run(); + + return std::make_pair(std::move(dst_x), std::move(dst_y)); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(Sobel5x5) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst_x = create_tensor(shape, DataType::S16); + Tensor dst_y = create_tensor(shape, DataType::S16); + + src.info()->set_format(Format::U8); + dst_x.info()->set_format(Format::S16); + dst_y.info()->set_format(Format::S16); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst_x.info()->is_resizable()); + BOOST_TEST(dst_y.info()->is_resizable()); + + // Create sobel 5x5 configure function + NESobel5x5 sobel_5x5; + sobel_5x5.configure(&src, &dst_x, &dst_y, border_mode); + + // Validate valid region + const ValidRegion src_valid_region = shape_to_valid_region(shape); + const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + + validate(src.info()->valid_region(), src_valid_region); + validate(dst_x.info()->valid_region(), dst_valid_region); + validate(dst_y.info()->valid_region(), dst_valid_region); + + // Validate padding + PaddingCalculator calculator(shape.x(), 16); + + calculator.set_border_mode(border_mode); + calculator.set_border_size(2); + + const PaddingSize dst_padding = calculator.required_padding(); + + calculator.set_processed_elements(8); + calculator.set_access_offset(-2); + + const PaddingSize src_padding = calculator.required_padding(); + + validate(src.info()->padding(), src_padding); + validate(dst_x.info()->padding(), dst_padding); + validate(dst_y.info()->padding(), dst_padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) +{ + uint8_t constant_border_value = 0; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + constant_border_value = distribution(gen); + } + + // Compute function + std::pair dst = compute_sobel_5x5(shape, border_mode, constant_border_value); + + // Compute reference + std::pair ref_dst = Reference::compute_reference_sobel_5x5(shape, border_mode, constant_border_value); + + // Calculate valid region + const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + + // Validate output + validate(Accessor(dst.first), ref_dst.first, valid_region); + validate(Accessor(dst.second), ref_dst.second, valid_region); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) +{ + uint8_t constant_border_value = 0; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution(0, 255); + constant_border_value = distribution(gen); + } + + // Compute function + std::pair dst = compute_sobel_5x5(shape, border_mode, constant_border_value); + + // Compute reference + std::pair ref_dst = Reference::compute_reference_sobel_5x5(shape, border_mode, constant_border_value); + + // Calculate valid region + const ValidRegion valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); + + // Validate output + validate(Accessor(dst.first), ref_dst.first, valid_region); + validate(Accessor(dst.second), ref_dst.second, valid_region); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/TableLookup.cpp b/tests/validation_old/NEON/TableLookup.cpp new file mode 100644 index 0000000000..f134e5d417 --- /dev/null +++ b/tests/validation_old/NEON/TableLookup.cpp @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "NEON/Helper.h" +#include "NEON/LutAccessor.h" +#include "PaddingCalculator.h" +#include "RawLutAccessor.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Helpers.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NETableLookup.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Table Lookup function. + * + * @param[in] shape Shape of the input tensors + * @param[in] data_type Datatype of the input/output tensors + * @param[in] lut The input LUT. + * + * @return Computed output tensor. + */ +Tensor compute_table_lookup(const TensorShape &shape, DataType data_type, Lut &lut) +{ + // Create tensors + Tensor src = create_tensor(shape, data_type); + Tensor dst = create_tensor(shape, data_type); + + // Create and configure function + NETableLookup table_lookup; + table_lookup.configure(&src, &lut, &dst); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + + // Compute function + table_lookup.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(TableLookup) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), + shape, data_type) +{ + //Create Lut + const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; + Lut lut(num_elem, data_type); + + if(data_type == DataType::U8) + { + fill_lookuptable(LutAccessor(lut)); + } + else + { + fill_lookuptable(LutAccessor(lut)); + } + + // Create tensors + Tensor src = create_tensor(shape, data_type); + Tensor dst = create_tensor(shape, data_type); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + NETableLookup table_lookup; + table_lookup.configure(&src, &lut, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, + SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), + shape, data_type) +{ + //Create Lut + const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; + Lut lut(num_elem, data_type); + + if(data_type == DataType::U8) + { + //Create rawLut + std::map rawlut; + + //Fill the Lut + fill_lookuptable(LutAccessor(lut)); + fill_lookuptable(RawLutAccessor(rawlut)); + + // Compute function + Tensor dst = compute_table_lookup(shape, data_type, lut); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); + + // Validate output + validate(Accessor(dst), ref_dst); + } + else + { + //Create rawLut + std::map rawlut; + + //Fill the Lut + fill_lookuptable(LutAccessor(lut)); + fill_lookuptable(RawLutAccessor(rawlut)); + + // Compute function + Tensor dst = compute_table_lookup(shape, data_type, lut); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); + + // Validate output + validate(Accessor(dst), ref_dst); + } +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, + LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), + shape, data_type) +{ + //Create Lut + const int num_elem = (data_type == DataType::U8) ? std::numeric_limits::max() + 1 : std::numeric_limits::max() - std::numeric_limits::lowest() + 1; + Lut lut(num_elem, data_type); + + if(data_type == DataType::U8) + { + //Create rawLut + std::map rawlut; + + //Fill the Lut + fill_lookuptable(LutAccessor(lut)); + fill_lookuptable(RawLutAccessor(rawlut)); + + // Compute function + Tensor dst = compute_table_lookup(shape, data_type, lut); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); + + // Validate output + validate(Accessor(dst), ref_dst); + } + else + { + //Create rawLut + std::map rawlut; + + //Fill the Lut + fill_lookuptable(LutAccessor(lut)); + fill_lookuptable(RawLutAccessor(rawlut)); + + // Compute function + Tensor dst = compute_table_lookup(shape, data_type, lut); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_table_lookup(shape, data_type, rawlut); + + // Validate output + validate(Accessor(dst), ref_dst); + } +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Threshold.cpp b/tests/validation_old/NEON/Threshold.cpp new file mode 100644 index 0000000000..d56ec5eb42 --- /dev/null +++ b/tests/validation_old/NEON/Threshold.cpp @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/dataset/ThresholdDataset.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEThreshold.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Threshold function. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] threshold Threshold. When the threshold type is RANGE, this is used as the lower threshold. + * @param[in] false_value value to set when the condition is not respected. + * @param[in] true_value value to set when the condition is respected. + * @param[in] type Thresholding type. Either RANGE or BINARY. + * @param[in] upper Upper threshold. Only used when the thresholding type is RANGE. + * + * @return Computed output tensor. + */ +Tensor compute_threshold(const TensorShape &shape, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) +{ + // Create tensors + Tensor src1 = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + // Create and configure function + NEThreshold thrsh; + thrsh.configure(&src1, &dst, threshold, false_value, true_value, type, upper); + + // Allocate tensors + src1.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src1.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src1), 0); + + // Compute function + thrsh.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(Threshold) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, + (SmallShapes() + LargeShapes()) * ThresholdDataset(), + shape, thrshConf) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + NEThreshold thrsh; + thrsh.configure(&src, &dst, thrshConf.threshold, thrshConf.false_value, thrshConf.true_value, thrshConf.type, thrshConf.upper); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, + SmallShapes() * ThresholdDataset(), + shape, thrshConf) +{ + // Compute function + Tensor dst = compute_threshold(shape, thrshConf.threshold, thrshConf.false_value, thrshConf.true_value, thrshConf.type, thrshConf.upper); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_threshold(shape, thrshConf.threshold, thrshConf.false_value, thrshConf.true_value, thrshConf.type, thrshConf.upper); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, + LargeShapes() * ThresholdDataset(), + shape, thrshConf) +{ + // Compute function + Tensor dst = compute_threshold(shape, thrshConf.threshold, thrshConf.false_value, thrshConf.true_value, thrshConf.type, thrshConf.upper); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_threshold(shape, thrshConf.threshold, thrshConf.false_value, thrshConf.true_value, thrshConf.type, thrshConf.upper); + + // Validate output + validate(Accessor(dst), ref_dst); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/WarpPerspective.cpp b/tests/validation_old/NEON/WarpPerspective.cpp new file mode 100644 index 0000000000..5a15591261 --- /dev/null +++ b/tests/validation_old/NEON/WarpPerspective.cpp @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "PaddingCalculator.h" +#include "TypePrinter.h" +#include "Utils.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Datasets.h" +#include "tests/validation_old/Helpers.h" +#include "tests/validation_old/Reference.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/NEON/functions/NEWarpPerspective.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +/** Compute Warp Perspective function. + * + * @param[in] input Shape of the input and output tensors. + * @param[in] matrix The perspective matrix. Must be 3x3 of type float. + * @param[in] policy The interpolation type. + * @param[in] border_mode Strategy to use for borders. + * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. + * + * @return Computed output tensor. + */ +Tensor compute_warp_perspective(const TensorShape &shape, const float *matrix, InterpolationPolicy policy, + BorderMode border_mode, uint8_t constant_border_value) +{ + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + // Create and configure function + NEWarpPerspective warp_perspective; + warp_perspective.configure(&src, &dst, matrix, policy, border_mode, constant_border_value); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + BOOST_TEST(!src.info()->is_resizable()); + BOOST_TEST(!dst.info()->is_resizable()); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + + // Compute function + warp_perspective.run(); + + return dst; +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(NEON) +BOOST_AUTO_TEST_SUITE(WarpPerspective) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) + * boost::unit_test::data::make({ InterpolationPolicy::BILINEAR, InterpolationPolicy::NEAREST_NEIGHBOR }) * BorderModes(), + shape, policy, border_mode) +{ + uint8_t constant_border_value = 0; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution_u8(0, 255); + constant_border_value = distribution_u8(gen); + } + + // Create the matrix + std::array matrix; + fill_warp_matrix<9>(matrix, 3, 3); + + // Create tensors + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, DataType::U8); + + BOOST_TEST(src.info()->is_resizable()); + BOOST_TEST(dst.info()->is_resizable()); + + // Create and configure function + NEWarpPerspective warp_perspective; + warp_perspective.configure(&src, &dst, matrix.data(), policy, border_mode, constant_border_value); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + + validate(src.info()->valid_region(), valid_region); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + PaddingCalculator calculator(shape.x(), 1); + calculator.set_border_mode(border_mode); + calculator.set_border_size(1); + + const PaddingSize read_padding(1); + const PaddingSize write_padding = calculator.required_padding(); + + validate(src.info()->padding(), read_padding); + validate(dst.info()->padding(), write_padding); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() + * boost::unit_test::data::make({ InterpolationPolicy::BILINEAR, InterpolationPolicy::NEAREST_NEIGHBOR }) + * BorderModes(), + shape, policy, border_mode) +{ + uint8_t constant_border_value = 0; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution_u8(0, 255); + constant_border_value = distribution_u8(gen); + } + + // Create the valid mask Tensor + RawTensor valid_mask(shape, DataType::U8); + + // Create the matrix + std::array matrix; + fill_warp_matrix<9>(matrix, 3, 3); + + // Compute function + Tensor dst = compute_warp_perspective(shape, matrix.data(), policy, border_mode, constant_border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_warp_perspective(shape, valid_mask, matrix.data(), policy, border_mode, constant_border_value); + + // Validate output + validate(Accessor(dst), ref_dst, valid_mask, 1, 0.2f); +} +BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() + * boost::unit_test::data::make({ InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR }) * BorderModes(), + shape, policy, border_mode) +{ + uint8_t constant_border_value = 0; + + // Generate a random constant value if border_mode is constant + if(border_mode == BorderMode::CONSTANT) + { + std::mt19937 gen(user_config.seed.get()); + std::uniform_int_distribution distribution_u8(0, 255); + constant_border_value = distribution_u8(gen); + } + + // Create the valid mask Tensor + RawTensor valid_mask(shape, DataType::U8); + + // Create the matrix + std::array matrix; + fill_warp_matrix<9>(matrix, 3, 3); + + // Compute function + Tensor dst = compute_warp_perspective(shape, matrix.data(), policy, border_mode, constant_border_value); + + // Compute reference + RawTensor ref_dst = Reference::compute_reference_warp_perspective(shape, valid_mask, matrix.data(), policy, border_mode, constant_border_value); + + // Validate output + validate(Accessor(dst), ref_dst, valid_mask, 1, 0.2f); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/ProgramOptions.cpp b/tests/validation_old/ProgramOptions.cpp new file mode 100644 index 0000000000..b5a7bb14ad --- /dev/null +++ b/tests/validation_old/ProgramOptions.cpp @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "ProgramOptions.h" + +#include "TypePrinter.h" +#include "TypeReader.h" + +#include "arm_compute/core/Types.h" + +#include +#include + +namespace arm_compute +{ +namespace test +{ +ProgramOptions::ProgramOptions() +{ + boost::program_options::options_description generic("Generic options"); + generic.add_options()("help", "Print help message")("seed", boost::program_options::value()->default_value(std::random_device()()), "Seed for the tensor library"); + + _visible.add(generic); + + _hidden.add_options()("path", boost::program_options::value(), "Path from where to load the asset/s"); + + _positional.add("path", 1); +} + +void ProgramOptions::add_options(const boost::program_options::options_description &options) +{ + _visible.add(options); +} + +bool ProgramOptions::wants_help() const +{ + return (_vm.count("help") != 0); +} + +std::string ProgramOptions::get_help() const +{ + std::stringstream help; + help << _visible; + + return help.str(); +} + +void ProgramOptions::parse_commandline(int argc, char **argv) +{ + boost::program_options::options_description all; + all.add(_visible).add(_hidden); + + boost::program_options::store(boost::program_options::command_line_parser(argc, argv) + .options(all) + .positional(_positional) + .allow_unregistered() + .run(), + _vm); + + if(_vm.count("help") == 0 && _vm.count("path") == 0) + { + throw boost::program_options::required_option("PATH"); + } + + boost::program_options::notify(_vm); +} +} // namespace test +} // namespace arm_compute diff --git a/tests/validation_old/ProgramOptions.h b/tests/validation_old/ProgramOptions.h new file mode 100644 index 0000000000..0b28355aa6 --- /dev/null +++ b/tests/validation_old/ProgramOptions.h @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_PROGRAM_OPTIONS_H__ +#define __ARM_COMPUTE_TEST_PROGRAM_OPTIONS_H__ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" +#include "boost/program_options.hpp" +#pragma GCC diagnostic pop + +#include +#include + +namespace arm_compute +{ +namespace test +{ +/** Defines available commandline arguments and allows to parse them. */ +class ProgramOptions +{ +public: + /** Defines available options. */ + ProgramOptions(); + + /** Signals if the --help flag has been passed on the commandline. */ + bool wants_help() const; + + /** Returns a string describing all available options. */ + std::string get_help() const; + + /** Parses the given arguments and makes them available via @ref get. + * + * @param[in] argc Number of command line arguments. + * @param[in] argv Pointer to the command line arguments. + */ + void parse_commandline(int argc, char **argv); + + /** Sets @p value if it has been specified on the command line. + * + * @note The type T has to match the type that has been specified for the + * command line option. + * + * @param[in] name Name of the option to query. + * @param[out] value Variable to which the value will be assigned. + * + * @return True if the value is assigned, false otherwise. + */ + template + bool get(const std::string &name, T &value) const; + +protected: + /** Allows subclasses to add more specific options + * + * @param[in] options Boost object containing options and their descriptions + */ + void add_options(const boost::program_options::options_description &options); + +private: + boost::program_options::options_description _hidden{}; + boost::program_options::options_description _visible{ "Configuration options" }; + boost::program_options::positional_options_description _positional{}; + boost::program_options::variables_map _vm{}; +}; + +template +bool ProgramOptions::get(const std::string &name, T &value) const +{ + if(_vm.count(name) != 0) + { + value = _vm[name].as(); + return true; + } + + return false; +} +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_PROGRAM_OPTIONS_H__ */ diff --git a/tests/validation_old/RawTensor.cpp b/tests/validation_old/RawTensor.cpp new file mode 100644 index 0000000000..bc2747d2a1 --- /dev/null +++ b/tests/validation_old/RawTensor.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "RawTensor.h" + +namespace arm_compute +{ +namespace test +{ +RawTensor::RawTensor(TensorShape shape, Format format, int fixed_point_position) + : SimpleTensor(shape, format, fixed_point_position) +{ + _buffer = support::cpp14::make_unique(SimpleTensor::num_elements() * SimpleTensor::num_channels() * SimpleTensor::element_size()); +} + +RawTensor::RawTensor(TensorShape shape, DataType data_type, int num_channels, int fixed_point_position) + : SimpleTensor(shape, data_type, num_channels, fixed_point_position) +{ + _buffer = support::cpp14::make_unique(SimpleTensor::num_elements() * SimpleTensor::num_channels() * SimpleTensor::element_size()); +} + +RawTensor::RawTensor(const RawTensor &tensor) + : SimpleTensor(tensor.shape(), tensor.data_type(), tensor.num_channels(), tensor.fixed_point_position()) +{ + _format = tensor.format(); + _buffer = support::cpp14::make_unique(num_elements() * num_channels() * element_size()); + std::copy_n(tensor.data(), num_elements() * num_channels() * element_size(), _buffer.get()); +} + +RawTensor &RawTensor::operator=(RawTensor tensor) +{ + swap(*this, tensor); + + return *this; +} + +const void *RawTensor::operator()(const Coordinates &coord) const +{ + return _buffer.get() + coord2index(_shape, coord) * element_size(); +} + +void *RawTensor::operator()(const Coordinates &coord) +{ + return _buffer.get() + coord2index(_shape, coord) * element_size(); +} +} // namespace test +} // namespace arm_compute diff --git a/tests/validation_old/RawTensor.h b/tests/validation_old/RawTensor.h new file mode 100644 index 0000000000..fd0ab2b9fd --- /dev/null +++ b/tests/validation_old/RawTensor.h @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_RAW_TENSOR_H__ +#define __ARM_COMPUTE_TEST_RAW_TENSOR_H__ + +#include "tests/SimpleTensor.h" + +namespace arm_compute +{ +namespace test +{ +/** Subclass of SimpleTensor using uint8_t as value type. + * + * Access operations (except for operator[]) will be based on the data type to + * copy the right number of elements. + */ +class RawTensor : public SimpleTensor +{ +public: + /** Create an uninitialised tensor of the given @p shape and @p format. + * + * @param[in] shape Shape of the new raw tensor. + * @param[in] format Format of the new raw tensor. + * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers + */ + RawTensor(TensorShape shape, Format format, int fixed_point_position = 0); + + /** Create an uninitialised tensor of the given @p shape and @p data type. + * + * @param[in] shape Shape of the new raw tensor. + * @param[in] data_type Data type of the new raw tensor. + * @param[in] num_channels (Optional) Number of channels (default = 1). + * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers (default = 0). + */ + RawTensor(TensorShape shape, DataType data_type, int num_channels = 1, int fixed_point_position = 0); + + /** Create a deep copy of the given @p tensor. + * + * @param[in] tensor To be copied tensor. + */ + RawTensor(const RawTensor &tensor); + + RawTensor &operator =(RawTensor tensor); + RawTensor(RawTensor &&) = default; + ~RawTensor() = default; + + /** Read only access to the specified element. + * + * @param[in] coord Coordinates of the desired element. + * + * @return A pointer to the desired element. + */ + const void *operator()(const Coordinates &coord) const override; + + /** Access to the specified element. + * + * @param[in] coord Coordinates of the desired element. + * + * @return A pointer to the desired element. + */ + void *operator()(const Coordinates &coord) override; +}; +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_RAW_TENSOR_H__ */ diff --git a/tests/validation_old/Reference.cpp b/tests/validation_old/Reference.cpp new file mode 100644 index 0000000000..9099820929 --- /dev/null +++ b/tests/validation_old/Reference.cpp @@ -0,0 +1,510 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "Reference.h" + +#include "Helpers.h" +#include "ReferenceCPP.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/validation_old/Helpers.h" + +#include +#include + +using namespace arm_compute::test; + +#ifndef DOXYGEN_SKIP_THIS +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +std::pair Reference::compute_reference_sobel_3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create reference + RawTensor ref_src(shape, Format::U8); + RawTensor ref_dst_x(shape, Format::S16); + RawTensor ref_dst_y(shape, Format::S16); + + // Fill reference + library->fill_tensor_uniform(ref_src, 0); + + // Compute reference + ReferenceCPP::sobel_3x3(ref_src, ref_dst_x, ref_dst_y, border_mode, constant_border_value); + + return std::make_pair(ref_dst_x, ref_dst_y); +} + +std::pair Reference::compute_reference_sobel_5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create reference + RawTensor ref_src(shape, Format::U8); + RawTensor ref_dst_x(shape, Format::S16); + RawTensor ref_dst_y(shape, Format::S16); + + // Fill reference + library->fill_tensor_uniform(ref_src, 0); + + // Compute reference + ReferenceCPP::sobel_5x5(ref_src, ref_dst_x, ref_dst_y, border_mode, constant_border_value); + + return std::make_pair(ref_dst_x, ref_dst_y); +} +void Reference::compute_reference_min_max_location(const TensorShape &shape, DataType dt_in, void *min, void *max, IArray &min_loc, IArray &max_loc, + uint32_t &min_count, uint32_t &max_count) +{ + // Create reference + RawTensor ref_src(shape, dt_in); + + // Fill reference + library->fill_tensor_uniform(ref_src, 0); + + // Compute reference + ReferenceCPP::min_max_location(ref_src, min, max, min_loc, max_loc, min_count, max_count); +} + +KeyPointArray Reference::compute_reference_harris_corners(const TensorShape &shape, float threshold, float min_dist, float sensitivity, + int32_t gradient_size, int32_t block_size, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create reference + RawTensor ref_src(shape, Format::U8); + RawTensor raw_Gx(shape, (gradient_size == 7) ? Format::S32 : Format::S16); + RawTensor raw_Gy(shape, (gradient_size == 7) ? Format::S32 : Format::S16); + RawTensor raw_candidates(shape, Format::F32); + RawTensor raw_non_maxima(shape, Format::F32); + + KeyPointArray corners(shape.total_size()); + + // Fill reference + library->fill_tensor_uniform(ref_src, 0); + + // Compute reference + ReferenceCPP::harris_corners(ref_src, raw_Gx, raw_Gy, raw_candidates, raw_non_maxima, threshold, min_dist, sensitivity, gradient_size, block_size, corners, border_mode, constant_border_value); + + return corners; +} + +RawTensor Reference::compute_reference_integral_image(const TensorShape &shape) +{ + // Create reference + RawTensor ref_src(shape, DataType::U8); + RawTensor ref_dst(shape, DataType::U32); + + // Fill reference + library->fill_tensor_uniform(ref_src, 0); + + // Compute reference + ReferenceCPP::integral_image(ref_src, ref_dst); + + return ref_dst; +} + +RawTensor Reference::compute_reference_absolute_difference(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out) +{ + // Create reference + RawTensor ref_src1(shape, dt_in0); + RawTensor ref_src2(shape, dt_in1); + RawTensor ref_dst(shape, dt_out); + + // Fill reference + library->fill_tensor_uniform(ref_src1, 0); + library->fill_tensor_uniform(ref_src2, 1); + + // Compute reference + ReferenceCPP::absolute_difference(ref_src1, ref_src2, ref_dst); + + return ref_dst; +} + +RawTensor Reference::compute_reference_accumulate(const TensorShape &shape) +{ + // Create reference + RawTensor ref_src(shape, DataType::U8); + RawTensor ref_dst(shape, DataType::S16); + + // Fill reference + library->fill_tensor_uniform(ref_src, 0); + library->fill_tensor_uniform(ref_dst, 1); + + // Compute reference + ReferenceCPP::accumulate(ref_src, ref_dst); + + return ref_dst; +} + +RawTensor Reference::compute_reference_accumulate_squared(const TensorShape &shape, uint32_t shift) +{ + // Create reference + RawTensor ref_src(shape, DataType::U8); + RawTensor ref_dst(shape, DataType::S16); + + // Fill reference + // ref_dst tensor filled with non-negative values + library->fill_tensor_uniform(ref_src, 0); + library->fill_tensor_uniform(ref_dst, 1, static_cast(0), std::numeric_limits::max()); + + // Compute reference + ReferenceCPP::accumulate_squared(ref_src, ref_dst, shift); + + return ref_dst; +} + +RawTensor Reference::compute_reference_accumulate_weighted(const TensorShape &shape, float alpha) +{ + // Create reference + RawTensor ref_src(shape, DataType::U8); + RawTensor ref_dst(shape, DataType::U8); + + // Fill reference + library->fill_tensor_uniform(ref_src, 0); + library->fill_tensor_uniform(ref_dst, 1); + + // Compute reference + ReferenceCPP::accumulate_weighted(ref_src, ref_dst, alpha); + + return ref_dst; +} + +RawTensor Reference::compute_reference_arithmetic_addition(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy convert_policy, int fixed_point_position) +{ + // Create reference + RawTensor ref_src1(shape, dt_in0, 1, fixed_point_position); + RawTensor ref_src2(shape, dt_in1, 1, fixed_point_position); + RawTensor ref_dst(shape, dt_out, 1, fixed_point_position); + + // Fill reference + library->fill_tensor_uniform(ref_src1, 0); + library->fill_tensor_uniform(ref_src2, 1); + + // Compute reference + ReferenceCPP::arithmetic_addition(ref_src1, ref_src2, ref_dst, convert_policy); + + return ref_dst; +} + +RawTensor Reference::compute_reference_arithmetic_subtraction(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy convert_policy, int fixed_point_position) +{ + // Create reference + RawTensor ref_src1(shape, dt_in0, 1, fixed_point_position); + RawTensor ref_src2(shape, dt_in1, 1, fixed_point_position); + RawTensor ref_dst(shape, dt_out, 1, fixed_point_position); + + // Fill reference + library->fill_tensor_uniform(ref_src1, 0); + library->fill_tensor_uniform(ref_src2, 1); + + // Compute reference + ReferenceCPP::arithmetic_subtraction(ref_src1, ref_src2, ref_dst, convert_policy); + + return ref_dst; +} + +RawTensor Reference::compute_reference_box3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create reference + RawTensor ref_src(shape, DataType::U8); + RawTensor ref_dst(shape, DataType::U8); + + // Fill reference + library->fill_tensor_uniform(ref_src, 0); + + // Compute reference + ReferenceCPP::box3x3(ref_src, ref_dst, border_mode, constant_border_value); + + return ref_dst; +} + +RawTensor Reference::compute_reference_depth_convert(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, + uint32_t shift, uint32_t fixed_point_position_in, uint32_t fixed_point_position_out) +{ + RawTensor ref_src(shape, dt_in, 1, fixed_point_position_in); + RawTensor ref_dst(shape, dt_out, 1, fixed_point_position_out); + + // Fill reference + library->fill_tensor_uniform(ref_src, 0); + + // Compute reference + ReferenceCPP::depth_convert(ref_src, ref_dst, policy, shift); + + return ref_dst; +} + +RawTensor Reference::compute_reference_gaussian3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create reference + RawTensor ref_src(shape, DataType::U8); + RawTensor ref_dst(shape, DataType::U8); + + // Fill reference + library->fill_tensor_uniform(ref_src, 0); + + // Compute reference + ReferenceCPP::gaussian3x3(ref_src, ref_dst, border_mode, constant_border_value); + + return ref_dst; +} + +RawTensor Reference::compute_reference_gaussian5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create reference + RawTensor ref_src(shape, DataType::U8); + RawTensor ref_dst(shape, DataType::U8); + + // Fill reference + library->fill_tensor_uniform(ref_src, 0); + + // Compute reference + ReferenceCPP::gaussian5x5(ref_src, ref_dst, border_mode, constant_border_value); + + return ref_dst; +} + +RawTensor Reference::compute_reference_non_linear_filter(const TensorShape &shape, NonLinearFilterFunction function, unsigned int mask_size, + MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value) +{ + // Create reference + RawTensor ref_src(shape, DataType::U8); + RawTensor ref_dst(shape, DataType::U8); + + // Fill reference + library->fill_tensor_uniform(ref_src, 0); + + // Compute reference + ReferenceCPP::non_linear_filter(ref_src, ref_dst, function, mask_size, pattern, mask, border_mode, constant_border_value); + + return ref_dst; +} + +RawTensor Reference::compute_reference_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, ConvertPolicy convert_policy, + RoundingPolicy rounding_policy) +{ + // Create reference + RawTensor ref_src1(shape, dt_in0); + RawTensor ref_src2(shape, dt_in1); + RawTensor ref_dst(shape, dt_out); + + // Fill reference + library->fill_tensor_uniform(ref_src1, 0); + library->fill_tensor_uniform(ref_src2, 1); + + // Compute reference + ReferenceCPP::pixel_wise_multiplication(ref_src1, ref_src2, ref_dst, scale, convert_policy, rounding_policy); + + return ref_dst; +} + +RawTensor Reference::compute_reference_fixed_point_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, int fixed_point_position, + ConvertPolicy convert_policy, RoundingPolicy rounding_policy) +{ + // Create reference + RawTensor ref_src1(shape, dt_in0, 1, fixed_point_position); + RawTensor ref_src2(shape, dt_in1, 1, fixed_point_position); + RawTensor ref_dst(shape, dt_out, 1, fixed_point_position); + + // Fill reference + library->fill_tensor_uniform(ref_src1, 0); + library->fill_tensor_uniform(ref_src2, 1); + + // Compute reference + ReferenceCPP::fixed_point_pixel_wise_multiplication(ref_src1, ref_src2, ref_dst, scale, convert_policy, rounding_policy); + + return ref_dst; +} + +template +RawTensor Reference::compute_reference_table_lookup(const TensorShape &shape, DataType dt_inout, std::map &lut) +{ + // Create reference + RawTensor ref_src(shape, dt_inout); + RawTensor ref_dst(shape, dt_inout); + // Fill reference + library->fill_tensor_uniform(ref_src, 0); + + // Compute reference + ReferenceCPP::table_lookup(ref_src, ref_dst, lut); + + return ref_dst; +} +template RawTensor arm_compute::test::validation::Reference::compute_reference_table_lookup(const TensorShape &shape, DataType dt_inout, std::map &lut); +template RawTensor arm_compute::test::validation::Reference::compute_reference_table_lookup(const TensorShape &shape, DataType dt_inout, std::map &lut); + +RawTensor Reference::compute_reference_threshold(const TensorShape &shape, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) +{ + // Create reference + RawTensor ref_src(shape, DataType::U8); + RawTensor ref_dst(shape, DataType::U8); + + // Fill reference + library->fill_tensor_uniform(ref_src, 0); + + // Compute reference + ReferenceCPP::threshold(ref_src, ref_dst, threshold, false_value, true_value, type, upper); + + return ref_dst; +} + +RawTensor Reference::compute_reference_warp_perspective(const TensorShape &shape, RawTensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, + uint8_t constant_border_value) +{ + // Create reference + RawTensor ref_src(shape, DataType::U8); + RawTensor ref_dst(shape, DataType::U8); + + // Fill reference + library->fill_tensor_uniform(ref_src, 0); + + // Compute reference + ReferenceCPP::warp_perspective(ref_src, ref_dst, valid_mask, matrix, policy, border_mode, constant_border_value); + + return ref_dst; +} + +RawTensor Reference::compute_reference_batch_normalization_layer(const TensorShape &shape0, const TensorShape &shape1, DataType dt, float epsilon, int fixed_point_position) +{ + // Create reference + RawTensor ref_src(shape0, dt, 1, fixed_point_position); + RawTensor ref_dst(shape0, dt, 1, fixed_point_position); + RawTensor ref_mean(shape1, dt, 1, fixed_point_position); + RawTensor ref_var(shape1, dt, 1, fixed_point_position); + RawTensor ref_beta(shape1, dt, 1, fixed_point_position); + RawTensor ref_gamma(shape1, dt, 1, fixed_point_position); + + // Fill tensors + switch(dt) + { + case DataType::QS8: + { + const std::pair bounds = get_batchnormalization_layer_test_bounds(fixed_point_position); + std::uniform_int_distribution<> distribution(bounds.first, bounds.second); + std::uniform_int_distribution<> distribution_var(0, bounds.second); + fill_tensors(distribution, { 0, 1, 3, 4 }, &ref_src, &ref_mean, &ref_beta, &ref_gamma); + fill_tensors(distribution_var, { 0 }, &ref_var); + break; + } + case DataType::QS16: + { + const std::pair bounds = get_batchnormalization_layer_test_bounds(fixed_point_position); + std::uniform_int_distribution<> distribution(bounds.first, bounds.second); + std::uniform_int_distribution<> distribution_var(0, bounds.second); + fill_tensors(distribution, { 0, 1, 3, 4 }, &ref_src, &ref_mean, &ref_beta, &ref_gamma); + fill_tensors(distribution_var, { 0 }, &ref_var); + break; + } + case DataType::F16: + { + const std::pair bounds = get_batchnormalization_layer_test_bounds(); + std::uniform_real_distribution<> distribution(bounds.first, bounds.second); + std::uniform_real_distribution<> distribution_var(0, bounds.second); + fill_tensors(distribution, { 0, 1, 3, 4 }, &ref_src, &ref_mean, &ref_beta, &ref_gamma); + fill_tensors(distribution_var, { 0 }, &ref_var); + break; + } + case DataType::F32: + { + const std::pair bounds = get_batchnormalization_layer_test_bounds(); + std::uniform_real_distribution<> distribution(bounds.first, bounds.second); + std::uniform_real_distribution<> distribution_var(0, bounds.second); + fill_tensors(distribution, { 0, 1, 3, 4 }, &ref_src, &ref_mean, &ref_beta, &ref_gamma); + fill_tensors(distribution_var, { 0 }, &ref_var); + break; + } + default: + { + ARM_COMPUTE_ERROR("Not supported"); + break; + } + } + + // Compute reference + ReferenceCPP::batch_normalization_layer(ref_src, ref_dst, ref_mean, ref_var, ref_beta, ref_gamma, epsilon, fixed_point_position); + + return ref_dst; +} + +RawTensor Reference::compute_reference_roi_pooling_layer(const TensorShape &shape, DataType dt, const std::vector &rois, const ROIPoolingLayerInfo &pool_info) +{ + TensorShape shape_dst; + shape_dst.set(0, pool_info.pooled_width()); + shape_dst.set(1, pool_info.pooled_height()); + shape_dst.set(2, shape.z()); + shape_dst.set(3, rois.size()); + + // Create reference + RawTensor ref_src(shape, dt); + RawTensor ref_dst(shape_dst, dt); + + // Fill reference + std::uniform_real_distribution<> distribution(-1, 1); + library->fill(ref_src, distribution, 0.0); + + // Compute reference + ReferenceCPP::roi_pooling_layer(ref_src, ref_dst, rois, pool_info); + + return ref_dst; +} + +RawTensor Reference::compute_reference_fixed_point_operation(const TensorShape &shape, DataType dt_in, DataType dt_out, FixedPointOp op, int fixed_point_position) +{ + // Create reference + RawTensor ref_src(shape, dt_in, 1, fixed_point_position); + RawTensor ref_dst(shape, dt_out, 1, fixed_point_position); + + // Fill reference + int min = 0; + int max = 0; + switch(op) + { + case(FixedPointOp::INV_SQRT): + min = 1; + max = (dt_in == DataType::QS8) ? 0x7F : 0x7FFF; + break; + case(FixedPointOp::LOG): + min = (1 << (fixed_point_position - 1)); + max = (dt_in == DataType::QS8) ? 0x3F : 0x3FFF; + break; + case(FixedPointOp::EXP): + min = -(1 << (fixed_point_position - 1)); + max = (1 << (fixed_point_position - 1)); + break; + case(FixedPointOp::RECIPROCAL): + min = 15; + max = (dt_in == DataType::QS8) ? 0x7F : 0x7FFF; + break; + default: + ARM_COMPUTE_ERROR("Fixed point operation not supported"); + } + std::uniform_int_distribution<> distribution(min, max); + library->fill(ref_src, distribution, 0); + + // Compute reference + ReferenceCPP::fixed_point_operation(ref_src, ref_dst, op); + + return ref_dst; +} + +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/Reference.h b/tests/validation_old/Reference.h new file mode 100644 index 0000000000..698b60e96b --- /dev/null +++ b/tests/validation_old/Reference.h @@ -0,0 +1,316 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_H__ +#define __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_H__ + +#include "RawTensor.h" +#include "Types.h" +#include "arm_compute/runtime/Array.h" + +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +/** Interface for reference implementations. */ +class Reference +{ +public: + /** Compute reference sobel 3x3. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] border_mode Border mode to use for input tensor + * @param[in] constant_border_value Constant value to use if @p border_mode is constant + * + * @return Computed raw tensors along x and y axis. + */ + static std::pair compute_reference_sobel_3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); + /** Compute reference sobel 5x5. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] border_mode Border mode to use for input tensor + * @param[in] constant_border_value Constant value to use if @p border_mode is constant + * + * @return Computed raw tensors along x and y axis. + */ + static std::pair compute_reference_sobel_5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); + /** Compute reference Harris corners. + * + * @param[in] shape Shape of input tensor + * @param[in] threshold Minimum threshold with which to eliminate Harris Corner scores (computed using the normalized Sobel kernel). + * @param[in] min_dist Radial Euclidean distance for the euclidean distance stage + * @param[in] sensitivity Sensitivity threshold k from the Harris-Stephens equation + * @param[in] gradient_size The gradient window size to use on the input. The implementation supports 3, 5, and 7 + * @param[in] block_size The block window size used to compute the Harris Corner score. The implementation supports 3, 5, and 7. + * @param[in] border_mode Border mode to use + * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. + * + * @return Computed corners' keypoints. + */ + static KeyPointArray compute_reference_harris_corners(const TensorShape &shape, float threshold, float min_dist, float sensitivity, + int32_t gradient_size, int32_t block_size, BorderMode border_mode, uint8_t constant_border_value); + /** Compute min max location. + * + * @param[in] shape Shape of the input tensors. + * @param[in] dt_in Data type of input tensor. + * @param[out] min Minimum value of tensor + * @param[out] max Maximum value of tensor + * @param[out] min_loc Array with locations of minimum values + * @param[out] max_loc Array with locations of maximum values + * @param[out] min_count Number of minimum values found + * @param[out] max_count Number of maximum values found + * + * @return Computed minimum, maximum values and their locations. + */ + static void compute_reference_min_max_location(const TensorShape &shape, DataType dt_in, void *min, void *max, IArray &min_loc, IArray &max_loc, + uint32_t &min_count, + uint32_t &max_count); + /** Compute reference integral image. + * + * @param[in] shape Shape of the input and output tensors. + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_integral_image(const TensorShape &shape); + /** Compute reference absolute difference. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in0 Data type of first input tensor. + * @param[in] dt_in1 Data type of second input tensor. + * @param[in] dt_out Data type of the output tensor. + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_absolute_difference(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out); + /** Compute reference accumulate. + * + * @param[in] shape Shape of the input and output tensors. + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_accumulate(const TensorShape &shape); + /** Compute reference accumulate. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] shift A uint32_t value within the range of [0, 15] + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_accumulate_squared(const TensorShape &shape, uint32_t shift); + /** Compute reference accumulate. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] alpha A float value within the range of [0, 1] + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_accumulate_weighted(const TensorShape &shape, float alpha); + /** Compute reference arithmetic addition. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in0 Data type of first input tensor. + * @param[in] dt_in1 Data type of second input tensor. + * @param[in] dt_out Data type of the output tensor. + * @param[in] convert_policy Overflow policy of the operation. + * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_arithmetic_addition(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy convert_policy, int fixed_point_position = 0); + /** Compute reference arithmetic subtraction. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in0 Data type of first input tensor. + * @param[in] dt_in1 Data type of second input tensor. + * @param[in] dt_out Data type of the output tensor. + * @param[in] convert_policy Overflow policy of the operation. + * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_arithmetic_subtraction(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, ConvertPolicy convert_policy, int fixed_point_position = 0); + /** Compute reference box3x3 filter. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] border_mode BorderMode used by the input tensor. + * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_box3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); + /** Compute reference depth convert. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in Data type of input tensor. + * @param[in] dt_out Data type of the output tensor. + * @param[in] policy Overflow policy of the operation. + * @param[in] shift Value for down/up conversions. Must be 0 <= shift < 8. + * @param[in] fixed_point_position_in (Optional) Fixed point position for the input tensor. + * @param[in] fixed_point_position_out (Optional) Fixed point position for the output tensor. + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_depth_convert(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, + uint32_t shift, uint32_t fixed_point_position_in = 0, uint32_t fixed_point_position_out = 0); + /** Compute reference gaussian3x3 filter. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] border_mode BorderMode used by the input tensor + * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_gaussian3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); + /** Compute reference gaussian5x5 filter. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] border_mode BorderMode used by the input tensor. + * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_gaussian5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); + /** Compute reference non linear filter function + * + * @param[in] shape Shape of the input and output tensors.Data type supported: U8 + * @param[in] function Non linear function to perform + * @param[in] mask_size Mask size. Supported sizes: 3, 5 + * @param[in] pattern Matrix pattern + * @param[in] mask The given mask. Will be used only if pattern is specified to PATTERN_OTHER + * @param[in] border_mode Strategy to use for borders. + * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT. + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_non_linear_filter(const TensorShape &shape, NonLinearFilterFunction function, unsigned int mask_size, + MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value = 0); + /** Compute reference pixel-wise multiplication + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in0 Data type of first input tensor. + * @param[in] dt_in1 Data type of second input tensor. + * @param[in] dt_out Data type of the output tensor. + * @param[in] scale Non-negative scale. + * @param[in] convert_policy Overflow policy of the operation. + * @param[in] rounding_policy Rounding policy of the operation. + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, ConvertPolicy convert_policy, + RoundingPolicy rounding_policy); + /** Compute reference pixel-wise multiplication. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in0 Data type of first input tensor. + * @param[in] dt_in1 Data type of second input tensor. + * @param[in] dt_out Data type of the output tensor. + * @param[in] scale Scale to apply after multiplication. Must be positive. + * @param[in] fixed_point_position Fixed point position that expresses the number of bits for the fractional part of the number. + * @param[in] convert_policy Overflow policy of the operation. + * @param[in] rounding_policy Rounding policy of the operation. + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_fixed_point_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, int fixed_point_position, + ConvertPolicy convert_policy, RoundingPolicy rounding_policy); + /** Compute reference Table Lookup. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_inout Data type of input/output tensor. + * @param[in] lut Input lookup table. + * + * @return Computed raw tensor. + */ + template + static RawTensor compute_reference_table_lookup(const TensorShape &shape, DataType dt_inout, std::map &lut); + /** Compute reference threshold. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] threshold Threshold. When the threshold type is RANGE, this is used as the lower threshold. + * @param[in] false_value value to set when the condition is not respected. + * @param[in] true_value value to set when the condition is respected. + * @param[in] type Thresholding type. Either RANGE or BINARY. + * @param[in] upper Upper threshold. Only used when the thresholding type is RANGE. + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_threshold(const TensorShape &shape, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper); + + /** Compute reference Warp Perspective. + * + * @param[in] shape Shape of the input and output tensors. + * @param[out] valid_mask Valid mask tensor. + * @param[in] matrix The perspective matrix. Must be 3x3 of type float. + * @param[in] policy The interpolation type. + * @param[in] border_mode Strategy to use for borders. + * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_warp_perspective(const TensorShape &shape, RawTensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, + uint8_t constant_border_value); + + /** Compute reference batch normalization layer. + * + * @param[in] shape0 Shape of the input and output tensors. + * @param[in] shape1 Shape of the vector tensors. + * @param[in] dt Data type of all input and output tensors. + * @param[in] epsilon Small value to avoid division with zero. + * @param[in] fixed_point_position Fixed point position. + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_batch_normalization_layer(const TensorShape &shape0, const TensorShape &shape1, DataType dt, float epsilon, int fixed_point_position = 0); + /** Compute reference roi pooling layer. + * + * @param[in] shape Shape of the input tensor. + * @param[in] dt Data type of input and output tensors. + * @param[in] rois Region of interest vector. + * @param[in] pool_info ROI Pooling Layer information. + */ + static RawTensor compute_reference_roi_pooling_layer(const TensorShape &shape, DataType dt, const std::vector &rois, const ROIPoolingLayerInfo &pool_info); + /** Compute reference fixed point operation. + * + * @param[in] shape Shape of the input and output tensors. + * @param[in] dt_in Data type of the input tensor. + * @param[in] dt_out Data type of the output tensor. + * @param[in] op Fixed point operation to perform. + * @param[in] fixed_point_position Number of bits for the fractional part of the fixed point numbers + * + * @return Computed raw tensor. + */ + static RawTensor compute_reference_fixed_point_operation(const TensorShape &shape, DataType dt_in, DataType dt_out, FixedPointOp op, int fixed_point_position); + +protected: + Reference() = default; + ~Reference() = default; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_H__ */ diff --git a/tests/validation_old/ReferenceCPP.cpp b/tests/validation_old/ReferenceCPP.cpp new file mode 100644 index 0000000000..31c170a040 --- /dev/null +++ b/tests/validation_old/ReferenceCPP.cpp @@ -0,0 +1,294 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "ReferenceCPP.h" + +#include "TensorFactory.h" +#include "TensorOperations.h" +#include "TensorVisitors.h" +#include "TypePrinter.h" + +#include "arm_compute/core/Coordinates.h" +#include "arm_compute/core/Error.h" +#include "arm_compute/core/TensorInfo.h" +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/runtime/Tensor.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include +#include +#include +#include + +using namespace arm_compute::test::validation::tensor_visitors; + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +// Sobel 3x3 +void ReferenceCPP::sobel_3x3(RawTensor &src, RawTensor &dst_x, RawTensor &dst_y, BorderMode border_mode, uint8_t constant_border_value) +{ + ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst_x.data_type() != DataType::S16 || dst_y.data_type() != DataType::S16); + Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); + Tensor dx(dst_x.shape(), dst_x.data_type(), dst_x.fixed_point_position(), reinterpret_cast(dst_x.data())); + Tensor dy(dst_y.shape(), dst_y.data_type(), dst_y.fixed_point_position(), reinterpret_cast(dst_y.data())); + tensor_operations::sobel_3x3(s, dx, dy, border_mode, constant_border_value); +} + +// Sobel 5x5 +void ReferenceCPP::sobel_5x5(RawTensor &src, RawTensor &dst_x, RawTensor &dst_y, BorderMode border_mode, uint8_t constant_border_value) +{ + ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst_x.data_type() != DataType::S16 || dst_y.data_type() != DataType::S16); + Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); + Tensor dx(dst_x.shape(), dst_x.data_type(), dst_x.fixed_point_position(), reinterpret_cast(dst_x.data())); + Tensor dy(dst_y.shape(), dst_y.data_type(), dst_y.fixed_point_position(), reinterpret_cast(dst_y.data())); + tensor_operations::sobel_5x5(s, dx, dy, border_mode, constant_border_value); +} + +// Harris corners +void ReferenceCPP::harris_corners(RawTensor &src, RawTensor &Gx, RawTensor &Gy, const RawTensor &candidates, const RawTensor &non_maxima, float threshold, float min_dist, float sensitivity, + int32_t gradient_size, int32_t block_size, KeyPointArray &corners, BorderMode border_mode, uint8_t constant_border_value) +{ + ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || (Gx.data_type() != DataType::S16 && Gx.data_type() != DataType::S32) || (Gy.data_type() != DataType::S16 && Gy.data_type() != DataType::S32) + || candidates.data_type() != DataType::F32 || non_maxima.data_type() != DataType::F32); + + Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); + Tensor c(candidates.shape(), candidates.data_type(), candidates.fixed_point_position(), const_cast(reinterpret_cast(candidates.data()))); // NOLINT + Tensor nm(non_maxima.shape(), non_maxima.data_type(), non_maxima.fixed_point_position(), const_cast(reinterpret_cast(non_maxima.data()))); // NOLINT + + if(gradient_size == 7) + { + Tensor gx(Gx.shape(), Gx.data_type(), Gx.fixed_point_position(), reinterpret_cast(Gx.data())); + Tensor gy(Gy.shape(), Gy.data_type(), Gy.fixed_point_position(), reinterpret_cast(Gy.data())); + tensor_operations::harris_corners(s, gx, gy, c, nm, threshold, min_dist, sensitivity, gradient_size, block_size, corners, border_mode, constant_border_value); + } + else + { + Tensor gx(Gx.shape(), Gx.data_type(), Gx.fixed_point_position(), reinterpret_cast(Gx.data())); + Tensor gy(Gy.shape(), Gy.data_type(), Gy.fixed_point_position(), reinterpret_cast(Gy.data())); + tensor_operations::harris_corners(s, gx, gy, c, nm, threshold, min_dist, sensitivity, gradient_size, block_size, corners, border_mode, constant_border_value); + } +} + +// Minimum maximum location +void ReferenceCPP::min_max_location(const RawTensor &src, void *min, void *max, IArray &min_loc, IArray &max_loc, uint32_t &min_count, uint32_t &max_count) +{ + const TensorVariant s = TensorFactory::get_tensor(src); + boost::apply_visitor(tensor_visitors::min_max_location_visitor(min, max, min_loc, max_loc, min_count, max_count), s); +} + +// Absolute difference +void ReferenceCPP::absolute_difference(const RawTensor &src1, const RawTensor &src2, RawTensor &dst) +{ + const TensorVariant s1 = TensorFactory::get_tensor(src1); + const TensorVariant s2 = TensorFactory::get_tensor(src2); + TensorVariant d = TensorFactory::get_tensor(dst); + boost::apply_visitor(absolute_difference_visitor(), s1, s2, d); +} + +// Integral image +void ReferenceCPP::integral_image(const RawTensor &src, RawTensor &dst) +{ + ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U32); + const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); + Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); + tensor_operations::integral_image(s, d); +} + +// Accumulate +void ReferenceCPP::accumulate(const RawTensor &src, RawTensor &dst) +{ + ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::S16); + const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); + Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); + tensor_operations::accumulate(s, d); +} + +// Accumulate squared +void ReferenceCPP::accumulate_squared(const RawTensor &src, RawTensor &dst, uint32_t shift) +{ + ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::S16); + const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); + Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); + tensor_operations::accumulate_squared(s, d, shift); +} + +// Accumulate weighted +void ReferenceCPP::accumulate_weighted(const RawTensor &src, RawTensor &dst, float alpha) +{ + ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); + const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); + Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); + tensor_operations::accumulate_weighted(s, d, alpha); +} + +// Arithmetic addition +void ReferenceCPP::arithmetic_addition(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, ConvertPolicy convert_policy) +{ + const TensorVariant s1 = TensorFactory::get_tensor(src1); + const TensorVariant s2 = TensorFactory::get_tensor(src2); + TensorVariant d = TensorFactory::get_tensor(dst); + boost::apply_visitor(arithmetic_addition_visitor(convert_policy), s1, s2, d); +} + +// Arithmetic subtraction +void ReferenceCPP::arithmetic_subtraction(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, ConvertPolicy convert_policy) +{ + const TensorVariant s1 = TensorFactory::get_tensor(src1); + const TensorVariant s2 = TensorFactory::get_tensor(src2); + TensorVariant d = TensorFactory::get_tensor(dst); + boost::apply_visitor(arithmetic_subtraction_visitor(convert_policy), s1, s2, d); +} + +// Box3x3 filter +void ReferenceCPP::box3x3(const RawTensor &src, RawTensor &dst, BorderMode border_mode, uint8_t constant_border_value) +{ + ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); + const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); + Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); + tensor_operations::box3x3(s, d, border_mode, constant_border_value); +} + +// Depth conversion +void ReferenceCPP::depth_convert(const RawTensor &src, RawTensor &dst, ConvertPolicy policy, uint32_t shift) +{ + const TensorVariant s = TensorFactory::get_tensor(src); + TensorVariant d = TensorFactory::get_tensor(dst); + boost::apply_visitor(tensor_visitors::depth_convert_visitor(policy, shift), s, d); +} + +// Gaussian3x3 filter +void ReferenceCPP::gaussian3x3(const RawTensor &src, RawTensor &dst, BorderMode border_mode, uint8_t constant_border_value) +{ + ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); + const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); + Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); + tensor_operations::gaussian3x3(s, d, border_mode, constant_border_value); +} + +// Gaussian5x5 filter +void ReferenceCPP::gaussian5x5(const RawTensor &src, RawTensor &dst, BorderMode border_mode, uint8_t constant_border_value) +{ + ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); + const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); + Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); + tensor_operations::gaussian5x5(s, d, border_mode, constant_border_value); +} + +// Non linear filter +void ReferenceCPP::non_linear_filter(const RawTensor &src, RawTensor &dst, NonLinearFilterFunction function, unsigned int mask_size, + MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value) +{ + ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); + const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); + Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); + tensor_operations::non_linear_filter(s, d, function, mask_size, pattern, mask, border_mode, constant_border_value); +} + +// Pixel-wise multiplication +void ReferenceCPP::pixel_wise_multiplication(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) +{ + const TensorVariant s1 = TensorFactory::get_tensor(src1); + const TensorVariant s2 = TensorFactory::get_tensor(src2); + TensorVariant d = TensorFactory::get_tensor(dst); + boost::apply_visitor(pixel_wise_multiplication_visitor(scale, convert_policy, rounding_policy), s1, s2, d); +} + +// Fixed-point Pixel-wise multiplication +void ReferenceCPP::fixed_point_pixel_wise_multiplication(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) +{ + const TensorVariant s1 = TensorFactory::get_tensor(src1); + const TensorVariant s2 = TensorFactory::get_tensor(src2); + TensorVariant d = TensorFactory::get_tensor(dst); + boost::apply_visitor(tensor_visitors::fixed_point_pixel_wise_multiplication_visitor(s1, s2, scale, convert_policy, rounding_policy), d); +} + +// Table lookup +template +void ReferenceCPP::table_lookup(const RawTensor &src, RawTensor &dst, std::map &lut) +{ + const TensorVariant s = TensorFactory::get_tensor(src); + TensorVariant d = TensorFactory::get_tensor(dst); + boost::apply_visitor(tensor_visitors::table_lookup(s, lut), d); +} +#ifndef DOXYGEN_SKIP_THIS +template void arm_compute::test::validation::ReferenceCPP::table_lookup(const RawTensor &src, RawTensor &dst, std::map &lut); +template void arm_compute::test::validation::ReferenceCPP::table_lookup(const RawTensor &src, RawTensor &dst, std::map &lut); +#endif /* DOXYGEN_SKIP_THIS */ + +// Threshold +void ReferenceCPP::threshold(const RawTensor &src, RawTensor &dst, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) +{ + ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); + const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); + Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); + tensor_operations::threshold(s, d, threshold, false_value, true_value, type, upper); +} + +// Warp perspective +void ReferenceCPP::warp_perspective(const RawTensor &src, RawTensor &dst, RawTensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) +{ + ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); + const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); + Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); + Tensor vmask(valid_mask.shape(), valid_mask.data_type(), valid_mask.fixed_point_position(), reinterpret_cast(valid_mask.data())); + tensor_operations::warp_perspective(s, d, vmask, matrix, policy, border_mode, constant_border_value); +} + +// Batch Normalization Layer +void ReferenceCPP::batch_normalization_layer(const RawTensor &src, RawTensor &dst, const RawTensor &mean, const RawTensor &var, const RawTensor &beta, const RawTensor &gamma, float epsilon, + int fixed_point_position) +{ + const TensorVariant s = TensorFactory::get_tensor(src); + TensorVariant d = TensorFactory::get_tensor(dst); + const TensorVariant m = TensorFactory::get_tensor(mean); + const TensorVariant v = TensorFactory::get_tensor(var); + const TensorVariant b = TensorFactory::get_tensor(beta); + const TensorVariant g = TensorFactory::get_tensor(gamma); + boost::apply_visitor(tensor_visitors::batch_normalization_layer_visitor(s, m, v, b, g, epsilon, fixed_point_position), d); +} + +// ROI Pooling Layer +void ReferenceCPP::roi_pooling_layer(const RawTensor &src, RawTensor &dst, const std::vector &rois, const ROIPoolingLayerInfo &pool_info) +{ + const TensorVariant s = TensorFactory::get_tensor(src); + TensorVariant d = TensorFactory::get_tensor(dst); + boost::apply_visitor(tensor_visitors::roi_pooling_layer_visitor(s, rois, pool_info), d); +} + +// Fixed point operation +void ReferenceCPP::fixed_point_operation(const RawTensor &src, RawTensor &dst, FixedPointOp op) +{ + const TensorVariant s = TensorFactory::get_tensor(src); + TensorVariant d = TensorFactory::get_tensor(dst); + boost::apply_visitor(tensor_visitors::fixed_point_operation_visitor(s, op), d); +} + +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation_old/ReferenceCPP.h b/tests/validation_old/ReferenceCPP.h new file mode 100644 index 0000000000..fcc4da471d --- /dev/null +++ b/tests/validation_old/ReferenceCPP.h @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_CPP_H__ +#define __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_CPP_H__ + +#include "RawTensor.h" +#include "Reference.h" + +#include +#include +#include +#include + +namespace arm_compute +{ +class Tensor; + +namespace test +{ +namespace validation +{ +/** C++ reference implementation. */ +class ReferenceCPP final : public Reference +{ +public: + /** Function to compute reference sobel 3x3. + * + * @param[in] src Input tensor. + * @param[in] dst_x Result tensor along x axis + * @param[in] dst_y Result tensor along y axis + * @param[in] border_mode Border mode to use for input tensor + * @param[in] constant_border_value Constant value to use if @p border_mode is constant + * + */ + static void sobel_3x3(RawTensor &src, RawTensor &dst_x, RawTensor &dst_y, BorderMode border_mode, uint8_t constant_border_value); + /** Function to compute reference sobel 5x5. + * + * @param[in] src Input tensor. + * @param[in] dst_x Result tensor along x axis + * @param[in] dst_y Result tensor along y axis + * @param[in] border_mode Border mode to use for input tensor + * @param[in] constant_border_value Constant value to use if @p border_mode is constant + * + */ + static void sobel_5x5(RawTensor &src, RawTensor &dst_x, RawTensor &dst_y, BorderMode border_mode, uint8_t constant_border_value); + /** Function to compute reference Harris corners. + * + * @param[in] src Input tensor + * @param[in] Gx Tensor used to compute Sobel along the x axis + * @param[in] Gy Tensor used to compute Sobel along the y axis + * @param[in] candidates Tensor used to store candidate corners + * @param[in] non_maxima Tensor used to store non_maxima suppressed candidate corners + * @param[in] threshold Minimum threshold with which to eliminate Harris Corner scores (computed using the normalized Sobel kernel). + * @param[in] min_dist Radial Euclidean distance for the euclidean distance stage + * @param[in] sensitivity Sensitivity threshold k from the Harris-Stephens equation + * @param[in] gradient_size The gradient window size to use on the input. The implementation supports 3, 5, and 7 + * @param[in] block_size The block window size used to compute the Harris Corner score. The implementation supports 3, 5, and 7. + * @param[out] corners Array of keypoints to store the results. + * @param[in] border_mode Border mode to use + * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. + * + */ + static void harris_corners(RawTensor &src, RawTensor &Gx, RawTensor &Gy, const RawTensor &candidates, const RawTensor &non_maxima, float threshold, float min_dist, float sensitivity, + int32_t gradient_size, int32_t block_size, KeyPointArray &corners, BorderMode border_mode, uint8_t constant_border_value); + /** Function to compute the min max values and their location in a tensor. + * + * @param[in] src Input tensor. + * @param[out] min Minimum value of the tensor. + * @param[out] max Maximum value of the tensor + * @param[out] min_loc Array with locations of minimum values + * @param[out] max_loc Array with locations of maximum values + * @param[out] min_count Number of minimum values found + * @param[out] max_count Number of maximum values found + */ + static void min_max_location(const RawTensor &src, void *min, void *max, IArray &min_loc, IArray &max_loc, uint32_t &min_count, uint32_t &max_count); + /** Function to compute the integral image of a tensor. + * + * @param[in] src Input tensor. + * @param[out] dst Result tensor. + */ + static void integral_image(const RawTensor &src, RawTensor &dst); + /** Function to compute the absolute difference between two tensors. + * + * @param[in] src1 First tensor. + * @param[in] src2 Second tensor. + * @param[out] dst Result tensor. + */ + static void absolute_difference(const RawTensor &src1, const RawTensor &src2, RawTensor &dst); + /** Function to accumulate an input tensor into an output tensor. + * + * @param[in] src Input tensor. + * @param[in, out] dst Result tensor. + */ + static void accumulate(const RawTensor &src, RawTensor &dst); + /** Function to accumulate a squared value from an input tensor to an output tensor. + * + * @param[in] src Input tensor. + * @param[in, out] dst Result tensor. + * @param[in] shift A uint32_t value within the range of [0, 15] + */ + static void accumulate_squared(const RawTensor &src, RawTensor &dst, uint32_t shift); + /** Function to accumulate a weighted value from an input tensor to an output tensor. + * + * @param[in] src Input tensor. + * @param[in, out] dst Result tensor. + * @param[in] alpha A float value within the range of [0, 1] + */ + static void accumulate_weighted(const RawTensor &src, RawTensor &dst, float alpha); + /** Arithmetic addition of @p src1 and @p src2 + * + * @param[in] src1 First tensor. + * @param[in] src2 Second tensor. + * @param[out] dst Result tensor. + * @param[in] convert_policy Overflow policy. + */ + static void arithmetic_addition(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, ConvertPolicy convert_policy); + /** Arithmetic subtraction of @p src2 from @p src1 + * + * @param[in] src1 First tensor. + * @param[in] src2 Second tensor. + * @param[out] dst Result tensor. + * @param[in] convert_policy Overflow policy. + */ + static void arithmetic_subtraction(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, ConvertPolicy convert_policy); + /** Function to compute box3x3 filtered result tensor. + * + * @param[in] src Input tensor. + * @param[out] dst Result tensor. + * @param[in] border_mode Border mode. + * @param[in] constant_border_value Constant border value if @p border_mode is BorderMode::CONSTANT. + */ + static void box3x3(const RawTensor &src, RawTensor &dst, BorderMode border_mode, uint8_t constant_border_value); + /** Depth conversion from @p src to @p dst + * + * @param[in] src First tensor. + * @param[out] dst Result tensor. + * @param[in] policy Overflow policy. + * @param[in] shift Value for down/up conversions. + */ + static void depth_convert(const RawTensor &src, RawTensor &dst, ConvertPolicy policy, uint32_t shift); + /** Function to compute gaussian3x3 filtered result tensor. + * + * @param[in] src Input tensor. + * @param[out] dst Result tensor. + * @param[in] border_mode Border mode + * @param[in] constant_border_value Constant border value if @p border_mode is BorderMode::CONSTANT + */ + static void gaussian3x3(const RawTensor &src, RawTensor &dst, BorderMode border_mode, uint8_t constant_border_value); + /** Function to compute gaussian5x5 filtered result tensor. + * + * @param[in] src Input tensor. + * @param[out] dst Result tensor. + * @param[in] border_mode Border mode + * @param[in] constant_border_value Constant border value if @p border_mode is BorderMode::CONSTANT + */ + static void gaussian5x5(const RawTensor &src, RawTensor &dst, BorderMode border_mode, uint8_t constant_border_value); + /** Compute non linear filter function. + * + * @param[in] src First input tensor + * @param[out] dst Output tensor + * @param[in] function Non linear function to perform + * @param[in] mask_size Mask size. Supported sizes: 3, 5 + * @param[in] pattern Matrix pattern + * @param[in] mask The given mask. + * @param[in] border_mode Strategy to use for borders. + * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT. + */ + static void non_linear_filter(const RawTensor &src, RawTensor &dst, NonLinearFilterFunction function, unsigned int mask_size, + MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value = 0); + /** Element-wise multiplication of @p src1, @p src2 and @p scale + * + * @param[in] src1 First tensor. + * @param[in] src2 Second tensor. + * @param[out] dst Result tensor. + * @param[in] scale A non-negative float multiplied to each product. + * @param[in] convert_policy Overflow policy. + * @param[in] rounding_policy Rounding policy. + */ + static void pixel_wise_multiplication(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy); + /** Fixed-point Pixel-wise multiplication of @p src1 by @p src2 + * + * @param[in] src1 First tensor. + * @param[in] src2 Second tensor. + * @param[out] dst Result tensor. + * @param[in] scale A non-negative float multiplied to each product. + * @param[in] convert_policy Overflow policy. + * @param[in] rounding_policy Rounding policy. + */ + static void fixed_point_pixel_wise_multiplication(const RawTensor &src1, const RawTensor &src2, RawTensor &dst, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy); + /** Table Lookup f@p src to @p dst + * + * @param[in] src Input tensor. + * @param[out] dst Result tensor. + * @param[in] lut Input lookup table. + */ + template + static void table_lookup(const RawTensor &src, RawTensor &dst, std::map &lut); + /** Threshold of@p src to @p dst + * + * @param[in] src Input tensor. + * @param[out] dst Result tensor. + * @param[in] threshold Threshold. When the threhold type is RANGE, this is used as the lower threshold. + * @param[in] false_value value to set when the condition is not respected. + * @param[in] true_value value to set when the condition is respected. + * @param[in] type Thresholding type. Either RANGE or BINARY. + * @param[in] upper Upper threshold. Only used when the thresholding type is RANGE. + */ + static void threshold(const RawTensor &src, RawTensor &dst, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper); + /** Warp perspective of@p src to @p dst + * + * @param[in] src First tensor. + * @param[out] dst Result tensor. + * @param[out] valid_mask Valid mask tensor. + * @param[in] matrix The perspective matrix. Must be 3x3 of type float. + * @param[in] policy The interpolation type. + * @param[in] border_mode Strategy to use for borders. + * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. + */ + static void warp_perspective(const RawTensor &src, RawTensor &dst, RawTensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value); + + /** Batch Normalization of @p src based on the information from @p norm_info. + * + * @param[in] src Input tensor. + * @param[out] dst Result tensor. + * @param[out] mean Mean vector tensor. + * @param[out] var Var vector tensor. + * @param[out] beta Beta vector tensor. + * @param[out] gamma Gamma vector tensor. + * @param[in] epsilon Small value to avoid division with zero. + * @param[in] fixed_point_position Fixed point position. + */ + static void batch_normalization_layer(const RawTensor &src, RawTensor &dst, const RawTensor &mean, const RawTensor &var, const RawTensor &beta, const RawTensor &gamma, float epsilon, + int fixed_point_position = 0); + /** ROI Pooling layer of @p src based on the information from @p pool_info and @p rois. + * + * @param[in] src Input tensor. + * @param[out] dst Result tensor. + * @param[in] rois Region of Interest points. + * @param[in] pool_info ROI Pooling Layer information. + */ + static void roi_pooling_layer(const RawTensor &src, RawTensor &dst, const std::vector &rois, const ROIPoolingLayerInfo &pool_info); + /** Fixed point operations of @p src + * + * @param[in] src Input tensor. + * @param[out] dst Result tensor. + * @param[in] op Fixed point operation to perform. + */ + static void fixed_point_operation(const RawTensor &src, RawTensor &dst, FixedPointOp op); + +private: + ReferenceCPP() = delete; + ~ReferenceCPP() = delete; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_CPP_H__ */ diff --git a/tests/validation_old/SConscript b/tests/validation_old/SConscript new file mode 100644 index 0000000000..fdf8e7fff8 --- /dev/null +++ b/tests/validation_old/SConscript @@ -0,0 +1,119 @@ +# Copyright (c) 2017 ARM Limited. +# +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +import SCons +import os.path + +Import('env') +Import('vars') + +# vars is imported from arm_compute: +variables = [ + #FIXME: Remove before release! + BoolVariable("openvx", "Enable OpenVX support in tests", False), + BoolVariable("openblas", "Enable OpenBLAS support in tests", False), + #FIXME Remove before release (And remove all references to INTERNAL_ONLY) + BoolVariable("internal_only", "Enable ARM internal only tests", True), + BoolVariable("pmu", "Enable PMU counters", False), + BoolVariable("validation_tests", "Build validation test programs", True), + BoolVariable("benchmark_tests", "Build benchmark test programs", True) +] + +# We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice) +new_options = Variables('scons') + +for v in variables: + new_options.Add(v) + vars.Add(v) + +# Clone the environment to make sure we're not polluting the arm_compute one: +old_validation_env = env.Clone() +vars.Update(old_validation_env) + +Help(new_options.GenerateHelpText(old_validation_env)) + +if old_validation_env['openblas']: + if env['os'] == 'bare_metal': + print("OpenBLAS is not supported on bare metal") + Exit(1) + old_validation_env.Append(CPPDEFINES = ['USE_OPENBLAS']) + old_validation_env.Append(LIBS = ['openblas', 'pthread']) + +if env['os'] in ['android', 'bare_metal'] or env['standalone']: + Import('arm_compute_a') + old_validation_env.Append(LIBS = [arm_compute_a]) + arm_compute_lib = arm_compute_a +else: + Import('arm_compute_so') + old_validation_env.Append(LIBS = ["arm_compute"]) + arm_compute_lib = arm_compute_so + +#FIXME Delete before release +if old_validation_env['internal_only']: + old_validation_env.Append(CPPDEFINES=['INTERNAL_ONLY']) + +old_validation_env.Append(CPPPATH = [".", "#tests", "#3rdparty/include"]) +old_validation_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])]) +old_validation_env.Append(LIBPATH = ["#build/%s" % env['build_dir']]) +old_validation_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']]) +old_validation_env.Append(LIBS = ['boost_program_options']) +old_validation_env.Append(CXXFLAGS = ['-Wno-missing-field-initializers']) +old_validation_env.Append(CPPDEFINES=['BOOST']) +old_validation_env.Append(LIBS = ['boost_unit_test_framework']) + +old_files_validation = Glob('*.cpp') + +# Add unit tests +old_files_validation += Glob('UNIT/*.cpp') +old_files_validation += Glob('UNIT/*/*.cpp') + +if env['opencl']: + Import('opencl') + + old_files_validation += Glob('CL/*.cpp') + old_files_validation += Glob('CL/*/*.cpp') + old_files_validation += Glob('system_tests/CL/*.cpp') + + old_validation_env.Append(LIBS = "OpenCL") + old_validation_env.Append(CPPDEFINES=['ARM_COMPUTE_CL']) + +#FIXME Remove before release +if old_validation_env['openvx']: + old_files_validation += Glob('VX/*.cpp') + old_files_validation += Glob('VX/*/*.cpp') + + old_validation_env.Append(LIBS = ['openvx', 'vxu']) + +if env['neon']: + old_files_validation += Glob('NEON/*.cpp') + old_files_validation += Glob('NEON/*/*.cpp') + old_files_validation += Glob('system_tests/NEON/*.cpp') + +if env['os'] == 'android': + old_validation_env.Append(LIBS = ["log"]) + +if old_validation_env['validation_tests']: + arm_compute_validation_old = old_validation_env.Program('arm_compute_validation_old', old_files_validation) + Depends(arm_compute_validation_old, arm_compute_lib) + if env['opencl']: + Depends(arm_compute_validation_old, opencl) + Default(arm_compute_validation_old) + Export('arm_compute_validation_old') diff --git a/tests/validation_old/Tensor.h b/tests/validation_old/Tensor.h new file mode 100644 index 0000000000..84d76e7143 --- /dev/null +++ b/tests/validation_old/Tensor.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_TENSOR_H__ +#define __ARM_COMPUTE_TEST_TENSOR_H__ + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class Tensor +{ +public: + Tensor() + : _shape(), _dt(DataType::UNKNOWN), _fixed_point_position(0), _ptr(nullptr), _ptr_const(nullptr) {}; + + Tensor(TensorShape shape, DataType dt, int fixed_point_position, T *ptr) + : _shape(shape), _dt(dt), _fixed_point_position(fixed_point_position), _ptr(ptr), _ptr_const(nullptr) {}; + + Tensor(TensorShape shape, DataType dt, int fixed_point_position, const T *ptr) + : _shape(shape), _dt(dt), _fixed_point_position(fixed_point_position), _ptr(nullptr), _ptr_const(ptr) {}; + + Tensor(const Tensor &tensor) = delete; + Tensor &operator=(const Tensor &) = delete; + Tensor(Tensor &&) = default; + Tensor &operator=(Tensor &&) = default; + + ~Tensor() = default; + + T &operator[](size_t offset) + { + ARM_COMPUTE_ERROR_ON(_ptr == nullptr); + + return _ptr[offset]; + } + + const T &operator[](size_t offset) const + { + const T *ptr = (_ptr_const != nullptr) ? _ptr_const : _ptr; + + ARM_COMPUTE_ERROR_ON(ptr == nullptr); + + return ptr[offset]; // NOLINT + } + + int num_elements() const + { + return std::accumulate(_shape.cbegin(), _shape.cend(), 1, std::multiplies()); + } + + TensorShape shape() const + { + return _shape; + } + + DataType data_type() const + { + return _dt; + } + + int fixed_point_position() const + { + return _fixed_point_position; + } + + const T *data() const + { + return (_ptr_const != nullptr) ? _ptr_const : _ptr; + } + + T *data() + { + return _ptr; + } + + const T *data_const() const + { + return _ptr_const; + } + +private: + TensorShape _shape; + DataType _dt; + int _fixed_point_position; + T *_ptr; + const T *_ptr_const; +}; +} // namespace validation +} // test +} // arm_compute + +#endif /* __ARM_COMPUTE_TEST_TENSOR_H__ */ diff --git a/tests/validation_old/TensorFactory.h b/tests/validation_old/TensorFactory.h new file mode 100644 index 0000000000..3f5b960927 --- /dev/null +++ b/tests/validation_old/TensorFactory.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_TENSOR_FACTORY_H__ +#define __ARM_COMPUTE_TEST_TENSOR_FACTORY_H__ + +#include "arm_compute/core/Error.h" +#include "tests/RawTensor.h" +#include "tests/validation_old/Tensor.h" +#include "tests/validation_old/half.h" + +#include "tests/validation_old/boost_wrapper.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +using TensorVariant = boost::variant, Tensor, + Tensor, Tensor, + Tensor, Tensor, + Tensor, + Tensor>; + +/** Helper to create a constant type if the passed reference is constant. */ +template +struct match_const +{ + using type = typename std::conditional::type>::value, const T, T>::type; +}; + +class TensorFactory +{ +public: + template + static TensorVariant get_tensor(R &&raw) + { + TensorVariant v; + DataType dt = raw.data_type(); + int fixed_point_position = raw.fixed_point_position(); + auto shape = raw.shape(); + auto data = raw.data(); + + switch(dt) + { + case DataType::U8: + using value_type_u8 = typename match_const::type; + v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); + break; + case DataType::S8: + case DataType::QS8: + using value_type_s8 = typename match_const::type; + v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); + break; + case DataType::U16: + using value_type_u16 = typename match_const::type; + v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); + break; + case DataType::S16: + case DataType::QS16: + using value_type_s16 = typename match_const::type; + v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); + break; + case DataType::U32: + using value_type_u32 = typename match_const::type; + v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); + break; + case DataType::S32: + using value_type_s32 = typename match_const::type; + v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); + break; + case DataType::F16: + using value_type_f16 = typename match_const::type; + v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); + break; + case DataType::F32: + using value_type_f32 = typename match_const::type; + v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); + break; + default: + ARM_COMPUTE_ERROR("NOT SUPPORTED!"); + } + return v; + } +}; +} // namespace validation +} // namespace test +} // namespace arm_compute + +#endif /* __ARM_COMPUTE_TEST_TENSOR_FACTORY_H__ */ diff --git a/tests/validation_old/TensorOperations.h b/tests/validation_old/TensorOperations.h new file mode 100644 index 0000000000..48661bbab9 --- /dev/null +++ b/tests/validation_old/TensorOperations.h @@ -0,0 +1,1178 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_TENSOR_OPERATIONS_H__ +#define __ARM_COMPUTE_TEST_TENSOR_OPERATIONS_H__ + +#include "arm_compute/core/FixedPoint.h" +#include "arm_compute/core/Helpers.h" +#include "arm_compute/core/Types.h" +#include "support/ToolchainSupport.h" +#include "tests/Types.h" +#include "tests/Utils.h" +#include "tests/validation_old/FixedPoint.h" +#include "tests/validation_old/Tensor.h" +#include "tests/validation_old/ValidationUserConfiguration.h" +#include "tests/validation_old/half.h" + +#include +#include +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace tensor_operations +{ +namespace +{ +template +struct is_floating_point + : std::integral_constant < bool, + std::is_same::type>::value || std::is_same::type>::value + || std::is_same::type>::value || std::is_same::type>::value > +{ +}; + +// Return a tensor element at a specified coordinate with different border modes +template +T tensor_elem_at(const Tensor &in, Coordinates coord, BorderMode border_mode, T constant_border_value) +{ + const int x = coord.x(); + const int y = coord.y(); + const int width = static_cast(in.shape().x()); + const int height = static_cast(in.shape().y()); + + // If coordinates beyond range of tensor's width or height + if(x < 0 || y < 0 || x >= width || y >= height) + { + if(border_mode == BorderMode::REPLICATE) + { + coord.set(0, std::max(0, std::min(x, width - 1))); + coord.set(1, std::max(0, std::min(y, height - 1))); + } + else + { + return constant_border_value; + } + } + + return in[coord2index(in.shape(), coord)]; +} + +/** Apply 2D spatial filter on a single element of @p in at coordinates @p coord + * + * - filter sizes have to be odd number + * - Row major order of filter assumed + * - TO_ZERO rounding policy assumed + * - SATURATE convert policy assumed + * + */ +template +void apply_2d_spatial_filter(Coordinates coord, const Tensor &in, Tensor &out, const TensorShape &filter_shape, const T2 *filter_itr, float scale, BorderMode border_mode, + T1 constant_border_value = 0) +{ + double val = 0; + const int x = coord.x(); + const int y = coord.y(); + for(int j = y - static_cast(filter_shape[1] / 2); j <= y + static_cast(filter_shape[1] / 2); ++j) + { + for(int i = x - static_cast(filter_shape[0] / 2); i <= x + static_cast(filter_shape[0] / 2); ++i) + { + coord.set(0, i); + coord.set(1, j); + val += static_cast(*filter_itr) * tensor_elem_at(in, coord, border_mode, constant_border_value); + ++filter_itr; + } + } + coord.set(0, x); + coord.set(1, y); + const double rounded_val = support::cpp11::trunc(val * static_cast(scale)); + out[coord2index(in.shape(), coord)] = saturate_cast(rounded_val); +} +} // namespace + +template +T bilinear_policy(const Tensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value) +{ + int idx = std::floor(xn); + int idy = std::floor(yn); + + const float dx = xn - idx; + const float dy = yn - idy; + const float dx_1 = 1.0f - dx; + const float dy_1 = 1.0f - dy; + + id.set(0, idx); + id.set(1, idy); + const T tl = tensor_elem_at(in, id, border_mode, constant_border_value); + id.set(0, idx + 1); + id.set(1, idy); + const T tr = tensor_elem_at(in, id, border_mode, constant_border_value); + id.set(0, idx); + id.set(1, idy + 1); + const T bl = tensor_elem_at(in, id, border_mode, constant_border_value); + id.set(0, idx + 1); + id.set(1, idy + 1); + const T br = tensor_elem_at(in, id, border_mode, constant_border_value); + + return tl * (dx_1 * dy_1) + tr * (dx * dy_1) + bl * (dx_1 * dy) + br * (dx * dy); +} + +bool valid_bilinear_policy(float xn, float yn, int width, int height, BorderMode border_mode) +{ + if(border_mode != BorderMode::UNDEFINED) + { + return true; + } + if((0 <= yn + 1) && (yn + 1 < height) && (0 <= xn + 1) && (xn + 1 < width)) + { + return true; + } + return false; +} + +// Sobel 3x3 +template +void sobel_3x3(Tensor &in, Tensor &out_x, Tensor &out_y, BorderMode border_mode, uint8_t constant_border_value) +{ + const std::array sobel_x{ { -1, 0, 1, -2, 0, 2, -1, 0, 1 } }; + const std::array sobel_y{ { -1, -2, -1, 0, 0, 0, 1, 2, 1 } }; + + for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) + { + const Coordinates id = index2coord(in.shape(), element_idx); + + apply_2d_spatial_filter(id, in, out_x, TensorShape(3U, 3U), sobel_x.data(), 1.f, border_mode, constant_border_value); + apply_2d_spatial_filter(id, in, out_y, TensorShape(3U, 3U), sobel_y.data(), 1.f, border_mode, constant_border_value); + } +} + +// Sobel 5x5 +template +void sobel_5x5(Tensor &in, Tensor &out_x, Tensor &out_y, BorderMode border_mode, uint8_t constant_border_value) +{ + const std::array sobel_x{ { + -1, -2, 0, 2, 1, + -4, -8, 0, 8, 4, + -6, -12, 0, 12, 6, + -4, -8, 0, 8, 4, + -1, -2, 0, 2, 1 + } }; + + const std::array sobel_y{ { + -1, -4, -6, -4, -1, + -2, -8, -12, -8, -2, + 0, 0, 0, 0, 0, + 2, 8, 12, 8, 2, + 1, 4, 6, 4, 1 + } }; + + for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) + { + const Coordinates id = index2coord(in.shape(), element_idx); + + apply_2d_spatial_filter(id, in, out_x, TensorShape(5U, 5U), sobel_x.data(), 1.f, border_mode, constant_border_value); + apply_2d_spatial_filter(id, in, out_y, TensorShape(5U, 5U), sobel_y.data(), 1.f, border_mode, constant_border_value); + } +} + +// Sobel 7x7 +template +void sobel_7x7(Tensor &in, Tensor &out_x, Tensor &out_y, BorderMode border_mode, uint8_t constant_border_value) +{ + const std::array sobel_x{ { + -1, -4, -5, 0, 5, 4, 1, + -6, -24, -30, 0, 30, 24, 6, + -15, -60, -75, 0, 75, 60, 15, + -20, -80, -100, 0, 100, 80, 20, + -15, -60, -75, 0, 75, 60, 15, + -6, -24, -30, 0, 30, 24, 6, + -1, -4, -5, 0, 5, 4, 1 + } }; + + const std::array sobel_y{ { + -1, -6, -15, -20, -15, -6, -1, + -4, -24, -60, -80, -60, -24, -4, + -5, -30, -75, -100, -75, -30, -5, + 0, 0, 0, 0, 0, 0, 0, + 5, 30, 75, 100, 75, 30, 5, + 4, 24, 60, 80, 60, 24, 4, + 1, 6, 15, 20, 15, 6, 1 + } }; + + for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) + { + const Coordinates id = index2coord(in.shape(), element_idx); + + apply_2d_spatial_filter(id, in, out_x, TensorShape(7U, 7U), sobel_x.data(), 1.f, border_mode, constant_border_value); + apply_2d_spatial_filter(id, in, out_y, TensorShape(7U, 7U), sobel_y.data(), 1.f, border_mode, constant_border_value); + } +} + +template +void non_maxima_suppression_3x3(Tensor &in, Tensor &out, BorderMode border_mode) +{ + for(int i = 0; i < in.num_elements(); ++i) + { + Coordinates coord = index2coord(in.shape(), i); + int x = coord.x(); + int y = coord.y(); + + if(in[i] >= tensor_elem_at(in, Coordinates(x - 1, y - 1), border_mode, 0.f) && in[i] >= tensor_elem_at(in, Coordinates(x, y - 1), border_mode, 0.f) + && in[i] >= tensor_elem_at(in, Coordinates(x + 1, y - 1), border_mode, 0.f) && in[i] >= tensor_elem_at(in, Coordinates(x - 1, y), border_mode, 0.f) + && in[i] > tensor_elem_at(in, Coordinates(x + 1, y), border_mode, 0.f) && in[i] > tensor_elem_at(in, Coordinates(x - 1, y + 1), border_mode, 0.f) + && in[i] > tensor_elem_at(in, Coordinates(x, y + 1), border_mode, 0.f) && in[i] > tensor_elem_at(in, Coordinates(x + 1, y + 1), border_mode, 0.f)) + { + out[i] = in[i]; + } + else + { + out[i] = 0; + } + } +} + +// Harris corners +template +void harris_corners(Tensor &in, Tensor &Gx, Tensor &Gy, Tensor &candidates, Tensor &non_maxima, float threshold, float min_dist, float sensitivity, + int32_t gradient_size, int32_t block_size, KeyPointArray &corners, BorderMode border_mode, uint8_t constant_border_value) +{ + ARM_COMPUTE_ERROR_ON(block_size != 3 && block_size != 5 && block_size != 7); + + ValidRegion valid_region = shape_to_valid_region(candidates.shape()); + float norm_factor = 0.f; + + // Sobel + switch(gradient_size) + { + case 3: + sobel_3x3(in, Gx, Gy, border_mode, constant_border_value); + norm_factor = 1.f / (4 * 255 * block_size); + break; + case 5: + sobel_5x5(in, Gx, Gy, border_mode, constant_border_value); + norm_factor = 1.f / (16 * 255 * block_size); + break; + case 7: + sobel_7x7(in, Gx, Gy, border_mode, constant_border_value); + norm_factor = 1.f / (64 * 255 * block_size); + break; + default: + ARM_COMPUTE_ERROR("Gradient size not supported."); + } + + //Calculate scores + for(int i = 0; i < in.num_elements(); ++i) + { + Coordinates in_coord = index2coord(in.shape(), i); + + float Gx2 = 0; + float Gy2 = 0; + float Gxy = 0; + + // Calculate Gx^2, Gy^2 and Gxy within the given window + for(int y = in_coord.y() - block_size / 2; y <= in_coord.y() + block_size / 2; ++y) + { + for(int x = in_coord.x() - block_size / 2; x <= in_coord.x() + block_size / 2; ++x) + { + Coordinates block_coord(x, y); + + float norm_gx = tensor_elem_at(Gx, block_coord, border_mode, static_cast(constant_border_value)) * norm_factor; + float norm_gy = tensor_elem_at(Gy, block_coord, border_mode, static_cast(constant_border_value)) * norm_factor; + + Gx2 += std::pow(norm_gx, 2); + Gy2 += std::pow(norm_gy, 2); + Gxy += norm_gx * norm_gy; + } + } + + float trace2 = std::pow(Gx2 + Gy2, 2); + float det = Gx2 * Gy2 - std::pow(Gxy, 2); + float response = det - sensitivity * trace2; + + if(response > threshold) + { + candidates[i] = response; + } + else + { + candidates[i] = 0.f; + } + } + + // Update valid region and remove candidates on borders for border_mode == UNDEFINED + if(border_mode == BorderMode::UNDEFINED) + { + valid_region = shape_to_valid_region(candidates.shape(), true, BorderSize((gradient_size / 2) + (block_size / 2))); + + for(int i = 0; i < candidates.num_elements(); ++i) + { + if(!is_in_valid_region(valid_region, index2coord(candidates.shape(), i))) + { + candidates[i] = 0.f; + } + } + } + + // Suppress non-maxima candidates + non_maxima_suppression_3x3(candidates, non_maxima, border_mode != BorderMode::UNDEFINED ? BorderMode::CONSTANT : BorderMode::UNDEFINED); + if(border_mode == BorderMode::UNDEFINED) + { + valid_region = shape_to_valid_region(non_maxima.shape(), true, BorderSize((gradient_size / 2) + (block_size / 2) + 1)); + } + + // Create vector of candidate corners + KeyPointArray candidates_vector(corners.max_num_values()); + for(int i = 0; i < non_maxima.num_elements(); ++i) + { + Coordinates coord = index2coord(non_maxima.shape(), i); + + if(non_maxima[i] != 0.f && is_in_valid_region(valid_region, coord)) + { + KeyPoint corner; + corner.x = coord.x(); + corner.y = coord.y(); + corner.tracking_status = 1; + corner.strength = non_maxima[i]; + + corner.scale = 0.f; + corner.orientation = 0.f; + corner.error = 0.f; + + candidates_vector.push_back(corner); + } + } + + // If there are any candidates, sort them by strength and add them to the output corners vector if there are no stronger corners within the given euclidean radius + if(candidates_vector.num_values() > 0) + { + std::sort(candidates_vector.buffer(), candidates_vector.buffer() + candidates_vector.num_values(), [](KeyPoint a, KeyPoint b) + { + return a.strength > b.strength; + }); + corners.push_back(candidates_vector.at(0)); + + for(size_t j = 0; j < candidates_vector.num_values(); ++j) + { + bool found = false; + int32_t x = candidates_vector.at(j).x; + int32_t y = candidates_vector.at(j).y; + + for(size_t i = 0; i < corners.num_values(); ++i) + { + int32_t corners_x = corners.at(i).x; + int32_t corners_y = corners.at(i).y; + + // Euclidean distance + if(std::sqrt((std::pow(x - corners_x, 2) + std::pow(y - corners_y, 2))) < min_dist) + { + found = true; + } + } + + // If no stronger corners within the given euclidean radius + if(!found) + { + corners.push_back(candidates_vector.at(j)); + } + } + } +} + +template +void compute_min_max(const Tensor &in, void *min, void *max) +{ + using type = typename std::conditional::value, float, int32_t>::type; + + // Set min and max to first pixel + type tmp_min = static_cast(in[0]); + type tmp_max = static_cast(in[0]); + + // Look for min and max values + for(int i = 1; i < in.num_elements(); ++i) + { + if(static_cast(in[i]) < tmp_min) + { + tmp_min = static_cast(in[i]); + } + if(static_cast(in[i]) > tmp_max) + { + tmp_max = static_cast(in[i]); + } + } + + *static_cast(min) = tmp_min; + *static_cast(max) = tmp_max; +} + +// Min max location +template +void min_max_location(const Tensor &in, void *min, void *max, IArray &min_loc, IArray &max_loc, uint32_t &min_count, uint32_t &max_count) +{ + const size_t width = in.shape().x(); + + compute_min_max(in, min, max); + + using type = typename std::conditional::value, float, int32_t>::type; + + type min_value = *static_cast(min); + type max_value = *static_cast(max); + + min_count = 0; + max_count = 0; + for(int i = 0; i < in.num_elements(); ++i) + { + if(static_cast(in[i]) == min_value) + { + Coordinates2D min_coord; + min_coord.x = static_cast(i % width); + min_coord.y = static_cast(i / width); + + min_loc.push_back(min_coord); + + min_count++; + } + if(static_cast(in[i]) == max_value) + { + Coordinates2D max_coord; + max_coord.x = static_cast(i % width); + max_coord.y = static_cast(i / width); + + max_loc.push_back(max_coord); + + max_count++; + } + } +} + +// Integral Image +void integral_image(const Tensor &in, Tensor &out) +{ + // Length of dimensions + const size_t width = in.shape().x(); + const size_t height = in.shape().y(); + const size_t depth = in.shape().z() * in.shape()[3] * in.shape()[4] * in.shape()[5]; + + const size_t image_size = width * height; + + for(size_t z = 0; z < depth; ++z) + { + size_t current_image = z * image_size; + + //First element of each image + out[current_image] = in[current_image]; + + // First row of each image (add only pixel on the left) + for(size_t x = 1; x < width; ++x) + { + out[current_image + x] = static_cast(in[current_image + x]) + out[current_image + x - 1]; + } + + // Subsequent rows + for(size_t y = 1; y < height; ++y) + { + size_t current_row = current_image + (width * y); + + // First element of each row (add only pixel up) + out[current_row] = static_cast(in[current_row]) + out[current_row - width]; + + // Following row elements + for(size_t x = 1; x < width; ++x) + { + size_t current_pixel = current_row + x; + + // out = in + up(out) + left(out) - up_left(out) + out[current_pixel] = static_cast(in[current_pixel]) + out[current_pixel - 1] + + out[current_pixel - width] - out[current_pixel - width - 1]; + } + } + } +} + +// Absolute difference +template +void absolute_difference(const Tensor &in1, const Tensor &in2, Tensor &out) +{ + using intermediate_type = typename common_promoted_signed_type::intermediate_type; + + for(int i = 0; i < in1.num_elements(); ++i) + { + intermediate_type val(std::abs(static_cast(in1[i]) - static_cast(in2[i]))); + out[i] = saturate_cast(val); + } +} + +// Accumulate +template +void accumulate(const Tensor &in, Tensor &out) +{ + using intermediate_type = typename common_promoted_signed_type::intermediate_type; + + for(int i = 0; i < in.num_elements(); ++i) + { + intermediate_type val = static_cast(out[i]) + static_cast(in[i]); + out[i] = saturate_cast(val); + } +} + +// Accumulate squared +template +void accumulate_squared(const Tensor &in, Tensor &out, uint32_t shift) +{ + if(shift > 15) + { + ARM_COMPUTE_ERROR("Shift in accumulate_squared must be within the range [0, 15]"); + } + using intermediate_type = typename common_promoted_signed_type::intermediate_type; + intermediate_type denom = 1 << shift; + + for(int i = 0; i < in.num_elements(); ++i) + { + intermediate_type val = static_cast(out[i]) + (static_cast(in[i]) * static_cast(in[i]) / denom); + out[i] = saturate_cast(val); + } +} + +// Accumulate weighted total_size = init_auto_padding(tensor_shape, num_channels, type); +template +void accumulate_weighted(const Tensor &in, Tensor &out, float alpha) +{ + if(alpha < 0.f || alpha > 1.f) + { + ARM_COMPUTE_ERROR("Weight (alpha) specified in accumulate_weighted must be within the range [0, 1]"); + } + using intermediate_type = typename common_promoted_signed_type::intermediate_type; + + for(int i = 0; i < in.num_elements(); ++i) + { + double val = (1. - static_cast(alpha)) * static_cast(out[i]) + static_cast(alpha) * static_cast(in[i]); + out[i] = static_cast(val); + } +} + +// Arithmetic addition +template +void arithmetic_addition(const Tensor &in1, const Tensor &in2, Tensor &out, ConvertPolicy convert_policy) +{ + using intermediate_type = typename common_promoted_signed_type::intermediate_type; + + for(int i = 0; i < in1.num_elements(); ++i) + { + intermediate_type val = static_cast(in1[i]) + static_cast(in2[i]); + out[i] = (convert_policy == ConvertPolicy::SATURATE) ? saturate_cast(val) : static_cast(val); + } +} + +// Arithmetic Subtraction +template +void arithmetic_subtraction(const Tensor &in1, const Tensor &in2, Tensor &out, ConvertPolicy convert_policy) +{ + using intermediate_type = typename common_promoted_signed_type::intermediate_type; + + for(int i = 0; i < in1.num_elements(); ++i) + { + intermediate_type val = static_cast(in1[i]) - static_cast(in2[i]); + out[i] = (convert_policy == ConvertPolicy::SATURATE) ? saturate_cast(val) : static_cast(val); + } +} + +// Box3x3 filter +template ::value>::type> +void box3x3(const Tensor &in, Tensor &out, BorderMode border_mode, T constant_border_value) +{ + const std::array filter{ { 1, 1, 1, 1, 1, 1, 1, 1, 1 } }; + float scale = 1.f / static_cast(filter.size()); + for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) + { + const Coordinates id = index2coord(in.shape(), element_idx); + apply_2d_spatial_filter(id, in, out, TensorShape(3U, 3U), filter.data(), scale, border_mode, constant_border_value); + } +} + +// Depth conversion +template < typename T1, typename T2, typename std::enable_if < std::is_integral::value &&is_floating_point::value, int >::type = 0 > +void depth_convert(const Tensor &in, Tensor &out, ConvertPolicy policy, uint32_t shift) +{ + using namespace fixed_point_arithmetic; + + const int fixed_point_position = in.fixed_point_position(); + for(int i = 0; i < in.num_elements(); ++i) + { + out[i] = static_cast(fixed_point(in[i], fixed_point_position, true)); + } +} + +template < typename T1, typename T2, typename std::enable_if < is_floating_point::value &&std::is_integral::value, int >::type = 0 > +void depth_convert(const Tensor &in, Tensor &out, ConvertPolicy policy, uint32_t shift) +{ + using namespace fixed_point_arithmetic; + + const int fixed_point_position = out.fixed_point_position(); + for(int i = 0; i < in.num_elements(); ++i) + { + out[i] = fixed_point(in[i], fixed_point_position).raw(); + } +} + +template < typename T1, typename T2, typename std::enable_if < std::is_integral::value &&std::is_integral::value &&!std::is_same::value, int >::type = 0 > +void depth_convert(const Tensor &in, Tensor &out, ConvertPolicy policy, uint32_t shift) +{ + // Up-casting + if(std::numeric_limits::digits <= std::numeric_limits::digits) + { + for(int i = 0; i < in.num_elements(); ++i) + { + out[i] = static_cast(in[i]) << shift; + } + } + // Down-casting + else + { + for(int i = 0; i < in.num_elements(); ++i) + { + T1 val = in[i] >> shift; + out[i] = ((policy == ConvertPolicy::SATURATE) ? saturate_cast(val) : static_cast(val)); + } + } +} + +template < typename T1, typename T2, typename std::enable_if < std::is_integral::value &&std::is_integral::value &&std::is_same::value, int >::type = 0 > +void depth_convert(const Tensor &in, Tensor &out, ConvertPolicy policy, uint32_t shift) +{ + using namespace fixed_point_arithmetic; + bool is_in_place = (&in == &out); + + const int fixed_point_position_in = in.fixed_point_position(); + const int fixed_point_position_out = (is_in_place) ? static_cast(shift) : out.fixed_point_position(); + + if(!is_in_place || (fixed_point_position_in != fixed_point_position_out)) + { + for(int i = 0; i < in.num_elements(); ++i) + { + auto x = fixed_point(in[i], fixed_point_position_in, true); + x.rescale(fixed_point_position_out); + out[i] = x.raw(); + } + } +} + +template < typename T1, typename T2, typename std::enable_if < is_floating_point::value &&is_floating_point::value, int >::type = 0 > +void depth_convert(const Tensor &in, Tensor &out, ConvertPolicy policy, uint32_t shift) +{ + for(int i = 0; i < in.num_elements(); ++i) + { + out[i] = static_cast(in[i]); + } +} + +// Gaussian3x3 filter +template ::value>::type> +void gaussian3x3(const Tensor &in, Tensor &out, BorderMode border_mode, T constant_border_value) +{ + const std::array filter{ { 1, 2, 1, 2, 4, 2, 1, 2, 1 } }; + const float scale = 1.f / 16.f; + for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) + { + const Coordinates id = index2coord(in.shape(), element_idx); + apply_2d_spatial_filter(id, in, out, TensorShape(3U, 3U), filter.data(), scale, border_mode, constant_border_value); + } +} + +// Gaussian5x5 filter +template ::value>::type> +void gaussian5x5(const Tensor &in, Tensor &out, BorderMode border_mode, T constant_border_value) +{ + const std::array filter{ { + 1, 4, 6, 4, 1, + 4, 16, 24, 16, 4, + 6, 24, 36, 24, 6, + 4, 16, 24, 16, 4, + 1, 4, 6, 4, 1 + } }; + const float scale = 1.f / 256.f; + for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) + { + const Coordinates id = index2coord(in.shape(), element_idx); + apply_2d_spatial_filter(id, in, out, TensorShape(5U, 5U), filter.data(), scale, border_mode, constant_border_value); + } +} + +// Non linear filter +template +void non_linear_filter(const Tensor &in, Tensor &out, NonLinearFilterFunction function, unsigned int mask_size, + MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value) +{ + ARM_COMPUTE_ERROR_ON(pattern == MatrixPattern::OTHER && mask == nullptr); + + using intermediate_type = typename common_promoted_signed_type::intermediate_type; + + const int sq_mask_size = mask_size * mask_size; + const int half_mask_size = mask_size / 2; + std::vector vals(sq_mask_size); + intermediate_type current_value = 0; + + const ValidRegion valid_region = shape_to_valid_region(in.shape(), border_mode == BorderMode::UNDEFINED, BorderSize(half_mask_size)); + + for(int element_idx = 0, count = 0, index = 0; element_idx < in.num_elements(); ++element_idx, count = 0, index = 0) + { + Coordinates id = index2coord(in.shape(), element_idx); + if(is_in_valid_region(valid_region, id)) + { + int idx = id.x(); + int idy = id.y(); + for(int y = idy - half_mask_size; y <= idy + half_mask_size; ++y) + { + for(int x = idx - half_mask_size; x <= idx + half_mask_size; ++x, ++index) + { + id.set(0, x); + id.set(1, y); + current_value = tensor_elem_at(in, id, border_mode, constant_border_value); + + if(mask[index] == 255) + { + vals[count] = static_cast(current_value); + ++count; + } + } + } + std::sort(vals.begin(), vals.begin() + count); + switch(function) + { + case NonLinearFilterFunction::MIN: + out[element_idx] = saturate_cast(vals[0]); + break; + case NonLinearFilterFunction::MAX: + out[element_idx] = saturate_cast(vals[count - 1]); + break; + case NonLinearFilterFunction::MEDIAN: + out[element_idx] = saturate_cast(vals[count / 2]); + break; + default: + ARM_COMPUTE_ERROR("Unsupported NonLinearFilter function."); + } + } + } +} + +// Pixel-wise multiplication +template +void pixel_wise_multiplication(const Tensor &in1, const Tensor &in2, Tensor &out, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) +{ + if(scale < 0) + { + ARM_COMPUTE_ERROR("Scale of pixel-wise multiplication must be non-negative"); + } + using intermediate_type = typename common_promoted_signed_type::intermediate_type; + for(int i = 0; i < in1.num_elements(); ++i) + { + double val = static_cast(in1[i]) * static_cast(in2[i]) * static_cast(scale); + if(is_floating_point::value) + { + out[i] = val; + } + else + { + double rounded_val = 0; + switch(rounding_policy) + { + case(RoundingPolicy::TO_ZERO): + rounded_val = support::cpp11::trunc(val); + break; + case(RoundingPolicy::TO_NEAREST_UP): + rounded_val = round_half_up(val); + break; + case(RoundingPolicy::TO_NEAREST_EVEN): + rounded_val = round_half_even(val); + break; + default: + ARM_COMPUTE_ERROR("Unsupported rounding policy"); + } + out[i] = (convert_policy == ConvertPolicy::SATURATE) ? saturate_cast(rounded_val) : static_cast(rounded_val); + } + } +} + +// Fixed-point Pixel-wise Multiplication +template ::value>::type> +void fixed_point_pixel_wise_multiplication(const Tensor &in1, const Tensor &in2, Tensor &out, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) +{ + using namespace fixed_point_arithmetic; + + const int fixed_point_position = in1.fixed_point_position(); + + ARM_COMPUTE_ERROR_ON_MSG(in1.data_type() != in2.data_type() || in1.data_type() != out.data_type(), + "Tensors must all have the same DataType"); + ARM_COMPUTE_ERROR_ON_MSG(fixed_point_position != in2.fixed_point_position() || fixed_point_position != out.fixed_point_position(), + "Fixed-point position must be the same for both inputs and outputs"); + + // Validate fixed_point_position + ARM_COMPUTE_ERROR_ON((in1.data_type() == DataType::QS8) && (fixed_point_position == 0 || fixed_point_position > 7)); + ARM_COMPUTE_ERROR_ON((in1.data_type() == DataType::QS16) && (fixed_point_position == 0 || fixed_point_position > 15)); + + const fixed_point fp_scale(scale, fixed_point_position); + const bool is_sat = convert_policy == ConvertPolicy::SATURATE; + + for(int i = 0; i < in1.num_elements(); ++i) + { + const fixed_point val1(in1[i], fixed_point_position, true); + fixed_point res(in2[i], fixed_point_position, true); + if(is_sat) + { + res = mul(mul(res, val1), fp_scale); + } + else + { + res = mul(mul(res, val1), fp_scale); + } + out[i] = res.raw(); + } +} + +//Table Lookup +template +void table_lookup(const Tensor &in, Tensor &out, std::map &lut) +{ + for(int i = 0; i < in.num_elements(); ++i) + { + out[i] = static_cast(lut[in[i]]); + } +} + +// Threshold +template +void threshold(const Tensor &in, Tensor &out, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) +{ + switch(type) + { + case ThresholdType::BINARY: + for(int i = 0; i < in.num_elements(); ++i) + { + out[i] = ((in[i] > threshold) ? true_value : false_value); + } + break; + case ThresholdType::RANGE: + for(int i = 0; i < in.num_elements(); ++i) + { + if(in[i] > upper) + { + out[i] = false_value; + } + else if(in[i] < threshold) + { + out[i] = false_value; + } + else + { + out[i] = true_value; + } + } + break; + default: + ARM_COMPUTE_ERROR("Thresholding type not recognised"); + break; + } +} + +// Warp Perspective +template +void warp_perspective(const Tensor &in, Tensor &out, Tensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) +{ + // x0 = M00 * x + M01 * y + M02 + // y0 = M10 * x + M11 * y + M12 + // z0 = M20 * x + M21 * y + M22 + // xn = x0 / z0 + // yn = y0 / z0 + const float M00 = matrix[0]; + const float M10 = matrix[1]; + const float M20 = matrix[2]; + const float M01 = matrix[0 + 1 * 3]; + const float M11 = matrix[1 + 1 * 3]; + const float M21 = matrix[2 + 1 * 3]; + const float M02 = matrix[0 + 2 * 3]; + const float M12 = matrix[1 + 2 * 3]; + const float M22 = matrix[2 + 2 * 3]; + + const int width = in.shape().x(); + const int height = in.shape().y(); + + for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) + { + valid_mask[element_idx] = 1; + Coordinates id = index2coord(in.shape(), element_idx); + int idx = id.x(); + int idy = id.y(); + const float z0 = M20 * idx + M21 * idy + M22; + + float x0 = (M00 * idx + M01 * idy + M02); + float y0 = (M10 * idx + M11 * idy + M12); + + float xn = x0 / z0; + float yn = y0 / z0; + id.set(0, static_cast(std::floor(xn))); + id.set(1, static_cast(std::floor(yn))); + if((0 <= yn) && (yn < height) && (0 <= xn) && (xn < width)) + { + switch(policy) + { + case InterpolationPolicy::NEAREST_NEIGHBOR: + out[element_idx] = tensor_elem_at(in, id, border_mode, constant_border_value); + break; + case InterpolationPolicy::BILINEAR: + (valid_bilinear_policy(xn, yn, width, height, border_mode)) ? out[element_idx] = bilinear_policy(in, id, xn, yn, border_mode, constant_border_value) : valid_mask[element_idx] = 0; + break; + case InterpolationPolicy::AREA: + default: + ARM_COMPUTE_ERROR("Interpolation not supported"); + } + } + else + { + if(border_mode == BorderMode::UNDEFINED) + { + valid_mask[element_idx] = 0; + } + else + { + switch(policy) + { + case InterpolationPolicy::NEAREST_NEIGHBOR: + if(border_mode == BorderMode::CONSTANT) + { + out[element_idx] = constant_border_value; + } + else if(border_mode == BorderMode::REPLICATE) + { + id.set(0, std::max(0, std::min(static_cast(xn), width - 1))); + id.set(1, std::max(0, std::min(static_cast(yn), height - 1))); + out[element_idx] = in[coord2index(in.shape(), id)]; + } + break; + case InterpolationPolicy::BILINEAR: + out[element_idx] = bilinear_policy(in, id, xn, yn, border_mode, constant_border_value); + break; + case InterpolationPolicy::AREA: + default: + ARM_COMPUTE_ERROR("Interpolation not supported"); + } + } + } + } +} + +// Batch Normalization Layer for fixed point type +template ::value, int>::type * = nullptr> +void batch_normalization_layer(const Tensor &in, Tensor &out, const Tensor &mean, const Tensor &var, const Tensor &beta, const Tensor &gamma, float epsilon, int fixed_point_position) +{ + const int cols = static_cast(in.shape()[0]); + const int rows = static_cast(in.shape()[1]); + const int depth = static_cast(in.shape()[2]); + int upper_dims = in.shape().total_size() / (cols * rows * depth); + + for(int r = 0; r < upper_dims; ++r) + { + for(int i = 0; i < depth; ++i) + { + for(int k = 0; k < rows; ++k) + { + for(int l = 0; l < cols; ++l) + { + const int pos = l + k * cols + i * rows * cols + r * cols * rows * depth; + fixed_point_arithmetic::fixed_point in_qs(in[pos], fixed_point_position, true); + fixed_point_arithmetic::fixed_point var_qs(var[i], fixed_point_position, true); + fixed_point_arithmetic::fixed_point mean_qs(mean[i], fixed_point_position, true); + fixed_point_arithmetic::fixed_point beta_qs(beta[i], fixed_point_position, true); + fixed_point_arithmetic::fixed_point gamma_qs(gamma[i], fixed_point_position, true); + fixed_point_arithmetic::fixed_point epsilon_qs(epsilon, fixed_point_position); + + auto denominator = fixed_point_arithmetic::inv_sqrt(var_qs + epsilon_qs); + auto numerator = in_qs - mean_qs; + auto x_bar = numerator * denominator; + x_bar = beta_qs + x_bar * gamma_qs; + out[pos] = x_bar.raw(); + } + } + } + } +} + +// Batch Normalization Layer for floating point type +template ::value, int>::type * = nullptr> +void batch_normalization_layer(const Tensor &in, Tensor &out, const Tensor &mean, const Tensor &var, const Tensor &beta, const Tensor &gamma, float epsilon, int fixed_point_position) +{ + const int cols = static_cast(in.shape()[0]); + const int rows = static_cast(in.shape()[1]); + const int depth = static_cast(in.shape()[2]); + int upper_dims = in.shape().total_size() / (cols * rows * depth); + + for(int r = 0; r < upper_dims; ++r) + { + for(int i = 0; i < depth; ++i) + { + for(int k = 0; k < rows; ++k) + { + for(int l = 0; l < cols; ++l) + { + const int pos = l + k * cols + i * rows * cols + r * cols * rows * depth; + const float denominator = sqrt(var[i] + epsilon); + const float numerator = in[pos] - mean[i]; + const float x_bar = numerator / denominator; + out[pos] = beta[i] + x_bar * gamma[i]; + } + } + } + } +} + +// ROI Pooling layer +template +void roi_pooling_layer(const Tensor &in, Tensor &out, const std::vector &rois, const ROIPoolingLayerInfo &pool_info) +{ + const int num_rois = rois.size(); + const int width_in = in.shape().x(); + const int height_in = in.shape().y(); + const int fms = in.shape().z(); + const int volume_in = width_in * height_in * fms; + const int pool_w = pool_info.pooled_width(); + const int pool_h = pool_info.pooled_height(); + const int volume_out = pool_w * pool_h * fms; + const float roi_scale = pool_info.spatial_scale(); + + // Iterate through all rois + for(int roi_idx = 0; roi_idx < num_rois; ++roi_idx) + { + // Get dimensions of current ROI + const ROI &roi = rois[roi_idx]; + + int batch_id = roi.batch_idx; + int roi_start_x = support::cpp11::round(roi.rect.x * roi_scale); + int roi_start_y = support::cpp11::round(roi.rect.y * roi_scale); + int roi_width = std::max(support::cpp11::round(roi.rect.width * roi_scale), 1.f); + int roi_height = std::max(support::cpp11::round(roi.rect.height * roi_scale), 1.f); + + // Determine pooling regions + float pool_region_size_x = static_cast(roi_width) / pool_w; + float pool_region_size_y = static_cast(roi_height) / pool_h; + + // Iterate through all channel + for(int fm = 0; fm < fms; ++fm) + { + // Calculate each output pixel + for(int py = 0; py < pool_h; ++py) + { + for(int px = 0; px < pool_w; ++px) + { + int region_start_x = static_cast(std::floor(px * pool_region_size_x)); + int region_end_x = static_cast(std::ceil((px + 1) * pool_region_size_x)); + int region_start_y = static_cast(std::floor(py * pool_region_size_y)); + int region_end_y = static_cast(std::ceil((py + 1) * pool_region_size_y)); + + region_start_x = std::min(std::max(region_start_x + roi_start_x, 0), width_in); + region_end_x = std::min(std::max(region_end_x + roi_start_x, 0), width_in); + region_start_y = std::min(std::max(region_start_y + roi_start_y, 0), height_in); + region_end_y = std::min(std::max(region_end_y + roi_start_y, 0), height_in); + + // Iterate through each pixel in the pooling region + if((region_end_x <= region_start_x) || (region_end_y <= region_start_y)) + { + out[roi_idx * volume_out + fm * pool_w * pool_h + py * pool_w + px] = 0; + } + else + { + T curr_max = std::numeric_limits::lowest(); + for(int j = region_start_y; j < region_end_y; ++j) + { + for(int i = region_start_x; i < region_end_x; ++i) + { + const auto val = in[batch_id * volume_in + fm * width_in * height_in + j * width_in + i]; + curr_max = std::max(val, curr_max); + } + } + out[roi_idx * volume_out + fm * pool_w * pool_h + py * pool_w + px] = curr_max; + } + } + } + } + } +} + +// Fixed point operations +template +void fixed_point_operation(const Tensor &in, Tensor &out, FixedPointOp op) +{ + int p = in.fixed_point_position(); + switch(op) + { + case FixedPointOp::EXP: + for(int i = 0; i < in.num_elements(); ++i) + { + out[i] = fixed_point_arithmetic::exp(fixed_point_arithmetic::fixed_point(in[i], p, true)).raw(); + } + break; + case FixedPointOp::LOG: + for(int i = 0; i < in.num_elements(); ++i) + { + out[i] = fixed_point_arithmetic::log(fixed_point_arithmetic::fixed_point(in[i], p, true)).raw(); + } + break; + case FixedPointOp::INV_SQRT: + for(int i = 0; i < in.num_elements(); ++i) + { + out[i] = fixed_point_arithmetic::inv_sqrt(fixed_point_arithmetic::fixed_point(in[i], p, true)).raw(); + } + break; + case FixedPointOp::RECIPROCAL: + for(int i = 0; i < in.num_elements(); ++i) + { + out[i] = fixed_point_arithmetic::div(fixed_point_arithmetic::fixed_point(1, p), fixed_point_arithmetic::fixed_point(in[i], p, true)).raw(); + } + break; + default: + ARM_COMPUTE_ERROR("Fixed point operation not supported"); + break; + } +} + +// Tensor print +template +void print(const Tensor &in, std::ostream &out) +{ + out << "\n"; + for(int i = 0; i < in.num_elements(); ++i) + { + out << in[i] << " "; + } + out << "\n"; +} +} // namespace tensor_operations +} // namespace validation +} // namespace test +} // namespace arm_compute + +#endif /* __ARM_COMPUTE_TEST_TENSOR_OPERATIONS_H__ */ diff --git a/tests/validation_old/TensorVisitors.h b/tests/validation_old/TensorVisitors.h new file mode 100644 index 0000000000..6e5f8c3b21 --- /dev/null +++ b/tests/validation_old/TensorVisitors.h @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_TENSOR_VISITORS_H__ +#define __ARM_COMPUTE_TEST_TENSOR_VISITORS_H__ + +#include "Tensor.h" +#include "TensorOperations.h" +#include "arm_compute/core/Error.h" +#include "arm_compute/core/Helpers.h" +#include "arm_compute/runtime/Lut.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace tensor_visitors +{ +// Min max location visitor +struct min_max_location_visitor : public boost::static_visitor<> +{ +public: + explicit min_max_location_visitor(void *min, void *max, IArray &min_loc, IArray &max_loc, uint32_t &min_count, uint32_t &max_count) + : _min(min), _max(max), _min_loc(min_loc), _max_loc(max_loc), _min_count(min_count), _max_count(max_count) + { + } + template + void operator()(const Tensor &in) const + { + tensor_operations::min_max_location(in, _min, _max, _min_loc, _max_loc, _min_count, _max_count); + } + +private: + void *_min; + void *_max; + IArray &_min_loc; + IArray &_max_loc; + uint32_t &_min_count; + uint32_t &_max_count; +}; +// Absolute Difference visitor +struct absolute_difference_visitor : public boost::static_visitor<> +{ +public: + template + void operator()(const Tensor &in1, const Tensor &in2, Tensor &out) const + { + tensor_operations::absolute_difference(in1, in2, out); + } +}; +// Arithmetic Addition visitor +struct arithmetic_addition_visitor : public boost::static_visitor<> +{ +public: + explicit arithmetic_addition_visitor(ConvertPolicy convert_policy) + : _policy(convert_policy) + { + } + + template + void operator()(const Tensor &in1, const Tensor &in2, Tensor &out) const + { + tensor_operations::arithmetic_addition(in1, in2, out, _policy); + } + +private: + ConvertPolicy _policy; +}; +// Arithmetic Subtraction visitor +struct arithmetic_subtraction_visitor : public boost::static_visitor<> +{ +public: + explicit arithmetic_subtraction_visitor(ConvertPolicy convert_policy) + : _policy(convert_policy) + { + } + + template + void operator()(const Tensor &in1, const Tensor &in2, Tensor &out) const + { + tensor_operations::arithmetic_subtraction(in1, in2, out, _policy); + } + +private: + ConvertPolicy _policy; +}; +// Depth Convert visitor +struct depth_convert_visitor : public boost::static_visitor<> +{ +public: + explicit depth_convert_visitor(ConvertPolicy policy, uint32_t shift) + : _policy(policy), _shift(shift) + { + } + + template + void operator()(const Tensor &in, Tensor &out) const + { + tensor_operations::depth_convert(in, out, _policy, _shift); + } + +private: + ConvertPolicy _policy; + uint32_t _shift; +}; +// Pixel-wise Multiplication visitor +struct pixel_wise_multiplication_visitor : public boost::static_visitor<> +{ +public: + explicit pixel_wise_multiplication_visitor(float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) + : _scale(scale), _convert_policy(convert_policy), _rounding_policy(rounding_policy) + { + } + + template + void operator()(const Tensor &in1, const Tensor &in2, Tensor &out) const + { + tensor_operations::pixel_wise_multiplication(in1, in2, out, _scale, _convert_policy, _rounding_policy); + } + +private: + float _scale; + ConvertPolicy _convert_policy; + RoundingPolicy _rounding_policy; +}; +// Fixed Point Pixel-wise Multiplication visitor +struct fixed_point_pixel_wise_multiplication_visitor : public boost::static_visitor<> +{ +public: + explicit fixed_point_pixel_wise_multiplication_visitor(const TensorVariant &in1, const TensorVariant &in2, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) + : _in1(in1), _in2(in2), _scale(scale), _convert_policy(convert_policy), _rounding_policy(rounding_policy) + { + } + + template ::value>::type> + void operator()(Tensor &out) const + { + const Tensor &in1 = boost::get>(_in1); + const Tensor &in2 = boost::get>(_in2); + tensor_operations::fixed_point_pixel_wise_multiplication(in1, in2, out, _scale, _convert_policy, _rounding_policy); + } + template < typename T, typename std::enable_if < !std::is_integral::value, int >::type = 0 > + void operator()(Tensor &out) const + { + ARM_COMPUTE_ERROR("NOT SUPPORTED!"); + } + +private: + const TensorVariant &_in1; + const TensorVariant &_in2; + float _scale; + ConvertPolicy _convert_policy; + RoundingPolicy _rounding_policy; +}; +// Table lookup operation +template +struct table_lookup : public boost::static_visitor<> +{ +public: + explicit table_lookup(const TensorVariant &in, std::map &lut) + : _in(in), _lut(lut) + { + } + + template + void operator()(Tensor &out) const + { + const auto &in = boost::get>(_in); + tensor_operations::table_lookup(in, out, _lut); + } + +private: + const TensorVariant &_in; + std::map &_lut; +}; +template struct arm_compute::test::validation::tensor_visitors::table_lookup; +template struct arm_compute::test::validation::tensor_visitors::table_lookup; + +// Batch Normalization Layer visitor +struct batch_normalization_layer_visitor : public boost::static_visitor<> +{ +public: + explicit batch_normalization_layer_visitor(const TensorVariant &in, const TensorVariant &mean, const TensorVariant &var, const TensorVariant &beta, const TensorVariant &gamma, float epsilon, + int fixed_point_position = 0) + : _in(in), _mean(mean), _var(var), _beta(beta), _gamma(gamma), _epsilon(epsilon), _fixed_point_position(fixed_point_position) + { + } + + template + void operator()(Tensor &out) const + { + const Tensor &in = boost::get>(_in); + const Tensor &mean = boost::get>(_mean); + const Tensor &var = boost::get>(_var); + const Tensor &beta = boost::get>(_beta); + const Tensor &gamma = boost::get>(_gamma); + tensor_operations::batch_normalization_layer(in, out, mean, var, beta, gamma, _epsilon, _fixed_point_position); + } + +private: + const TensorVariant &_in, &_mean, &_var, &_beta, &_gamma; + float _epsilon; + int _fixed_point_position; +}; + +// ROI Pooling layer +struct roi_pooling_layer_visitor : public boost::static_visitor<> +{ +public: + explicit roi_pooling_layer_visitor(const TensorVariant &in, const std::vector &rois, ROIPoolingLayerInfo pool_info) + : _in(in), _rois(rois), _pool_info(pool_info) + { + } + + template + void operator()(Tensor &out) const + { + const Tensor &in = boost::get>(_in); + tensor_operations::roi_pooling_layer(in, out, _rois, _pool_info); + } + +private: + const TensorVariant &_in; + const std::vector &_rois; + ROIPoolingLayerInfo _pool_info; +}; + +// Fixed Point operations visitor +struct fixed_point_operation_visitor : public boost::static_visitor<> +{ +public: + explicit fixed_point_operation_visitor(const TensorVariant &in, FixedPointOp op) + : _in(in), _op(op) + { + } + + template ::value, int>::type = 0> + void operator()(Tensor &out) const + { + const Tensor &in = boost::get>(_in); + tensor_operations::fixed_point_operation(in, out, _op); + } + template < typename T, typename std::enable_if < !std::is_integral::value, int >::type = 0 > + void operator()(Tensor &out) const + { + ARM_COMPUTE_ERROR("NOT SUPPORTED!"); + } + +private: + const TensorVariant &_in; + FixedPointOp _op; +}; +// Print Tensor visitor +struct print_visitor : public boost::static_visitor<> +{ +public: + explicit print_visitor(std::ostream &out) + : _out(out) + { + } + + template + void operator()(const Tensor &in) const + { + tensor_operations::print(in, _out); + } + +private: + std::ostream &_out; +}; +} // namespace tensor_visitors +} // namespace validation +} // namespace test +} // namespace arm_compute + +#endif /* __ARM_COMPUTE_TEST_TENSOR_VISITORS_H__ */ diff --git a/tests/validation_old/UNIT/FixedPoint.cpp b/tests/validation_old/UNIT/FixedPoint.cpp new file mode 100644 index 0000000000..53fef97769 --- /dev/null +++ b/tests/validation_old/UNIT/FixedPoint.cpp @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "tests/validation_old/FixedPoint.h" + +#include "TypePrinter.h" +#include "Utils.h" +#include "support/ToolchainSupport.h" +#include "tests/validation_old/Validation.h" +#include "tests/validation_old/ValidationUserConfiguration.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +std::string func_names[] = +{ + "add", "sub", "mul", "exp", "log", "inv_sqrt" +}; +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(UNIT) +BOOST_AUTO_TEST_SUITE(FixedPoint) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(FixedPointQS8Inputs, boost::unit_test::data::make(func_names) * boost::unit_test::data::xrange(1, 7), func_name, frac_bits) +{ + const std::string base_file_name = user_config.path.get() + "/dumps/" + func_name + "_Q8." + support::cpp11::to_string(frac_bits); + std::ifstream inputs_file{ base_file_name + ".in", std::ios::binary | std::ios::in }; + + BOOST_TEST_INFO(base_file_name + ".in"); + BOOST_TEST_REQUIRE(inputs_file.good()); + + float float_val = 0.f; + + // Read first value + inputs_file.read(reinterpret_cast(&float_val), sizeof(float_val)); + + while(inputs_file.good()) + { + // Convert to fixed point + fixed_point_arithmetic::fixed_point in_val(float_val, frac_bits); + + // Check that the value didn't change + BOOST_TEST(static_cast(in_val) == float_val); + + // Read next value + inputs_file.read(reinterpret_cast(&float_val), sizeof(float_val)); + } +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +//FIXME: Figure out how to handle expected failures properly +// The last input argument specifies the expected number of failures for a +// given combination of (function name, number of fractional bits) as defined +// by the first two arguments. +BOOST_DATA_TEST_CASE(FixedPointQS8Outputs, (boost::unit_test::data::make(func_names) * boost::unit_test::data::xrange(1, 7)) ^ (boost::unit_test::data::make({ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 13, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 33, 96 })), + func_name, frac_bits, expected_failures) +{ + const std::string base_file_name = user_config.path.get() + "/dumps/" + func_name + "_Q8." + support::cpp11::to_string(frac_bits); + std::ifstream inputs_file{ base_file_name + ".in", std::ios::binary | std::ios::in }; + std::ifstream reference_file{ base_file_name + ".out", std::ios::binary | std::ios::in }; + + BOOST_TEST_INFO(base_file_name + ".in"); + BOOST_TEST_REQUIRE(inputs_file.good()); + BOOST_TEST_INFO(base_file_name + ".out"); + BOOST_TEST_REQUIRE(reference_file.good()); + + const float step_size = std::pow(2.f, -frac_bits); + + float float_val = 0.f; + float ref_val = 0.f; + int64_t num_mismatches = 0; + + // Read first values + inputs_file.read(reinterpret_cast(&float_val), sizeof(float_val)); + reference_file.read(reinterpret_cast(&ref_val), sizeof(ref_val)); + + while(inputs_file.good() && reference_file.good()) + { + fixed_point_arithmetic::fixed_point in_val(float_val, frac_bits); + fixed_point_arithmetic::fixed_point out_val(0.f, frac_bits); + + float tolerance = 0.f; + + if(func_name == "add") + { + out_val = in_val + in_val; + } + else if(func_name == "sub") + { + out_val = in_val - in_val; //NOLINT + } + else if(func_name == "mul") + { + tolerance = 1.f * step_size; + out_val = in_val * in_val; + } + else if(func_name == "exp") + { + tolerance = 2.f * step_size; + out_val = fixed_point_arithmetic::exp(in_val); + } + else if(func_name == "log") + { + tolerance = 4.f * step_size; + out_val = fixed_point_arithmetic::log(in_val); + } + else if(func_name == "inv_sqrt") + { + tolerance = 5.f * step_size; + out_val = fixed_point_arithmetic::inv_sqrt(in_val); + } + + if(std::abs(static_cast(out_val) - ref_val) > tolerance) + { + BOOST_TEST_INFO("input = " << in_val); + BOOST_TEST_INFO("output = " << out_val); + BOOST_TEST_INFO("reference = " << ref_val); + BOOST_TEST_INFO("tolerance = " << tolerance); + BOOST_TEST_WARN((std::abs(static_cast(out_val) - ref_val) <= tolerance)); + + ++num_mismatches; + } + + // Read next values + inputs_file.read(reinterpret_cast(&float_val), sizeof(float_val)); + reference_file.read(reinterpret_cast(&ref_val), sizeof(ref_val)); + } + + BOOST_TEST(num_mismatches == expected_failures); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/UNIT/TensorInfo.cpp b/tests/validation_old/UNIT/TensorInfo.cpp new file mode 100644 index 0000000000..f2a3acfee0 --- /dev/null +++ b/tests/validation_old/UNIT/TensorInfo.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "TypePrinter.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/TensorInfo.h" +#include "arm_compute/core/Types.h" + +#include "tests/validation_old/boost_wrapper.h" + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(UNIT) +BOOST_AUTO_TEST_SUITE(TensorInfoValidation) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(AutoPadding, + boost::unit_test::data::make({ TensorShape{}, + TensorShape{ 10U }, + TensorShape{ 10U, 10U }, + TensorShape{ 10U, 10U, 10U }, + TensorShape{ 10U, 10U, 10U, 10U }, + TensorShape{ 10U, 10U, 10U, 10U, 10U }, + TensorShape{ 10U, 10U, 10U, 10U, 10U, 10U } + }) + ^ boost::unit_test::data::make({ PaddingSize{ 0, 0, 0, 0 }, + PaddingSize{ 0, 36, 0, 4 }, + PaddingSize{ 4, 36, 4, 4 }, + PaddingSize{ 4, 36, 4, 4 }, + PaddingSize{ 4, 36, 4, 4 }, + PaddingSize{ 4, 36, 4, 4 }, + PaddingSize{ 4, 36, 4, 4 } + }) + ^ boost::unit_test::data::make({ Strides{}, + Strides{ 1U }, + Strides{ 1U, 50U }, + Strides{ 1U, 50U, 900U }, + Strides{ 1U, 50U, 900U, 9000U }, + Strides{ 1U, 50U, 900U, 9000U, 90000U }, + Strides{ 1U, 50U, 900U, 9000U, 90000U, 900000U } + }) + ^ boost::unit_test::data::make( +{ + 0, + 4, + 204, + 204, + 204, + 204, + 204, +}), +shape, auto_padding, strides, offset) +{ + TensorInfo info{ shape, Format::U8 }; + + BOOST_TEST(!info.has_padding()); + + info.auto_padding(); + + validate(info.padding(), auto_padding); + BOOST_TEST(compare_dimensions(info.strides_in_bytes(), strides)); + BOOST_TEST(info.offset_first_element_in_bytes() == offset); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/UNIT/TensorShape.cpp b/tests/validation_old/UNIT/TensorShape.cpp new file mode 100644 index 0000000000..dc75b93de4 --- /dev/null +++ b/tests/validation_old/UNIT/TensorShape.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "TypePrinter.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/core/TensorShape.h" + +#include "tests/validation_old/boost_wrapper.h" + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(UNIT) +BOOST_AUTO_TEST_SUITE(TensorShapeValidation) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Construction, + boost::unit_test::data::make({ TensorShape{}, + TensorShape{ 1U }, + TensorShape{ 2U }, + TensorShape{ 2U, 3U }, + TensorShape{ 2U, 3U, 5U }, + TensorShape{ 2U, 3U, 5U, 7U }, + TensorShape{ 2U, 3U, 5U, 7U, 11U }, + TensorShape{ 2U, 3U, 5U, 7U, 11U, 13U } + }) + ^ boost::unit_test::data::make({ 0, 0, 1, 2, 3, 4, 5, 6 }) ^ boost::unit_test::data::make({ 0, 1, 2, 6, 30, 210, 2310, 30030 }), + shape, num_dimensions, total_size) +{ + BOOST_TEST(shape.num_dimensions() == num_dimensions); + BOOST_TEST(shape.total_size() == total_size); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(SetEmpty, boost::unit_test::data::make({ 0, 1, 2, 3, 4, 5 }), dimension) +{ + TensorShape shape; + + shape.set(dimension, 10); + + BOOST_TEST(shape.num_dimensions() == dimension + 1); + BOOST_TEST(shape.total_size() == 10); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/UNIT/Utils.cpp b/tests/validation_old/UNIT/Utils.cpp new file mode 100644 index 0000000000..b302bf27c1 --- /dev/null +++ b/tests/validation_old/UNIT/Utils.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "Utils.h" + +#include "TypePrinter.h" +#include "tests/validation_old/Validation.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(UNIT) +BOOST_AUTO_TEST_SUITE(Utils) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RoundHalfUp, boost::unit_test::data::make({ 1.f, 1.2f, 1.5f, 2.5f, 2.9f, -3.f, -3.5f, -3.8f, -4.3f, -4.5f }) ^ boost::unit_test::data::make({ 1.f, 1.f, 2.f, 3.f, 3.f, -3.f, -3.f, -4.f, -4.f, -4.f }), + value, result) +{ + BOOST_TEST(round_half_up(value) == result); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(RoundHalfEven, boost::unit_test::data::make({ 1.f, 1.2f, 1.5f, 2.5f, 2.9f, -3.f, -3.5f, -3.8f, -4.3f, -4.5f }) ^ boost::unit_test::data::make({ 1.f, 1.f, 2.f, 2.f, 3.f, -3.f, -4.f, -4.f, -4.f, -4.f }), + value, result) +{ + BOOST_TEST(round_half_even(value) == result); +} + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Index2Coord, boost::unit_test::data::make({ TensorShape{ 1U }, TensorShape{ 2U }, TensorShape{ 2U, 3U } }) ^ boost::unit_test::data::make({ 0, 1, 2 }) ^ + boost::unit_test::data::make({ Coordinates{ 0 }, Coordinates{ 1 }, Coordinates{ 0, 1 } }), shape, index, ref_coordinate) +{ + Coordinates coordinate = index2coord(shape, index); + + BOOST_TEST(compare_dimensions(coordinate, ref_coordinate)); +} + +//FIXME: Negative tests only work in debug mode +#if 0 +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Index2CoordFail, boost::unit_test::data::make({ TensorShape{}, TensorShape{ 2U }, TensorShape{ 2U } }) ^ boost::unit_test::data::make({ 0, -1, 2 }), shape, index) +{ + BOOST_CHECK_THROW(index2coord(shape, index), std::runtime_error); +} +#endif /* 0 */ + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Coord2Index, boost::unit_test::data::make({ TensorShape{ 1U }, TensorShape{ 2U }, TensorShape{ 2U, 3U } }) ^ boost::unit_test::data::make({ Coordinates{ 0 }, Coordinates{ 1 }, Coordinates{ 0, 1 } }) + ^ boost::unit_test::data::make({ 0, 1, 2 }), + shape, coordinate, ref_index) +{ + int index = coord2index(shape, coordinate); + + BOOST_TEST(index == ref_index); +} + +//FIXME: Negative tests only work in debug mode +#if 0 +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) +BOOST_DATA_TEST_CASE(Coord2IndexFail, boost::unit_test::data::make({ TensorShape{}, TensorShape{ 2U } }) ^ boost::unit_test::data::make({ Coordinates{ 0 }, Coordinates{} }), shape, coordinate) +{ + BOOST_CHECK_THROW(coord2index(shape, coordinate), std::runtime_error); +} +#endif /* 0 */ + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/UserConfiguration.cpp b/tests/validation_old/UserConfiguration.cpp new file mode 100644 index 0000000000..a24de90468 --- /dev/null +++ b/tests/validation_old/UserConfiguration.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "UserConfiguration.h" + +#include "ProgramOptions.h" + +#include + +namespace arm_compute +{ +namespace test +{ +UserConfiguration::UserConfiguration(const ProgramOptions &options) +{ + std::random_device::result_type tmp_seed = 0; + if(options.get("seed", tmp_seed)) + { + seed = tmp_seed; + } + + std::string tmp_path; + if(options.get("path", tmp_path)) + { + path = tmp_path; + } + + unsigned int tmp_threads = 0; + if(options.get("threads", tmp_threads)) + { + threads = tmp_threads; + } +} +} // namespace test +} // namespace arm_compute diff --git a/tests/validation_old/UserConfiguration.h b/tests/validation_old/UserConfiguration.h new file mode 100644 index 0000000000..815da04810 --- /dev/null +++ b/tests/validation_old/UserConfiguration.h @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_USER_CONFIGURATION_H__ +#define __ARM_COMPUTE_TEST_USER_CONFIGURATION_H__ + +#include "arm_compute/core/Error.h" +#include "arm_compute/core/Types.h" + +#include +#include + +namespace arm_compute +{ +namespace test +{ +class ProgramOptions; + +/** Container providing easy access to runtime options provided by the user. */ +struct UserConfiguration +{ +protected: + /** Wrapper around options to store if an option has been set. */ + template + class Option + { + public: + /** Initialise the option to its default (C++) value and mark it as 'not set'. */ + Option(); + + /** Initialise the option to the given @p value and mark it as 'set'. */ + Option(const T &value); + + /** Assign the given @p value and mark it as 'set'. */ + Option &operator=(const T &value); + + /** Query if the option has been set. */ + constexpr bool is_set() const; + + /** Return the underlying value as constant. */ + T get() const; + + /** Return the underlying value. */ + T &get(); + + /** Implicitly return the underlying value. */ + operator T() const; + + private: + T _value; + bool _is_set; + }; + +public: + UserConfiguration() = default; + + /** Initialise the configuration according to the program options. + * + * @param[in] options Parsed command line options. + */ + UserConfiguration(const ProgramOptions &options); + + Option path{}; + Option seed{}; + Option threads{}; +}; + +template +UserConfiguration::Option::Option() + : _value{}, _is_set{ false } +{ +} + +template +UserConfiguration::Option::Option(const T &value) + : _value{ value }, _is_set{ true } +{ +} + +template +UserConfiguration::Option &UserConfiguration::Option::operator=(const T &value) +{ + _value = value; + _is_set = true; + + return *this; +} + +template +constexpr bool UserConfiguration::Option::is_set() const +{ + return _is_set; +} + +template +T UserConfiguration::Option::get() const +{ + ARM_COMPUTE_ERROR_ON(!is_set()); + return _value; +} + +template +T &UserConfiguration::Option::get() +{ + return _value; +} + +template +UserConfiguration::Option::operator T() const +{ + ARM_COMPUTE_ERROR_ON(!is_set()); + return _value; +} +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_USER_CONFIGURATION_H__ */ diff --git a/tests/validation_old/Validation.cpp b/tests/validation_old/Validation.cpp new file mode 100644 index 0000000000..8f173ba962 --- /dev/null +++ b/tests/validation_old/Validation.cpp @@ -0,0 +1,477 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "Validation.h" + +#include "arm_compute/core/Coordinates.h" +#include "arm_compute/core/Error.h" +#include "arm_compute/core/FixedPoint.h" +#include "arm_compute/core/IArray.h" +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/runtime/Tensor.h" +#include "tests/IAccessor.h" +#include "tests/RawTensor.h" +#include "tests/TypePrinter.h" +#include "tests/Utils.h" +#include "tests/validation_old/half.h" + +#include +#include +#include +#include +#include +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Get the data from *ptr after casting according to @p data_type and then convert the data to double. + * + * @param[in] ptr Pointer to value. + * @param[in] data_type Data type of both values. + * + * @return The data from the ptr after converted to double. + */ +double get_double_data(const void *ptr, DataType data_type) +{ + if(ptr == nullptr) + { + ARM_COMPUTE_ERROR("Can't dereference a null pointer!"); + } + + switch(data_type) + { + case DataType::U8: + return *reinterpret_cast(ptr); + case DataType::S8: + return *reinterpret_cast(ptr); + case DataType::QS8: + return *reinterpret_cast(ptr); + case DataType::U16: + return *reinterpret_cast(ptr); + case DataType::S16: + return *reinterpret_cast(ptr); + case DataType::QS16: + return *reinterpret_cast(ptr); + case DataType::U32: + return *reinterpret_cast(ptr); + case DataType::S32: + return *reinterpret_cast(ptr); + case DataType::U64: + return *reinterpret_cast(ptr); + case DataType::S64: + return *reinterpret_cast(ptr); + case DataType::F16: + return *reinterpret_cast(ptr); + case DataType::F32: + return *reinterpret_cast(ptr); + case DataType::F64: + return *reinterpret_cast(ptr); + case DataType::SIZET: + return *reinterpret_cast(ptr); + default: + ARM_COMPUTE_ERROR("NOT SUPPORTED!"); + } +} + +bool is_equal(double target, double ref, double max_absolute_error = std::numeric_limits::epsilon(), double max_relative_error = 0.0001f) +{ + if(!std::isfinite(target) || !std::isfinite(ref)) + { + return false; + } + + // No need further check if they are equal + if(ref == target) + { + return true; + } + + // Need this check for the situation when the two values close to zero but have different sign + if(std::abs(std::abs(ref) - std::abs(target)) <= max_absolute_error) + { + return true; + } + + double relative_error = 0; + + if(std::abs(target) > std::abs(ref)) + { + relative_error = std::abs((target - ref) / target); + } + else + { + relative_error = std::abs((ref - target) / ref); + } + + return relative_error <= max_relative_error; +} + +void check_border_element(const IAccessor &tensor, const Coordinates &id, + const BorderMode &border_mode, const void *border_value, + int64_t &num_elements, int64_t &num_mismatches) +{ + const size_t channel_size = element_size_from_data_type(tensor.data_type()); + const auto ptr = static_cast(tensor(id)); + + if(border_mode == BorderMode::REPLICATE) + { + Coordinates border_id{ id }; + border_id.set(1, 0); + border_value = tensor(border_id); + } + + // Iterate over all channels within one element + for(int channel = 0; channel < tensor.num_channels(); ++channel) + { + const size_t channel_offset = channel * channel_size; + const double target = get_double_data(ptr + channel_offset, tensor.data_type()); + const double ref = get_double_data(static_cast(border_value) + channel_offset, tensor.data_type()); + const bool equal = is_equal(target, ref); + + BOOST_TEST_INFO("id = " << id); + BOOST_TEST_INFO("channel = " << channel); + BOOST_TEST_INFO("reference = " << std::setprecision(5) << ref); + BOOST_TEST_INFO("target = " << std::setprecision(5) << target); + BOOST_TEST_WARN(equal); + + if(!equal) + { + ++num_mismatches; + } + + ++num_elements; + } +} + +void check_single_element(const Coordinates &id, const IAccessor &tensor, const RawTensor &reference, float tolerance_value, + uint64_t wrap_range, int min_channels, size_t channel_size, int64_t &num_mismatches, int64_t &num_elements) +{ + const auto ptr = static_cast(tensor(id)); + const auto ref_ptr = static_cast(reference(id)); + + // Iterate over all channels within one element + for(int channel = 0; channel < min_channels; ++channel) + { + const size_t channel_offset = channel * channel_size; + const double target = get_double_data(ptr + channel_offset, reference.data_type()); + const double ref = get_double_data(ref_ptr + channel_offset, reference.data_type()); + bool equal = is_equal(target, ref, tolerance_value); + + if(wrap_range != 0 && !equal) + { + equal = is_equal(target, ref, wrap_range - tolerance_value); + } + + if(!equal) + { + BOOST_TEST_INFO("id = " << id); + BOOST_TEST_INFO("channel = " << channel); + BOOST_TEST_INFO("reference = " << std::setprecision(5) << ref); + BOOST_TEST_INFO("target = " << std::setprecision(5) << target); + BOOST_TEST_WARN(equal); + ++num_mismatches; + } + ++num_elements; + } +} +} // namespace + +void validate(const arm_compute::ValidRegion ®ion, const arm_compute::ValidRegion &reference) +{ + BOOST_TEST(region.anchor.num_dimensions() == reference.anchor.num_dimensions()); + BOOST_TEST(region.shape.num_dimensions() == reference.shape.num_dimensions()); + + for(unsigned int d = 0; d < region.anchor.num_dimensions(); ++d) + { + BOOST_TEST(region.anchor[d] == reference.anchor[d]); + } + + for(unsigned int d = 0; d < region.shape.num_dimensions(); ++d) + { + BOOST_TEST(region.shape[d] == reference.shape[d]); + } +} + +void validate(const arm_compute::PaddingSize &padding, const arm_compute::PaddingSize &reference) +{ + BOOST_TEST(padding.top == reference.top); + BOOST_TEST(padding.right == reference.right); + BOOST_TEST(padding.bottom == reference.bottom); + BOOST_TEST(padding.left == reference.left); +} + +void validate(const IAccessor &tensor, const RawTensor &reference, float tolerance_value, float tolerance_number, uint64_t wrap_range) +{ + // Validate with valid region covering the entire shape + validate(tensor, reference, shape_to_valid_region(tensor.shape()), tolerance_value, tolerance_number, wrap_range); +} + +void validate(const IAccessor &tensor, const RawTensor &reference, const ValidRegion &valid_region, float tolerance_value, float tolerance_number, uint64_t wrap_range) +{ + int64_t num_mismatches = 0; + int64_t num_elements = 0; + + BOOST_TEST(tensor.element_size() == reference.element_size()); + BOOST_TEST(tensor.format() == reference.format()); + BOOST_TEST(tensor.data_type() == reference.data_type()); + BOOST_TEST(tensor.num_channels() == reference.num_channels()); + BOOST_TEST(compare_dimensions(tensor.shape(), reference.shape())); + + const int min_elements = std::min(tensor.num_elements(), reference.num_elements()); + const int min_channels = std::min(tensor.num_channels(), reference.num_channels()); + const size_t channel_size = element_size_from_data_type(reference.data_type()); + + // Iterate over all elements within valid region, e.g. U8, S16, RGB888, ... + for(int element_idx = 0; element_idx < min_elements; ++element_idx) + { + const Coordinates id = index2coord(reference.shape(), element_idx); + if(is_in_valid_region(valid_region, id)) + { + check_single_element(id, tensor, reference, tolerance_value, wrap_range, min_channels, channel_size, num_mismatches, num_elements); + } + } + + const int64_t absolute_tolerance_number = tolerance_number * num_elements; + const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; + + BOOST_TEST(num_mismatches <= absolute_tolerance_number, + num_mismatches << " values (" << std::setprecision(2) << percent_mismatches + << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)"); +} + +void validate(const IAccessor &tensor, const RawTensor &reference, const RawTensor &valid_mask, float tolerance_value, float tolerance_number, uint64_t wrap_range) +{ + int64_t num_mismatches = 0; + int64_t num_elements = 0; + + BOOST_TEST(tensor.element_size() == reference.element_size()); + BOOST_TEST(tensor.format() == reference.format()); + BOOST_TEST(tensor.data_type() == reference.data_type()); + BOOST_TEST(tensor.num_channels() == reference.num_channels()); + BOOST_TEST(compare_dimensions(tensor.shape(), reference.shape())); + + const int min_elements = std::min(tensor.num_elements(), reference.num_elements()); + const int min_channels = std::min(tensor.num_channels(), reference.num_channels()); + const size_t channel_size = element_size_from_data_type(reference.data_type()); + + // Iterate over all elements within valid region, e.g. U8, S16, RGB888, ... + for(int element_idx = 0; element_idx < min_elements; ++element_idx) + { + const Coordinates id = index2coord(reference.shape(), element_idx); + if(valid_mask[element_idx] == 1) + { + check_single_element(id, tensor, reference, tolerance_value, wrap_range, min_channels, channel_size, num_mismatches, num_elements); + } + else + { + ++num_elements; + } + } + + const int64_t absolute_tolerance_number = tolerance_number * num_elements; + const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; + + BOOST_TEST(num_mismatches <= absolute_tolerance_number, + num_mismatches << " values (" << std::setprecision(2) << percent_mismatches + << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)"); +} + +void validate(const IAccessor &tensor, const void *reference_value) +{ + BOOST_TEST_REQUIRE((reference_value != nullptr)); + + int64_t num_mismatches = 0; + int64_t num_elements = 0; + const size_t channel_size = element_size_from_data_type(tensor.data_type()); + + // Iterate over all elements, e.g. U8, S16, RGB888, ... + for(int element_idx = 0; element_idx < tensor.num_elements(); ++element_idx) + { + const Coordinates id = index2coord(tensor.shape(), element_idx); + + const auto ptr = static_cast(tensor(id)); + + // Iterate over all channels within one element + for(int channel = 0; channel < tensor.num_channels(); ++channel) + { + const size_t channel_offset = channel * channel_size; + const double target = get_double_data(ptr + channel_offset, tensor.data_type()); + const double ref = get_double_data(reference_value, tensor.data_type()); + const bool equal = is_equal(target, ref); + + BOOST_TEST_INFO("id = " << id); + BOOST_TEST_INFO("channel = " << channel); + BOOST_TEST_INFO("reference = " << std::setprecision(5) << ref); + BOOST_TEST_INFO("target = " << std::setprecision(5) << target); + BOOST_TEST_WARN(equal); + + if(!equal) + { + ++num_mismatches; + } + + ++num_elements; + } + } + + const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; + + BOOST_TEST(num_mismatches == 0, + num_mismatches << " values (" << std::setprecision(2) << percent_mismatches << "%) mismatched"); +} + +void validate(const IAccessor &tensor, BorderSize border_size, const BorderMode &border_mode, const void *border_value) +{ + if(border_mode == BorderMode::UNDEFINED) + { + return; + } + else if(border_mode == BorderMode::CONSTANT) + { + BOOST_TEST((border_value != nullptr)); + } + + int64_t num_mismatches = 0; + int64_t num_elements = 0; + const int slice_size = tensor.shape()[0] * tensor.shape()[1]; + + for(int element_idx = 0; element_idx < tensor.num_elements(); element_idx += slice_size) + { + Coordinates id = index2coord(tensor.shape(), element_idx); + + // Top border + for(int y = -border_size.top; y < 0; ++y) + { + id.set(1, y); + + for(int x = -border_size.left; x < static_cast(tensor.shape()[0]) + static_cast(border_size.right); ++x) + { + id.set(0, x); + + check_border_element(tensor, id, border_mode, border_value, num_elements, num_mismatches); + } + } + + // Bottom border + for(int y = tensor.shape()[1]; y < static_cast(tensor.shape()[1]) + static_cast(border_size.bottom); ++y) + { + id.set(1, y); + + for(int x = -border_size.left; x < static_cast(tensor.shape()[0]) + static_cast(border_size.right); ++x) + { + id.set(0, x); + + check_border_element(tensor, id, border_mode, border_value, num_elements, num_mismatches); + } + } + + // Left/right border + for(int y = 0; y < static_cast(tensor.shape()[1]); ++y) + { + id.set(1, y); + + // Left border + for(int x = -border_size.left; x < 0; ++x) + { + id.set(0, x); + + check_border_element(tensor, id, border_mode, border_value, num_elements, num_mismatches); + } + + // Right border + for(int x = tensor.shape()[0]; x < static_cast(tensor.shape()[0]) + static_cast(border_size.right); ++x) + { + id.set(0, x); + + check_border_element(tensor, id, border_mode, border_value, num_elements, num_mismatches); + } + } + } + + const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; + + BOOST_TEST(num_mismatches == 0, + num_mismatches << " values (" << std::setprecision(2) << percent_mismatches << "%) mismatched"); +} + +void validate(std::vector classified_labels, std::vector expected_labels) +{ + ARM_COMPUTE_UNUSED(classified_labels); + ARM_COMPUTE_UNUSED(expected_labels); + BOOST_TEST(expected_labels.size() != 0); + BOOST_TEST(classified_labels.size() == expected_labels.size()); + + for(unsigned int i = 0; i < expected_labels.size(); ++i) + { + BOOST_TEST(classified_labels[i] == expected_labels[i]); + } +} + +void validate(float target, float ref, float tolerance_abs_error, float tolerance_relative_error) +{ + const bool equal = is_equal(target, ref, tolerance_abs_error, tolerance_relative_error); + + BOOST_TEST_INFO("reference = " << std::setprecision(5) << ref); + BOOST_TEST_INFO("target = " << std::setprecision(5) << target); + BOOST_TEST(equal); +} + +void validate(IArray &target, IArray &ref, int64_t tolerance) +{ + int64_t num_mismatches = 0; + + BOOST_TEST_WARN(target.num_values() == ref.num_values()); + + for(size_t i = 0; i < target.num_values(); ++i) + { + KeyPoint *ref_val = std::find_if(ref.buffer(), ref.buffer() + ref.num_values(), [&target, i](KeyPoint key) + { + return key.x == target.at(i).x && key.y == target.at(i).y; + }); + + const KeyPoint &key = target.at(i); + + if((ref_val == ref.buffer() + ref.num_values()) || !(is_equal(key.strength, ref_val->strength) && is_equal(key.scale, ref_val->scale) && is_equal(key.orientation, ref_val->orientation) + && is_equal(key.tracking_status, ref_val->tracking_status) && is_equal(key.error, ref_val->error))) + { + ++num_mismatches; + + BOOST_TEST_WARN(is_equal(key.strength, ref_val->strength)); + BOOST_TEST_WARN(is_equal(key.scale, ref_val->scale)); + BOOST_TEST_WARN(is_equal(key.orientation, ref_val->orientation)); + BOOST_TEST_WARN(is_equal(key.tracking_status, ref_val->tracking_status)); + BOOST_TEST_WARN(is_equal(key.error, ref_val->error)); + } + } + + BOOST_TEST(num_mismatches <= tolerance); +} +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation_old/Validation.h b/tests/validation_old/Validation.h new file mode 100644 index 0000000000..4c8752b937 --- /dev/null +++ b/tests/validation_old/Validation.h @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_H__ +#define __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_H__ + +#include "arm_compute/core/Types.h" +#include "arm_compute/runtime/Array.h" +#include "tests/RawTensor.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include + +namespace arm_compute +{ +class Tensor; + +namespace test +{ +class IAccessor; + +namespace validation +{ +template +boost::test_tools::predicate_result compare_dimensions(const Dimensions &dimensions1, const Dimensions &dimensions2) +{ + if(dimensions1.num_dimensions() != dimensions2.num_dimensions()) + { + boost::test_tools::predicate_result result(false); + result.message() << "Different dimensionality [" << dimensions1.num_dimensions() << "!=" << dimensions2.num_dimensions() << "]"; + return result; + } + + for(unsigned int i = 0; i < dimensions1.num_dimensions(); ++i) + { + if(dimensions1[i] != dimensions2[i]) + { + boost::test_tools::predicate_result result(false); + result.message() << "Mismatch in dimension " << i << " [" << dimensions1[i] << "!=" << dimensions2[i] << "]"; + return result; + } + } + + return true; +} + +/** Validate valid regions. + * + * - Dimensionality has to be the same. + * - Anchors have to match. + * - Shapes have to match. + */ +void validate(const arm_compute::ValidRegion ®ion, const arm_compute::ValidRegion &reference); + +/** Validate padding. + * + * Padding on all sides has to be the same. + */ +void validate(const arm_compute::PaddingSize &padding, const arm_compute::PaddingSize &reference); + +/** Validate tensors. + * + * - Dimensionality has to be the same. + * - All values have to match. + * + * @note: wrap_range allows cases where reference tensor rounds up to the wrapping point, causing it to wrap around to + * zero while the test tensor stays at wrapping point to pass. This may permit true erroneous cases (difference between + * reference tensor and test tensor is multiple of wrap_range), but such errors would be detected by + * other test cases. + */ +void validate(const IAccessor &tensor, const RawTensor &reference, float tolerance_value = 0.f, float tolerance_number = 0.f, uint64_t wrap_range = 0); + +/** Validate tensors with valid region. + * + * - Dimensionality has to be the same. + * - All values have to match. + * + * @note: wrap_range allows cases where reference tensor rounds up to the wrapping point, causing it to wrap around to + * zero while the test tensor stays at wrapping point to pass. This may permit true erroneous cases (difference between + * reference tensor and test tensor is multiple of wrap_range), but such errors would be detected by + * other test cases. + */ +void validate(const IAccessor &tensor, const RawTensor &reference, const ValidRegion &valid_region, float tolerance_value = 0.f, float tolerance_number = 0.f, uint64_t wrap_range = 0); + +/** Validate tensors with valid mask. + * + * - Dimensionality has to be the same. + * - All values have to match. + * + * @note: wrap_range allows cases where reference tensor rounds up to the wrapping point, causing it to wrap around to + * zero while the test tensor stays at wrapping point to pass. This may permit true erroneous cases (difference between + * reference tensor and test tensor is multiple of wrap_range), but such errors would be detected by + * other test cases. + */ +void validate(const IAccessor &tensor, const RawTensor &reference, const RawTensor &valid_mask, float tolerance_value = 0.f, float tolerance_number = 0.f, uint64_t wrap_range = 0); + +/** Validate tensors against constant value. + * + * - All values have to match. + */ +void validate(const IAccessor &tensor, const void *reference_value); + +/** Validate border against a constant value. + * + * - All border values have to match the specified value if mode is CONSTANT. + * - All border values have to be replicated if mode is REPLICATE. + * - Nothing is validated for mode UNDEFINED. + */ +void validate(const IAccessor &tensor, BorderSize border_size, const BorderMode &border_mode, const void *border_value); + +/** Validate classified labels against expected ones. + * + * - All values should match + */ +void validate(std::vector classified_labels, std::vector expected_labels); + +/** Validate float value. + * + * - All values should match + */ +void validate(float target, float ref, float tolerance_abs_error = std::numeric_limits::epsilon(), float tolerance_relative_error = 0.0001f); + +/** Validate min max location. + * + * - All values should match + */ +template +void validate_min_max_loc(T min, T ref_min, T max, T ref_max, + IArray &min_loc, IArray &ref_min_loc, IArray &max_loc, IArray &ref_max_loc, + uint32_t min_count, uint32_t ref_min_count, uint32_t max_count, uint32_t ref_max_count) +{ + BOOST_TEST(min == ref_min); + BOOST_TEST(max == ref_max); + + BOOST_TEST(min_count == min_loc.num_values()); + BOOST_TEST(max_count == max_loc.num_values()); + BOOST_TEST(ref_min_count == ref_min_loc.num_values()); + BOOST_TEST(ref_max_count == ref_max_loc.num_values()); + + BOOST_TEST(min_count == ref_min_count); + BOOST_TEST(max_count == ref_max_count); + + for(uint32_t i = 0; i < min_count; i++) + { + Coordinates2D *same_coords = std::find_if(ref_min_loc.buffer(), ref_min_loc.buffer() + min_count, [&min_loc, i](Coordinates2D coord) + { + return coord.x == min_loc.at(i).x && coord.y == min_loc.at(i).y; + }); + + BOOST_TEST(same_coords != ref_min_loc.buffer() + min_count); + } + + for(uint32_t i = 0; i < max_count; i++) + { + Coordinates2D *same_coords = std::find_if(ref_max_loc.buffer(), ref_max_loc.buffer() + max_count, [&max_loc, i](Coordinates2D coord) + { + return coord.x == max_loc.at(i).x && coord.y == max_loc.at(i).y; + }); + + BOOST_TEST(same_coords != ref_max_loc.buffer() + max_count); + } +} + +/** Validate KeyPoint arrays. + * + * - All values should match + */ +void validate(IArray &target, IArray &ref, int64_t tolerance = 0); +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_H__ */ diff --git a/tests/validation_old/ValidationProgramOptions.cpp b/tests/validation_old/ValidationProgramOptions.cpp new file mode 100644 index 0000000000..adb8c5ab6c --- /dev/null +++ b/tests/validation_old/ValidationProgramOptions.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "ValidationProgramOptions.h" + +#include + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" +#include "boost/program_options.hpp" +#pragma GCC diagnostic pop + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +ValidationProgramOptions::ValidationProgramOptions() +{ + boost::program_options::options_description options("Validation options"); + options.add_options()("runs", boost::program_options::value()->default_value(1), "Repetitions per test"); + options.add_options()("threads", boost::program_options::value()->default_value(std::thread::hardware_concurrency()), "Number of parallel CPU threads"); + add_options(options); +} +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation_old/ValidationProgramOptions.h b/tests/validation_old/ValidationProgramOptions.h new file mode 100644 index 0000000000..6b29b807de --- /dev/null +++ b/tests/validation_old/ValidationProgramOptions.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_VALIDATION_PROGRAM_OPTIONS_H__ +#define __ARM_COMPUTE_TEST_VALIDATION_PROGRAM_OPTIONS_H__ + +#include "ProgramOptions.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +/** Subclass of @ref ProgramOptions that adds validation specific options. */ +class ValidationProgramOptions : public ProgramOptions +{ +public: + /** Defines additonal options. */ + ValidationProgramOptions(); +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_VALIDATION_PROGRAM_OPTIONS_H__ */ diff --git a/tests/validation_old/ValidationUserConfiguration.h b/tests/validation_old/ValidationUserConfiguration.h new file mode 100644 index 0000000000..a9b8b4fe40 --- /dev/null +++ b/tests/validation_old/ValidationUserConfiguration.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_USER_CONFIGURATION_H__ +#define __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_USER_CONFIGURATION_H__ + +#include "UserConfiguration.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +// Validation requires no specific configuration +using ValidationUserConfiguration = UserConfiguration; +} // namespace validation + +extern validation::ValidationUserConfiguration user_config; +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_USER_CONFIGURATION_H__ */ diff --git a/tests/validation_old/boost_wrapper.h b/tests/validation_old/boost_wrapper.h new file mode 100644 index 0000000000..b584e4cd1f --- /dev/null +++ b/tests/validation_old/boost_wrapper.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Woverloaded-virtual" +#pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" +#pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic ignored "-Wsign-compare" +#include "boost/test/unit_test.hpp" +#include "boost/variant.hpp" +#include "boost/variant/multivisitors.hpp" +#pragma GCC diagnostic pop + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#include "boost/test/data/test_case.hpp" +#pragma GCC diagnostic pop + +#include "boost/test/data/monomorphic.hpp" diff --git a/tests/validation_old/dataset/ActivationFunctionDataset.h b/tests/validation_old/dataset/ActivationFunctionDataset.h new file mode 100644 index 0000000000..b72cffbcd9 --- /dev/null +++ b/tests/validation_old/dataset/ActivationFunctionDataset.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_ACTIVATION_FUNCTION_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_ACTIVATION_FUNCTION_DATASET_H__ + +#include "arm_compute/core/Types.h" +#include "tests/validation_old/dataset/GenericDataset.h" + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +/** Data set containing all possible activation functions. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on all activation functions. + */ +class ActivationFunctions final : public GenericDataset +{ +public: + ActivationFunctions() + : GenericDataset + { + ActivationLayerInfo::ActivationFunction::ABS, + ActivationLayerInfo::ActivationFunction::LINEAR, + ActivationLayerInfo::ActivationFunction::LOGISTIC, + ActivationLayerInfo::ActivationFunction::RELU, + ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, + ActivationLayerInfo::ActivationFunction::LEAKY_RELU, + ActivationLayerInfo::ActivationFunction::SOFT_RELU, + ActivationLayerInfo::ActivationFunction::SQRT, + ActivationLayerInfo::ActivationFunction::SQUARE, + ActivationLayerInfo::ActivationFunction::TANH + } + { + } + + ~ActivationFunctions() = default; +}; +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_DATASET_ACTIVATION_FUNCTION_DATASET_H__ */ diff --git a/tests/validation_old/dataset/ActivationLayerDataset.h b/tests/validation_old/dataset/ActivationLayerDataset.h new file mode 100644 index 0000000000..ead52a2961 --- /dev/null +++ b/tests/validation_old/dataset/ActivationLayerDataset.h @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_ACTIVATION_LAYER_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_ACTIVATION_LAYER_DATASET_H__ + +#include "TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/validation_old/dataset/GenericDataset.h" + +#include +#include + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +class ActivationLayerDataObject +{ +public: + operator std::string() const + { + std::stringstream ss; + ss << "ActivationLayer"; + ss << "_I" << shape; + ss << "_F_" << info.activation(); + return ss.str(); + } + +public: + TensorShape shape; + ActivationLayerInfo info; +}; + +template +using ActivationLayerDataset = GenericDataset; + +class AlexNetActivationLayerDataset final : public ActivationLayerDataset<5> +{ +public: + AlexNetActivationLayerDataset() + : GenericDataset + { + ActivationLayerDataObject{ TensorShape(55U, 55U, 96U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + ActivationLayerDataObject{ TensorShape(27U, 27U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + ActivationLayerDataObject{ TensorShape(13U, 13U, 384U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + ActivationLayerDataObject{ TensorShape(13U, 13U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + ActivationLayerDataObject{ TensorShape(4096U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + } + { + } + + ~AlexNetActivationLayerDataset() = default; +}; + +class LeNet5ActivationLayerDataset final : public ActivationLayerDataset<1> +{ +public: + LeNet5ActivationLayerDataset() + : GenericDataset + { + ActivationLayerDataObject{ TensorShape(500U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + } + { + } + + ~LeNet5ActivationLayerDataset() = default; +}; + +class GoogLeNetActivationLayerDataset final : public ActivationLayerDataset<33> +{ +public: + GoogLeNetActivationLayerDataset() + : GenericDataset + { + // conv1/relu_7x7 + ActivationLayerDataObject{ TensorShape(112U, 112U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // conv2/relu_3x3_reduce + ActivationLayerDataObject{ TensorShape(56U, 56U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // conv2/relu_3x3 + ActivationLayerDataObject{ TensorShape(56U, 56U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_3a/relu_1x1, inception_3b/relu_pool_proj + ActivationLayerDataObject{ TensorShape(28U, 28U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_3a/relu_3x3_reduce, inception_3b/relu_5x5 + ActivationLayerDataObject{ TensorShape(28U, 28U, 96U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_3a/relu_3x3, inception_3b/relu_1x1, inception_3b/relu_3x3_reduce + ActivationLayerDataObject{ TensorShape(28U, 28U, 128U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_3a/relu_5x5_reduce + ActivationLayerDataObject{ TensorShape(28U, 28U, 16U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_3a/relu_5x5, inception_3a/relu_pool_proj, inception_3b/relu_5x5_reduce + ActivationLayerDataObject{ TensorShape(28U, 28U, 32U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_3b/relu_3x3 + ActivationLayerDataObject{ TensorShape(28U, 28U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4a/relu_1x1 + ActivationLayerDataObject{ TensorShape(14U, 14U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4a/relu_3x3_reduce + ActivationLayerDataObject{ TensorShape(14U, 14U, 96U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4a/relu_3x3 + ActivationLayerDataObject{ TensorShape(14U, 14U, 208U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4a/relu_5x5_reduce + ActivationLayerDataObject{ TensorShape(14U, 14U, 16U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4a/relu_5x5 + ActivationLayerDataObject{ TensorShape(14U, 14U, 48U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4a/relu_pool_proj, inception_4b/relu_5x5, inception_4b/relu_pool_proj, inception_4c/relu_5x5, inception_4c/relu_pool_proj, inception_4d/relu_5x5, inception_4d/relu_pool_proj + ActivationLayerDataObject{ TensorShape(14U, 14U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4b/relu_1x1, inception_4e/relu_3x3_reduce + ActivationLayerDataObject{ TensorShape(14U, 14U, 160U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4b/relu_3x3_reduce, inception_4d/relu_1x1 + ActivationLayerDataObject{ TensorShape(14U, 14U, 112U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4b/relu_3x3 + ActivationLayerDataObject{ TensorShape(14U, 14U, 224U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4b/relu_5x5_reduce, inception_4c/relu_5x5_reduce + ActivationLayerDataObject{ TensorShape(14U, 14U, 24U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4c/relu_1x1, inception_4c/relu_3x3_reduce, inception_4e/relu_5x5, inception_4e/relu_pool_proj + ActivationLayerDataObject{ TensorShape(14U, 14U, 128U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4c/relu_3x3, inception_4e/relu_1x1 + ActivationLayerDataObject{ TensorShape(14U, 14U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4d/relu_3x3_reduce + ActivationLayerDataObject{ TensorShape(14U, 14U, 144U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4d/relu_3x3 + ActivationLayerDataObject{ TensorShape(14U, 14U, 288U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4d/relu_5x5_reduce, inception_4e/relu_5x5_reduce + ActivationLayerDataObject{ TensorShape(14U, 14U, 32U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4e/relu_3x3 + ActivationLayerDataObject{ TensorShape(14U, 14U, 320U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_5a/relu_1x1 + ActivationLayerDataObject{ TensorShape(7U, 7U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_5a/relu_3x3_reduce + ActivationLayerDataObject{ TensorShape(7U, 7U, 160U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_5a/relu_3x3 + ActivationLayerDataObject{ TensorShape(7U, 7U, 320U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_5a/relu_5x5_reduce + ActivationLayerDataObject{ TensorShape(7U, 7U, 32U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_5a/relu_5x5, inception_5a/relu_pool_proj, inception_5b/relu_5x5, inception_5b/relu_pool_proj + ActivationLayerDataObject{ TensorShape(7U, 7U, 128U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_5b/relu_1x1, inception_5b/relu_3x3 + ActivationLayerDataObject{ TensorShape(7U, 7U, 384U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_5b/relu_3x3_reduce + ActivationLayerDataObject{ TensorShape(7U, 7U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_5b/relu_5x5_reduce + ActivationLayerDataObject{ TensorShape(7U, 7U, 48U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) } + } + { + } + + ~GoogLeNetActivationLayerDataset() = default; +}; + +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_DATASET_ACTIVATION_LAYER_DATASET_H__ diff --git a/tests/validation_old/dataset/BatchNormalizationLayerDataset.h b/tests/validation_old/dataset/BatchNormalizationLayerDataset.h new file mode 100644 index 0000000000..ca1e3b694c --- /dev/null +++ b/tests/validation_old/dataset/BatchNormalizationLayerDataset.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_BATCH_NORMALIZATION_LAYER_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_BATCH_NORMALIZATION_LAYER_DATASET_H__ + +#include "TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/validation_old/dataset/GenericDataset.h" + +#include +#include + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +class BatchNormalizationLayerDataObject +{ +public: + operator std::string() const + { + std::stringstream ss; + ss << "BatchNormalizationLayer"; + ss << "_I" << shape0; + ss << "_I" << shape1; + ss << "_I" << epsilon; + return ss.str(); + } + + friend std::ostream &operator<<(std::ostream &s, const BatchNormalizationLayerDataObject &obj) + { + s << static_cast(obj); + return s; + } + +public: + TensorShape shape0; + TensorShape shape1; + float epsilon; +}; + +template +using BatchNormalizationLayerDataset = GenericDataset; + +class RandomBatchNormalizationLayerDataset final : public BatchNormalizationLayerDataset<3> +{ +public: + RandomBatchNormalizationLayerDataset() + : GenericDataset + { + BatchNormalizationLayerDataObject{ TensorShape(15U, 16U, 2U, 12U), TensorShape(2U), 0.1f }, + BatchNormalizationLayerDataObject{ TensorShape(21U, 11U, 12U, 7U), TensorShape(12U), 0.1f }, + BatchNormalizationLayerDataObject{ TensorShape(7U, 3U, 6U, 11U), TensorShape(6U), 0.1f }, + } + { + } + + ~RandomBatchNormalizationLayerDataset() = default; +}; + +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_DATASET_BATCH_NORMALIZATION_LAYER_DATASET_H__ diff --git a/tests/validation_old/dataset/BorderModeDataset.h b/tests/validation_old/dataset/BorderModeDataset.h new file mode 100644 index 0000000000..d1eb48d3bd --- /dev/null +++ b/tests/validation_old/dataset/BorderModeDataset.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_BORDER_MODE_DATASET_H__ +#define __ARM_COMPUTE_TEST_BORDER_MODE_DATASET_H__ + +#include "arm_compute/core/Types.h" + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +#include + +namespace arm_compute +{ +namespace test +{ +/** Data set containing all possible border modes. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on all border modes. + */ +class BorderModes +{ +public: + /** Type of the samples in the data set. */ + using sample = BorderMode; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else /* BOOST */ + unsigned int size() const +#endif /* BOOST */ + { + return _modes.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const BorderMode *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _modes.data(); + } + +private: + std::array _modes{ { BorderMode::UNDEFINED, BorderMode::CONSTANT, BorderMode::REPLICATE } }; +}; +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_BORDER_MODE_DATASET_H__ */ diff --git a/tests/validation_old/dataset/ConvertPolicyDataset.h b/tests/validation_old/dataset/ConvertPolicyDataset.h new file mode 100644 index 0000000000..591b7ad388 --- /dev/null +++ b/tests/validation_old/dataset/ConvertPolicyDataset.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_CONVERT_POLICY_DATASETS_H__ +#define __ARM_COMPUTE_TEST_CONVERT_POLICY_DATASETS_H__ + +#include "arm_compute/core/Types.h" + +#include + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +/** Data set containing all possible convert/overflow policies. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on different convert policies. + */ +class ConvertPolicies +{ +public: + /** Type of the samples in the data set. */ + using sample = ConvertPolicy; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else /* BOOST */ + unsigned int size() const +#endif /* BOOST */ + { + return _policies.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const ConvertPolicy *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _policies.data(); + } + +private: + std::array _policies{ { ConvertPolicy::WRAP, ConvertPolicy::SATURATE } }; +}; +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_CONVERT_POLICY_DATASETS_H__ */ diff --git a/tests/validation_old/dataset/ConvolutionLayerDataset.h b/tests/validation_old/dataset/ConvolutionLayerDataset.h new file mode 100644 index 0000000000..4fcba8d86d --- /dev/null +++ b/tests/validation_old/dataset/ConvolutionLayerDataset.h @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_CONVOLUTION_LAYER_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_CONVOLUTION_LAYER_DATASET_H__ + +#include "TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "tests/validation_old/dataset/GenericDataset.h" +#include "tests/validation_old/dataset/ShapeDatasets.h" + +#include +#include + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +/** Convolution Layer data object */ +class ConvolutionLayerDataObject +{ +public: + operator std::string() const + { + std::stringstream ss; + ss << "ConvolutionLayer"; + ss << "_I" << src_shape; + ss << "_K" << weights_shape; + ss << "_PS" << info; + return ss.str(); + } + + friend std::ostream &operator<<(std::ostream &os, const ConvolutionLayerDataObject &obj) + { + os << static_cast(obj); + return os; + } + +public: + TensorShape src_shape; + TensorShape weights_shape; + TensorShape bias_shape; + TensorShape dst_shape; + PadStrideInfo info; +}; + +template +using ConvolutionLayerDataset = GenericDataset; + +/** Data set containing small convolution layer shapes */ +class SmallConvolutionLayerDataset final : public ConvolutionLayerDataset<6> +{ +public: + SmallConvolutionLayerDataset() + : GenericDataset + { + ConvolutionLayerDataObject{ TensorShape(23U, 27U, 5U), TensorShape(3U, 3U, 5U, 21U), TensorShape(21U), TensorShape(11U, 25U, 21U), PadStrideInfo(2, 1, 0, 0) }, + ConvolutionLayerDataObject{ TensorShape(33U, 27U, 7U), TensorShape(5U, 5U, 7U, 16U), TensorShape(16U), TensorShape(11U, 12U, 16U), PadStrideInfo(3, 2, 1, 0) }, + ConvolutionLayerDataObject{ TensorShape(17U, 31U, 2U, 7U), TensorShape(5U, 5U, 2U, 19U), TensorShape(19U), TensorShape(15U, 15U, 19U, 7U), PadStrideInfo(1, 2, 1, 1) }, + ConvolutionLayerDataObject{ TensorShape(23U, 27U, 5U), TensorShape(3U, 1U, 5U, 21U), TensorShape(21U), TensorShape(11U, 27U, 21U), PadStrideInfo(2, 1, 0, 0) }, + ConvolutionLayerDataObject{ TensorShape(33U, 27U, 7U), TensorShape(5U, 7U, 7U, 16U), TensorShape(16U), TensorShape(11U, 11U, 16U), PadStrideInfo(3, 2, 1, 0) }, + ConvolutionLayerDataObject{ TensorShape(17U, 31U, 2U, 7U), TensorShape(5U, 3U, 2U, 19U), TensorShape(19U), TensorShape(15U, 16U, 19U, 7U), PadStrideInfo(1, 2, 1, 1) } + } + { + } + + ~SmallConvolutionLayerDataset() = default; +}; + +/** Data set containing direct convolution tensor shapes. */ +class DirectConvolutionShapes final : public ShapeDataset<4> +{ +public: + DirectConvolutionShapes() + : ShapeDataset(TensorShape(3U, 3U, 3U, 2U, 4U, 5U), + TensorShape(32U, 37U, 3U), + TensorShape(64U, 32U, 4U, 2U), + TensorShape(13U, 15U, 8U, 3U)) + { + } +}; + +/** AlexNet's convolution layers tensor shapes. */ +class AlexNetConvolutionLayerDataset final : public ConvolutionLayerDataset<5> +{ +public: + AlexNetConvolutionLayerDataset() + : GenericDataset + { + ConvolutionLayerDataObject{ TensorShape(227U, 227U, 3U), TensorShape(11U, 11U, 3U, 96U), TensorShape(96U), TensorShape(55U, 55U, 96U), PadStrideInfo(4, 4, 0, 0) }, + ConvolutionLayerDataObject{ TensorShape(27U, 27U, 96U), TensorShape(5U, 5U, 96U, 256U), TensorShape(256U), TensorShape(27U, 27U, 256U), PadStrideInfo(1, 1, 2, 2) }, + ConvolutionLayerDataObject{ TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1) }, + ConvolutionLayerDataObject{ TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1) }, + ConvolutionLayerDataObject{ TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U), PadStrideInfo(1, 1, 1, 1) } + } + { + } + + ~AlexNetConvolutionLayerDataset() = default; +}; + +/** LeNet5's convolution layers tensor shapes. */ +class LeNet5ConvolutionLayerDataset final : public ConvolutionLayerDataset<2> +{ +public: + LeNet5ConvolutionLayerDataset() + : GenericDataset + { + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 1U), TensorShape(5U, 5U, 1U, 20U), TensorShape(20U), TensorShape(24U, 24U, 20U), PadStrideInfo(1, 1, 0, 0) }, + ConvolutionLayerDataObject{ TensorShape(12U, 12U, 20U), TensorShape(5U, 5U, 20U, 50U), TensorShape(50U), TensorShape(8U, 8U, 50U), PadStrideInfo(1, 1, 0, 0) }, + } + { + } + + ~LeNet5ConvolutionLayerDataset() = default; +}; + +/** GoogleLeNet v1 convolution layers tensor shapes (Part 1). + * + * @note Dataset is split into two to avoid a register allocation failure produced by clang in Android debug builds. + */ +class GoogLeNetConvolutionLayerDataset1 final : public ConvolutionLayerDataset<32> +{ +public: + GoogLeNetConvolutionLayerDataset1() + : GenericDataset + { + // conv1/7x7_s2 + ConvolutionLayerDataObject{ TensorShape(224U, 224U, 3U), TensorShape(7U, 7U, 3U, 64U), TensorShape(64U), TensorShape(112U, 112U, 64U), PadStrideInfo(2, 2, 3, 3) }, + // conv2/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(56U, 56U, 64U), TensorShape(1U, 1U, 64U, 64U), TensorShape(64U), TensorShape(56U, 56U, 64U), PadStrideInfo(1, 1, 0, 0) }, + // conv2/3x3 + ConvolutionLayerDataObject{ TensorShape(56U, 56U, 64U), TensorShape(3U, 3U, 64U, 192U), TensorShape(192U), TensorShape(56U, 56U, 192U), PadStrideInfo(1, 1, 1, 1) }, + // inception_3a/1x1 + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0) }, + // inception_3a/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 96U), TensorShape(96U), TensorShape(28U, 28U, 96U), PadStrideInfo(1, 1, 0, 0) }, + // inception_3a/3x3 + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 96U), TensorShape(3U, 3U, 96U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 1, 1) }, + // inception_3a/5x5_reduce + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 16U), TensorShape(16U), TensorShape(28U, 28U, 16U), PadStrideInfo(1, 1, 0, 0) }, + // inception_3a/5x5 + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 16U), TensorShape(5U, 5U, 16U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 2, 2) }, + // inception_3a/pool_proj + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0) }, + // inception_3b/1x1, inception_3b/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 0, 0) }, + // inception_3b/3x3 + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 128U), TensorShape(3U, 3U, 128U, 192U), TensorShape(192U), TensorShape(28U, 28U, 192U), PadStrideInfo(1, 1, 1, 1) }, + // inception_3b/5x5_reduce + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0) }, + // inception_3b/5x5 + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 32U), TensorShape(5U, 5U, 32U, 96U), TensorShape(96U), TensorShape(28U, 28U, 96U), PadStrideInfo(1, 1, 2, 2) }, + // inception_3b/pool_proj + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4a/1x1 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 192U), TensorShape(192U), TensorShape(14U, 14U, 192U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4a/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 96U), TensorShape(96U), TensorShape(14U, 14U, 96U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4a/3x3 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 96U), TensorShape(3U, 3U, 96U, 208U), TensorShape(208U), TensorShape(14U, 14U, 208U), PadStrideInfo(1, 1, 1, 1) }, + // inception_4a/5x5_reduce + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 16U), TensorShape(16U), TensorShape(14U, 14U, 16U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4a/5x5 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 16U), TensorShape(5U, 5U, 16U, 48U), TensorShape(48U), TensorShape(14U, 14U, 48U), PadStrideInfo(1, 1, 2, 2) }, + // inception_4a/pool_proj + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4b/1x1 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4b/3x3_reduce, inception_4d/1x1 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 112U), TensorShape(112U), TensorShape(14U, 14U, 112U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4b/3x3 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 112U), TensorShape(3U, 3U, 112U, 224U), TensorShape(224U), TensorShape(14U, 14U, 224U), PadStrideInfo(1, 1, 1, 1) }, + // inception_4b/5x5_reduce, inception_4c/5x5_reduce + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 24U), TensorShape(24U), TensorShape(14U, 14U, 24U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4b/5x5, inception_4c/5x5 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 24U), TensorShape(5U, 5U, 24U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 2, 2) }, + // inception_4b/pool_proj, inception_4c/pool_proj, inception_4d/pool_proj + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4c/1x1, inception_4c/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4c/3x3 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 128U), TensorShape(3U, 3U, 128U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 1, 1) }, + // inception_4d/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 144U), TensorShape(144U), TensorShape(14U, 14U, 144U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4d/3x3 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 144U), TensorShape(3U, 3U, 144U, 288U), TensorShape(288U), TensorShape(14U, 14U, 288U), PadStrideInfo(1, 1, 1, 1) }, + // inception_4d/5x5_reduce + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4d/5x5 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 32U), TensorShape(5U, 5U, 32U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 2, 2) }, + } + { + } + + ~GoogLeNetConvolutionLayerDataset1() = default; +}; + +/** GoogleLeNet v1 convolution layers tensor shapes (Part 2). */ +class GoogLeNetConvolutionLayerDataset2 final : public ConvolutionLayerDataset<17> +{ +public: + GoogLeNetConvolutionLayerDataset2() + : GenericDataset + { + // inception_4e/1x1 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4e/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4e/3x3 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(14U, 14U, 320U), PadStrideInfo(1, 1, 1, 1) }, + // inception_4e/5x5_reduce + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4e/5x5 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 32U), TensorShape(5U, 5U, 32U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 2, 2) }, + // inception_4e/pool_proj + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0) }, + // inception_5a/1x1 + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 256U), TensorShape(256U), TensorShape(7U, 7U, 256U), PadStrideInfo(1, 1, 0, 0) }, + // inception_5a/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 160U), TensorShape(160U), TensorShape(7U, 7U, 160U), PadStrideInfo(1, 1, 0, 0) }, + // inception_5a/3x3 + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(7U, 7U, 320U), PadStrideInfo(1, 1, 1, 1) }, + // inception_5a/5x5_reduce + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 32U), TensorShape(32U), TensorShape(7U, 7U, 32U), PadStrideInfo(1, 1, 0, 0) }, + // inception_5a/5x5 + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 32U), TensorShape(5U, 5U, 32U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 2, 2) }, + // inception_5a/pool_proj, inception_5b/pool_proj + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 0, 0) }, + // inception_5b/1x1 + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 0, 0) }, + // inception_5b/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 192U), TensorShape(192U), TensorShape(7U, 7U, 192U), PadStrideInfo(1, 1, 0, 0) }, + // inception_5b/3x3 + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 192U), TensorShape(3U, 3U, 192U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 1, 1) }, + // inception_5b/5x5_reduce + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 48U), TensorShape(48U), TensorShape(7U, 7U, 48U), PadStrideInfo(1, 1, 0, 0) }, + // inception_5b/5x5 + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 48U), TensorShape(5U, 5U, 48U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 2, 2) } + } + { + } + + ~GoogLeNetConvolutionLayerDataset2() = default; +}; +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_DATASET_CONVOLUTION_LAYER_DATASET_H__ */ diff --git a/tests/validation_old/dataset/DataTypeDatasets.h b/tests/validation_old/dataset/DataTypeDatasets.h new file mode 100644 index 0000000000..34fc782b10 --- /dev/null +++ b/tests/validation_old/dataset/DataTypeDatasets.h @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATA_TYPE_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATA_TYPE_DATASET_H__ + +#include "arm_compute/core/Types.h" + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +/** Abstract data set containing data types. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on different data types. + */ +template +class DataTypes +{ +public: + /** Type of the samples in the data set. */ + using sample = DataType; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else /* BOOST */ + unsigned int size() const +#endif /* BOOST */ + { + return _types.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const DataType *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _types.data(); + } + +protected: + /** Protected constructor to make the class abstract. */ + template + DataTypes(Ts &&... types) + : _types{ { types... } } + { + } + + /** Protected destructor to prevent deletion of derived classes through a + * pointer to the base class. + */ + ~DataTypes() = default; + +private: + std::array _types; +}; + +/** Data set containing all data types. */ +class AllDataTypes final : public DataTypes<14> +{ +public: + AllDataTypes() + : DataTypes{ DataType::U8, DataType::S8, DataType::U16, DataType::S16, + DataType::U32, DataType::S32, DataType::U64, DataType::S64, + DataType::F16, DataType::F32, DataType::F64, DataType::SIZET, + DataType::QS8, DataType::QS16 } + { + } + + ~AllDataTypes() = default; +}; + +/** Data set containing all unsigned data types. */ +class UnsignedDataTypes final : public DataTypes<4> +{ +public: + UnsignedDataTypes() + : DataTypes{ DataType::U8, DataType::U16, DataType::U32, DataType::U64 } + { + } + + ~UnsignedDataTypes() = default; +}; + +/** Data set containing all signed data types. */ +class SignedDataTypes final : public DataTypes<4> +{ +public: + SignedDataTypes() + : DataTypes{ DataType::S8, DataType::S16, DataType::S32, DataType::S64 } + { + } + + ~SignedDataTypes() = default; +}; + +/** Data set containing all floating point data types. */ +class FloatDataTypes final : public DataTypes<3> +{ +public: + FloatDataTypes() + : DataTypes{ DataType::F16, DataType::F32, DataType::F64 } + { + } + + ~FloatDataTypes() = default; +}; + +/** Data set containing all fixed point data types. */ +class FixedPointDataTypes final : public DataTypes<2> +{ +public: + FixedPointDataTypes() + : DataTypes{ DataType::QS8, DataType::QS16 } + { + } + + ~FixedPointDataTypes() = default; +}; + +/** Supported CNN float types. */ +class CNNFloatDataTypes final : public DataTypes<1> +{ +public: + CNNFloatDataTypes() + : DataTypes{ DataType::F32 } + { + } + + ~CNNFloatDataTypes() = default; +}; + +/** Supported CNN fixed point types. */ +class CNNFixedPointDataTypes final : public DataTypes<2> +{ +public: + CNNFixedPointDataTypes() + : DataTypes{ DataType::QS8, DataType::QS16 } + { + } + + ~CNNFixedPointDataTypes() = default; +}; + +/** Supported CNN types. */ +class CNNDataTypes final : public DataTypes<2> +{ +public: + CNNDataTypes() + : DataTypes{ DataType::F32, DataType::QS8 } + { + } + + ~CNNDataTypes() = default; +}; +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_DATA_TYPE_DATASET_H__ */ diff --git a/tests/validation_old/dataset/FullyConnectedLayerDataset.h b/tests/validation_old/dataset/FullyConnectedLayerDataset.h new file mode 100644 index 0000000000..3564560788 --- /dev/null +++ b/tests/validation_old/dataset/FullyConnectedLayerDataset.h @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_FULLY_CONNECTED_LAYER_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_FULLY_CONNECTED_LAYER_DATASET_H__ + +#include "TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "tests/validation_old/dataset/GenericDataset.h" + +#include +#include + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +class FullyConnectedLayerDataObject +{ +public: + operator std::string() const + { + std::stringstream ss; + ss << "FullyConnectedLayer"; + ss << "_I" << src_shape; + ss << "_K" << weights_shape; + return ss.str(); + } + + friend std::ostream &operator<<(std::ostream &os, const FullyConnectedLayerDataObject &obj) + { + os << static_cast(obj); + return os; + } + +public: + TensorShape src_shape; + TensorShape weights_shape; + TensorShape bias_shape; + TensorShape dst_shape; + bool transpose_weights; + bool are_weights_reshaped; +}; + +template +using FullyConnectedLayerDataset = GenericDataset; + +class SmallFullyConnectedLayerDataset final : public FullyConnectedLayerDataset<5> +{ +public: + SmallFullyConnectedLayerDataset() + : GenericDataset + { + FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 7U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U), true, false }, + FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 7U, 3U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U, 3U), true, false }, + FullyConnectedLayerDataObject{ TensorShape(201U), TensorShape(201U, 529U), TensorShape(529U), TensorShape(529U), true, false }, + FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 7U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U), true, true }, + FullyConnectedLayerDataObject{ TensorShape(201U), TensorShape(201U, 529U), TensorShape(529U), TensorShape(529U), true, true }, + } + { + } + + ~SmallFullyConnectedLayerDataset() = default; +}; + +class LargeFullyConnectedLayerDataset final : public FullyConnectedLayerDataset<5> +{ +public: + LargeFullyConnectedLayerDataset() + : GenericDataset + { + FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 257U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U), true, false }, + FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 257U, 2U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U, 2U), true, false }, + FullyConnectedLayerDataObject{ TensorShape(3127U), TensorShape(3127U, 989U), TensorShape(989U), TensorShape(989U), true, false }, + FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 257U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U), true, true }, + FullyConnectedLayerDataObject{ TensorShape(3127U), TensorShape(3127U, 989U), TensorShape(989U), TensorShape(989U), true, true }, + } + { + } + + ~LargeFullyConnectedLayerDataset() = default; +}; + +class AlexNetFullyConnectedLayerDataset final : public FullyConnectedLayerDataset<3> +{ +public: + AlexNetFullyConnectedLayerDataset() + : GenericDataset + { + FullyConnectedLayerDataObject{ TensorShape(6U, 6U, 256U), TensorShape(9216U, 4096U), TensorShape(4096U), TensorShape(4096U), true }, + FullyConnectedLayerDataObject{ TensorShape(4096U), TensorShape(4096U, 4096U), TensorShape(4096U), TensorShape(4096U), true }, + FullyConnectedLayerDataObject{ TensorShape(4096U), TensorShape(4096U, 1000U), TensorShape(1000U), TensorShape(1000U), true }, + } + { + } + + ~AlexNetFullyConnectedLayerDataset() = default; +}; + +class LeNet5FullyConnectedLayerDataset final : public FullyConnectedLayerDataset<2> +{ +public: + LeNet5FullyConnectedLayerDataset() + : GenericDataset + { + FullyConnectedLayerDataObject{ TensorShape(4U, 4U, 50U), TensorShape(800U, 500U), TensorShape(500U), TensorShape(500U) }, + FullyConnectedLayerDataObject{ TensorShape(500U), TensorShape(500U, 10U), TensorShape(10U), TensorShape(10U) }, + } + { + } + + ~LeNet5FullyConnectedLayerDataset() = default; +}; + +class GoogLeNetFullyConnectedLayerDataset final : public FullyConnectedLayerDataset<1> +{ +public: + GoogLeNetFullyConnectedLayerDataset() + : GenericDataset + { + FullyConnectedLayerDataObject{ TensorShape(1024U), TensorShape(1024U, 1000U), TensorShape(1000U), TensorShape(1000U), true }, + } + { + } + + ~GoogLeNetFullyConnectedLayerDataset() = default; +}; +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_DATASET_FULLY_CONNECTED_LAYER_DATASET_H__ */ diff --git a/tests/validation_old/dataset/GEMMDataset.h b/tests/validation_old/dataset/GEMMDataset.h new file mode 100644 index 0000000000..5250827340 --- /dev/null +++ b/tests/validation_old/dataset/GEMMDataset.h @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_GEMM_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_GEMM_DATASET_H__ + +#include "TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/validation_old/dataset/GenericDataset.h" + +#include +#include + +#include +#include + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +class GEMMDataObject +{ +public: + //Data object used for matrix multiple + //D = alpha * A * B + beta * C; + TensorShape shape_a; + TensorShape shape_b; + TensorShape shape_c; + TensorShape shape_d; + float alpha; + float beta; + + operator std::string() const + { + std::stringstream ss; + ss << "GEMM"; + ss << "_A" << shape_a; + ss << "_B" << shape_b; + ss << "_C" << shape_c; + ss << "_D" << shape_d; + ss << "_alpha" << alpha; + ss << "_beta" << beta; + return ss.str(); + } + + friend std::ostream &operator<<(std::ostream &os, const GEMMDataObject &obj) + { + os << static_cast(obj); + return os; + } +}; + +class SmallGEMMDataset : public GenericDataset +{ +public: + SmallGEMMDataset() + : GenericDataset + { + GEMMDataObject{ TensorShape(21U, 13U), TensorShape(33U, 21U), TensorShape(33U, 13U), TensorShape(33U, 13U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(31U, 1U), TensorShape(23U, 31U), TensorShape(23U, 1U), TensorShape(23U, 1U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(38U, 12U), TensorShape(21U, 38U), TensorShape(21U, 12U), TensorShape(21U, 12U), 0.2f, 1.2f }, + GEMMDataObject{ TensorShape(32U, 1U), TensorShape(17U, 32U), TensorShape(17U, 1U), TensorShape(17U, 1U), 0.4f, 0.7f }, + } + { + } + + ~SmallGEMMDataset() = default; +}; + +class LargeGEMMDataset : public GenericDataset +{ +public: + LargeGEMMDataset() + : GenericDataset + { + GEMMDataObject{ TensorShape(923U, 429U), TensorShape(871U, 923U), TensorShape(871U, 429U), TensorShape(871U, 429U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1021U, 1U), TensorShape(783U, 1021U), TensorShape(783U, 1U), TensorShape(783U, 1U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(681U, 1023U), TensorShape(213U, 681U), TensorShape(213U, 1023U), TensorShape(213U, 1023U), 0.2f, 1.2f }, + GEMMDataObject{ TensorShape(941U, 1U), TensorShape(623U, 941U), TensorShape(623U, 1U), TensorShape(623U, 1U), 0.4f, 0.7f }, + } + { + } + + ~LargeGEMMDataset() = default; +}; + +class GoogLeNetGEMMDataset1 : public GenericDataset +{ +public: + GoogLeNetGEMMDataset1() + : GenericDataset + { + GEMMDataObject{ TensorShape(147U, 12544U), TensorShape(64U, 147U), TensorShape(64U, 12544U), TensorShape(64U, 12544U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(64U, 3136U), TensorShape(64U, 64U), TensorShape(64U, 3136U), TensorShape(64U, 3136U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(576U, 3136U), TensorShape(192U, 576U), TensorShape(192U, 3136U), TensorShape(192U, 3136U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(192U, 784U), TensorShape(64U, 192U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(192U, 784U), TensorShape(96U, 192U), TensorShape(96U, 784U), TensorShape(96U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(864U, 784U), TensorShape(128U, 864U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(192U, 784U), TensorShape(16U, 192U), TensorShape(16U, 784U), TensorShape(16U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(400U, 784U), TensorShape(32U, 400U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(192U, 784U), TensorShape(32U, 192U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(256U, 784U), TensorShape(128U, 256U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(256U, 784U), TensorShape(128U, 256U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1152U, 784U), TensorShape(192U, 1152U), TensorShape(192U, 784U), TensorShape(192U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(256U, 784U), TensorShape(32U, 256U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(800U, 784U), TensorShape(96U, 800U), TensorShape(96U, 784U), TensorShape(96U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(256U, 784U), TensorShape(64U, 256U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(480U, 196U), TensorShape(192U, 480U), TensorShape(192U, 196U), TensorShape(192U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(480U, 196U), TensorShape(96U, 480U), TensorShape(96U, 196U), TensorShape(96U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(864U, 196U), TensorShape(204U, 864U), TensorShape(204U, 196U), TensorShape(204U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(480U, 196U), TensorShape(16U, 480U), TensorShape(16U, 196U), TensorShape(16U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(400U, 196U), TensorShape(48U, 400U), TensorShape(48U, 196U), TensorShape(48U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(480U, 196U), TensorShape(64U, 480U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(508U, 196U), TensorShape(160U, 508U), TensorShape(160U, 196U), TensorShape(160U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(508U, 196U), TensorShape(112U, 508U), TensorShape(112U, 196U), TensorShape(112U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1008U, 196U), TensorShape(224U, 1008U), TensorShape(224U, 196U), TensorShape(224U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(508U, 196U), TensorShape(24U, 508U), TensorShape(24U, 196U), TensorShape(24U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(600U, 196U), TensorShape(64U, 600U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(508U, 196U), TensorShape(64U, 508U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(512U, 196U), TensorShape(128U, 512U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(512U, 196U), TensorShape(128U, 512U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1152U, 196U), TensorShape(256U, 1152U), TensorShape(256U, 196U), TensorShape(256U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(512U, 196U), TensorShape(24U, 512U), TensorShape(24U, 196U), TensorShape(24U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(600U, 196U), TensorShape(64U, 600U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f } + } + { + } + + ~GoogLeNetGEMMDataset1() = default; +}; + +class GoogLeNetGEMMDataset2 : public GenericDataset +{ +public: + GoogLeNetGEMMDataset2() + : GenericDataset + { + GEMMDataObject{ TensorShape(512U, 196U), TensorShape(64U, 512U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(512U, 196U), TensorShape(112U, 512U), TensorShape(112U, 196U), TensorShape(112U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(512U, 196U), TensorShape(144U, 512U), TensorShape(144U, 196U), TensorShape(144U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1296U, 196U), TensorShape(288U, 1296U), TensorShape(288U, 196U), TensorShape(288U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(512U, 196U), TensorShape(32U, 512U), TensorShape(32U, 196U), TensorShape(32U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(800U, 196U), TensorShape(64U, 800U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(512U, 196U), TensorShape(64U, 512U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(528U, 196U), TensorShape(256U, 528U), TensorShape(256U, 196U), TensorShape(256U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(528U, 196U), TensorShape(160U, 528U), TensorShape(160U, 196U), TensorShape(160U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1440U, 196U), TensorShape(320U, 1440U), TensorShape(320U, 196U), TensorShape(320U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(528U, 196U), TensorShape(32U, 528U), TensorShape(32U, 196U), TensorShape(32U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(800U, 196U), TensorShape(128U, 800U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(528U, 196U), TensorShape(128U, 528U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(832U, 49U), TensorShape(256U, 832U), TensorShape(256U, 49U), TensorShape(256U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(832U, 49U), TensorShape(160U, 832U), TensorShape(160U, 49U), TensorShape(160U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1440U, 49U), TensorShape(320U, 1440U), TensorShape(320U, 49U), TensorShape(320U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(832U, 49U), TensorShape(48U, 832U), TensorShape(48U, 49U), TensorShape(48U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1200U, 49U), TensorShape(128U, 1200U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(832U, 49U), TensorShape(128U, 832U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(832U, 49U), TensorShape(384U, 832U), TensorShape(384U, 49U), TensorShape(384U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(832U, 49U), TensorShape(192U, 832U), TensorShape(192U, 49U), TensorShape(192U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1728U, 49U), TensorShape(384U, 1728U), TensorShape(384U, 49U), TensorShape(384U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(832U, 49U), TensorShape(48U, 832U), TensorShape(48U, 49U), TensorShape(48U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1200U, 49U), TensorShape(128U, 1200U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(832U, 49U), TensorShape(128U, 832U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(508U, 16U), TensorShape(128U, 508U), TensorShape(128U, 16U), TensorShape(128U, 16U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(2048U, 1U), TensorShape(1024U, 2048U), TensorShape(1024U, 1U), TensorShape(1024U, 1U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(528U, 16U), TensorShape(128U, 528U), TensorShape(128U, 16U), TensorShape(128U, 16U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(2048U, 1U), TensorShape(1024U, 2048U), TensorShape(1024U, 1U), TensorShape(1024U, 1U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f } + } + { + } + + ~GoogLeNetGEMMDataset2() = default; +}; + +class MatrixMultiplyDataset : public GenericDataset +{ +public: + MatrixMultiplyDataset() + : GenericDataset + { + GEMMDataObject{ TensorShape(1024U, 1U), TensorShape(1000U, 1024U), TensorShape(1000U, 1U), TensorShape(1000U, 1U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(256U, 784U), TensorShape(64U, 256U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1152U, 2704U), TensorShape(256U, 1152U), TensorShape(256U, 2704U), TensorShape(256U, 2704U), 1.0f, 0.0f }, + } + { + } + + ~MatrixMultiplyDataset() = default; +}; +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_DATASET_GEMM_DATASET_H__ diff --git a/tests/validation_old/dataset/GenericDataset.h b/tests/validation_old/dataset/GenericDataset.h new file mode 100644 index 0000000000..d2c9f2db34 --- /dev/null +++ b/tests/validation_old/dataset/GenericDataset.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_GENERIC_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_GENERIC_DATASET_H__ + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +#include + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +/** Abstract data set containing multiple objects T. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on different configurations. + */ +template +class GenericDataset +{ +public: + /** Type of the samples in the data set. */ + using sample = T; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else /* BOOST */ + unsigned int size() const +#endif /* BOOST */ + { + return _data.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const T *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _data.data(); + } + +protected: + /** Protected constructor to make the class abstract. */ + template + GenericDataset(Ts... objs) + : _data{ { objs... } } + { + } + + /** Protected destructor to prevent deletion of derived class through a + * pointer to the base class. + */ + ~GenericDataset() = default; + +private: + std::array _data; +}; +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_DATASET_GENERIC_DATASET_H__ */ diff --git a/tests/validation_old/dataset/ImageDatasets.h b/tests/validation_old/dataset/ImageDatasets.h new file mode 100644 index 0000000000..7fcd067e1b --- /dev/null +++ b/tests/validation_old/dataset/ImageDatasets.h @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_IMAGE_DATASETS_H__ +#define __ARM_COMPUTE_TEST_IMAGE_DATASETS_H__ + +#include +#include + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +/** Abstract data set containing image names. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on different images. + */ +template +class ImageDataset +{ +public: + /** Type of the samples in the data set. */ + using sample = const std::string; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else /* BOOST */ + unsigned int size() const +#endif /* BOOST */ + { + return _images.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const std::string *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _images.data(); + } + +protected: + /** Protected constructor to make the class abstract. */ + template + ImageDataset(Ts... images) + : _images{ { images... } } + { + } + + /** Protected destructor to prevent deletion of derived class through a + * pointer to the base class. + */ + ~ImageDataset() = default; + +private: + std::array _images; +}; + +/** Data set containing names of small images. */ +class SmallImages final : public ImageDataset<2> +{ +public: + SmallImages() + : ImageDataset("128x128.ppm", "640x480.ppm") + { + } +}; + +/** Data set containing names of large images. */ +class LargeImages final : public ImageDataset<3> +{ +public: + LargeImages() +#ifdef INTERNAL_ONLY + : ImageDataset("1280x720.ppm", "1920x1080.ppm", "4160x3120.ppm") + // The 4k image is too large to distribute +#else /* INTERNAL_ONLY */ + : ImageDataset("1280x720.ppm", "1920x1080.ppm") +#endif /* INTERNAL_ONLY */ + { + } +}; +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_IMAGE_DATASETS_H__ */ diff --git a/tests/validation_old/dataset/InterpolationPolicyDataset.h b/tests/validation_old/dataset/InterpolationPolicyDataset.h new file mode 100644 index 0000000000..64cc9bf239 --- /dev/null +++ b/tests/validation_old/dataset/InterpolationPolicyDataset.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_INTERPOLATION_POLICY_DATASET_H__ +#define __ARM_COMPUTE_TEST_INTERPOLATION_POLICY_DATASET_H__ + +#include "arm_compute/core/Types.h" + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +/** Data set containing all possible interpolation policies. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on all interpolation policies. + */ +class InterpolationPolicies +{ +public: + /** Type of the samples in the data set. */ + using sample = InterpolationPolicy; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else /* BOOST */ + unsigned int size() const +#endif /* BOOST */ + { + return _policies.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const InterpolationPolicy *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _policies.data(); + } + +private: + std::array _policies{ { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR, InterpolationPolicy::AREA } }; +}; +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_INTERPOLATION_POLICY_DATASET_H__ */ diff --git a/tests/validation_old/dataset/MatrixPatternDataset.h b/tests/validation_old/dataset/MatrixPatternDataset.h new file mode 100644 index 0000000000..7d7d365d91 --- /dev/null +++ b/tests/validation_old/dataset/MatrixPatternDataset.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_MATRIX_PATTERN_DATASET_H__ +#define __ARM_COMPUTE_TEST_MATRIX_PATTERN_DATASET_H__ + +#include "arm_compute/core/Types.h" + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +#include + +namespace arm_compute +{ +namespace test +{ +/** Data set containing all possible border modes. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on all border modes. + */ +class MatrixPatterns +{ +public: + /** Type of the samples in the data set. */ + using sample = MatrixPattern; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else /* BOOST */ + unsigned int size() const +#endif /* BOOST */ + { + return _patterns.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const MatrixPattern *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _patterns.data(); + } + +private: + std::array _patterns{ { MatrixPattern::BOX, MatrixPattern::CROSS, MatrixPattern::DISK, MatrixPattern::OTHER } }; +}; +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_MATRIX_PATTERN_DATASET_H__ */ diff --git a/tests/validation_old/dataset/NonLinearFilterFunctionDataset.h b/tests/validation_old/dataset/NonLinearFilterFunctionDataset.h new file mode 100644 index 0000000000..c961c84866 --- /dev/null +++ b/tests/validation_old/dataset/NonLinearFilterFunctionDataset.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_NON_LINEAR_FILTER_FUNCTION_DATASET_H__ +#define __ARM_COMPUTE_TEST_NON_LINEAR_FILTER_FUNCTION_DATASET_H__ + +#include "arm_compute/core/Types.h" + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +#include + +namespace arm_compute +{ +namespace test +{ +/** Data set containing all possible non linear filter function. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on all border modes. + */ +class NonLinearFilterFunctions +{ +public: + /** Type of the samples in the data set. */ + using sample = NonLinearFilterFunction; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else /* BOOST */ + unsigned int size() const +#endif /* BOOST */ + { + return _functions.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const NonLinearFilterFunction *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _functions.data(); + } + +private: + std::array _functions{ { NonLinearFilterFunction::MAX, NonLinearFilterFunction::MEDIAN, NonLinearFilterFunction::MIN } }; +}; +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_NON_LINEAR_FILTER_FUNCTION_DATASET_H__ */ diff --git a/tests/validation_old/dataset/NormalizationLayerDataset.h b/tests/validation_old/dataset/NormalizationLayerDataset.h new file mode 100644 index 0000000000..cd3c14d948 --- /dev/null +++ b/tests/validation_old/dataset/NormalizationLayerDataset.h @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_NORMALIZATION_LAYER_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_NORMALIZATION_LAYER_DATASET_H__ + +#include "TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/validation_old/dataset/GenericDataset.h" + +#include +#include + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +class NormalizationLayerDataObject +{ +public: + operator std::string() const + { + std::stringstream ss; + ss << "NormalizationLayer"; + ss << "_I" << shape; + ss << "_F_" << info.type(); + ss << "_S_" << info.norm_size(); + return ss.str(); + } + +public: + TensorShape shape; + NormalizationLayerInfo info; +}; + +template +using NormalizationLayerDataset = GenericDataset; + +class GoogLeNetNormalizationLayerDataset final : public NormalizationLayerDataset<2> +{ +public: + GoogLeNetNormalizationLayerDataset() + : GenericDataset + { + // conv2/norm2 + NormalizationLayerDataObject{ TensorShape(56U, 56U, 192U), NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f) }, + // pool1/norm1 + NormalizationLayerDataObject{ TensorShape(56U, 56U, 64U), NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f) } + } + { + } + + ~GoogLeNetNormalizationLayerDataset() = default; +}; + +class AlexNetNormalizationLayerDataset final : public NormalizationLayerDataset<2> +{ +public: + AlexNetNormalizationLayerDataset() + : GenericDataset + { + NormalizationLayerDataObject{ TensorShape(55U, 55U, 96U), NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f) }, + NormalizationLayerDataObject{ TensorShape(27U, 27U, 256U), NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f) }, + } + { + } + + ~AlexNetNormalizationLayerDataset() = default; +}; + +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_DATASET_NORMALIZATION_LAYER_DATASET_H__ */ diff --git a/tests/validation_old/dataset/NormalizationTypeDataset.h b/tests/validation_old/dataset/NormalizationTypeDataset.h new file mode 100644 index 0000000000..2a89dbea30 --- /dev/null +++ b/tests/validation_old/dataset/NormalizationTypeDataset.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_NORMALIZATION_TYPE_DATASET_H__ +#define __ARM_COMPUTE_TEST_NORMALIZATION_TYPE_DATASET_H__ + +#include "arm_compute/core/Types.h" + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +/** Data set containing all possible normalization types. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on all normalization types. + */ +class NormalizationTypes +{ +public: + /** Type of the samples in the data set. */ + using sample = NormType; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else /* BOOST */ + unsigned int size() const +#endif /* BOOST */ + { + return _types.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const NormType *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _types.data(); + } + +private: + const std::array _types{ { NormType::IN_MAP_1D, NormType::IN_MAP_2D, NormType::CROSS_MAP } }; +}; +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_NORMALIZATION_TYPE_DATASET_H__ */ diff --git a/tests/validation_old/dataset/PoolingLayerDataset.h b/tests/validation_old/dataset/PoolingLayerDataset.h new file mode 100644 index 0000000000..6895ae4fae --- /dev/null +++ b/tests/validation_old/dataset/PoolingLayerDataset.h @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_POOLING_LAYER_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_POOLING_LAYER_DATASET_H__ + +#include "TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/validation_old/dataset/GenericDataset.h" + +#include + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +class PoolingLayerDataObject +{ +public: + operator std::string() const + { + std::stringstream ss; + ss << "PoolingLayer"; + ss << "_I" << src_shape; + ss << "_S_" << info.pool_size(); + ss << "_F_" << info.pool_type(); + ss << "_PS" << info.pad_stride_info(); + return ss.str(); + } + + friend std::ostream &operator<<(std::ostream &s, const PoolingLayerDataObject &obj) + { + s << static_cast(obj); + return s; + } + +public: + TensorShape src_shape; + TensorShape dst_shape; + PoolingLayerInfo info; +}; + +template +using PoolingLayerDataset = GenericDataset; + +class AlexNetPoolingLayerDataset final : public PoolingLayerDataset<3> +{ +public: + AlexNetPoolingLayerDataset() + : GenericDataset + { + PoolingLayerDataObject{ TensorShape(55U, 55U, 96U), TensorShape(27U, 27U, 96U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) }, + PoolingLayerDataObject{ TensorShape(27U, 27U, 256U), TensorShape(13U, 13U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) }, + PoolingLayerDataObject{ TensorShape(13U, 13U, 256U), TensorShape(6U, 6U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) }, + } + { + } + + ~AlexNetPoolingLayerDataset() = default; +}; + +class LeNet5PoolingLayerDataset final : public PoolingLayerDataset<2> +{ +public: + LeNet5PoolingLayerDataset() + : GenericDataset + { + PoolingLayerDataObject{ TensorShape(24U, 24U, 20U), TensorShape(12U, 12U, 20U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0)) }, + PoolingLayerDataObject{ TensorShape(8U, 8U, 50U), TensorShape(4U, 4U, 50U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0)) }, + } + { + } + + ~LeNet5PoolingLayerDataset() = default; +}; + +class GoogLeNetPoolingLayerDataset final : public PoolingLayerDataset<10> +{ +public: + GoogLeNetPoolingLayerDataset() + : GenericDataset + { + // FIXME: Add support for 7x7 pooling layer pool5/7x7_s1 + // pool1/3x3_s2 + PoolingLayerDataObject{ TensorShape(112U, 112U, 64U), TensorShape(56U, 56U, 64U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) }, + // pool2/3x3_s2 + PoolingLayerDataObject{ TensorShape(56U, 56U, 192U), TensorShape(28U, 28U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) }, + // inception_3a/pool + PoolingLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(28U, 28U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, + // inception_3b/pool + PoolingLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(28U, 28U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, + // pool3/3x3_s2 + PoolingLayerDataObject{ TensorShape(28U, 28U, 480U), TensorShape(14U, 14U, 480U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) }, + // inception_4a/pool + PoolingLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(14U, 14U, 480U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, + // inception_4b/pool, inception_4c/pool, inception_4d/pool + PoolingLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(14U, 14U, 512U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, + // inception_4e/pool + PoolingLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(14U, 14U, 528U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, + // pool4/3x3_s2 + PoolingLayerDataObject{ TensorShape(14U, 14U, 832U), TensorShape(7U, 7U, 832U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) }, + // inception_5a/pool, inception_5b/pool + PoolingLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(7U, 7U, 832U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, + } + { + } + + ~GoogLeNetPoolingLayerDataset() = default; +}; +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_DATASET_POOLING_LAYER_DATASET_H__ diff --git a/tests/validation_old/dataset/PoolingTypesDataset.h b/tests/validation_old/dataset/PoolingTypesDataset.h new file mode 100644 index 0000000000..a826df35ce --- /dev/null +++ b/tests/validation_old/dataset/PoolingTypesDataset.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_POOLING_TYPE_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_POOLING_TYPE_DATASET_H__ + +#include "arm_compute/core/Types.h" +#include "tests/validation_old/dataset/GenericDataset.h" + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +/** Data set containing all possible pooling types. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on all pooling types. + */ +class PoolingTypes final : public GenericDataset +{ +public: + PoolingTypes() + : GenericDataset{ PoolingType::MAX, PoolingType::AVG } + { + } + + ~PoolingTypes() = default; +}; +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_DATASET_POOLING_TYPE_DATASET_H__ diff --git a/tests/validation_old/dataset/RoundingPolicyDataset.h b/tests/validation_old/dataset/RoundingPolicyDataset.h new file mode 100644 index 0000000000..af946b41bd --- /dev/null +++ b/tests/validation_old/dataset/RoundingPolicyDataset.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_ROUNDING_POLICY_DATASETS_H__ +#define __ARM_COMPUTE_TEST_ROUNDING_POLICY_DATASETS_H__ + +#include "arm_compute/core/Types.h" + +#include + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +/** Data set containing all possible rounding policies. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on different rounding policies. + */ +class RoundingPolicies +{ +public: + /** Type of the samples in the data set. */ + using sample = RoundingPolicy; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else /* BOOST */ + unsigned int size() const +#endif /* BOOST */ + { + return _policies.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const RoundingPolicy *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _policies.data(); + } + +private: + std::array _policies{ { RoundingPolicy::TO_ZERO, RoundingPolicy::TO_NEAREST_UP, RoundingPolicy::TO_NEAREST_EVEN } }; +}; +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_ROUNDING_POLICY_DATASETS_H__ */ diff --git a/tests/validation_old/dataset/ShapeDatasets.h b/tests/validation_old/dataset/ShapeDatasets.h new file mode 100644 index 0000000000..3c986ab7ae --- /dev/null +++ b/tests/validation_old/dataset/ShapeDatasets.h @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ +#define __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ + +#include "arm_compute/core/TensorShape.h" + +#include + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +/** Abstract data set containing tensor shapes. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on different tensor shapes. + */ +template +class ShapeDataset +{ +public: + /** Type of the samples in the data set. */ + using sample = TensorShape; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else /* BOOST */ + unsigned int size() const +#endif /* BOOST */ + { + return _shapes.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const TensorShape *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _shapes.data(); + } + +protected: + /** Protected constructor to make the class abstract. */ + template + ShapeDataset(Ts... shapes) + : _shapes{ { shapes... } } + { + } + + /** Protected destructor to prevent deletion of derived class through a + * pointer to the base class. + */ + ~ShapeDataset() = default; + +private: + std::array _shapes; +}; + +/** Data set containing one 1D tensor shape. */ +class Small1DShape final : public ShapeDataset<1> +{ +public: + Small1DShape() + : ShapeDataset(TensorShape(256U)) + { + } +}; + +/** Data set containing two small 2D tensor shapes. */ +class Small2DShapes final : public ShapeDataset<2> +{ +public: + Small2DShapes() + : ShapeDataset(TensorShape(17U, 17U), + TensorShape(640U, 480U)) + { + } +}; + +/** Data set containing small tensor shapes. */ +class SmallShapes final : public ShapeDataset<3> +{ +public: + SmallShapes() + : ShapeDataset(TensorShape(7U, 7U), + TensorShape(27U, 13U, 2U), + TensorShape(128U, 64U, 1U, 3U)) + { + } +}; + +/** Data set containing large tensor shapes. */ +class LargeShapes final : public ShapeDataset<3> +{ +public: + LargeShapes() + : ShapeDataset(TensorShape(1920U, 1080U), + TensorShape(1245U, 652U, 1U, 3U), + TensorShape(4160U, 3120U)) + { + } +}; + +/** Data set containing two 2D large tensor shapes. */ +class Large2DShapes final : public ShapeDataset<2> +{ +public: + Large2DShapes() + : ShapeDataset(TensorShape(1920U, 1080U), + TensorShape(4160U, 3120U)) + { + } +}; +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ */ diff --git a/tests/validation_old/dataset/ThresholdDataset.h b/tests/validation_old/dataset/ThresholdDataset.h new file mode 100644 index 0000000000..74d0b9cfbe --- /dev/null +++ b/tests/validation_old/dataset/ThresholdDataset.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_THRESHOLD_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_THRESHOLD_DATASET_H__ + +#include "TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/validation_old/dataset/GenericDataset.h" + +#include +#include + +#include +#include + +#ifdef BOOST +#include "tests/validation_old/boost_wrapper.h" +#endif /* BOOST */ + +namespace arm_compute +{ +namespace test +{ +class ThresholdDataObject +{ +public: + uint8_t threshold; + uint8_t false_value; + uint8_t true_value; + ThresholdType type; + uint8_t upper; + + operator std::string() const + { + std::stringstream ss; + ss << "Threshold"; + ss << "_threshold_value" << threshold; + ss << "_false_value" << std::boolalpha << false_value; + ss << "_true_value" << std::boolalpha << true_value; + ss << "_type"; + ss << ((type == ThresholdType::BINARY) ? "binary" : "range"); + ss << "_upper" << upper; + return ss.str(); + } + + friend std::ostream &operator<<(std::ostream &os, const ThresholdDataObject &obj) + { + os << static_cast(obj); + return os; + } +}; + +class ThresholdDataset : public GenericDataset +{ +public: + ThresholdDataset() + : GenericDataset + { + ThresholdDataObject{ 10U, 25U, 3U, ThresholdType::BINARY, 0U }, + ThresholdDataObject{ 20U, 1U, 0U, ThresholdType::BINARY, 0U }, + ThresholdDataObject{ 30U, 1U, 0U, ThresholdType::RANGE, 100U }, + ThresholdDataObject{ 100U, 1U, 0U, ThresholdType::RANGE, 200U }, + } + { + } + + ~ThresholdDataset() = default; +}; + +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_DATASET_THRESHOLD_DATASET_H__ */ diff --git a/tests/validation_old/half.h b/tests/validation_old/half.h new file mode 100644 index 0000000000..d8aa341068 --- /dev/null +++ b/tests/validation_old/half.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_HALF_H__ +#define __ARM_COMPUTE_TEST_HALF_H__ + +#ifdef __ANDROID__ +// Android toolchain is broken and doesn't support all CPP11 math functions. +#define HALF_ENABLE_CPP11_CMATH 0 +#endif /* __ANDROID__ */ + +// Set style to round to nearest +#define HALF_ROUND_STYLE 1 +#define HALF_ROUND_TIES_TO_EVEN 1 + +#include "half/half.hpp" +#endif /* __ARM_COMPUTE_TEST_HALF_H__ */ diff --git a/tests/validation_old/main.cpp b/tests/validation_old/main.cpp new file mode 100644 index 0000000000..9f15c3a7bc --- /dev/null +++ b/tests/validation_old/main.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#define BOOST_TEST_ALTERNATIVE_INIT_API + +#include "Utils.h" +#include "ValidationProgramOptions.h" +#include "ValidationUserConfiguration.h" +#include "support/ToolchainSupport.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" + +#include "arm_compute/runtime/Scheduler.h" + +#include "tests/validation_old/boost_wrapper.h" + +#include +#include +#include + +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace arm_compute +{ +namespace test +{ +ValidationUserConfiguration user_config; +std::unique_ptr library; +} // namespace test +} // namespace arm_compute + +struct GlobalFixture +{ + GlobalFixture() + { + library = arm_compute::support::cpp14::make_unique(user_config.path.get(), user_config.seed); + std::cout << "Seed: " << library->seed() << "\n"; + } +}; + +BOOST_GLOBAL_FIXTURE(GlobalFixture); + +bool init_unit_test() +{ + boost::unit_test::framework::master_test_suite().p_name.value = "Compute Library Validation Tests"; + + ValidationProgramOptions options; + + int &argc = boost::unit_test::framework::master_test_suite().argc; + char **argv = boost::unit_test::framework::master_test_suite().argv; + + try + { + options.parse_commandline(argc, argv); + + if(options.wants_help()) + { + std::cout << "Usage: " << argv[0] << " [options] PATH\n"; + std::cout << options.get_help() << "\n"; + return false; + } + + user_config = ValidationUserConfiguration(options); + } + catch(const boost::program_options::required_option &err) + { + std::cerr << "Error: " << err.what() << "\n"; + std::cout << "\nUsage: " << argv[0] << " [options] PATH\n"; + std::cout << options.get_help() << "\n"; + return false; + } + + std::cout << "Using " << user_config.threads << " CPU " << (user_config.threads == 1 ? "thread" : "threads") << "\n"; + arm_compute::Scheduler::get().set_num_threads(user_config.threads); + return true; +} diff --git a/tests/validation_old/model_objects/AlexNet.h b/tests/validation_old/model_objects/AlexNet.h new file mode 100644 index 0000000000..45622e2118 --- /dev/null +++ b/tests/validation_old/model_objects/AlexNet.h @@ -0,0 +1,585 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_MODEL_OBJECTS_ALEXNET_H__ +#define __ARM_COMPUTE_TEST_MODEL_OBJECTS_ALEXNET_H__ + +#include "arm_compute/runtime/Tensor.h" + +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/Utils.h" + +#include + +using namespace arm_compute; +using namespace arm_compute::test; + +namespace arm_compute +{ +namespace test +{ +namespace model_objects +{ +/** AlexNet model object */ +template +class AlexNet +{ +public: + AlexNet() + : _batches(1), _reshaped_weights(false) + { + } + + void init_weights(unsigned int batches, bool reshaped_weights = false) + { + _batches = batches; + _reshaped_weights = reshaped_weights; + + // Initialize weights and biases + if(!_reshaped_weights) + { + for(auto &wi : w) + { + wi = std::unique_ptr(new TensorType()); + } + for(auto &bi : b) + { + bi = std::unique_ptr(new TensorType()); + } + w[0]->allocator()->init(TensorInfo(TensorShape(11U, 11U, 3U, 96U), 1, dt, fixed_point_position)); + b[0]->allocator()->init(TensorInfo(TensorShape(96U), 1, dt, fixed_point_position)); + w[1]->allocator()->init(TensorInfo(TensorShape(5U, 5U, 48U, 256U), 1, dt, fixed_point_position)); + b[1]->allocator()->init(TensorInfo(TensorShape(256U), 1, dt, fixed_point_position)); + w[2]->allocator()->init(TensorInfo(TensorShape(3U, 3U, 256U, 384U), 1, dt, fixed_point_position)); + b[2]->allocator()->init(TensorInfo(TensorShape(384U), 1, dt, fixed_point_position)); + w[3]->allocator()->init(TensorInfo(TensorShape(3U, 3U, 192U, 384U), 1, dt, fixed_point_position)); + b[3]->allocator()->init(TensorInfo(TensorShape(384U), 1, dt, fixed_point_position)); + w[4]->allocator()->init(TensorInfo(TensorShape(3U, 3U, 192U, 256U), 1, dt, fixed_point_position)); + b[4]->allocator()->init(TensorInfo(TensorShape(256U), 1, dt, fixed_point_position)); + w[5]->allocator()->init(TensorInfo(TensorShape(9216U, 4096U), 1, dt, fixed_point_position)); + b[5]->allocator()->init(TensorInfo(TensorShape(4096U), 1, dt, fixed_point_position)); + w[6]->allocator()->init(TensorInfo(TensorShape(4096U, 4096U), 1, dt, fixed_point_position)); + b[6]->allocator()->init(TensorInfo(TensorShape(4096U), 1, dt, fixed_point_position)); + w[7]->allocator()->init(TensorInfo(TensorShape(4096U, 1000U), 1, dt, fixed_point_position)); + b[7]->allocator()->init(TensorInfo(TensorShape(1000U), 1, dt, fixed_point_position)); + + w21 = std::unique_ptr(new SubTensorType(w[1].get(), TensorShape(5U, 5U, 48U, 128U), Coordinates())); + w22 = std::unique_ptr(new SubTensorType(w[1].get(), TensorShape(5U, 5U, 48U, 128U), Coordinates(0, 0, 0, 128))); + b21 = std::unique_ptr(new SubTensorType(b[1].get(), TensorShape(128U), Coordinates())); + b22 = std::unique_ptr(new SubTensorType(b[1].get(), TensorShape(128U), Coordinates(128))); + + w41 = std::unique_ptr(new SubTensorType(w[3].get(), TensorShape(3U, 3U, 192U, 192U), Coordinates())); + w42 = std::unique_ptr(new SubTensorType(w[3].get(), TensorShape(3U, 3U, 192U, 192U), Coordinates(0, 0, 0, 192))); + b41 = std::unique_ptr(new SubTensorType(b[3].get(), TensorShape(192U), Coordinates())); + b42 = std::unique_ptr(new SubTensorType(b[3].get(), TensorShape(192U), Coordinates(192))); + + w51 = std::unique_ptr(new SubTensorType(w[4].get(), TensorShape(3U, 3U, 192U, 128U), Coordinates())); + w52 = std::unique_ptr(new SubTensorType(w[4].get(), TensorShape(3U, 3U, 192U, 128U), Coordinates(0, 0, 0, 128))); + b51 = std::unique_ptr(new SubTensorType(b[4].get(), TensorShape(128U), Coordinates())); + b52 = std::unique_ptr(new SubTensorType(b[4].get(), TensorShape(128U), Coordinates(128))); + } + else + { + const unsigned int dt_size = 16 / arm_compute::data_size_from_type(dt); + + // Create tensor for the reshaped weights + w[0] = std::unique_ptr(new TensorType()); + auto w21_tensor = std::unique_ptr(new TensorType()); + auto w22_tensor = std::unique_ptr(new TensorType()); + w[2] = std::unique_ptr(new TensorType()); + auto w41_tensor = std::unique_ptr(new TensorType()); + auto w42_tensor = std::unique_ptr(new TensorType()); + auto w51_tensor = std::unique_ptr(new TensorType()); + auto w52_tensor = std::unique_ptr(new TensorType()); + + w[0]->allocator()->init(TensorInfo(TensorShape(366U * dt_size, 96U / dt_size), 1, dt, fixed_point_position)); + w21_tensor->allocator()->init(TensorInfo(TensorShape(1248U * dt_size, 128U / dt_size), 1, dt, fixed_point_position)); + w22_tensor->allocator()->init(TensorInfo(TensorShape(1248U * dt_size, 128U / dt_size), 1, dt, fixed_point_position)); + w[2]->allocator()->init(TensorInfo(TensorShape(2560U * dt_size, 384U / dt_size), 1, dt, fixed_point_position)); + w41_tensor->allocator()->init(TensorInfo(TensorShape(1920U * dt_size, 192U / dt_size), 1, dt, fixed_point_position)); + w42_tensor->allocator()->init(TensorInfo(TensorShape(1920U * dt_size, 192U / dt_size), 1, dt, fixed_point_position)); + w51_tensor->allocator()->init(TensorInfo(TensorShape(1920U * dt_size, 128U / dt_size), 1, dt, fixed_point_position)); + w52_tensor->allocator()->init(TensorInfo(TensorShape(1920U * dt_size, 128U / dt_size), 1, dt, fixed_point_position)); + + w21 = std::move(w21_tensor); + w22 = std::move(w22_tensor); + w41 = std::move(w41_tensor); + w42 = std::move(w42_tensor); + w51 = std::move(w51_tensor); + w52 = std::move(w52_tensor); + + w[5] = std::unique_ptr(new TensorType()); + w[6] = std::unique_ptr(new TensorType()); + w[7] = std::unique_ptr(new TensorType()); + b[5] = std::unique_ptr(new TensorType()); + b[6] = std::unique_ptr(new TensorType()); + b[7] = std::unique_ptr(new TensorType()); + + b[5]->allocator()->init(TensorInfo(TensorShape(4096U), 1, dt, fixed_point_position)); + b[6]->allocator()->init(TensorInfo(TensorShape(4096U), 1, dt, fixed_point_position)); + b[7]->allocator()->init(TensorInfo(TensorShape(1000U), 1, dt, fixed_point_position)); + + if(_batches > 1 && std::is_same::value) + { + w[5]->allocator()->init(TensorInfo(TensorShape(9216U * dt_size, 4096U / dt_size), 1, dt, fixed_point_position)); + w[6]->allocator()->init(TensorInfo(TensorShape(4096U * dt_size, 4096U / dt_size), 1, dt, fixed_point_position)); + w[7]->allocator()->init(TensorInfo(TensorShape(4096U * dt_size, 1000U / dt_size), 1, dt, fixed_point_position)); + } + else + { + w[5]->allocator()->init(TensorInfo(TensorShape(4096U, 9216U), 1, dt, fixed_point_position)); + w[6]->allocator()->init(TensorInfo(TensorShape(4096U, 4096U), 1, dt, fixed_point_position)); + w[7]->allocator()->init(TensorInfo(TensorShape(1000U, 4096U), 1, dt, fixed_point_position)); + } + } + } + + void build() + { + input.allocator()->init(TensorInfo(TensorShape(227U, 227U, 3U, _batches), 1, dt, fixed_point_position)); + output.allocator()->init(TensorInfo(TensorShape(1000U, _batches), 1, dt, fixed_point_position)); + + // Initialize intermediate tensors + // Layer 1 + conv1_out.allocator()->init(TensorInfo(TensorShape(55U, 55U, 96U, _batches), 1, dt, fixed_point_position)); + act1_out.allocator()->init(TensorInfo(TensorShape(55U, 55U, 96U, _batches), 1, dt, fixed_point_position)); + norm1_out.allocator()->init(TensorInfo(TensorShape(55U, 55U, 96U, _batches), 1, dt, fixed_point_position)); + pool1_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 96U, _batches), 1, dt, fixed_point_position)); + pool11_out = std::unique_ptr(new SubTensorType(&pool1_out, TensorShape(27U, 27U, 48U, _batches), Coordinates())); + pool12_out = std::unique_ptr(new SubTensorType(&pool1_out, TensorShape(27U, 27U, 48U, _batches), Coordinates(0, 0, 48))); + // Layer 2 + conv2_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 256U, _batches), 1, dt, fixed_point_position)); + conv21_out = std::unique_ptr(new SubTensorType(&conv2_out, TensorShape(27U, 27U, 128U, _batches), Coordinates())); + conv22_out = std::unique_ptr(new SubTensorType(&conv2_out, TensorShape(27U, 27U, 128U, _batches), Coordinates(0, 0, 128))); + act2_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 256U, _batches), 1, dt, fixed_point_position)); + norm2_out.allocator()->init(TensorInfo(TensorShape(27U, 27U, 256U, _batches), 1, dt, fixed_point_position)); + pool2_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 256U, _batches), 1, dt, fixed_point_position)); + // Layer 3 + conv3_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, dt, fixed_point_position)); + act3_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, dt, fixed_point_position)); + act31_out = std::unique_ptr(new SubTensorType(&act3_out, TensorShape(13U, 13U, 192U, _batches), Coordinates())); + act32_out = std::unique_ptr(new SubTensorType(&act3_out, TensorShape(13U, 13U, 192U, _batches), Coordinates(0, 0, 192))); + // Layer 4 + conv4_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, dt, fixed_point_position)); + conv41_out = std::unique_ptr(new SubTensorType(&conv4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates())); + conv42_out = std::unique_ptr(new SubTensorType(&conv4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates(0, 0, 192))); + act4_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 384U, _batches), 1, dt, fixed_point_position)); + act41_out = std::unique_ptr(new SubTensorType(&act4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates())); + act42_out = std::unique_ptr(new SubTensorType(&act4_out, TensorShape(13U, 13U, 192U, _batches), Coordinates(0, 0, 192))); + // Layer 5 + conv5_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 256U, _batches), 1, dt, fixed_point_position)); + conv51_out = std::unique_ptr(new SubTensorType(&conv5_out, TensorShape(13U, 13U, 128U, _batches), Coordinates())); + conv52_out = std::unique_ptr(new SubTensorType(&conv5_out, TensorShape(13U, 13U, 128U, _batches), Coordinates(0, 0, 128))); + act5_out.allocator()->init(TensorInfo(TensorShape(13U, 13U, 256U, _batches), 1, dt, fixed_point_position)); + pool5_out.allocator()->init(TensorInfo(TensorShape(6U, 6U, 256U, _batches), 1, dt, fixed_point_position)); + // Layer 6 + fc6_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, dt, fixed_point_position)); + act6_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, dt, fixed_point_position)); + // Layer 7 + fc7_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, dt, fixed_point_position)); + act7_out.allocator()->init(TensorInfo(TensorShape(4096U, _batches), 1, dt, fixed_point_position)); + // Layer 8 + fc8_out.allocator()->init(TensorInfo(TensorShape(1000U, _batches), 1, dt, fixed_point_position)); + + // Allocate layers + { + // Layer 1 + conv1 = std::unique_ptr(new ConvolutionLayerFunction()); + act1 = std::unique_ptr(new ActivationLayerFunction()); + norm1 = std::unique_ptr(new NormalizationLayerFunction()); + pool1 = std::unique_ptr(new PoolingLayerFunction()); + // Layer 2 + conv21 = std::unique_ptr(new ConvolutionLayerFunction()); + conv22 = std::unique_ptr(new ConvolutionLayerFunction()); + act2 = std::unique_ptr(new ActivationLayerFunction()); + norm2 = std::unique_ptr(new NormalizationLayerFunction()); + pool2 = std::unique_ptr(new PoolingLayerFunction()); + // Layer 3 + conv3 = std::unique_ptr(new ConvolutionLayerFunction()); + act3 = std::unique_ptr(new ActivationLayerFunction()); + // Layer 4 + conv41 = std::unique_ptr(new ConvolutionLayerFunction()); + conv42 = std::unique_ptr(new ConvolutionLayerFunction()); + act4 = std::unique_ptr(new ActivationLayerFunction()); + // Layer 5 + conv51 = std::unique_ptr(new ConvolutionLayerFunction()); + conv52 = std::unique_ptr(new ConvolutionLayerFunction()); + act5 = std::unique_ptr(new ActivationLayerFunction()); + pool5 = std::unique_ptr(new PoolingLayerFunction()); + // Layer 6 + fc6 = std::unique_ptr(new FullyConnectedLayerFunction()); + act6 = std::unique_ptr(new ActivationLayerFunction()); + // Layer 7 + fc7 = std::unique_ptr(new FullyConnectedLayerFunction()); + act7 = std::unique_ptr(new ActivationLayerFunction()); + // Layer 8 + fc8 = std::unique_ptr(new FullyConnectedLayerFunction()); + // Softmax + smx = std::unique_ptr(new SoftmaxLayerFunction()); + } + + // Configure Layers + { + // Layer 1 + conv1->configure(&input, w[0].get(), b[0].get(), &conv1_out, PadStrideInfo(4, 4, 0, 0), WeightsInfo(_reshaped_weights, 11U, 11U, 96U)); + act1->configure(&conv1_out, &act1_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + norm1->configure(&act1_out, &norm1_out, NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)); + pool1->configure(&norm1_out, &pool1_out, PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); + // Layer 2 + conv21->configure(pool11_out.get(), w21.get(), b21.get(), conv21_out.get(), PadStrideInfo(1, 1, 2, 2), WeightsInfo(_reshaped_weights, 5U, 5U, 128U)); + conv22->configure(pool12_out.get(), w22.get(), b22.get(), conv22_out.get(), PadStrideInfo(1, 1, 2, 2), WeightsInfo(_reshaped_weights, 5U, 5U, 128U)); + act2->configure(&conv2_out, &act2_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + norm2->configure(&act2_out, &norm2_out, NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)); + pool2->configure(&norm2_out, &pool2_out, PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); + // Layer 3 + conv3->configure(&pool2_out, w[2].get(), b[2].get(), &conv3_out, PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 384U)); + act3->configure(&conv3_out, &act3_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + // Layer 4 + conv41->configure(act31_out.get(), w41.get(), b41.get(), conv41_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 192U)); + conv42->configure(act32_out.get(), w42.get(), b42.get(), conv42_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 192U)); + act4->configure(&conv4_out, &act4_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + // Layer 5 + conv51->configure(act41_out.get(), w51.get(), b51.get(), conv51_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 128U)); + conv52->configure(act42_out.get(), w52.get(), b52.get(), conv52_out.get(), PadStrideInfo(1, 1, 1, 1), WeightsInfo(_reshaped_weights, 3U, 3U, 128U)); + act5->configure(&conv5_out, &act5_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + pool5->configure(&act5_out, &pool5_out, PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0))); + // Layer 6 + fc6->configure(&pool5_out, w[5].get(), b[5].get(), &fc6_out, true, _reshaped_weights); + act6->configure(&fc6_out, &act6_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + // Layer 7 + fc7->configure(&act6_out, w[6].get(), b[6].get(), &fc7_out, true, _reshaped_weights); + act7->configure(&fc7_out, &act7_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + // Layer 8 + fc8->configure(&act7_out, w[7].get(), b[7].get(), &fc8_out, true, _reshaped_weights); + // Softmax + smx->configure(&fc8_out, &output); + } + } + + void allocate() + { + input.allocator()->allocate(); + output.allocator()->allocate(); + for(auto &wi : w) + { + if(wi.get()) + { + wi->allocator()->allocate(); + } + } + for(auto &bi : b) + { + if(bi.get()) + { + bi->allocator()->allocate(); + } + } + if(_reshaped_weights) + { + dynamic_cast(w21.get())->allocator()->allocate(); + dynamic_cast(w22.get())->allocator()->allocate(); + dynamic_cast(w41.get())->allocator()->allocate(); + dynamic_cast(w42.get())->allocator()->allocate(); + dynamic_cast(w51.get())->allocator()->allocate(); + dynamic_cast(w52.get())->allocator()->allocate(); + } + conv1_out.allocator()->allocate(); + act1_out.allocator()->allocate(); + norm1_out.allocator()->allocate(); + pool1_out.allocator()->allocate(); + conv2_out.allocator()->allocate(); + act2_out.allocator()->allocate(); + norm2_out.allocator()->allocate(); + pool2_out.allocator()->allocate(); + conv3_out.allocator()->allocate(); + act3_out.allocator()->allocate(); + conv4_out.allocator()->allocate(); + act4_out.allocator()->allocate(); + conv5_out.allocator()->allocate(); + act5_out.allocator()->allocate(); + pool5_out.allocator()->allocate(); + fc6_out.allocator()->allocate(); + act6_out.allocator()->allocate(); + fc7_out.allocator()->allocate(); + act7_out.allocator()->allocate(); + fc8_out.allocator()->allocate(); + } + + /** Fills the trainable parameters and input with random data. */ + void fill_random() + { + library->fill_tensor_uniform(Accessor(input), 0); + if(!_reshaped_weights) + { + for(unsigned int i = 0; i < w.size(); ++i) + { + library->fill_tensor_uniform(Accessor(*w[i]), i + 1); + library->fill_tensor_uniform(Accessor(*b[i]), i + 10); + } + } + else + { + library->fill_tensor_uniform(Accessor(*w[0]), 1); + library->fill_tensor_uniform(Accessor(*w[2]), 2); + + library->fill_tensor_uniform(Accessor(*w[5]), 3); + library->fill_tensor_uniform(Accessor(*b[5]), 4); + library->fill_tensor_uniform(Accessor(*w[6]), 5); + library->fill_tensor_uniform(Accessor(*b[6]), 6); + library->fill_tensor_uniform(Accessor(*w[7]), 7); + library->fill_tensor_uniform(Accessor(*b[7]), 8); + + library->fill_tensor_uniform(Accessor(*dynamic_cast(w21.get())), 9); + library->fill_tensor_uniform(Accessor(*dynamic_cast(w22.get())), 10); + library->fill_tensor_uniform(Accessor(*dynamic_cast(w41.get())), 11); + library->fill_tensor_uniform(Accessor(*dynamic_cast(w42.get())), 12); + library->fill_tensor_uniform(Accessor(*dynamic_cast(w51.get())), 13); + library->fill_tensor_uniform(Accessor(*dynamic_cast(w52.get())), 14); + } + } + +#ifdef INTERNAL_ONLY + /** Fills the trainable parameters from binary files + * + * @param weights Files names containing the weights data + * @param biases Files names containing the bias data + */ + void fill(std::vector weights, std::vector biases) + { + ARM_COMPUTE_ERROR_ON(weights.size() != w.size()); + ARM_COMPUTE_ERROR_ON(biases.size() != b.size()); + ARM_COMPUTE_ERROR_ON(_reshaped_weights); + + for(unsigned int i = 0; i < weights.size(); ++i) + { + library->fill_layer_data(Accessor(*w[i]), weights[i]); + library->fill_layer_data(Accessor(*b[i]), biases[i]); + } + } + + /** Feed input to network from file. + * + * @param name File name of containing the input data. + */ + void feed(std::string name) + { + library->fill_layer_data(Accessor(input), name); + } +#endif /* INTERNAL_ONLY */ + + /** Get the classification results. + * + * @return Vector containing the classified labels + */ + std::vector get_classifications() + { + std::vector classified_labels; + Accessor output_accessor(output); + + Window window; + window.set(Window::DimX, Window::Dimension(0, 1, 1)); + for(unsigned int d = 1; d < output_accessor.shape().num_dimensions(); ++d) + { + window.set(d, Window::Dimension(0, output_accessor.shape()[d], 1)); + } + + execute_window_loop(window, [&](const Coordinates & id) + { + int max_idx = 0; + float val = 0; + const void *const out_ptr = output_accessor(id); + for(unsigned int l = 0; l < output_accessor.shape().x(); ++l) + { + float curr_val = reinterpret_cast(out_ptr)[l]; + if(curr_val > val) + { + max_idx = l; + val = curr_val; + } + } + classified_labels.push_back(max_idx); + }); + return classified_labels; + } + + /** Clear all allocated memory from the tensor objects */ + void clear() + { + conv1.reset(); + act1.reset(); + norm1.reset(); + pool1.reset(); + conv21.reset(); + conv22.reset(); + act2.reset(); + norm2.reset(); + pool2.reset(); + conv3.reset(); + act3.reset(); + conv41.reset(); + conv42.reset(); + act4.reset(); + conv51.reset(); + conv52.reset(); + act5.reset(); + pool5.reset(); + fc6.reset(); + act6.reset(); + fc7.reset(); + act7.reset(); + fc8.reset(); + smx.reset(); + + // Free allocations + input.allocator()->free(); + output.allocator()->free(); + for(auto &wi : w) + { + wi.reset(); + } + for(auto &bi : b) + { + bi.reset(); + } + + w21.reset(); + w22.reset(); + b21.reset(); + b21.reset(); + w41.reset(); + w42.reset(); + b41.reset(); + b42.reset(); + w51.reset(); + w52.reset(); + b51.reset(); + b52.reset(); + + conv1_out.allocator()->free(); + act1_out.allocator()->free(); + norm1_out.allocator()->free(); + pool1_out.allocator()->free(); + conv2_out.allocator()->free(); + act2_out.allocator()->free(); + norm2_out.allocator()->free(); + pool2_out.allocator()->free(); + conv3_out.allocator()->free(); + act3_out.allocator()->free(); + conv4_out.allocator()->free(); + act4_out.allocator()->free(); + conv5_out.allocator()->free(); + act5_out.allocator()->free(); + pool5_out.allocator()->free(); + fc6_out.allocator()->free(); + act6_out.allocator()->free(); + fc7_out.allocator()->free(); + act7_out.allocator()->free(); + fc8_out.allocator()->free(); + } + + /** Runs the model */ + void run() + { + // Layer 1 + conv1->run(); + act1->run(); + norm1->run(); + pool1->run(); + // Layer 2 + conv21->run(); + conv22->run(); + act2->run(); + norm2->run(); + pool2->run(); + // Layer 3 + conv3->run(); + act3->run(); + // Layer 4 + conv41->run(); + conv42->run(); + act4->run(); + // Layer 5 + conv51->run(); + conv52->run(); + act5->run(); + pool5->run(); + // Layer 6 + fc6->run(); + act6->run(); + // Layer 7 + fc7->run(); + act7->run(); + // Layer 8 + fc8->run(); + // Softmax + smx->run(); + } + +private: + unsigned int _batches; + bool _reshaped_weights; + + std::unique_ptr act1{ nullptr }, act2{ nullptr }, act3{ nullptr }, act4{ nullptr }, act5{ nullptr }, act6{ nullptr }, act7{ nullptr }; + std::unique_ptr conv1{ nullptr }, conv21{ nullptr }, conv22{ nullptr }, conv3{ nullptr }, conv41{ nullptr }, conv42{ nullptr }, conv51{ nullptr }, conv52{ nullptr }; + std::unique_ptr fc6{ nullptr }, fc7{ nullptr }, fc8{}; + std::unique_ptr norm1{ nullptr }, norm2{ nullptr }; + std::unique_ptr pool1{ nullptr }, pool2{ nullptr }, pool5{ nullptr }; + std::unique_ptr smx{ nullptr }; + + TensorType input{}, output{}; + std::array, 8> w{}, b{}; + std::unique_ptr w21{ nullptr }, w22{ nullptr }, b21{ nullptr }, b22{ nullptr }; + std::unique_ptr w41{ nullptr }, w42{ nullptr }, b41{ nullptr }, b42{ nullptr }; + std::unique_ptr w51{ nullptr }, w52{ nullptr }, b51{ nullptr }, b52{ nullptr }; + + TensorType conv1_out{}, act1_out{}, norm1_out{}, pool1_out{}; + TensorType conv2_out{}, act2_out{}, pool2_out{}, norm2_out{}; + TensorType conv3_out{}, act3_out{}; + TensorType conv4_out{}, act4_out{}; + TensorType conv5_out{}, act5_out{}, pool5_out{}; + TensorType fc6_out{}, act6_out{}; + TensorType fc7_out{}, act7_out{}; + TensorType fc8_out{}; + + std::unique_ptr pool11_out{ nullptr }, pool12_out{ nullptr }; + std::unique_ptr conv21_out{ nullptr }, conv22_out{ nullptr }; + std::unique_ptr act31_out{ nullptr }, act32_out{ nullptr }; + std::unique_ptr conv41_out{ nullptr }, conv42_out{ nullptr }, act41_out{ nullptr }, act42_out{ nullptr }; + std::unique_ptr conv51_out{ nullptr }, conv52_out{ nullptr }; +}; +} // namespace model_objects +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_MODEL_OBJECTS_ALEXNET_H__ diff --git a/tests/validation_old/model_objects/LeNet5.h b/tests/validation_old/model_objects/LeNet5.h new file mode 100644 index 0000000000..d3e72b0010 --- /dev/null +++ b/tests/validation_old/model_objects/LeNet5.h @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_MODEL_OBJECTS_LENET5_H__ +#define __ARM_COMPUTE_TEST_MODEL_OBJECTS_LENET5_H__ + +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/Utils.h" + +#include + +using namespace arm_compute; +using namespace arm_compute::test; + +namespace arm_compute +{ +namespace test +{ +namespace model_objects +{ +/** Lenet5 model object */ +template +class LeNet5 +{ +public: + /** Initialize and build the model. + * + * @param batches Number of batches should handle + */ + void build(unsigned int batches) + { + // Initialize input, output, weights and biases + input.allocator()->init(TensorInfo(TensorShape(28U, 28U, 1U, batches), 1, DataType::F32)); + output.allocator()->init(TensorInfo(TensorShape(10U, batches), 1, DataType::F32)); + w[0].allocator()->init(TensorInfo(TensorShape(5U, 5U, 1U, 20U), 1, DataType::F32)); + b[0].allocator()->init(TensorInfo(TensorShape(20U), 1, DataType::F32)); + w[1].allocator()->init(TensorInfo(TensorShape(5U, 5U, 20U, 50U), 1, DataType::F32)); + b[1].allocator()->init(TensorInfo(TensorShape(50U), 1, DataType::F32)); + w[2].allocator()->init(TensorInfo(TensorShape(800U, 500U), 1, DataType::F32)); + b[2].allocator()->init(TensorInfo(TensorShape(500U), 1, DataType::F32)); + w[3].allocator()->init(TensorInfo(TensorShape(500U, 10U), 1, DataType::F32)); + b[3].allocator()->init(TensorInfo(TensorShape(10U), 1, DataType::F32)); + + // Initialize intermediate tensors + // Layer 1 + conv1_out.allocator()->init(TensorInfo(TensorShape(24U, 24U, 20U, batches), 1, DataType::F32)); + pool1_out.allocator()->init(TensorInfo(TensorShape(12U, 12U, 20U, batches), 1, DataType::F32)); + // Layer 2 + conv2_out.allocator()->init(TensorInfo(TensorShape(8U, 8U, 50U, batches), 1, DataType::F32)); + pool2_out.allocator()->init(TensorInfo(TensorShape(4U, 4U, 50U, batches), 1, DataType::F32)); + // Layer 3 + fc1_out.allocator()->init(TensorInfo(TensorShape(500U, batches), 1, DataType::F32)); + act1_out.allocator()->init(TensorInfo(TensorShape(500U, batches), 1, DataType::F32)); + // Layer 6 + fc2_out.allocator()->init(TensorInfo(TensorShape(10U, batches), 1, DataType::F32)); + + // Allocate layers + { + // Layer 1 + conv1 = std::unique_ptr(new ConvolutionLayerFunction()); + pool1 = std::unique_ptr(new PoolingLayerFunction()); + // Layer 2 + conv2 = std::unique_ptr(new ConvolutionLayerFunction()); + pool2 = std::unique_ptr(new PoolingLayerFunction()); + // Layer 3 + fc1 = std::unique_ptr(new FullyConnectedLayerFunction()); + act1 = std::unique_ptr(new ActivationLayerFunction()); + // Layer 4 + fc2 = std::unique_ptr(new FullyConnectedLayerFunction()); + // Softmax + smx = std::unique_ptr(new SoftmaxLayerFunction()); + } + + // Configure Layers + { + conv1->configure(&input, &w[0], &b[0], &conv1_out, PadStrideInfo(1, 1, 0, 0)); + pool1->configure(&conv1_out, &pool1_out, PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0))); + conv2->configure(&pool1_out, &w[1], &b[1], &conv2_out, PadStrideInfo(1, 1, 0, 0)); + pool2->configure(&conv2_out, &pool2_out, PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0))); + fc1->configure(&pool2_out, &w[2], &b[2], &fc1_out); + act1->configure(&fc1_out, &act1_out, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); + fc2->configure(&act1_out, &w[3], &b[3], &fc2_out); + smx->configure(&fc2_out, &output); + } + + // Allocate tensors + { + input.allocator()->allocate(); + output.allocator()->allocate(); + for(auto &wi : w) + { + wi.allocator()->allocate(); + } + for(auto &bi : b) + { + bi.allocator()->allocate(); + } + conv1_out.allocator()->allocate(); + pool1_out.allocator()->allocate(); + conv2_out.allocator()->allocate(); + pool2_out.allocator()->allocate(); + fc1_out.allocator()->allocate(); + act1_out.allocator()->allocate(); + fc2_out.allocator()->allocate(); + } + } + + /** Fills the trainable parameters and input with random data. */ + void fill_random() + { + std::uniform_real_distribution<> distribution(-1, 1); + library->fill(Accessor(input), distribution, 0); + for(unsigned int i = 0; i < w.size(); ++i) + { + library->fill(Accessor(w[i]), distribution, i + 1); + library->fill(Accessor(b[i]), distribution, i + 10); + } + } + +#ifdef INTERNAL_ONLY + /** Fills the trainable parameters from binary files + * + * @param weights Files names containing the weights data + * @param biases Files names containing the bias data + */ + void fill(std::vector weights, std::vector biases) + { + ARM_COMPUTE_ERROR_ON(weights.size() != w.size()); + ARM_COMPUTE_ERROR_ON(biases.size() != b.size()); + + for(unsigned int i = 0; i < weights.size(); ++i) + { + library->fill_layer_data(Accessor(w[i]), weights[i]); + library->fill_layer_data(Accessor(b[i]), biases[i]); + } + } + + /** Feed input to network from file. + * + * @param name File name of containing the input data. + */ + void feed(std::string name) + { + library->fill_layer_data(Accessor(input), name); + } +#endif /* INTERNAL_ONLY */ + + /** Get the classification results. + * + * @return Vector containing the classified labels + */ + std::vector get_classifications() + { + std::vector classified_labels; + Accessor output_accessor(output); + + Window window; + window.set(Window::DimX, Window::Dimension(0, 1, 1)); + for(unsigned int d = 1; d < output_accessor.shape().num_dimensions(); ++d) + { + window.set(d, Window::Dimension(0, output_accessor.shape()[d], 1)); + } + + execute_window_loop(window, [&](const Coordinates & id) + { + int max_idx = 0; + float val = 0; + const void *const out_ptr = output_accessor(id); + for(unsigned int l = 0; l < output_accessor.shape().x(); ++l) + { + float curr_val = reinterpret_cast(out_ptr)[l]; + if(curr_val > val) + { + max_idx = l; + val = curr_val; + } + } + classified_labels.push_back(max_idx); + }); + return classified_labels; + } + + /** Clear all allocated memory from the tensor objects */ + void clear() + { + conv1.reset(); + pool1.reset(); + conv2.reset(); + pool2.reset(); + fc1.reset(); + act1.reset(); + fc2.reset(); + smx.reset(); + + input.allocator()->free(); + output.allocator()->free(); + for(auto &wi : w) + { + wi.allocator()->free(); + } + for(auto &bi : b) + { + bi.allocator()->free(); + } + + conv1_out.allocator()->free(); + pool1_out.allocator()->free(); + conv2_out.allocator()->free(); + pool2_out.allocator()->free(); + fc1_out.allocator()->free(); + act1_out.allocator()->free(); + fc2_out.allocator()->free(); + } + + /** Runs the model */ + void run() + { + // Layer 1 + conv1->run(); + pool1->run(); + // Layer 2 + conv2->run(); + pool2->run(); + // Layer 3 + fc1->run(); + act1->run(); + // Layer 4 + fc2->run(); + // Softmax + smx->run(); + } + +private: + std::unique_ptr act1{ nullptr }; + std::unique_ptr conv1{ nullptr }, conv2{ nullptr }; + std::unique_ptr fc1{ nullptr }, fc2{ nullptr }; + std::unique_ptr pool1{ nullptr }, pool2{ nullptr }; + std::unique_ptr smx{ nullptr }; + + TensorType input{}, output{}; + std::array w{}, b{}; + + TensorType conv1_out{}, pool1_out{}; + TensorType conv2_out{}, pool2_out{}; + TensorType fc1_out{}, act1_out{}; + TensorType fc2_out{}; +}; +} // namespace model_objects +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_MODEL_OBJECTS_LENET5_H__ diff --git a/tests/validation_old/system_tests/CL/AlexNet.cpp b/tests/validation_old/system_tests/CL/AlexNet.cpp new file mode 100644 index 0000000000..b403b6e93c --- /dev/null +++ b/tests/validation_old/system_tests/CL/AlexNet.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifdef INTERNAL_ONLY //FIXME Delete this file before the release +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/runtime/CL/CLSubTensor.h" +#include "arm_compute/runtime/CL/functions/CLActivationLayer.h" +#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h" +#include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h" +#include "arm_compute/runtime/CL/functions/CLNormalizationLayer.h" +#include "arm_compute/runtime/CL/functions/CLPoolingLayer.h" +#include "arm_compute/runtime/CL/functions/CLSoftmaxLayer.h" + +#include "tests/validation_old/model_objects/AlexNet.h" + +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +using CLAlexNetModel = model_objects::AlexNet; +std::vector compute_alexnet(unsigned int batches, std::string input_file) +{ + std::vector weight_files = { "cnn_data/alexnet_model/conv1_w.dat", + "cnn_data/alexnet_model/conv2_w.dat", + "cnn_data/alexnet_model/conv3_w.dat", + "cnn_data/alexnet_model/conv4_w.dat", + "cnn_data/alexnet_model/conv5_w.dat", + "cnn_data/alexnet_model/fc6_w.dat", + "cnn_data/alexnet_model/fc7_w.dat", + "cnn_data/alexnet_model/fc8_w.dat" + }; + + std::vector bias_files = { "cnn_data/alexnet_model/conv1_b.dat", + "cnn_data/alexnet_model/conv2_b.dat", + "cnn_data/alexnet_model/conv3_b.dat", + "cnn_data/alexnet_model/conv4_b.dat", + "cnn_data/alexnet_model/conv5_b.dat", + "cnn_data/alexnet_model/fc6_b.dat", + "cnn_data/alexnet_model/fc7_b.dat", + "cnn_data/alexnet_model/fc8_b.dat" + }; + CLAlexNetModel network{}; + network.init_weights(batches); + network.build(); + network.allocate(); + network.fill(weight_files, bias_files); + network.feed(std::move(input_file)); + network.run(); + + return network.get_classifications(); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(SYSTEM_TESTS) +BOOST_AUTO_TEST_SUITE(CL) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_AUTO_TEST_CASE(AlexNet) +{ + // Compute alexnet + std::vector classified_labels = compute_alexnet(1, "cnn_data/imagenet_data/shark.dat"); + + // Expected labels + std::vector expected_labels = { 2 }; + + // Validate labels + validate(classified_labels, expected_labels); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ +#endif /* INTERNAL_ONLY */ diff --git a/tests/validation_old/system_tests/CL/LeNet5.cpp b/tests/validation_old/system_tests/CL/LeNet5.cpp new file mode 100644 index 0000000000..0f34dd1ae7 --- /dev/null +++ b/tests/validation_old/system_tests/CL/LeNet5.cpp @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifdef INTERNAL_ONLY //FIXME Delete this file before the release +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "CL/CLAccessor.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/runtime/CL/functions/CLActivationLayer.h" +#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h" +#include "arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h" +#include "arm_compute/runtime/CL/functions/CLPoolingLayer.h" +#include "arm_compute/runtime/CL/functions/CLSoftmaxLayer.h" + +#include "tests/validation_old/model_objects/LeNet5.h" + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +using CLLeNet5Model = model_objects::LeNet5; +std::vector compute_lenet5(unsigned int batches, std::string input_file) +{ + std::vector weight_files = { "cnn_data/lenet_model/conv1_w.dat", + "cnn_data/lenet_model/conv2_w.dat", + "cnn_data/lenet_model/ip1_w.dat", + "cnn_data/lenet_model/ip2_w.dat" + }; + + std::vector bias_files = { "cnn_data/lenet_model/conv1_b.dat", + "cnn_data/lenet_model/conv2_b.dat", + "cnn_data/lenet_model/ip1_b.dat", + "cnn_data/lenet_model/ip2_b.dat" + }; + CLLeNet5Model network{}; + network.build(batches); + network.fill(weight_files, bias_files); + network.feed(std::move(input_file)); + network.run(); + + return network.get_classifications(); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(SYSTEM_TESTS) +BOOST_AUTO_TEST_SUITE(CL) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_AUTO_TEST_CASE(LeNet5) +{ + // Compute alexnet + std::vector classified_labels = compute_lenet5(10, "cnn_data/mnist_data/input100.dat"); + + // Expected labels + std::vector expected_labels = { 7, 2, 1, 0, 4, 1, 4, 9, 5, 9 }; + + // Validate labels + validate(classified_labels, expected_labels); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ +#endif /* INTERNAL_ONLY */ diff --git a/tests/validation_old/system_tests/NEON/AlexNet.cpp b/tests/validation_old/system_tests/NEON/AlexNet.cpp new file mode 100644 index 0000000000..9697cf35e8 --- /dev/null +++ b/tests/validation_old/system_tests/NEON/AlexNet.cpp @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifdef INTERNAL_ONLY //FIXME Delete this file before the release +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" +#include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" +#include "arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h" +#include "arm_compute/runtime/NEON/functions/NENormalizationLayer.h" +#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" +#include "arm_compute/runtime/NEON/functions/NESoftmaxLayer.h" +#include "arm_compute/runtime/SubTensor.h" + +#include "tests/validation_old/model_objects/AlexNet.h" + +#include + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +using NEAlexNetModel = model_objects::AlexNet; +std::vector compute_alexnet(unsigned int batches, std::string input_file) +{ + std::vector weight_files = { "cnn_data/alexnet_model/conv1_w.dat", + "cnn_data/alexnet_model/conv2_w.dat", + "cnn_data/alexnet_model/conv3_w.dat", + "cnn_data/alexnet_model/conv4_w.dat", + "cnn_data/alexnet_model/conv5_w.dat", + "cnn_data/alexnet_model/fc6_w.dat", + "cnn_data/alexnet_model/fc7_w.dat", + "cnn_data/alexnet_model/fc8_w.dat" + }; + + std::vector bias_files = { "cnn_data/alexnet_model/conv1_b.dat", + "cnn_data/alexnet_model/conv2_b.dat", + "cnn_data/alexnet_model/conv3_b.dat", + "cnn_data/alexnet_model/conv4_b.dat", + "cnn_data/alexnet_model/conv5_b.dat", + "cnn_data/alexnet_model/fc6_b.dat", + "cnn_data/alexnet_model/fc7_b.dat", + "cnn_data/alexnet_model/fc8_b.dat" + }; + NEAlexNetModel network{}; + + network.init_weights(batches); + network.build(); + network.allocate(); + network.fill(weight_files, bias_files); + network.feed(std::move(input_file)); + network.run(); + + return network.get_classifications(); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(SYSTEM_TESTS) +BOOST_AUTO_TEST_SUITE(NEON) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_AUTO_TEST_CASE(AlexNet) +{ + // Compute alexnet + std::vector classified_labels = compute_alexnet(1, "cnn_data/imagenet_data/shark.dat"); + + // Expected labels + std::vector expected_labels = { 2 }; + + // Validate labels + validate(classified_labels, expected_labels); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ +#endif /* INTERNAL_ONLY */ diff --git a/tests/validation_old/system_tests/NEON/LeNet5.cpp b/tests/validation_old/system_tests/NEON/LeNet5.cpp new file mode 100644 index 0000000000..916df98eb6 --- /dev/null +++ b/tests/validation_old/system_tests/NEON/LeNet5.cpp @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifdef INTERNAL_ONLY //FIXME Delete this file before the release +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "NEON/Accessor.h" +#include "tests/validation_old/Validation.h" + +#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h" +#include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" +#include "arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h" +#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" +#include "arm_compute/runtime/NEON/functions/NESoftmaxLayer.h" + +#include "tests/validation_old/model_objects/LeNet5.h" + +using namespace arm_compute; +using namespace arm_compute::test; +using namespace arm_compute::test::validation; + +namespace +{ +using NELeNet5Model = model_objects::LeNet5; +std::vector compute_lenet5(unsigned int batches, std::string input_file) +{ + std::vector weight_files = { "cnn_data/lenet_model/conv1_w.dat", + "cnn_data/lenet_model/conv2_w.dat", + "cnn_data/lenet_model/ip1_w.dat", + "cnn_data/lenet_model/ip2_w.dat" + }; + + std::vector bias_files = { "cnn_data/lenet_model/conv1_b.dat", + "cnn_data/lenet_model/conv2_b.dat", + "cnn_data/lenet_model/ip1_b.dat", + "cnn_data/lenet_model/ip2_b.dat" + }; + NELeNet5Model network{}; + network.build(batches); + network.fill(weight_files, bias_files); + network.feed(std::move(input_file)); + network.run(); + + return network.get_classifications(); +} +} // namespace + +#ifndef DOXYGEN_SKIP_THIS +BOOST_AUTO_TEST_SUITE(SYSTEM_TESTS) +BOOST_AUTO_TEST_SUITE(NEON) + +BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) +BOOST_AUTO_TEST_CASE(LeNet5) +{ + // Compute alexnet + std::vector classified_labels = compute_lenet5(10, "cnn_data/mnist_data/input100.dat"); + + // Expected labels + std::vector expected_labels = { 7, 2, 1, 0, 4, 1, 4, 9, 5, 9 }; + + // Validate labels + validate(classified_labels, expected_labels); +} + +BOOST_AUTO_TEST_SUITE_END() +BOOST_AUTO_TEST_SUITE_END() +#endif /* DOXYGEN_SKIP_THIS */ +#endif /* INTERNAL_ONLY */ -- cgit v1.2.1