--- /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 __LOCO_IR_CANONICAL_NODE_H__
+#define __LOCO_IR_CANONICAL_NODE_H__
+
+#include "loco/IR/Node.h"
+#include "loco/IR/Dialect.h"
+#include "loco/IR/CanonicalOpcode.h"
+
+namespace loco
+{
+
+struct CanonicalNode : public Node
+{
+ virtual ~CanonicalNode() = default;
+
+ Dialect *dialect(void) const final;
+ virtual CanonicalOpcode opcode(void) const = 0;
+};
+
+template <CanonicalOpcode Code> struct CanonicalNodeImpl : public CanonicalNode
+{
+ virtual ~CanonicalNodeImpl() = default;
+
+ CanonicalOpcode opcode(void) const final { return Code; }
+};
+
+} // namespace loco
+
+#endif // __LOCO_IR_CANONICAL_NODE_H__
#include "loco/IR/FeatureCodec.h"
#include "loco/IR/FilterCodec.h"
#include "loco/IR/NodeMixins.h"
+#include "loco/IR/CanonicalNode.h"
namespace loco
{
*
* This node may encode memory transfer (such as CPU -> GPU or GPU -> CPU)
*/
-class Forward final : public FixedArityNode<1, Node>
+class Forward final : public FixedArityNode<1, CanonicalNodeImpl<CanonicalOpcode::Forward>>
{
public:
Forward() = default;
--- /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 "loco/IR/CanonicalNode.h"
+#include "loco/IR/CanonicalDialect.h"
+
+namespace loco
+{
+
+Dialect *CanonicalNode::dialect(void) const { return CanonicalDialect::get(); }
+
+} // namespace loco
*/
#include "loco/IR/Nodes.h"
+#include "loco/IR/CanonicalDialect.h"
#include <gtest/gtest.h>
{
loco::Forward forward_node;
+ ASSERT_EQ(forward_node.dialect(), loco::CanonicalDialect::get());
+ ASSERT_EQ(forward_node.opcode(), loco::CanonicalOpcode::Forward);
+
ASSERT_EQ(forward_node.input(), nullptr);
}