From 3db1ba9938986e7096184ad22020a71775075d03 Mon Sep 17 00:00:00 2001 From: Isabella Gottardi Date: Fri, 17 May 2019 12:35:20 +0100 Subject: COMPMID-2362: Add Quantization Layer to the graph API Change-Id: I9766ad54e8da1367ba192dfeeccdc879f3729550 Signed-off-by: Isabella Gottardi Reviewed-on: https://review.mlplatform.org/c/1172 Comments-Addressed: Arm Jenkins Reviewed-by: Georgios Pinitas Tested-by: Arm Jenkins --- arm_compute/graph/backends/FunctionHelpers.h | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 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 f6e6286a19..785f6dc3b9 100644 --- a/arm_compute/graph/backends/FunctionHelpers.h +++ b/arm_compute/graph/backends/FunctionHelpers.h @@ -1045,6 +1045,43 @@ std::unique_ptr create_priorbox_layer(PriorBoxLayerNode &node) return std::move(func); } +/** Create a backend quantization layer function + * + * @tparam QuantizationLayerFunction Backend quantization function + * @tparam TargetInfo Target-specific information + * + * @param[in] node Node to create the backend function for + * + * @return Backend quantization layer function + */ +template +std::unique_ptr create_quantization_layer(QuantizationLayerNode &node) +{ + validate_node(node, 1 /* expected inputs */, 1 /* expected outputs */); + + // Extract IO and info + typename TargetInfo::TensorType *input = get_backing_tensor(node.input(0)); + typename TargetInfo::TensorType *output = get_backing_tensor(node.output(0)); + ARM_COMPUTE_ERROR_ON(input == nullptr); + ARM_COMPUTE_ERROR_ON(output == nullptr); + + // Create and configure function + auto func = support::cpp14::make_unique(); + func->configure(input, output); + + // Log info + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiated " + << node.name() + << " Type: " << node.type() + << " Target: " << TargetInfo::TargetType + << " Data Type: " << input->info()->data_type() + << " Input shape: " << input->info()->tensor_shape() + << " Output shape: " << output->info()->tensor_shape() + << std::endl); + + return std::move(func); +} + /** Create a backend reorg layer function * * @tparam ReorgLayerFunction Backend reorg function -- cgit v1.2.1