[enco] Emit setInput and setOutput calls (#1246)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 30 Aug 2018 06:48:36 +0000 (15:48 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 30 Aug 2018 06:48:36 +0000 (15:48 +0900)
With this commit, generated code will includes the call for the
following APIs (if necessary):
 - ANeuralNetworksExecution_setInput
 - ANeuralNetworksExecution_setOutput

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/enco/core/src/CppGen/Subnet.cpp

index 4f77211..df16df6 100644 (file)
@@ -394,8 +394,27 @@ std::unique_ptr<pp::MultiLineText> SubnetBlockCompiler::compile(const ANNBinder
   res->append();
   res->append("ANeuralNetworksExecution_create(", compilation, ", &execution);");
 
-  // TODO Invoke setInput & setOutput method
-  res->append(S(assert("NYI");));
+  // Emit ANeuralNetworksExecution_setInput call(s)
+  for (uint32_t n = 0; n < binder->module()->input()->size(); ++n)
+  {
+    auto bag = binder->input(n);
+    auto base = _mem.base(bag);
+    auto size = _mem.size(bag);
+
+    res->append("ANeuralNetworksExecution_setInput(execution, ", n, ", nullptr, ", base, ", ", size,
+                ");");
+  }
+
+  // Emit ANeuralNetworksExecution_setOutput call(s)
+  for (uint32_t n = 0; n < binder->module()->output()->size(); ++n)
+  {
+    auto bag = binder->output(n);
+    auto base = _mem.base(bag);
+    auto size = _mem.size(bag);
+
+    res->append("ANeuralNetworksExecution_setOutput(execution, ", n, ", nullptr, ", base, ", ",
+                size, ");");
+  }
 
   res->append("ANeuralNetworksExecution_startCompute(execution, &event);");
   res->append("ANeuralNetworksEvent_wait(event);");