template bool CanonicalNodeConverter<loco::EltwiseMul>::run(loco::Graph *graph);
// TODO loco::EltwiseSqrt
// TODO loco::EltwiseSub
-// TODO loco::FeatureBiasAdd
+template bool CanonicalNodeConverter<loco::FeatureBiasAdd>::run(loco::Graph *graph);
// TODO loco::FixedReshape
template bool CanonicalNodeConverter<loco::MaxPool2D>::run(loco::Graph *graph);
template bool CanonicalNodeConverter<loco::ReLU>::run(loco::Graph *graph);
--- /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 "FeatureBiasAddConverter.h"
+
+#include "Dialect/IR/TFLNodes.h"
+
+#include "GraphBlock.h"
+
+#include <loco.h>
+#include <loco/Service/ShapeInference.h>
+
+#include <cassert>
+
+namespace exo
+{
+
+/**
+ * @brief Converts loco::FeatureBiasAdd to locoex::TFLAdd
+ *
+ * Before:
+ * Foo ---+
+ * |
+ * loco::FeatureBiasAdd - FeatureDecode - ...
+ * |
+ * Bar - BiasEncode --+
+ *
+ * After:
+ *
+ * Foo - loco::FeatureDecode --+ loco::FeatureBiasAdd
+ * |(x)
+ * TFLAdd -- loco::FeatureEncode - FeatureDecode - ...
+ * |(y)
+ * Bar - BiasEncode - loco::BiasDecode --+
+ */
+bool FeatureBiasAddConverter::convert(loco::FeatureBiasAdd *origin)
+{
+ auto *graph = origin->graph();
+
+ auto tfl_add = graph->nodes()->create<locoex::TFLAdd>();
+
+ // handling input x
+ assert(loco::shape_get(origin->value()).domain() == loco::Domain::Feature);
+
+ auto fea_dec = make_feature_decode<DefaultLayout::NHWC>(origin->value());
+ tfl_add->x(fea_dec);
+
+ // handling input y
+ auto bias_dec = graph->nodes()->create<loco::BiasDecode>();
+ assert(bias_dec != nullptr);
+
+ bias_dec->input(origin->bias());
+
+ tfl_add->y(bias_dec);
+
+ // handling output
+ auto fea_enc = make_feature_encode<DefaultLayout::NHWC>(tfl_add);
+
+ loco::replace(origin).with(fea_enc);
+ origin->value(nullptr);
+
+ return true;
+}
+
+} // namespace exo
--- /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 __CONVERSION_FEATUREBIASADD_CONVERTER__
+#define __CONVERSION_FEATUREBIASADD_CONVERTER__
+
+#include "CanonicalNodeConverter.h"
+
+#include <loco.h>
+
+namespace exo
+{
+
+class FeatureBiasAddConverter : public CanonicalNodeConverter<loco::FeatureBiasAdd>
+{
+public:
+ const char *name(void) const final { return "exo::TFLAddConverter"; }
+
+public:
+ bool convert(loco::FeatureBiasAdd *origin) final;
+};
+
+} // namespace exo
+
+#endif // __CONVERSION_FEATUREBIASADD_CONVERTER__