--- /dev/null
+/*
+ * 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 "Div.h"
+#include "Convert.h"
+
+#include <cassert>
+
+flatbuffers::Offset<void> DivChef::value(flatbuffers::FlatBufferBuilder &fbb) const
+{
+ auto &operation = (*_operation);
+
+ assert(operation.has_div_options());
+
+ auto tflite_activation = as_tflite_activation(operation.div_options().activation());
+
+ tflite::DivOptionsBuilder div_options_builder{fbb};
+ div_options_builder.add_fused_activation_function(tflite_activation);
+
+ return div_options_builder.Finish().Union();
+}
+
+std::unique_ptr<OpChef> DivChefFactory::create(const tflchef::Operation *operation) const
+{
+ return std::unique_ptr<OpChef>{new DivChef{operation}};
+}
--- /dev/null
+/*
+ * 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_DIV_H__
+#define __OP_DIV_H__
+
+#include "OpChef.h"
+
+class DivChef final : public OpChef
+{
+public:
+ explicit DivChef(const tflchef::Operation *operation) : _operation{operation}
+ {
+ // DO NOTHING
+ }
+
+public:
+ tflite::BuiltinOperator code(void) const override { return tflite::BuiltinOperator_DIV; }
+
+ tflite::BuiltinOptions type(void) const override { return tflite::BuiltinOptions_DivOptions; }
+
+ flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override;
+
+private:
+ const tflchef::Operation *_operation;
+};
+
+struct DivChefFactory final : public OpChefFactory
+{
+ std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override;
+};
+
+#endif // __OP_DIV_H__
OP_CHEF(Concatenation, ConcatenationChefFactory)
OP_CHEF(Conv2D, Conv2DChefFactory)
OP_CHEF(DepthwiseConv2D, DepthwiseConv2DChefFactory)
+OP_CHEF(Div, DivChefFactory)
OP_CHEF(MaxPool2D, MaxPool2DChefFactory)
OP_CHEF(ReLU, ReLUChefFactory)
OP_CHEF(ReLU6, ReLU6ChefFactory)
#include "Op/Concatenation.h"
#include "Op/Conv2D.h"
#include "Op/DepthwiseConv2D.h"
+#include "Op/Div.h"
#include "Op/MaxPool2D.h"
#include "Op/ReLU.h"
#include "Op/ReLU6.h"
optional Activation activation = 1 [default = NONE];
}
+message DivOptions {
+ optional Activation activation = 1 [default = NONE];
+}
+
message Operation {
optional string type = 1;
repeated string input = 2;
optional ReshapeOptions reshape_options = 104;
optional DepthwiseConv2DOptions depthwiseconv2d_options = 105;
optional SubOptions sub_options = 106;
+ optional DivOptions div_options = 107;
}
message ModelRecipe {
--- /dev/null
+operand {
+ name: "ifm1"
+ type: FLOAT32
+ shape { dim: 1 dim: 4 dim: 4 dim: 3 }
+}
+operand {
+ name: "ifm2"
+ type: FLOAT32
+ shape { dim: 1 dim: 4 dim: 4 dim: 3 }
+}
+operand {
+ name: "ofm"
+ type: FLOAT32
+ shape { dim: 1 dim: 4 dim: 4 dim: 3 }
+}
+operation {
+ type: "Div"
+ input: "ifm1"
+ input: "ifm2"
+ output: "ofm"
+ div_options {
+ activation: NONE
+ }
+}
+input: "ifm1"
+input: "ifm2"
+output: "ofm"