From 9e10c2b9ee9ce2e8f74f80e22842a47479ba1174 Mon Sep 17 00:00:00 2001 From: Rob Hughes Date: Tue, 23 Jul 2019 15:37:19 +0100 Subject: [PATCH] Fix various uses of non-standard C++: * Replace u_int32_t with uint32_t * Replace size_t with uint32_t for initializer list of TensorInfo * Replace variable size arrays with std::vector * Replace reference to local variable during its initialisation Change-Id: I298b3995f1525f90a1ab2416d7e270315698fae3 --- src/armnn/test/TestNameAndDescriptorLayerVisitor.cpp | 6 +++--- src/backends/backendsCommon/test/LayerTests.cpp | 4 ++-- src/backends/reference/workloads/Debug.cpp | 2 +- src/backends/reference/workloads/StridedSlice.cpp | 4 ++-- tests/InferenceModel.hpp | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/armnn/test/TestNameAndDescriptorLayerVisitor.cpp b/src/armnn/test/TestNameAndDescriptorLayerVisitor.cpp index b841e72..653612f 100644 --- a/src/armnn/test/TestNameAndDescriptorLayerVisitor.cpp +++ b/src/armnn/test/TestNameAndDescriptorLayerVisitor.cpp @@ -8,7 +8,7 @@ namespace armnn { -void Set2dDataValues(SplitterDescriptor descriptor, u_int32_t value) +void Set2dDataValues(SplitterDescriptor descriptor, uint32_t value) { for (unsigned int i = 0; i < descriptor.GetNumViews(); ++i) { @@ -20,7 +20,7 @@ void Set2dDataValues(SplitterDescriptor descriptor, u_int32_t value) } } -void Set2dDataValues(OriginsDescriptor& descriptor, u_int32_t value) +void Set2dDataValues(OriginsDescriptor& descriptor, uint32_t value) { for (unsigned int i = 0; i < descriptor.GetNumViews(); ++i) { @@ -425,4 +425,4 @@ BOOST_AUTO_TEST_CASE(CheckStridedSliceLayerVisitorNameNullAndDescriptor) BOOST_AUTO_TEST_SUITE_END() -} //namespace armnn \ No newline at end of file +} //namespace armnn diff --git a/src/backends/backendsCommon/test/LayerTests.cpp b/src/backends/backendsCommon/test/LayerTests.cpp index b40a3f5..f996eda 100644 --- a/src/backends/backendsCommon/test/LayerTests.cpp +++ b/src/backends/backendsCommon/test/LayerTests.cpp @@ -3262,7 +3262,7 @@ LayerTestResult ElementwiseTestHelper( const unsigned int outShape[4], std::vector outValues, float qScale = 0.0f, int qOffset = 0) { - const size_t dimensionCount = 4; + const uint32_t dimensionCount = 4; armnn::TensorInfo inputTensorInfo0{dimensionCount, shape0, ArmnnTypeInput}; armnn::TensorInfo inputTensorInfo1{dimensionCount, shape1, ArmnnTypeInput}; armnn::TensorInfo outputTensorInfo{dimensionCount, outShape, ArmnnTypeOutput}; @@ -4097,7 +4097,7 @@ LayerTestResult MultiplicationTestHelper( const unsigned int outShape[4], const std::vector & outValues) { - const size_t dimensionCount = 4; + const uint32_t dimensionCount = 4; armnn::TensorInfo inputTensorInfo0{dimensionCount, shape0, armnn::DataType::Float32}; armnn::TensorInfo inputTensorInfo1{dimensionCount, shape1, armnn::DataType::Float32}; armnn::TensorInfo outputTensorInfo{dimensionCount, outShape, armnn::DataType::Float32}; diff --git a/src/backends/reference/workloads/Debug.cpp b/src/backends/reference/workloads/Debug.cpp index d1c9fdd..09a0dfc 100644 --- a/src/backends/reference/workloads/Debug.cpp +++ b/src/backends/reference/workloads/Debug.cpp @@ -23,7 +23,7 @@ void Debug(const TensorInfo& inputInfo, const unsigned int numElements = inputInfo.GetNumElements(); const TensorShape& inputShape = inputInfo.GetShape(); - unsigned int strides[numDims]; + std::vector strides(numDims, 0); strides[numDims - 1] = inputShape[numDims - 1]; for (unsigned int i = 2; i <= numDims; i++) diff --git a/src/backends/reference/workloads/StridedSlice.cpp b/src/backends/reference/workloads/StridedSlice.cpp index 9f2b1e7..62f06dc 100644 --- a/src/backends/reference/workloads/StridedSlice.cpp +++ b/src/backends/reference/workloads/StridedSlice.cpp @@ -68,7 +68,7 @@ TensorShape ExtendShape(const TensorShape& inputShape, return inputShape; } - unsigned int newSizes[newNumDimensions]; + std::vector newSizes(newNumDimensions, 0); unsigned int diff = newNumDimensions - inputShape.GetNumDimensions(); @@ -82,7 +82,7 @@ TensorShape ExtendShape(const TensorShape& inputShape, newSizes[i] = inputShape[i - diff]; } - return TensorShape(newNumDimensions, newSizes); + return TensorShape(newNumDimensions, newSizes.data()); } } // Anonymous namespace diff --git a/tests/InferenceModel.hpp b/tests/InferenceModel.hpp index 8e463ec..4ad5872 100644 --- a/tests/InferenceModel.hpp +++ b/tests/InferenceModel.hpp @@ -400,7 +400,7 @@ public: { boost::filesystem::path filename = params.m_ModelPath; filename.replace_extension("dot"); - std::fstream file(filename.c_str(),file.out); + std::fstream file(filename.c_str(), std::ios_base::out); optNet->SerializeToDot(file); } -- 2.7.4