diff options
author | Rob Hughes <robert.hughes@arm.com> | 2020-05-20 15:27:37 +0100 |
---|---|---|
committer | Rob Hughes <robert.hughes@arm.com> | 2020-06-02 13:55:30 +0000 |
commit | bb46dde88befe14583eaac83f65775a7543d4586 (patch) | |
tree | 61baff7d93acd0a24184bc0dfa8af540168e1e4c /src/backends | |
parent | 8acafd13ad2169b6edc86f5e42602ec604d39648 (diff) | |
download | armnn-bb46dde88befe14583eaac83f65775a7543d4586.tar.gz |
Fix a few build warnings:
* Remove redundant asserts for unsigned ints being positive
* Remove unneeded include of lightweight_test.hpp header
* Remove unused exception variable names
* Replace hardcoded 0.0f with T() for some template functions
* Add a few static_casts
Change-Id: I290b0433cf995f6d0199422eaa10f816e5fd8eb9
Signed-off-by: Robert Hughes <robert.hughes@arm.com>
Diffstat (limited to 'src/backends')
4 files changed, 44 insertions, 44 deletions
diff --git a/src/backends/backendsCommon/test/JsonPrinterTestImpl.cpp b/src/backends/backendsCommon/test/JsonPrinterTestImpl.cpp index 2aa713f1ed..50dc61b1f4 100644 --- a/src/backends/backendsCommon/test/JsonPrinterTestImpl.cpp +++ b/src/backends/backendsCommon/test/JsonPrinterTestImpl.cpp @@ -65,7 +65,7 @@ std::vector<double> ExtractMeasurements(const std::string& exp) armnn::stringUtils::StringTrim(numberString, "\t,\n"); numbers.push_back(std::stod(numberString)); } - catch (std::invalid_argument const& e) + catch (std::invalid_argument const&) { BOOST_FAIL("Could not convert measurements to double: " + numberString); } @@ -80,7 +80,7 @@ std::vector<double> ExtractMeasurements(const std::string& exp) armnn::stringUtils::StringTrim(numberString, "\t,\n"); numbers.push_back(std::stod(numberString)); } - catch (std::invalid_argument const& e) + catch (std::invalid_argument const&) { BOOST_FAIL("Could not convert measurements to double: " + numberString); } diff --git a/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp index 154ece2657..acc888ebc0 100644 --- a/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp @@ -76,7 +76,7 @@ boost::multi_array<T, 1> GetBias2(bool biasEnabled, float qScale) if(biasEnabled) { armnn::TensorInfo biasDesc({static_cast<unsigned int>(Bias2.size())}, ArmnnType); - boost::multi_array<T, 1> bias = MakeTensor<T, 1>(biasDesc, QuantizedVector<T>(Bias2, qScale, 0.0f)); + boost::multi_array<T, 1> bias = MakeTensor<T, 1>(biasDesc, QuantizedVector<T>(Bias2, qScale, 0)); return bias; } else @@ -92,7 +92,7 @@ boost::multi_array<T, 1> GetBias4(bool biasEnabled, float qScale) if(biasEnabled) { armnn::TensorInfo biasDesc({static_cast<unsigned int>(Bias4.size())}, ArmnnType); - boost::multi_array<T, 1> bias = MakeTensor<T, 1>(biasDesc, QuantizedVector<T>(Bias4, qScale, 0.0f)); + boost::multi_array<T, 1> bias = MakeTensor<T, 1>(biasDesc, QuantizedVector<T>(Bias4, qScale, 0)); return bias; } else @@ -108,7 +108,7 @@ boost::multi_array<T, 1> GetBias8(bool biasEnabled, float qScale) if(biasEnabled) { armnn::TensorInfo biasDesc({static_cast<unsigned int>(Bias4.size())}, ArmnnType); - boost::multi_array<T, 1> bias = MakeTensor<T, 1>(biasDesc, QuantizedVector<T>(Bias8, qScale, 0.0f)); + boost::multi_array<T, 1> bias = MakeTensor<T, 1>(biasDesc, QuantizedVector<T>(Bias8, qScale, 0)); return bias; } else diff --git a/src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp index 0ae55e4c60..c7f902ab04 100644 --- a/src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/LstmTestImpl.cpp @@ -160,28 +160,28 @@ LstmNoCifgNoPeepholeNoProjectionTestImpl( LayerTestResult<T, 2> ret(outputTensorInfo); - std::vector<float> inputVector; + std::vector<T> inputVector; inputVector.assign(input.data(), input.data() + (batchSize * inputSize)); - auto inputTensor = MakeTensor<float,2>(inputTensorInfo, inputVector); + auto inputTensor = MakeTensor<T,2>(inputTensorInfo, inputVector); - std::vector<float> cellStateInVector(batchSize * numUnits, 0.f); - auto cellStateInTensor = MakeTensor<float,2>(cellStateInTensorInfo, cellStateInVector); + std::vector<T> cellStateInVector(batchSize * numUnits, T()); + auto cellStateInTensor = MakeTensor<T,2>(cellStateInTensorInfo, cellStateInVector); - std::vector<float> outputStateInVector(batchSize * outputSize, 0.f); - auto outputStateInTensor = MakeTensor<float,2>(outputStateInTensorInfo, outputStateInVector); + std::vector<T> outputStateInVector(batchSize * outputSize, T()); + auto outputStateInTensor = MakeTensor<T,2>(outputStateInTensorInfo, outputStateInVector); - std::vector<float> scratchBufferVector(batchSize * numUnits * 4, 0.f); - auto scratchBufferTensor = MakeTensor<float,2>(scratchBufferTensorInfo, scratchBufferVector); + std::vector<T> scratchBufferVector(batchSize * numUnits * 4, T()); + auto scratchBufferTensor = MakeTensor<T,2>(scratchBufferTensorInfo, scratchBufferVector); - std::vector<float> outputStateOutVector(batchSize * outputSize, 0.f); - auto outputStateOutTensor = MakeTensor<float,2>(outputStateOutTensorInfo, outputStateOutVector); + std::vector<T> outputStateOutVector(batchSize * outputSize, T()); + auto outputStateOutTensor = MakeTensor<T,2>(outputStateOutTensorInfo, outputStateOutVector); - std::vector<float> cellStateOutVector(batchSize * numUnits, 0.f); - auto cellStateOutTensor = MakeTensor<float,2>(cellStateOutTensorInfo, cellStateOutVector); + std::vector<T> cellStateOutVector(batchSize * numUnits, T()); + auto cellStateOutTensor = MakeTensor<T,2>(cellStateOutTensorInfo, cellStateOutVector); - std::vector<float> outputVector; + std::vector<T> outputVector; outputVector.assign(outputExpected.data(), outputExpected.data() + (batchSize * outputSize)); - ret.outputExpected = MakeTensor<float, 2>(outputTensorInfo, outputVector); + ret.outputExpected = MakeTensor<T, 2>(outputTensorInfo, outputVector); std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); std::unique_ptr<armnn::ITensorHandle> cellStateInHandle = @@ -363,28 +363,28 @@ LstmLayerNoCifgWithPeepholeWithProjectionTestImpl(armnn::IWorkloadFactory& workl LayerTestResult<T, 2> ret(outputTensorInfo); - std::vector<float> inputVector; + std::vector<T> inputVector; inputVector.assign(input.data(), input.data() + (batchSize * inputSize)); - auto inputTensor = MakeTensor<float,2>(inputTensorInfo, inputVector); + auto inputTensor = MakeTensor<T,2>(inputTensorInfo, inputVector); - std::vector<float> cellStateInVector(batchSize * numUnits, 0.f); - auto cellStateInTensor = MakeTensor<float,2>(cellStateInTensorInfo, cellStateInVector); + std::vector<T> cellStateInVector(batchSize * numUnits, T()); + auto cellStateInTensor = MakeTensor<T,2>(cellStateInTensorInfo, cellStateInVector); - std::vector<float> outputStateInVector(batchSize * outputSize, 0.f); - auto outputStateInTensor = MakeTensor<float,2>(outputStateInTensorInfo, outputStateInVector); + std::vector<T> outputStateInVector(batchSize * outputSize, T()); + auto outputStateInTensor = MakeTensor<T,2>(outputStateInTensorInfo, outputStateInVector); - std::vector<float> scratchBufferVector(batchSize * numUnits * 4, 0.f); - auto scratchBufferTensor = MakeTensor<float,2>(scratchBufferTensorInfo, scratchBufferVector); + std::vector<T> scratchBufferVector(batchSize * numUnits * 4, T()); + auto scratchBufferTensor = MakeTensor<T,2>(scratchBufferTensorInfo, scratchBufferVector); - std::vector<float> outputStateOutVector(batchSize * outputSize, 0.f); - auto outputStateOutTensor = MakeTensor<float,2>(outputStateOutTensorInfo, outputStateOutVector); + std::vector<T> outputStateOutVector(batchSize * outputSize, T()); + auto outputStateOutTensor = MakeTensor<T,2>(outputStateOutTensorInfo, outputStateOutVector); - std::vector<float> cellStateOutVector(batchSize * numUnits, 0.f); - auto cellStateOutTensor = MakeTensor<float,2>(cellStateOutTensorInfo, cellStateOutVector); + std::vector<T> cellStateOutVector(batchSize * numUnits, T()); + auto cellStateOutTensor = MakeTensor<T,2>(cellStateOutTensorInfo, cellStateOutVector); - std::vector<float> outputVector; + std::vector<T> outputVector; outputVector.assign(outputExpected.data(), outputExpected.data() + (batchSize * outputSize)); - ret.outputExpected = MakeTensor<float, 2>(outputTensorInfo, outputVector); + ret.outputExpected = MakeTensor<T, 2>(outputTensorInfo, outputVector); std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); std::unique_ptr<armnn::ITensorHandle> cellStateInHandle = @@ -1195,27 +1195,27 @@ LayerTestResult<T, 2> LstmLayerWithCifgWithPeepholeNoProjectionTestImpl( // List of outputs - std::vector<float> scratchBufferVector(batchSize * scratchBufferSize, 0.f); - auto scratchBufferTensor = MakeTensor<float,2>(scratchBufferTensorInfo, scratchBufferVector); + std::vector<T> scratchBufferVector(batchSize * scratchBufferSize, T()); + auto scratchBufferTensor = MakeTensor<T,2>(scratchBufferTensorInfo, scratchBufferVector); LayerTestResult<T, 2> ret0(scratchBufferTensorInfo); // Output state for a certain time step - std::vector<float> outputStateOutVector(batchSize * outputSize, 0.f); - auto outputStateOutTensor = MakeTensor<float,2>(outputStateOutTensorInfo, outputStateOutVector); + std::vector<T> outputStateOutVector(batchSize * outputSize, T()); + auto outputStateOutTensor = MakeTensor<T,2>(outputStateOutTensorInfo, outputStateOutVector); LayerTestResult<T, 2> ret1(outputStateOutTensorInfo); // Cell state for a certain time step - std::vector<float> cellStateOutVector(batchSize * cellSize, 0.f); - auto cellStateOutTensor = MakeTensor<float,2>(cellStateOutTensorInfo, cellStateOutVector); + std::vector<T> cellStateOutVector(batchSize * cellSize, T()); + auto cellStateOutTensor = MakeTensor<T,2>(cellStateOutTensorInfo, cellStateOutVector); LayerTestResult<T, 2> ret2(cellStateOutTensorInfo); // Output for a certain time step - std::vector<float> outputVector(batchSize * outputSize, 0.f); - auto outputTensor = MakeTensor<float, 2>(outputTensorInfo, outputVector); - std::vector<float> outputData; + std::vector<T> outputVector(batchSize * outputSize, T()); + auto outputTensor = MakeTensor<T, 2>(outputTensorInfo, outputVector); + std::vector<T> outputData; outputData.assign(outputExpected.data(), outputExpected.data() + batchSize*outputSize); LayerTestResult<T, 2> ret3(outputTensorInfo); - ret3.outputExpected = MakeTensor<float, 2>(outputTensorInfo, outputData); + ret3.outputExpected = MakeTensor<T, 2>(outputTensorInfo, outputData); // Prepare the inputs and outputs for the workload std::unique_ptr<armnn::ITensorHandle> inputHandle = diff --git a/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.cpp index 813c623cff..a599bae4b5 100644 --- a/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/TransposeConvolution2dTestImpl.cpp @@ -105,7 +105,7 @@ void TransposeConvolution2dTestImpl(armnn::IWorkloadFactory& workloadFactory, ExecuteWorkload(*workload, memoryManager); // copy output - output.second = std::vector<T>(output.first.GetNumElements(), 0.0f); + output.second = std::vector<T>(output.first.GetNumElements(), T()); CopyDataFromITensorHandle(output.second.data(), outputHandle.get()); } |