[loco] Add index getter (#6367)
author박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 8 Aug 2019 04:19:19 +0000 (13:19 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 8 Aug 2019 04:19:19 +0000 (13:19 +0900)
This commit extends GraphInput and GraphOutput class with "index"
getter.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
compiler/loco/include/loco/IR/Graph.h
compiler/loco/include/loco/IR/GraphInputIndex.h [new file with mode: 0644]
compiler/loco/include/loco/IR/GraphOutputIndex.h [new file with mode: 0644]
compiler/loco/include/loco/IR/Nodes.h
compiler/loco/src/IR/Graph.test.cpp
compiler/loco/src/IR/GraphInputIndex.cpp [new file with mode: 0644]
compiler/loco/src/IR/GraphOutputIndex.cpp [new file with mode: 0644]

index f228daf..0e576dc 100644 (file)
@@ -20,6 +20,8 @@
 #include "loco/IR/DataType.h"
 #include "loco/IR/Nodes.h"
 #include "loco/IR/NodePool.h"
+#include "loco/IR/GraphInputIndex.h"
+#include "loco/IR/GraphOutputIndex.h"
 
 #include "loco/ADT/ObjectPool.h"
 
@@ -119,6 +121,9 @@ public:
 
   ~GraphInput() = default;
 
+public:
+  GraphInputIndex index(void) const { return _index; }
+
 private:
   uint32_t _index;
 
@@ -160,6 +165,9 @@ public:
 
   ~GraphOutput() = default;
 
+public:
+  GraphOutputIndex index(void) const { return _index; }
+
 private:
   uint32_t _index;
 
diff --git a/compiler/loco/include/loco/IR/GraphInputIndex.h b/compiler/loco/include/loco/IR/GraphInputIndex.h
new file mode 100644 (file)
index 0000000..3c7ae98
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * 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_GRAPH_INPUT_INDEX_H__
+#define __LOCO_IR_GRAPH_INPUT_INDEX_H__
+
+#include <cstdint>
+
+namespace loco
+{
+
+using GraphInputIndex = uint32_t;
+
+} // namespace loco
+
+#endif // __LOCO_IR_GRAPH_INPUT_INDEX_H__
diff --git a/compiler/loco/include/loco/IR/GraphOutputIndex.h b/compiler/loco/include/loco/IR/GraphOutputIndex.h
new file mode 100644 (file)
index 0000000..3231cbd
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * 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_GRAPH_OUTPUT_INDEX_H__
+#define __LOCO_IR_GRAPH_OUTPUT_INDEX_H__
+
+#include <cstdint>
+
+namespace loco
+{
+
+using GraphOutputIndex = uint32_t;
+
+} // namespace loco
+
+#endif // __LOCO_IR_GRAPH_OUTPUT_INDEX_H__
index fd7c051..a858ad0 100644 (file)
@@ -31,6 +31,8 @@
 #include "loco/IR/DepthwiseFilterCodec.h"
 #include "loco/IR/NodeMixins.h"
 #include "loco/IR/CanonicalNodeDecl.h"
+#include "loco/IR/GraphInputIndex.h"
+#include "loco/IR/GraphOutputIndex.h"
 
 namespace loco
 {
@@ -38,10 +40,6 @@ namespace loco
 class GraphInput;
 class GraphOutput;
 
-// TODO Find a proper location for these declarations
-using GraphInputIndex = uint32_t;
-using GraphOutputIndex = uint32_t;
-
 /**
  * @brief Make a value visible to user
  */
index 90f9e9e..628621e 100644 (file)
@@ -90,6 +90,7 @@ TEST(GraphTest, create_input)
 
   // TODO Add more checks
   ASSERT_EQ(input->shape(), nullptr);
+  ASSERT_EQ(input->index(), 0);
 }
 
 TEST(GraphTest, create_output)
@@ -100,6 +101,7 @@ TEST(GraphTest, create_output)
 
   // TODO Add more checks
   ASSERT_EQ(output->shape(), nullptr);
+  ASSERT_EQ(output->index(), 0);
 }
 
 namespace
diff --git a/compiler/loco/src/IR/GraphInputIndex.cpp b/compiler/loco/src/IR/GraphInputIndex.cpp
new file mode 100644 (file)
index 0000000..0c94d70
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * 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/GraphInputIndex.h"
+
+// NOTE This file validates "GraphInputIndex.h". Please DO NOT remove this file.
diff --git a/compiler/loco/src/IR/GraphOutputIndex.cpp b/compiler/loco/src/IR/GraphOutputIndex.cpp
new file mode 100644 (file)
index 0000000..e6fdb9f
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * 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/GraphOutputIndex.h"
+
+// NOTE This file validates "GraphOutputIndex.h". Please DO NOT remove this file.