diff options
author | Isabella Gottardi <isabella.gottardi@arm.com> | 2019-01-08 13:48:44 +0000 |
---|---|---|
committer | Isabella Gottardi <isabella.gottardi@arm.com> | 2019-08-06 07:58:16 +0000 |
commit | a7acb3cbabeb66ce647684466a04c96b2963c9c9 (patch) | |
tree | 7988b75372c8ad1dfa3c8d028ab3a603a5e5a047 /arm_compute/graph/backends | |
parent | 4746326ecb075dcfa123aaa8b38de5ec3e534b60 (diff) | |
download | ComputeLibrary-a7acb3cbabeb66ce647684466a04c96b2963c9c9.tar.gz |
COMPMID-1849: Implement CPPDetectionPostProcessLayer
* Add DetectionPostProcessLayer
* Add DetectionPostProcessLayer at the graph
Change-Id: I7e56f6cffc26f112d26dfe74853085bb8ec7d849
Signed-off-by: Isabella Gottardi <isabella.gottardi@arm.com>
Reviewed-on: https://review.mlplatform.org/c/1639
Reviewed-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'arm_compute/graph/backends')
-rw-r--r-- | arm_compute/graph/backends/FunctionHelpers.h | 56 | ||||
-rw-r--r-- | arm_compute/graph/backends/ValidateHelpers.h | 27 |
2 files changed, 83 insertions, 0 deletions
diff --git a/arm_compute/graph/backends/FunctionHelpers.h b/arm_compute/graph/backends/FunctionHelpers.h index ed5b35c0d1..dd833061a9 100644 --- a/arm_compute/graph/backends/FunctionHelpers.h +++ b/arm_compute/graph/backends/FunctionHelpers.h @@ -644,6 +644,62 @@ std::unique_ptr<IFunction> create_detection_output_layer(DetectionOutputLayerNod return std::move(func); } + +/** Create a backend detection post process layer function + * + * @tparam DetectionPostProcessLayerFunction Backend detection output function + * @tparam TargetInfo Target-specific information + * + * @param[in] node Node to create the backend function for + * + * @return Backend detection post process layer function + */ +template <typename DetectionPostProcessLayerFunction, typename TargetInfo> +std::unique_ptr<IFunction> create_detection_post_process_layer(DetectionPostProcessLayerNode &node) +{ + validate_node<TargetInfo>(node, 3 /* expected inputs */, 4 /* expected outputs */); + + // Extract IO and info + typename TargetInfo::TensorType *input0 = get_backing_tensor<TargetInfo>(node.input(0)); + typename TargetInfo::TensorType *input1 = get_backing_tensor<TargetInfo>(node.input(1)); + typename TargetInfo::TensorType *input2 = get_backing_tensor<TargetInfo>(node.input(2)); + typename TargetInfo::TensorType *output0 = get_backing_tensor<TargetInfo>(node.output(0)); + typename TargetInfo::TensorType *output1 = get_backing_tensor<TargetInfo>(node.output(1)); + typename TargetInfo::TensorType *output2 = get_backing_tensor<TargetInfo>(node.output(2)); + typename TargetInfo::TensorType *output3 = get_backing_tensor<TargetInfo>(node.output(3)); + const DetectionPostProcessLayerInfo detect_info = node.detection_post_process_info(); + + ARM_COMPUTE_ERROR_ON(input0 == nullptr); + ARM_COMPUTE_ERROR_ON(input1 == nullptr); + ARM_COMPUTE_ERROR_ON(input2 == nullptr); + ARM_COMPUTE_ERROR_ON(output0 == nullptr); + ARM_COMPUTE_ERROR_ON(output1 == nullptr); + ARM_COMPUTE_ERROR_ON(output2 == nullptr); + ARM_COMPUTE_ERROR_ON(output3 == nullptr); + + // Create and configure function + auto func = support::cpp14::make_unique<DetectionPostProcessLayerFunction>(); + func->configure(input0, input1, input2, output0, output1, output2, output3, detect_info); + + // Log info + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " + << node.name() + << " Type: " << node.type() + << " Target: " << TargetInfo::TargetType + << " Data Type: " << input0->info()->data_type() + << " Input0 shape: " << input0->info()->tensor_shape() + << " Input1 shape: " << input1->info()->tensor_shape() + << " Input2 shape: " << input2->info()->tensor_shape() + << " Output0 shape: " << output0->info()->tensor_shape() + << " Output1 shape: " << output1->info()->tensor_shape() + << " Output2 shape: " << output2->info()->tensor_shape() + << " Output3 shape: " << output3->info()->tensor_shape() + << " DetectionPostProcessLayer info: " << detect_info + << std::endl); + + return std::move(func); +} + /** Create a backend element-wise operation layer function * * @tparam EltwiseFunctions Backend element-wise function diff --git a/arm_compute/graph/backends/ValidateHelpers.h b/arm_compute/graph/backends/ValidateHelpers.h index 3a5686336b..13de273bdf 100644 --- a/arm_compute/graph/backends/ValidateHelpers.h +++ b/arm_compute/graph/backends/ValidateHelpers.h @@ -228,6 +228,33 @@ Status validate_detection_output_layer(DetectionOutputLayerNode &node) return DetectionOutputLayer::validate(input0, input1, input2, output, detect_info); } +/** Validates a detection post process layer node + * + * @tparam DetectionPostProcessLayer DetectionOutput layer type + * + * @param[in] node Node to validate + * + * @return Status + */ +template <typename DetectionPostProcessLayer> +Status validate_detection_post_process_layer(DetectionPostProcessLayerNode &node) +{ + ARM_COMPUTE_LOG_GRAPH_VERBOSE("Validating DetectionPostProcessLayer node with ID : " << node.id() << " and Name: " << node.name() << std::endl); + ARM_COMPUTE_RETURN_ERROR_ON(node.num_inputs() != 3); + ARM_COMPUTE_RETURN_ERROR_ON(node.num_outputs() != 4); + + // Extract IO and info + arm_compute::ITensorInfo *input0 = get_backing_tensor_info(node.input(0)); + arm_compute::ITensorInfo *input1 = get_backing_tensor_info(node.input(1)); + arm_compute::ITensorInfo *input2 = get_backing_tensor_info(node.input(2)); + arm_compute::ITensorInfo *output0 = get_backing_tensor_info(node.output(0)); + arm_compute::ITensorInfo *output1 = get_backing_tensor_info(node.output(1)); + arm_compute::ITensorInfo *output2 = get_backing_tensor_info(node.output(2)); + arm_compute::ITensorInfo *output3 = get_backing_tensor_info(node.output(3)); + const DetectionPostProcessLayerInfo detect_info = node.detection_post_process_info(); + + return DetectionPostProcessLayer::validate(input0, input1, input2, output0, output1, output2, output3, detect_info); +} /** Validates a Generate Proposals layer node * |