2 * Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "luci/ConnectNode.h"
19 #include "ConnectNode.test.h"
21 #include <luci/Service/CircleNodeClone.h>
23 #include <gtest/gtest.h>
28 using namespace luci::test;
30 class NodeGraphlet : public NodeGraphletT<luci::CircleTransposeConv>
33 NodeGraphlet() = default;
36 void init(loco::Graph *g) override
38 NodeGraphletT<luci::CircleTransposeConv>::init(g);
40 _node->padding(luci::Padding::VALID);
41 _node->fusedActivationFunction(luci::FusedActFunc::RELU);
45 class TestNodeGraph : public TestIsOGraph<4>, public NodeGraphlet
48 TestNodeGraph() = default;
51 void init(const ShapeU32 shape)
53 TestIsOGraph<4>::init({shape, shape, shape, shape}, shape);
54 NodeGraphlet::init(g());
56 node()->inputSizes(input(0));
57 node()->filter(input(1));
58 node()->outBackprop(input(2));
59 node()->bias(input(3));
61 output()->from(node());
67 TEST(ConnectNodeTest, connect_TransposeConv)
72 ConnectionTestHelper cth;
73 cth.prepare_inputs(&tng);
75 auto *node = tng.node();
76 ASSERT_NO_THROW(loco::must_cast<luci::CircleTransposeConv *>(node));
78 auto *clone = luci::clone_node(node, cth.graph_clone());
79 ASSERT_NO_THROW(loco::must_cast<luci::CircleTransposeConv *>(clone));
81 cth.clone_connect(node, clone);
83 ASSERT_EQ(4, clone->arity());
84 ASSERT_EQ(cth.inputs(0), clone->arg(0));
85 ASSERT_EQ(cth.inputs(1), clone->arg(1));
86 ASSERT_EQ(cth.inputs(2), clone->arg(2));
87 ASSERT_EQ(cth.inputs(3), clone->arg(3));
90 TEST(ConnectNodeTest, connect_TransposeConv_NEG)
95 ConnectionTestHelper cth;
96 cth.prepare_inputs_miss(&tng);
98 auto *node = tng.node();
99 ASSERT_NO_THROW(loco::must_cast<luci::CircleTransposeConv *>(node));
101 auto *clone = luci::clone_node(node, cth.graph_clone());
102 ASSERT_NO_THROW(loco::must_cast<luci::CircleTransposeConv *>(clone));
104 EXPECT_ANY_THROW(cth.clone_connect(node, clone));