--- /dev/null
+/*
+ * Copyright (c) 2019 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 "FullyConnected.h"
+#include "Convert.h"
+
+#include <cassert>
+
+flatbuffers::Offset<void> FullyConnectedChef::value(flatbuffers::FlatBufferBuilder &fbb) const
+{
+ auto &operation = (*_operation);
+
+ assert(operation.has_fullyconnected_options());
+
+ auto tflite_activation = as_tflite_activation(operation.fullyconnected_options().activation());
+
+ tflite::FullyConnectedOptionsBuilder fc_options_builder{fbb};
+ fc_options_builder.add_fused_activation_function(tflite_activation);
+
+ return fc_options_builder.Finish().Union();
+}
+
+std::unique_ptr<OpChef> FullyConnectedChefFactory::create(const tflchef::Operation *operation) const
+{
+ return std::unique_ptr<OpChef>{new FullyConnectedChef{operation}};
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 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_FULLYCONNECTED_H__
+#define __OP_FULLYCONNECTED_H__
+
+#include "OpChef.h"
+
+class FullyConnectedChef final : public OpChef
+{
+public:
+ explicit FullyConnectedChef(const tflchef::Operation *operation) : _operation{operation}
+ {
+ // DO NOTHING
+ }
+
+public:
+ tflite::BuiltinOperator code(void) const override
+ {
+ return tflite::BuiltinOperator_FULLY_CONNECTED;
+ }
+
+ tflite::BuiltinOptions type(void) const override
+ {
+ return tflite::BuiltinOptions_FullyConnectedOptions;
+ }
+
+ flatbuffers::Offset<void> value(flatbuffers::FlatBufferBuilder &fbb) const override;
+
+private:
+ const tflchef::Operation *_operation;
+};
+
+struct FullyConnectedChefFactory final : public OpChefFactory
+{
+ std::unique_ptr<OpChef> create(const tflchef::Operation *operation) const override;
+};
+
+#endif // __OP_FULLYCONNECTED_H__
OP_CHEF(Conv2D, Conv2DChefFactory)
OP_CHEF(DepthwiseConv2D, DepthwiseConv2DChefFactory)
OP_CHEF(Div, DivChefFactory)
+OP_CHEF(FullyConnected, FullyConnectedChefFactory)
OP_CHEF(MaxPool2D, MaxPool2DChefFactory)
OP_CHEF(ReLU, ReLUChefFactory)
OP_CHEF(ReLU6, ReLU6ChefFactory)
#include "Op/Conv2D.h"
#include "Op/DepthwiseConv2D.h"
#include "Op/Div.h"
+#include "Op/FullyConnected.h"
#include "Op/MaxPool2D.h"
#include "Op/ReLU.h"
#include "Op/ReLU6.h"
optional Activation activation = 1 [default = NONE];
}
+message FullyConnectedOptions {
+ optional Activation activation = 1 [default = NONE];
+}
+
message Operation {
optional string type = 1;
repeated string input = 2;
optional DepthwiseConv2DOptions depthwiseconv2d_options = 105;
optional SubOptions sub_options = 106;
optional DivOptions div_options = 107;
+ optional FullyConnectedOptions fullyconnected_options = 108;
}
message ModelRecipe {
--- /dev/null
+operand {
+ name: "in"
+ type: FLOAT32
+ shape { dim: 1 dim: 64 }
+}
+operand {
+ name: "weight"
+ type: FLOAT32
+ shape { dim: 8 dim: 64 }
+}
+operand {
+ name: "bias"
+ type: FLOAT32
+ shape { dim: 8 }
+}
+operand {
+ name: "out"
+ type: FLOAT32
+ shape { dim: 1 dim: 8 }
+}
+operation {
+ type: "FullyConnected"
+ fullyconnected_options {
+ activation: NONE
+ }
+ input: "in"
+ input: "weight"
+ input: "bias"
+ output: "out"
+}
+input: "in"
+input: "weight"
+input: "bias"
+output: "out"