From ec6997563a7cccf58431267cca39435ecd57cd32 Mon Sep 17 00:00:00 2001 From: Michele Di Giorgio Date: Fri, 22 Mar 2019 15:25:32 +0000 Subject: COMPMID-2076: Add StackLayer to the graph API Change-Id: Ifae23659c2471d9c052bc8adf066c5228d6e8b23 Signed-off-by: Michele Di Giorgio Reviewed-on: https://review.mlplatform.org/c/893 Tested-by: Arm Jenkins Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins --- arm_compute/graph/backends/FunctionHelpers.h | 43 ++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'arm_compute/graph/backends/FunctionHelpers.h') diff --git a/arm_compute/graph/backends/FunctionHelpers.h b/arm_compute/graph/backends/FunctionHelpers.h index 4a423d2490..e05f4bc8cf 100644 --- a/arm_compute/graph/backends/FunctionHelpers.h +++ b/arm_compute/graph/backends/FunctionHelpers.h @@ -1276,6 +1276,49 @@ std::unique_ptr create_softmax_layer(SoftmaxLayerNode &node, GraphCon return std::move(func); } + +/** Create a backend layer stack function + * + * @tparam StackLayerFunction Backend stack function + * @tparam TargetInfo Target-specific information + * + * @param[in] node Node to create the backend function for + * + * @return Backend stack layer function + */ +template +std::unique_ptr create_stack_layer(StackLayerNode &node) +{ + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Creating Stack node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_ERROR_ON(node.num_outputs() != 1); + + // Extract IO and info + std::vector inputs; + for(unsigned int i = 0; i < node.num_inputs(); ++i) + { + inputs.push_back(get_backing_tensor(node.input(i))); + } + typename TargetInfo::TensorType *output = get_backing_tensor(node.output(0)); + const int axis = node.axis(); + + // Create and configure function + auto func = support::cpp14::make_unique(); + func->configure(inputs, axis, output); + + // Log info + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " + << node.name() + << " Type: " << node.type() + << " Target: " << TargetInfo::TargetType + << " Data Type: " << output->info()->data_type() + << " Inputs shape: " << inputs[0]->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() + << " Num Inputs: " << inputs.size() + << " Axis: " << axis + << std::endl); + + return std::move(func); +} /** Create a backend Upsample layer function * * @tparam UpsampleLayerFunction Backend Upsample function -- cgit v1.2.1