From: 남궁석/동작제어Lab(SR)/Engineer/삼성전자 Date: Wed, 14 Nov 2018 23:50:53 +0000 (+0900) Subject: [tflchef] Support ReLU in tflchef (#2283) X-Git-Tag: nncc_backup~1326 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=64821e4c51c9eb804ea6032ebe57116c1ef50072;p=platform%2Fcore%2Fml%2Fnnfw.git [tflchef] Support ReLU in tflchef (#2283) This commit will enable ReLU in tflchef Signed-off-by: Seok NamKoong --- diff --git a/contrib/tflchef/core/src/Op/ReLU.cpp b/contrib/tflchef/core/src/Op/ReLU.cpp new file mode 100644 index 0000000..3fb8d3f --- /dev/null +++ b/contrib/tflchef/core/src/Op/ReLU.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ReLU.h" + +flatbuffers::Offset ReLUChef::value(flatbuffers::FlatBufferBuilder &fbb) const +{ + return flatbuffers::Offset(); +} + +std::unique_ptr ReLUChefFactory::create(const tflchef::Operation *operation) const +{ + return std::unique_ptr{new ReLUChef{operation}}; +} diff --git a/contrib/tflchef/core/src/Op/ReLU.h b/contrib/tflchef/core/src/Op/ReLU.h new file mode 100644 index 0000000..778458c --- /dev/null +++ b/contrib/tflchef/core/src/Op/ReLU.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __OP_RELU_H__ +#define __OP_RELU_H__ + +#include "OpChef.h" + +class ReLUChef final : public OpChef +{ +public: + explicit ReLUChef(const tflchef::Operation *operation) : _operation{operation} + { + // DO NOTHING + } + +public: + tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_RELU; } + + tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_NONE; } + + flatbuffers::Offset value(flatbuffers::FlatBufferBuilder &fbb) const override; + +private: + const tflchef::Operation *_operation; +}; + +struct ReLUChefFactory final : public OpChefFactory +{ + std::unique_ptr create(const tflchef::Operation *operation) const override; +}; + +#endif // __OP_RELU_H__ diff --git a/contrib/tflchef/core/src/OpChef.def b/contrib/tflchef/core/src/OpChef.def index d9050a5..1448af6 100644 --- a/contrib/tflchef/core/src/OpChef.def +++ b/contrib/tflchef/core/src/OpChef.def @@ -9,5 +9,6 @@ OP_CHEF(Concatenation, ConcatenationChefFactory) OP_CHEF(Conv2D, Conv2DChefFactory) OP_CHEF(DepthwiseConv2D, DepthwiseConv2DChefFactory) OP_CHEF(MaxPool2D, MaxPool2DChefFactory) +OP_CHEF(ReLU, ReLUChefFactory) OP_CHEF(ReLU6, ReLU6ChefFactory) OP_CHEF(Reshape, ReshapeChefFactory) diff --git a/contrib/tflchef/core/src/OpChefs.h b/contrib/tflchef/core/src/OpChefs.h index bd2060f..9d88ebb 100644 --- a/contrib/tflchef/core/src/OpChefs.h +++ b/contrib/tflchef/core/src/OpChefs.h @@ -22,6 +22,7 @@ #include "Op/Conv2D.h" #include "Op/DepthwiseConv2D.h" #include "Op/MaxPool2D.h" +#include "Op/ReLU.h" #include "Op/ReLU6.h" #include "Op/Reshape.h" diff --git a/contrib/tflchef/tests/relu/test.recipe b/contrib/tflchef/tests/relu/test.recipe new file mode 100644 index 0000000..8eaa360 --- /dev/null +++ b/contrib/tflchef/tests/relu/test.recipe @@ -0,0 +1,17 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } +} +operand { + name: "ofm" + type: FLOAT32 + shape { dim: 1 dim: 3 dim: 3 dim: 2 } +} +operation { + type: "ReLU" + input: "ifm" + output: "ofm" +} +input: "ifm" +output: "ofm"