}
};
+struct DepthwiseConv2DLayer final
+{
+ class Return
+ {
+ public:
+ Return(loco::DepthwiseConv2D *node) : _node{node}
+ {
+ // DO NOTHING
+ }
+
+ public:
+ loco::DepthwiseConv2D *node(void) { return _node; }
+
+ private:
+ loco::DepthwiseConv2D *_node;
+ };
+
+ std::unique_ptr<Return> operator()(GraphBuilder::Context *ctx)
+ {
+ auto depthwiseconv2d_node = ctx->graph()->nodes()->create<loco::DepthwiseConv2D>();
+
+ depthwiseconv2d_node->ker(ctx->stack()->pop());
+ depthwiseconv2d_node->ifm(ctx->stack()->pop());
+
+ ctx->stack()->push(depthwiseconv2d_node);
+
+ return stdex::make_unique<Return>(depthwiseconv2d_node);
+ }
+};
+
struct FixedReshapeLayer final
{
class Return
Relu,
FeatureCodec,
AvgPool2D,
+ DepthwiseConv2D,
MaxPool2D,
TensorConcat,
FixedReshape,
};
+namespace
+{
+
+template <loco::Domain D> loco::Permutation<D> make_NHWC_perm(void);
+
+template <> loco::Permutation<loco::Domain::Feature> make_NHWC_perm(void)
+{
+ loco::Permutation<loco::Domain::Feature> perm;
+
+ perm[loco::FeatureAxis::Count] = 0;
+ perm[loco::FeatureAxis::Height] = 1;
+ perm[loco::FeatureAxis::Width] = 2;
+ perm[loco::FeatureAxis::Depth] = 3;
+
+ return perm;
+}
+
+template <loco::Domain D> loco::Permutation<D> make_HWCM_perm(void);
+
+template <> loco::Permutation<loco::Domain::DepthwiseFilter> make_HWCM_perm(void)
+{
+ loco::Permutation<loco::Domain::DepthwiseFilter> perm;
+
+ perm[loco::DepthwiseFilterAxis::Height] = 0;
+ perm[loco::DepthwiseFilterAxis::Width] = 1;
+ perm[loco::DepthwiseFilterAxis::Depth] = 2;
+ perm[loco::DepthwiseFilterAxis::Multiplier] = 3;
+
+ return perm;
+}
+
+} // namespace
+
template <GraphCode Code> class GraphTestcase;
template <> class GraphTestcase<GraphCode::Identity> final
std::unique_ptr<loco::Graph> _graph;
};
+template <> class GraphTestcase<GraphCode::DepthwiseConv2D> final
+{
+public:
+ GraphTestcase()
+ {
+ using namespace loco;
+
+ _graph = make_graph();
+
+ auto graph_builder = make_graph_builder(_graph.get());
+
+ Permutation<Domain::Feature> perm = make_NHWC_perm<Domain::Feature>();
+ Permutation<Domain::DepthwiseFilter> filter_perm = make_HWCM_perm<Domain::DepthwiseFilter>();
+
+ pull_node = graph_builder->push<InputLayer>()->name("input")->node();
+ encode_node = graph_builder->push<FeatureEncodeLayer>()->perm(perm)->node();
+
+ const_node = graph_builder->push<ConstGenLayer>()->node();
+
+ filter_encode_node =
+ graph_builder->push<DepthwiseFilterEncodeLayer>()->perm(filter_perm)->node();
+
+ depthwiseconv2d_node = graph_builder->push<DepthwiseConv2DLayer>()->node();
+
+ decode_node = graph_builder->push<FeatureDecodeLayer>()->perm(perm)->node();
+ push_node = graph_builder->push<OutputLayer>()->name("output")->node();
+ }
+
+public:
+ loco::Graph *graph() { return _graph.get(); }
+
+ loco::Pull *pull_node = nullptr;
+ loco::FeatureEncode *encode_node = nullptr;
+ loco::ConstGen *const_node = nullptr;
+ loco::DepthwiseFilterEncode *filter_encode_node = nullptr;
+ loco::DepthwiseConv2D *depthwiseconv2d_node = nullptr;
+ loco::FeatureDecode *decode_node = nullptr;
+ loco::Push *push_node = nullptr;
+
+private:
+ std::unique_ptr<loco::Graph> _graph;
+};
+
template <> class GraphTestcase<GraphCode::MaxPool2D> final
{
public:
std::unique_ptr<loco::Graph> _graph;
};
-namespace
-{
-
-template <loco::Domain D> loco::Permutation<D> make_NHWC_perm(void);
-
-template <> loco::Permutation<loco::Domain::Feature> make_NHWC_perm(void)
-{
- loco::Permutation<loco::Domain::Feature> perm;
-
- perm[loco::FeatureAxis::Count] = 0;
- perm[loco::FeatureAxis::Height] = 1;
- perm[loco::FeatureAxis::Width] = 2;
- perm[loco::FeatureAxis::Depth] = 3;
-
- return perm;
-}
-
-} // namespace
#endif // __GRAPH_TESTCASE_H__