From 20b15d9c37fc7a4fe7ba3b4f74ada820af225e25 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Tue, 4 Sep 2018 13:54:08 +0900 Subject: [PATCH] [neurun] Define default value in constructor (#2567) Define default value in constructor for kernel Signed-off-by: Hyeongseok Oh --- runtimes/neurun/src/kernel/acl_cl/ConcatLayer.cc | 6 ++++++ runtimes/neurun/src/kernel/acl_cl/ConcatLayer.h | 2 +- runtimes/neurun/src/kernel/cpu/AvgPoolLayer.cc | 9 +++++++++ runtimes/neurun/src/kernel/cpu/AvgPoolLayer.h | 2 +- runtimes/neurun/src/kernel/cpu/ConcatLayer.cc | 7 +++++++ runtimes/neurun/src/kernel/cpu/ConcatLayer.h | 2 +- runtimes/neurun/src/kernel/cpu/ConvolutionLayer.cc | 9 +++++++++ runtimes/neurun/src/kernel/cpu/ConvolutionLayer.h | 2 +- runtimes/neurun/src/kernel/cpu/FullyConnectedLayer.cc | 8 ++++++++ runtimes/neurun/src/kernel/cpu/FullyConnectedLayer.h | 2 +- runtimes/neurun/src/kernel/cpu/MaxPoolLayer.cc | 9 +++++++++ runtimes/neurun/src/kernel/cpu/MaxPoolLayer.h | 2 +- runtimes/neurun/src/kernel/cpu/ReshapeLayer.cc | 6 ++++++ runtimes/neurun/src/kernel/cpu/ReshapeLayer.h | 2 +- runtimes/neurun/src/kernel/cpu/SoftMaxLayer.cc | 7 +++++++ runtimes/neurun/src/kernel/cpu/SoftMaxLayer.h | 2 +- 16 files changed, 69 insertions(+), 8 deletions(-) diff --git a/runtimes/neurun/src/kernel/acl_cl/ConcatLayer.cc b/runtimes/neurun/src/kernel/acl_cl/ConcatLayer.cc index f71c8af..f2a8dae 100644 --- a/runtimes/neurun/src/kernel/acl_cl/ConcatLayer.cc +++ b/runtimes/neurun/src/kernel/acl_cl/ConcatLayer.cc @@ -49,6 +49,12 @@ namespace kernel namespace acl_cl { +ConcatLayer::ConcatLayer() + : _input_allocs(), _output_alloc(nullptr), _axis(0), _input_type(OperandType::FLOAT32) +{ + // DO NOTHING +} + bool ConcatLayer::concatenationFloat32() { // Input and output size check diff --git a/runtimes/neurun/src/kernel/acl_cl/ConcatLayer.h b/runtimes/neurun/src/kernel/acl_cl/ConcatLayer.h index 1341832..d6e7d7d 100644 --- a/runtimes/neurun/src/kernel/acl_cl/ConcatLayer.h +++ b/runtimes/neurun/src/kernel/acl_cl/ConcatLayer.h @@ -43,7 +43,7 @@ namespace acl_cl class ConcatLayer : public ::arm_compute::IFunction { public: - ConcatLayer() {} + ConcatLayer(); public: void configure(const std::vector<::arm_compute::ICLTensor *> &input_allocs, diff --git a/runtimes/neurun/src/kernel/cpu/AvgPoolLayer.cc b/runtimes/neurun/src/kernel/cpu/AvgPoolLayer.cc index e5e118c..b11fc3b 100644 --- a/runtimes/neurun/src/kernel/cpu/AvgPoolLayer.cc +++ b/runtimes/neurun/src/kernel/cpu/AvgPoolLayer.cc @@ -36,6 +36,15 @@ namespace cpu uint32_t paddingHeight = (uint32_t)_paddingTop; \ uint32_t paddingWidth = (uint32_t)_paddingLeft; +AvgPoolLayer::AvgPoolLayer() + : _inputData(nullptr), _outputData(nullptr), _inputShape(), _outputShape(), _paddingLeft(0), + _paddingTop(0), _paddingRight(0), _paddingBottom(0), _strideWidth(0), _strideHeight(0), + _kernelWidth(0), _kernelHeight(0), _activation(ANEURALNETWORKS_FUSED_NONE), + _inputType(OperandType::FLOAT32) +{ + // DO NOTHING +} + bool AvgPoolLayer::averagePoolFloat32() { diff --git a/runtimes/neurun/src/kernel/cpu/AvgPoolLayer.h b/runtimes/neurun/src/kernel/cpu/AvgPoolLayer.h index 5d2540c..2d74eeb 100644 --- a/runtimes/neurun/src/kernel/cpu/AvgPoolLayer.h +++ b/runtimes/neurun/src/kernel/cpu/AvgPoolLayer.h @@ -19,7 +19,7 @@ namespace cpu class AvgPoolLayer : public ::arm_compute::IFunction { public: - AvgPoolLayer() {} + AvgPoolLayer(); public: bool averagePoolFloat32(); diff --git a/runtimes/neurun/src/kernel/cpu/ConcatLayer.cc b/runtimes/neurun/src/kernel/cpu/ConcatLayer.cc index 5c2c207..4514d5d 100644 --- a/runtimes/neurun/src/kernel/cpu/ConcatLayer.cc +++ b/runtimes/neurun/src/kernel/cpu/ConcatLayer.cc @@ -27,6 +27,13 @@ namespace kernel namespace cpu { +ConcatLayer::ConcatLayer() + : _inputDataPtrs(), _outputData(nullptr), _axis(0), _inputShapes(), _outputShape(), + _inputType(OperandType::FLOAT32) +{ + // DO NOTHING +} + bool ConcatLayer::concatenationFloat32() { int num_inputs = _inputShapes.size(); diff --git a/runtimes/neurun/src/kernel/cpu/ConcatLayer.h b/runtimes/neurun/src/kernel/cpu/ConcatLayer.h index a209de0..6c02172 100644 --- a/runtimes/neurun/src/kernel/cpu/ConcatLayer.h +++ b/runtimes/neurun/src/kernel/cpu/ConcatLayer.h @@ -36,7 +36,7 @@ namespace cpu class ConcatLayer : public ::arm_compute::IFunction { public: - ConcatLayer() {} + ConcatLayer(); public: bool concatenationFloat32(); diff --git a/runtimes/neurun/src/kernel/cpu/ConvolutionLayer.cc b/runtimes/neurun/src/kernel/cpu/ConvolutionLayer.cc index 8524eee..b84b545 100644 --- a/runtimes/neurun/src/kernel/cpu/ConvolutionLayer.cc +++ b/runtimes/neurun/src/kernel/cpu/ConvolutionLayer.cc @@ -68,6 +68,15 @@ static std::mutex executionMutex; im2colGuard.reset(im2colData); \ } +ConvolutionLayer::ConvolutionLayer() + : _inputData(nullptr), _kernelData(nullptr), _outputData(nullptr), _biasData(nullptr), + _inputShape(), _kernelShape(), _outputShape(), _biasShape(), _paddingLeft(0), _paddingTop(0), + _paddingRight(0), _paddingBottom(0), _strideWidth(0), _strideHeight(0), + _activation(ANEURALNETWORKS_FUSED_NONE), _inputType(OperandType::FLOAT32) +{ + // DO NOTHING +} + bool ConvolutionLayer::convFloat32() { ANDROID_NN_CONV_PARAMETERS(float) diff --git a/runtimes/neurun/src/kernel/cpu/ConvolutionLayer.h b/runtimes/neurun/src/kernel/cpu/ConvolutionLayer.h index 44ffc3e..8b07286 100644 --- a/runtimes/neurun/src/kernel/cpu/ConvolutionLayer.h +++ b/runtimes/neurun/src/kernel/cpu/ConvolutionLayer.h @@ -19,7 +19,7 @@ namespace cpu class ConvolutionLayer : public ::arm_compute::IFunction { public: - ConvolutionLayer() {} + ConvolutionLayer(); public: bool convFloat32(); diff --git a/runtimes/neurun/src/kernel/cpu/FullyConnectedLayer.cc b/runtimes/neurun/src/kernel/cpu/FullyConnectedLayer.cc index a43811e..cbd2ef8 100644 --- a/runtimes/neurun/src/kernel/cpu/FullyConnectedLayer.cc +++ b/runtimes/neurun/src/kernel/cpu/FullyConnectedLayer.cc @@ -30,6 +30,14 @@ namespace kernel namespace cpu { +FullyConnectedLayer::FullyConnectedLayer() + : _inputData(nullptr), _weightsData(nullptr), _biasData(nullptr), _outputData(nullptr), + _inputShape(), _weightsShape(), _biasShape(), _outputShape(), + _activation(ANEURALNETWORKS_FUSED_NONE), _inputType(OperandType::FLOAT32) +{ + // DO NOTHING +} + // executionMutex is used to protect concurrent access of non-threadsafe resources // like gemmlowp::GemmContext. // std::mutex is safe for pthreads on Android. diff --git a/runtimes/neurun/src/kernel/cpu/FullyConnectedLayer.h b/runtimes/neurun/src/kernel/cpu/FullyConnectedLayer.h index 637cf54..d91dc0f 100644 --- a/runtimes/neurun/src/kernel/cpu/FullyConnectedLayer.h +++ b/runtimes/neurun/src/kernel/cpu/FullyConnectedLayer.h @@ -19,7 +19,7 @@ namespace cpu class FullyConnectedLayer : public ::arm_compute::IFunction { public: - FullyConnectedLayer() {} + FullyConnectedLayer(); public: bool fullyConnectedFloat32(); diff --git a/runtimes/neurun/src/kernel/cpu/MaxPoolLayer.cc b/runtimes/neurun/src/kernel/cpu/MaxPoolLayer.cc index e40974e..79af572 100644 --- a/runtimes/neurun/src/kernel/cpu/MaxPoolLayer.cc +++ b/runtimes/neurun/src/kernel/cpu/MaxPoolLayer.cc @@ -19,6 +19,15 @@ namespace cpu uint32_t paddingHeight = (uint32_t)_paddingTop; \ uint32_t paddingWidth = (uint32_t)_paddingLeft; +MaxPoolLayer::MaxPoolLayer() + : _inputData(nullptr), _outputData(nullptr), _inputShape(), _outputShape(), _paddingLeft(0), + _paddingTop(0), _paddingRight(0), _paddingBottom(0), _strideWidth(0), _strideHeight(0), + _kernelWidth(0), _kernelHeight(0), _activation(ANEURALNETWORKS_FUSED_NONE), + _inputType(OperandType::FLOAT32) +{ + // DO NOTHING +} + bool MaxPoolLayer::maxPoolFloat32() { diff --git a/runtimes/neurun/src/kernel/cpu/MaxPoolLayer.h b/runtimes/neurun/src/kernel/cpu/MaxPoolLayer.h index 60d15f9..57652cf 100644 --- a/runtimes/neurun/src/kernel/cpu/MaxPoolLayer.h +++ b/runtimes/neurun/src/kernel/cpu/MaxPoolLayer.h @@ -19,7 +19,7 @@ namespace cpu class MaxPoolLayer : public ::arm_compute::IFunction { public: - MaxPoolLayer() {} + MaxPoolLayer(); public: bool maxPoolFloat32(); diff --git a/runtimes/neurun/src/kernel/cpu/ReshapeLayer.cc b/runtimes/neurun/src/kernel/cpu/ReshapeLayer.cc index 3e5b442..377f783 100644 --- a/runtimes/neurun/src/kernel/cpu/ReshapeLayer.cc +++ b/runtimes/neurun/src/kernel/cpu/ReshapeLayer.cc @@ -28,6 +28,12 @@ namespace kernel namespace cpu { +ReshapeLayer::ReshapeLayer() + : _inputData(nullptr), _outputData(nullptr), _inputShape(), _outputShape() +{ + // DO NOTHING +} + bool ReshapeLayer::reshapeGeneric() { size_t count = sizeOfData(_inputShape.type, _inputShape.dimensions); diff --git a/runtimes/neurun/src/kernel/cpu/ReshapeLayer.h b/runtimes/neurun/src/kernel/cpu/ReshapeLayer.h index 23ac710..7da7217 100644 --- a/runtimes/neurun/src/kernel/cpu/ReshapeLayer.h +++ b/runtimes/neurun/src/kernel/cpu/ReshapeLayer.h @@ -19,7 +19,7 @@ namespace cpu class ReshapeLayer : public ::arm_compute::IFunction { public: - ReshapeLayer() {} + ReshapeLayer(); public: bool reshapeGeneric(); diff --git a/runtimes/neurun/src/kernel/cpu/SoftMaxLayer.cc b/runtimes/neurun/src/kernel/cpu/SoftMaxLayer.cc index 5c3e82e..af2c944 100644 --- a/runtimes/neurun/src/kernel/cpu/SoftMaxLayer.cc +++ b/runtimes/neurun/src/kernel/cpu/SoftMaxLayer.cc @@ -10,6 +10,13 @@ namespace kernel namespace cpu { +SoftMaxLayer::SoftMaxLayer() + : _inputData(nullptr), _outputData(nullptr), _beta(0.0), _inputShape(), _outputShape(), + _inputType(OperandType::FLOAT32) +{ + // DO NOTHING +} + bool SoftMaxLayer::softmaxFloat32() { ::tflite::Dims<4> dim; diff --git a/runtimes/neurun/src/kernel/cpu/SoftMaxLayer.h b/runtimes/neurun/src/kernel/cpu/SoftMaxLayer.h index 0008ba4..c8838ab 100644 --- a/runtimes/neurun/src/kernel/cpu/SoftMaxLayer.h +++ b/runtimes/neurun/src/kernel/cpu/SoftMaxLayer.h @@ -19,7 +19,7 @@ namespace cpu class SoftMaxLayer : public ::arm_compute::IFunction { public: - SoftMaxLayer() {} + SoftMaxLayer(); public: bool softmaxFloat32(); -- 2.7.4