[locoex/customop] Adding COpCall node (#4290)
author윤현식/On-Device Lab(SR)/Principal Engineer/삼성전자 <hyunsik.yoon@samsung.com>
Tue, 16 Jul 2019 07:06:07 +0000 (16:06 +0900)
committer박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 16 Jul 2019 07:06:07 +0000 (16:06 +0900)
COpCall node (previously merged as Call node) is added with some methods.

Signed-off-by: Hyun Sik Yoon <hyunsik.yoon@samsung.com>
contrib/locoex-customop/CMakeLists.txt
contrib/locoex-customop/include/locoex/COpCall.h [new file with mode: 0644]
contrib/locoex-customop/include/locoex/customop/Call.h [deleted file]
contrib/locoex-customop/requires.cmake
contrib/locoex-customop/src/COpCall.cpp [moved from contrib/locoex-customop/src/Call.cpp with 89% similarity]

index 0f2b38f..75e7e81 100644 (file)
@@ -5,6 +5,7 @@ list(REMOVE_ITEM SOURCES ${TESTS})
 add_library(locoex_customop SHARED ${SOURCES})
 target_include_directories(locoex_customop PUBLIC include)
 target_link_libraries(locoex_customop PUBLIC loco)
+target_link_libraries(locoex_customop PRIVATE plier_tf)
 
 if(NOT ENABLE_TEST)
   return()
diff --git a/contrib/locoex-customop/include/locoex/COpCall.h b/contrib/locoex-customop/include/locoex/COpCall.h
new file mode 100644 (file)
index 0000000..13d6b7e
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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 __LOCOEX_COPCALL_H__
+#define __LOCOEX_COPCALL_H__
+
+#include "VariadicArityNode.h"
+#include "locoex/COpAttrTypes.h"
+#include "locoex/COpNode.h"
+
+#include <loco/IR/NodeMixins.h>
+
+#include <map>
+#include <memory>
+
+namespace locoex
+{
+
+/**
+ * @brief Class to calls custom operation
+ */
+class COpCall final : public VariadicArityNode<COpNode>,
+                      public loco::NodeMixin<loco::NodeTrait::TensorShape>
+{
+public:
+  COpCall(unsigned arity) : VariadicArityNode<COpNode>(arity) {}
+
+public:
+  void op(const std::string &op) { _op.assign(op); }
+  const std::string &op() { return _op; }
+
+  void name(const std::string &name) { _name.assign(name); }
+  const std::string &name() { return _name; }
+
+  void input(uint32_t nth, loco::Node *node) { at(nth)->node(node); }
+  loco::Node *input(uint32_t nth) const { return at(nth)->node(); }
+
+  // TODO add methods for accessing attributes
+
+private:
+  std::string _op;
+  std::string _name;
+};
+
+} // namespace locoex
+
+#endif // __LOCOEX_COPCALL_H__
diff --git a/contrib/locoex-customop/include/locoex/customop/Call.h b/contrib/locoex-customop/include/locoex/customop/Call.h
deleted file mode 100644 (file)
index 903b6e0..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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 __LOCOEX_CUSTOMOP_CALL_H__
-#define __LOCOEX_CUSTOMOP_CALL_H__
-
-namespace locoex
-{
-namespace customop
-{
-
-/**
- * @brief Class to represents custom operation.
- *        In IR, Call node means a node that eventually calls custom op and its kernel.
- */
-class Call final // TODO inherit parents
-{
-public:
-  Call() = default;
-
-  // TODO implement methods
-};
-
-} // namespace customop
-} // namespace locoex
-
-#endif // __LOCOEX_CUSTOMOP_CALL_H__
similarity index 89%
rename from contrib/locoex-customop/src/Call.cpp
rename to contrib/locoex-customop/src/COpCall.cpp
index 0e4efc5..514d47a 100644 (file)
@@ -14,6 +14,6 @@
  * limitations under the License.
  */
 
-#include "locoex/customop/Call.h"
+#include "locoex/COpCall.h"
 
-// TODO implement body of Call node
+// TODO add methods for accessing attributes