From 7bfb199c1461fd553a78ca1947855c7d25106803 Mon Sep 17 00:00:00 2001 From: Alex Gilday Date: Thu, 15 Feb 2018 11:07:18 +0000 Subject: COMPMID-915: Create ResNet50 example ResidualLayer node (COMPMID-916) also created as required for the ResNet architecture. Change-Id: I3aef0b6d6fd5bfcd4916fed4d8d4466b8a92b70d Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/120562 Tested-by: Jenkins Reviewed-by: Anthony Barbier Reviewed-by: Georgios Pinitas --- src/graph/operations/CLSimpleOperations.cpp | 30 ++++++++++++++++++++++++++++- src/graph/operations/NESimpleOperations.cpp | 30 ++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) (limited to 'src/graph/operations') diff --git a/src/graph/operations/CLSimpleOperations.cpp b/src/graph/operations/CLSimpleOperations.cpp index 94e3fe15f7..fe56122009 100644 --- a/src/graph/operations/CLSimpleOperations.cpp +++ b/src/graph/operations/CLSimpleOperations.cpp @@ -66,6 +66,34 @@ REGISTER_SIMPLE_OPERATION(CLActivationLayerOperation, OPENCL, OperationType::Act return std::move(activation); } +/* Arithmetic addition */ +REGISTER_SIMPLE_OPERATION(CLArithmeticAdditionOperation, OPENCL, OperationType::ArithmeticAddition) +{ + ARM_COMPUTE_ERROR_ON(ctx.num_inputs() != 2); + ARM_COMPUTE_ERROR_ON(ctx.num_outputs() != 1); + ARM_COMPUTE_ERROR_ON(dynamic_cast(ctx.input(0)) == nullptr); + ARM_COMPUTE_ERROR_ON(dynamic_cast(ctx.input(1)) == nullptr); + ARM_COMPUTE_ERROR_ON(dynamic_cast(ctx.output(0)) == nullptr); + + // Extract IO and info + auto *in1 = dynamic_cast(ctx.input(0)); + auto *in2 = dynamic_cast(ctx.input(1)); + auto *out = dynamic_cast(ctx.output(0)); + + auto addition = arm_compute::support::cpp14::make_unique(); + addition->configure(in1, in2, out, ConvertPolicy::SATURATE); + + // Log info + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiating CLArithmeticAddition" + << " Data Type: " << in1->info()->data_type() + << " Input 1 shape: " << in1->info()->tensor_shape() + << " Input 2 shape: " << in2->info()->tensor_shape() + << " Output shape: " << out->info()->tensor_shape() + << std::endl); + + return std::move(addition); +} + /* Batch Normalization Layer */ REGISTER_SIMPLE_OPERATION(CLBatchNormalizationLayerOperation, OPENCL, OperationType::BatchNormalizationLayer) { @@ -464,4 +492,4 @@ REGISTER_SIMPLE_OPERATION(CLSoftmaxLayerOperation, OPENCL, OperationType::Softma << std::endl); return std::move(smx); -} \ No newline at end of file +} diff --git a/src/graph/operations/NESimpleOperations.cpp b/src/graph/operations/NESimpleOperations.cpp index 265bed6b7a..4154b9a59c 100644 --- a/src/graph/operations/NESimpleOperations.cpp +++ b/src/graph/operations/NESimpleOperations.cpp @@ -66,6 +66,34 @@ REGISTER_SIMPLE_OPERATION(NEActivationLayerOperation, NEON, OperationType::Activ return std::move(activation); } +/* Arithmetic addition */ +REGISTER_SIMPLE_OPERATION(NEArithmeticAdditionOperation, NEON, OperationType::ArithmeticAddition) +{ + ARM_COMPUTE_ERROR_ON(ctx.num_inputs() != 2); + ARM_COMPUTE_ERROR_ON(ctx.num_outputs() != 1); + ARM_COMPUTE_ERROR_ON(dynamic_cast(ctx.input(0)) == nullptr); + ARM_COMPUTE_ERROR_ON(dynamic_cast(ctx.input(1)) == nullptr); + ARM_COMPUTE_ERROR_ON(dynamic_cast(ctx.output(0)) == nullptr); + + // Extract IO and info + auto *in1 = dynamic_cast(ctx.input(0)); + auto *in2 = dynamic_cast(ctx.input(1)); + auto *out = dynamic_cast(ctx.output(0)); + + auto addition = arm_compute::support::cpp14::make_unique(); + addition->configure(in1, in2, out, ConvertPolicy::SATURATE); + + // Log info + ARM_COMPUTE_LOG_GRAPH_INFO("Instantiating NEArithmeticAddition" + << " Data Type: " << in1->info()->data_type() + << " Input 1 shape: " << in1->info()->tensor_shape() + << " Input 2 shape: " << in2->info()->tensor_shape() + << " Output shape: " << out->info()->tensor_shape() + << std::endl); + + return std::move(addition); +} + /* Batch Normalization Layer */ REGISTER_SIMPLE_OPERATION(NEBatchNormalizationLayerOperation, NEON, OperationType::BatchNormalizationLayer) { @@ -464,4 +492,4 @@ REGISTER_SIMPLE_OPERATION(NESoftmaxLayerOperation, NEON, OperationType::SoftmaxL << std::endl); return std::move(smx); -} \ No newline at end of file +} -- cgit v1.2.1