[nnc] Allocate ACL elementwise op output and temporary tensors (#2914)
authorIvan Vagin/AI Tools Lab /SRR/Engineer/삼성전자 <ivan.vagin@samsung.com>
Wed, 23 Jan 2019 20:57:29 +0000 (23:57 +0300)
committerEfimov Alexander/AI Tools Lab/./Samsung Electronics <a.efimov@samsung.com>
Wed, 23 Jan 2019 20:57:29 +0000 (23:57 +0300)
Allocate ACL elementwise op output and temporary tensors

Signed-off-by: Ivan Vagin <ivan.vagin@samsung.com>
contrib/nnc/passes/acl_soft_backend/AclCppOpGenerator.cpp

index 8f69740..a93af66 100644 (file)
@@ -637,6 +637,7 @@ void AclCppOpGenerator::visit(ops::TanhOp& op) {
 void AclCppOpGenerator::visit(ops::ElementwiseOp& op) {
   // Create the output tensor in the DOM and obtain its identifier.
   auto out = genTensor(op, op.getOutputShape(0));
+  addToPersistentTensors(out);
 
   auto& prev_nodes = op.getPrevNodes();
   assert(prev_nodes.size() >= 2);
@@ -675,11 +676,11 @@ void AclCppOpGenerator::visit(ops::DeConv2DOp& op) {
 }
 
 void AclCppOpGenerator::visit(ops::EluOp&) {
-  throw AclCppException("Not supported by the ACL library yet.");
+  throw AclCppException("EluOp not supported by the ACL library yet.");
 }
 
 void AclCppOpGenerator::visit(ops::PadOp&) {
-  throw AclCppException("Not supported by the ACL library yet.");
+  throw AclCppException("PadOp not supported by the ACL library yet.");
 }
 
 template <typename Op>
@@ -832,12 +833,14 @@ shared_ptr<ArtifactId> AclCppOpGenerator::genMultiplication(const string& prefix
 
   // Create a unit tensor in the DOM.
   auto unit = genTensor(operation_name + "_unit", ir_unit_shape);
+  addToPersistentTensors(unit);
 
   // Fill the unit tensor with the 1 value.
   fillTensor(unit, "1");
 
   // Create a tmp tensor in the DOM to store the result of 1 / in2.
   auto tmp = genTensor(operation_name + "_tmp", ir_shape);
+  genTensorAllocation(_infBlock, tmp);
 
   // Create an instance of the CLArithmeticDivision class as a member of the artifact class.
   auto arithmetic_div_layer_var1 = _artifactClass->var(false, "arm_compute::CLArithmeticDivision",
@@ -863,6 +866,8 @@ shared_ptr<ArtifactId> AclCppOpGenerator::genMultiplication(const string& prefix
   // Generate the call: arithmetic_div_layer2.run();
   _infBlock->call("run", {}, arithmetic_div_layer2);
 
+  genTensorDeallocation(_infBlock, tmp);
+
   return out;
 }