LAYER_ZONEOUT_LSTMCELL, /**< Zoneout LSTM Cell Layer type */
LAYER_GRUCELL, /**< GRU Cell Layer type */
LAYER_REDUCE_MEAN, /**< Reduce mean Layer type */
+ LAYER_IDENTITY, /**< Identity Layer type */
LAYER_LOSS_MSE = 500, /**< Mean Squared Error Loss Layer type */
LAYER_LOSS_CROSS_ENTROPY_SIGMOID, /**< Cross Entropy with Sigmoid Loss Layer
type */
$(NNTRAINER_ROOT)/nntrainer/layers/common_properties.cpp \
$(NNTRAINER_ROOT)/nntrainer/layers/layer_impl.cpp \
$(NNTRAINER_ROOT)/nntrainer/layers/reduce_mean_layer.cpp \
+ $(NNTRAINER_ROOT)/nntrainer/layers/identity_layer.cpp \
$(NNTRAINER_ROOT)/nntrainer/graph/network_graph.cpp \
$(NNTRAINER_ROOT)/nntrainer/graph/graph_core.cpp \
$(NNTRAINER_ROOT)/nntrainer/graph/connection.cpp \
#include <flatten_layer.h>
#include <gru.h>
#include <grucell.h>
+#include <identity_layer.h>
#include <input_layer.h>
#include <lstm.h>
#include <lstmcell.h>
MoLAttentionLayer::type, LayerType::LAYER_MOL_ATTENTION);
ac.registerFactory(nntrainer::createLayer<ReduceMeanLayer>,
ReduceMeanLayer::type, LayerType::LAYER_REDUCE_MEAN);
+ ac.registerFactory(nntrainer::createLayer<IdentityLayer>, IdentityLayer::type,
+ LayerType::LAYER_IDENTITY);
#ifdef ENABLE_NNSTREAMER_BACKBONE
ac.registerFactory(nntrainer::createLayer<NNStreamerLayer>,
--- /dev/null
+// SPDX-License-Identifier: Apache-2.0
+/**
+ * Copyright (C) 2021 Jihoon Lee <jhoon.it.lee@samsung.com>
+ *
+ * @file identity.cpp
+ * @date 16 Dec 2021
+ * @brief This is identity layer flows everything as it is
+ * @see https://github.com/nnstreamer/nntrainer
+ * @author Jihoon Lee <jhoon.it.lee@samsung.com>
+ * @bug No known bugs except for NYI items
+ *
+ */
+#include <identity_layer.h>
+#include <layer_context.h>
+#include <nntrainer_error.h>
+#include <stdexcept>
+#include <tensor.h>
+
+namespace nntrainer {
+IdentityLayer::IdentityLayer() {}
+
+IdentityLayer::~IdentityLayer() {}
+
+void IdentityLayer::finalize(InitLayerContext &context) {
+ context.setOutputDimensions(context.getInputDimensions());
+}
+
+void IdentityLayer::forwarding(RunLayerContext &context, bool training) {
+ if (!context.executeInPlace()) {
+ for (unsigned int i = 0, sz = context.getNumInputs(); i < sz; ++i) {
+ Tensor &hidden_ = context.getOutput(i);
+ Tensor &input_ = context.getInput(i);
+ hidden_.copyData(input_);
+ }
+ }
+}
+
+void IdentityLayer::calcDerivative(RunLayerContext &context) {
+ if (!context.executeInPlace()) {
+ for (unsigned int i = 0, sz = context.getNumInputs(); i < sz; ++i) {
+ Tensor &d_hidden = context.getIncomingDerivative(i);
+ Tensor &d_input = context.getOutgoingDerivative(i);
+ d_input.copyData(d_hidden);
+ }
+ }
+}
+
+void IdentityLayer::setProperty(const std::vector<std::string> &values) {
+ NNTR_THROW_IF(values.size(), std::invalid_argument)
+ << "Identity layer has left unparsed properties";
+}
+} // namespace nntrainer