diff options
author | Isabella Gottardi <isabella.gottardi@arm.com> | 2019-05-17 12:35:20 +0100 |
---|---|---|
committer | Isabella Gottardi <isabella.gottardi@arm.com> | 2019-05-20 07:51:02 +0000 |
commit | 3db1ba9938986e7096184ad22020a71775075d03 (patch) | |
tree | 5018e5eecc1c1c81277e8a4c37bc0ad76245d95e /arm_compute/graph/backends/FunctionHelpers.h | |
parent | 0eb16cfa5ff4484658ba8630a8dea072445dacbd (diff) | |
download | ComputeLibrary-3db1ba9938986e7096184ad22020a71775075d03.tar.gz |
COMPMID-2362: Add Quantization Layer to the graph API
Change-Id: I9766ad54e8da1367ba192dfeeccdc879f3729550
Signed-off-by: Isabella Gottardi <isabella.gottardi@arm.com>
Reviewed-on: https://review.mlplatform.org/c/1172
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'arm_compute/graph/backends/FunctionHelpers.h')
-rw-r--r-- | arm_compute/graph/backends/FunctionHelpers.h | 37 |
1 files changed, 37 insertions, 0 deletions
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<IFunction> 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 <typename QuantizationLayerFunction, typename TargetInfo> +std::unique_ptr<IFunction> create_quantization_layer(QuantizationLayerNode &node) +{ + validate_node<TargetInfo>(node, 1 /* expected inputs */, 1 /* expected outputs */); + + // Extract IO and info + typename TargetInfo::TensorType *input = get_backing_tensor<TargetInfo>(node.input(0)); + typename TargetInfo::TensorType *output = get_backing_tensor<TargetInfo>(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<QuantizationLayerFunction>(); + 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 |