static constexpr size_t SINGLE_INOUT_IDX = 0;
void FlattenLayer::finalize(InitLayerContext &context) {
- ReshapeLayer::setProperty({"target_shape=-1"});
+ const TensorDim &in_dim = context.getInputDimensions()[0];
+
+ std::string target_shape =
+ "target_shape=1:1:" + std::to_string(in_dim.getFeatureLen());
+ ReshapeLayer::setProperty({target_shape});
+
/** @note the output dimension is in invalid state till finalize of
* reshape_layer is finished */
ReshapeLayer::finalize(context);
- const TensorDim &in_dim = context.getInputDimensions()[0];
if (in_dim.channel() == 1 && in_dim.height() == 1) {
ml_logw("Warning: the flatten layer is redundant");
}
}
void FlattenLayer::setProperty(const std::vector<std::string> &values) {
- if (!values.empty()) {
+ auto remain_props = loadProperties(values, reshape_props);
+ if (!remain_props.empty()) {
std::string msg = "[FlattenLayer] Unknown Layer Properties count " +
std::to_string(values.size());
throw exception::not_supported(msg);
}
void FlattenLayer::exportTo(Exporter &exporter,
- const ExportMethods &method) const {}
+ const ExportMethods &method) const {
+ exporter.saveResult(reshape_props, method, this);
+}
} /* namespace nntrainer */