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::CircleReverseSequence>
33 NodeGraphlet() = default;
36 class TestNodeGraph : public TestIsOGraph<2>, public NodeGraphlet
39 TestNodeGraph() = default;
42 void init(const ShapeU32 shape)
44 TestIsOGraph<2>::init({shape, shape}, shape);
45 NodeGraphlet::init(g());
47 node()->input(input(0));
48 node()->seq_lengths(input(1));
50 output()->from(node());
56 TEST(ConnectNodeTest, connect_ReverseSequence)
61 ConnectionTestHelper cth;
62 cth.prepare_inputs(&tng);
64 auto *node = tng.node();
65 ASSERT_NO_THROW(loco::must_cast<luci::CircleReverseSequence *>(node));
67 auto *clone = luci::clone_node(node, cth.graph_clone());
68 ASSERT_NO_THROW(loco::must_cast<luci::CircleReverseSequence *>(clone));
70 cth.clone_connect(node, clone);
72 ASSERT_EQ(2, clone->arity());
73 ASSERT_EQ(cth.inputs(0), clone->arg(0));
74 ASSERT_EQ(cth.inputs(1), clone->arg(1));
77 TEST(ConnectNodeTest, connect_ReverseSequence_NEG)
82 ConnectionTestHelper cth;
83 cth.prepare_inputs_miss(&tng);
85 auto *node = tng.node();
86 ASSERT_NO_THROW(loco::must_cast<luci::CircleReverseSequence *>(node));
88 auto *clone = luci::clone_node(node, cth.graph_clone());
89 ASSERT_NO_THROW(loco::must_cast<luci::CircleReverseSequence *>(clone));
91 EXPECT_ANY_THROW(cth.clone_connect(node, clone));