diff options
author | Michele Di Giorgio <michele.digiorgio@arm.com> | 2019-03-22 15:25:32 +0000 |
---|---|---|
committer | Michele Di Giorgio <michele.digiorgio@arm.com> | 2019-03-25 17:16:41 +0000 |
commit | ec6997563a7cccf58431267cca39435ecd57cd32 (patch) | |
tree | da355630d63858e31bf84acd5a0f588a1ea4f61f /arm_compute/graph/backends | |
parent | 2761c2f0b60175469e959982a25ff0abdca6c9ce (diff) | |
download | ComputeLibrary-ec6997563a7cccf58431267cca39435ecd57cd32.tar.gz |
COMPMID-2076: Add StackLayer to the graph API
Change-Id: Ifae23659c2471d9c052bc8adf066c5228d6e8b23
Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Reviewed-on: https://review.mlplatform.org/c/893
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'arm_compute/graph/backends')
-rw-r--r-- | arm_compute/graph/backends/FunctionHelpers.h | 43 |
1 files changed, 43 insertions, 0 deletions
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<IFunction> 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 <typename StackLayerFunction, typename TargetInfo> +std::unique_ptr<arm_compute::IFunction> 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<typename TargetInfo::TensorType *> inputs; + for(unsigned int i = 0; i < node.num_inputs(); ++i) + { + inputs.push_back(get_backing_tensor<TargetInfo>(node.input(i))); + } + typename TargetInfo::TensorType *output = get_backing_tensor<TargetInfo>(node.output(0)); + const int axis = node.axis(); + + // Create and configure function + auto func = support::cpp14::make_unique<StackLayerFunction>(); + 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 |