From 1167487ea8e54a76d0a3625e0aa84e2ad9ffd317 Mon Sep 17 00:00:00 2001 From: Giorgio Arena Date: Wed, 7 Feb 2018 15:38:12 +0000 Subject: COMPMID-897 Merge batch normalization with bounded relu Change-Id: I9a607fe620f795cdea1a99fdd3f5f8c2fc76f980 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/119234 Tested-by: Jenkins Reviewed-by: Gian Marco Iodice Reviewed-by: Georgios Pinitas --- src/graph/nodes/BatchNormalizationLayer.cpp | 3 ++- src/graph/operations/CLSimpleOperations.cpp | 22 +++++++++++++--------- src/graph/operations/NESimpleOperations.cpp | 20 ++++++++++++-------- 3 files changed, 27 insertions(+), 18 deletions(-) (limited to 'src/graph') diff --git a/src/graph/nodes/BatchNormalizationLayer.cpp b/src/graph/nodes/BatchNormalizationLayer.cpp index 7851aa5b9e..24287ac61a 100644 --- a/src/graph/nodes/BatchNormalizationLayer.cpp +++ b/src/graph/nodes/BatchNormalizationLayer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -77,6 +77,7 @@ std::unique_ptr BatchNormalizationLayer::instantiate_nod node_ctx.add_input(_gamma.tensor()); node_ctx.add_output(out); node_ctx.add_parameter("epsilon", _epsilon); + node_ctx.add_parameter("act_info", _act_info); // Configure operation auto func = OperationRegistry::get().find_operation(OperationType::BatchNormalizationLayer, _target_hint)->configure(node_ctx); diff --git a/src/graph/operations/CLSimpleOperations.cpp b/src/graph/operations/CLSimpleOperations.cpp index 61315e73b2..94e3fe15f7 100644 --- a/src/graph/operations/CLSimpleOperations.cpp +++ b/src/graph/operations/CLSimpleOperations.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -79,17 +79,18 @@ REGISTER_SIMPLE_OPERATION(CLBatchNormalizationLayerOperation, OPENCL, OperationT ARM_COMPUTE_ERROR_ON(dynamic_cast(ctx.output(0)) == nullptr); // Extract IO and info - auto *in = dynamic_cast(ctx.input(0)); - auto *mean = dynamic_cast(ctx.input(1)); - auto *var = dynamic_cast(ctx.input(2)); - auto *beta = dynamic_cast(ctx.input(3)); - auto *gamma = dynamic_cast(ctx.input(4)); - auto *out = dynamic_cast(ctx.output(0)); - const auto epsilon = ctx.parameter("epsilon"); + auto *in = dynamic_cast(ctx.input(0)); + auto *mean = dynamic_cast(ctx.input(1)); + auto *var = dynamic_cast(ctx.input(2)); + auto *beta = dynamic_cast(ctx.input(3)); + auto *gamma = dynamic_cast(ctx.input(4)); + auto *out = dynamic_cast(ctx.output(0)); + const auto epsilon = ctx.parameter("epsilon"); + const auto act_info = ctx.parameter("act_info"); // Create and configure function auto batch_norm = arm_compute::support::cpp14::make_unique(); - batch_norm->configure(in, out, mean, var, beta, gamma, epsilon); + batch_norm->configure(in, out, mean, var, beta, gamma, epsilon, act_info); // Log info ARM_COMPUTE_LOG_GRAPH_INFO("Instantiating CLBatchNormalizationLayer" @@ -101,6 +102,9 @@ REGISTER_SIMPLE_OPERATION(CLBatchNormalizationLayerOperation, OPENCL, OperationT << " Beta shape: " << beta->info()->tensor_shape() << " Gamma shape: " << gamma->info()->tensor_shape() << " Epsilon: " << epsilon + << " Activation function: " << act_info.activation() + << " a: " << act_info.a() + << " b: " << act_info.b() << std::endl); return std::move(batch_norm); diff --git a/src/graph/operations/NESimpleOperations.cpp b/src/graph/operations/NESimpleOperations.cpp index 5a00e230ea..265bed6b7a 100644 --- a/src/graph/operations/NESimpleOperations.cpp +++ b/src/graph/operations/NESimpleOperations.cpp @@ -79,17 +79,18 @@ REGISTER_SIMPLE_OPERATION(NEBatchNormalizationLayerOperation, NEON, OperationTyp ARM_COMPUTE_ERROR_ON(dynamic_cast(ctx.output(0)) == nullptr); // Extract IO and info - auto *in = dynamic_cast(ctx.input(0)); - auto *mean = dynamic_cast(ctx.input(1)); - auto *var = dynamic_cast(ctx.input(2)); - auto *beta = dynamic_cast(ctx.input(3)); - auto *gamma = dynamic_cast(ctx.input(4)); - auto *out = dynamic_cast(ctx.output(0)); - const auto epsilon = ctx.parameter("epsilon"); + auto *in = dynamic_cast(ctx.input(0)); + auto *mean = dynamic_cast(ctx.input(1)); + auto *var = dynamic_cast(ctx.input(2)); + auto *beta = dynamic_cast(ctx.input(3)); + auto *gamma = dynamic_cast(ctx.input(4)); + auto *out = dynamic_cast(ctx.output(0)); + const auto epsilon = ctx.parameter("epsilon"); + const auto act_info = ctx.parameter("act_info"); // Create and configure function auto batch_norm = arm_compute::support::cpp14::make_unique(); - batch_norm->configure(in, out, mean, var, beta, gamma, epsilon); + batch_norm->configure(in, out, mean, var, beta, gamma, epsilon, act_info); // Log info ARM_COMPUTE_LOG_GRAPH_INFO("Instantiating NEBatchNormalizationLayer" @@ -101,6 +102,9 @@ REGISTER_SIMPLE_OPERATION(NEBatchNormalizationLayerOperation, NEON, OperationTyp << " Beta shape: " << beta->info()->tensor_shape() << " Gamma shape: " << gamma->info()->tensor_shape() << " Epsilon: " << epsilon + << " Activation function: " << act_info.activation() + << " a: " << act_info.a() + << " b: " << act_info.b() << std::endl); return std::move(batch_norm); -- cgit v1.2.1