COMPMID-630 : Rework nodes for selective target compilation.
Reworked nodes:
-ActivationLayer
Change-Id: Iaa394531ef208db48caa2c18a41ad9a845471f94
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/92281
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
diff --git a/src/graph/nodes/ActivationLayer.cpp b/src/graph/nodes/ActivationLayer.cpp
index df73ba7..ea87fd9 100644
--- a/src/graph/nodes/ActivationLayer.cpp
+++ b/src/graph/nodes/ActivationLayer.cpp
@@ -23,45 +23,11 @@
*/
#include "arm_compute/graph/nodes/ActivationLayer.h"
-#include "arm_compute/runtime/CL/CLTensor.h"
-#include "arm_compute/runtime/CL/functions/CLActivationLayer.h"
-#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h"
-#include "arm_compute/runtime/Tensor.h"
-#include "support/ToolchainSupport.h"
-#include "utils/TypePrinter.h"
+#include "arm_compute/graph/NodeContext.h"
+#include "arm_compute/graph/OperationRegistry.h"
using namespace arm_compute::graph;
-namespace
-{
-template <typename ActivationType, typename TensorType, TargetHint target_hint>
-std::unique_ptr<arm_compute::IFunction> instantiate_function(arm_compute::ITensor *input, arm_compute::ITensor *output, const ActivationLayerInfo &activation_info)
-{
- auto activation = arm_compute::support::cpp14::make_unique<ActivationType>();
- activation->configure(
- dynamic_cast<TensorType *>(input),
- dynamic_cast<TensorType *>(output),
- activation_info);
-
- return std::move(activation);
-}
-
-template <TargetHint target_hint>
-std::unique_ptr<arm_compute::IFunction> instantiate(arm_compute::ITensor *input, arm_compute::ITensor *output, const ActivationLayerInfo &activation_info);
-
-template <>
-std::unique_ptr<arm_compute::IFunction> instantiate<TargetHint::OPENCL>(arm_compute::ITensor *input, arm_compute::ITensor *output, const ActivationLayerInfo &activation_info)
-{
- return instantiate_function<arm_compute::CLActivationLayer, arm_compute::ICLTensor, TargetHint::OPENCL>(input, output, activation_info);
-}
-
-template <>
-std::unique_ptr<arm_compute::IFunction> instantiate<TargetHint::NEON>(arm_compute::ITensor *input, arm_compute::ITensor *output, const ActivationLayerInfo &activation_info)
-{
- return instantiate_function<arm_compute::NEActivationLayer, arm_compute::ITensor, TargetHint::NEON>(input, output, activation_info);
-}
-} // namespace
-
ActivationLayer::ActivationLayer(const ActivationLayerInfo activation_info)
: _activation_info(activation_info)
{
@@ -78,23 +44,14 @@
arm_compute::ITensor *in = input->tensor();
arm_compute::ITensor *out = output->tensor();
- if(_target_hint == TargetHint::OPENCL)
- {
- func = instantiate<TargetHint::OPENCL>(in, out, _activation_info);
- ARM_COMPUTE_LOG_GRAPH_INFO("Instantiating CLActivationLayer");
- }
- else
- {
- func = instantiate<TargetHint::NEON>(in, out, _activation_info);
- ARM_COMPUTE_LOG_GRAPH_INFO("Instantiating NEActivationLayer");
- }
+ // Create node context
+ NodeContext node_ctx("ActivationLayer");
+ node_ctx.add_input(in);
+ node_ctx.add_output(out);
+ node_ctx.add_parameter<ActivationLayerInfo>("ActivationLayerInfo", _activation_info);
- ARM_COMPUTE_LOG_GRAPH_INFO(" Data Type: " << in->info()->data_type()
- << " Input shape: " << in->info()->tensor_shape()
- << " Output shape: " << out->info()->tensor_shape()
- << " Activation function: " << _activation_info.activation()
- << " a: " << _activation_info.a()
- << " b: " << _activation_info.b()
- << std::endl);
+ // Get function
+ func = OperationRegistry::get().find_operation("ActivationLayer", _target_hint)->configure(node_ctx);
+
return func;
}