Introduce IODescription struct (#5678)
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Thu, 18 Jul 2019 07:30:48 +0000 (16:30 +0900)
committer이한종/On-Device Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Thu, 18 Jul 2019 07:30:48 +0000 (16:30 +0900)
Introduce IODescription, InputDesc, and OutputDesc struct to gather input and output buffer information in execution instance
Introduce IODescription field in Execution class

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
runtimes/neurun/core/include/exec/Execution.h
runtimes/neurun/core/include/exec/IODescription.h [new file with mode: 0644]
runtimes/neurun/core/src/exec/Execution.cc [new file with mode: 0644]

index 3a2fc86..e5fdf86 100644 (file)
@@ -22,6 +22,7 @@
 #define __NEURUN_EXEC_EXECUTION_H__
 
 #include "exec/IExecutor.h"
+#include "IODescription.h"
 
 namespace neurun
 {
@@ -40,10 +41,7 @@ public:
    * @brief     Construct a new Execution object
    * @param[in] executor  Model executor
    */
-  Execution(const std::shared_ptr<IExecutor> &executor) : _executor{executor}
-  {
-    // DO NOTHING
-  }
+  Execution(const std::shared_ptr<IExecutor> &executor);
 
 public:
   /**
@@ -107,6 +105,7 @@ public:
 
 private:
   const std::shared_ptr<IExecutor> _executor;
+  IODescription _io_desc;
 };
 
 } // namespace exec
diff --git a/runtimes/neurun/core/include/exec/IODescription.h b/runtimes/neurun/core/include/exec/IODescription.h
new file mode 100644 (file)
index 0000000..4809f34
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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 __NEURUN_EXEC_IO_DESCRIPTION_H__
+#define __NEURUN_EXEC_IO_DESCRIPTION_H__
+
+#include <vector>
+
+#include "model/OperandInfo.h"
+
+namespace neurun
+{
+namespace exec
+{
+
+struct InputDesc
+{
+  const model::OperandInfo info;
+  const void *buffer;
+  const size_t size;
+
+  InputDesc(void) = delete;
+  InputDesc(const model::OperandInfo &info, const void *buffer, const size_t size)
+      : info(info), buffer(buffer), size(size)
+  {
+  }
+};
+
+struct OutputDesc
+{
+  const model::OperandInfo info;
+  void *buffer;
+  const size_t size;
+
+  OutputDesc(void) = delete;
+  OutputDesc(const model::OperandInfo &info, void *buffer, const size_t size)
+      : info(info), buffer(buffer), size(size)
+  {
+  }
+};
+
+struct IODescription
+{
+  std::vector<std::unique_ptr<InputDesc>> inputs;
+  std::vector<std::unique_ptr<OutputDesc>> outputs;
+};
+
+} // namespace exec
+} // namespace neurun
+
+#endif // __NEURUN_EXEC_IO_DESCRIPTION_H__
diff --git a/runtimes/neurun/core/src/exec/Execution.cc b/runtimes/neurun/core/src/exec/Execution.cc
new file mode 100644 (file)
index 0000000..d096878
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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 "exec/Execution.h"
+
+namespace neurun
+{
+namespace exec
+{
+
+Execution::Execution(const std::shared_ptr<IExecutor> &executor) : _executor{executor}, _io_desc{}
+{
+  _io_desc.inputs.resize(_executor->model().inputs.size());
+  _io_desc.outputs.resize(_executor->model().outputs.size());
+}
+
+} // namespace exec
+} // namespace neurun