aboutsummaryrefslogtreecommitdiff
path: root/src/core/CL/kernels/CLActivationLayerKernel.cpp
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2020-07-06 14:57:36 +0100
committerGeorgios Pinitas <georgios.pinitas@arm.com>2020-07-07 15:07:27 +0000
commitab23dd0fbc632063235a6ad408241dc79a35d3e4 (patch)
tree310eda0ec4f48c84ae1f0b520279ee2202bea6e6 /src/core/CL/kernels/CLActivationLayerKernel.cpp
parent6eb73458c4869165c88d33c6a745a91cdc73a36a (diff)
downloadComputeLibrary-ab23dd0fbc632063235a6ad408241dc79a35d3e4.tar.gz
COMPMID-3387: Support memory injection in CLActivationLayer
Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com> Change-Id: I31f9620607b372fc3340c71e748a5ea177d9da62 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3520 Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/CL/kernels/CLActivationLayerKernel.cpp')
-rw-r--r--src/core/CL/kernels/CLActivationLayerKernel.cpp43
1 files changed, 19 insertions, 24 deletions
diff --git a/src/core/CL/kernels/CLActivationLayerKernel.cpp b/src/core/CL/kernels/CLActivationLayerKernel.cpp
index d40e9a15be..e030177549 100644
--- a/src/core/CL/kernels/CLActivationLayerKernel.cpp
+++ b/src/core/CL/kernels/CLActivationLayerKernel.cpp
@@ -34,6 +34,7 @@
#include "arm_compute/core/Utils.h"
#include "arm_compute/core/Window.h"
#include "arm_compute/core/utils/helpers/float_ops.h"
+#include "arm_compute/core/utils/misc/Cast.h"
#include "support/StringSupport.h"
#include <cmath>
@@ -116,16 +117,11 @@ std::pair<Status, Window> validate_and_configure_window(ITensorInfo *input, ITen
} // namespace
CLActivationLayerKernel::CLActivationLayerKernel()
- : _input(nullptr), _output(nullptr), _run_in_place(false)
+ : _run_in_place(false)
{
}
-void CLActivationLayerKernel::configure(ICLTensor *input, ICLTensor *output, ActivationLayerInfo act_info)
-{
- configure(CLKernelLibrary::get().get_compile_context(), input, output, act_info);
-}
-
-void CLActivationLayerKernel::configure(const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, ActivationLayerInfo act_info)
+void CLActivationLayerKernel::configure(const CLCompileContext &compile_context, ITensorInfo *input, ITensorInfo *output, ActivationLayerInfo act_info)
{
ARM_COMPUTE_ERROR_ON_NULLPTR(input);
@@ -134,14 +130,13 @@ void CLActivationLayerKernel::configure(const CLCompileContext &compile_context,
if(output != nullptr)
{
// Output auto inizialitation if not yet initialized
- auto_init_if_empty(*output->info(),
- *input->info()->clone());
+ auto_init_if_empty(*output, *input->clone());
}
- ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), (output != nullptr) ? output->info() : nullptr, act_info));
+ ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input, (output != nullptr) ? output : nullptr, act_info));
- const unsigned int num_elems_processed_per_iteration = 16 / input->info()->element_size();
- const DataType dt = input->info()->data_type();
+ const unsigned int num_elems_processed_per_iteration = 16 / input->element_size();
+ const DataType dt = input->data_type();
float a_const = act_info.a();
float b_const = act_info.b();
@@ -163,7 +158,7 @@ void CLActivationLayerKernel::configure(const CLCompileContext &compile_context,
// Set quantization info build options
if(is_quantized)
{
- const UniformQuantizationInfo iq_info = input->info()->quantization_info().uniform();
+ const UniformQuantizationInfo iq_info = input->quantization_info().uniform();
if(!perform_activation_in_float)
{
@@ -214,7 +209,7 @@ void CLActivationLayerKernel::configure(const CLCompileContext &compile_context,
// Set scale and offset of the input and output if they have different quantization info
if(output != nullptr)
{
- const UniformQuantizationInfo oq_info = output->info()->quantization_info().uniform();
+ const UniformQuantizationInfo oq_info = output->quantization_info().uniform();
if(iq_info != oq_info)
{
@@ -233,12 +228,8 @@ void CLActivationLayerKernel::configure(const CLCompileContext &compile_context,
// Create kernel
_kernel = create_kernel(compile_context, kernel_name, build_opts.options());
- // Make sure _kernel is initialized before calling the parent's configure
- _input = input;
- _output = output;
-
// Configure kernel window
- auto win_config = validate_and_configure_window(input->info(), (_run_in_place) ? nullptr : output->info());
+ auto win_config = validate_and_configure_window(input, (_run_in_place) ? nullptr : output);
ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
ICLKernel::configure_internal(win_config.second);
@@ -246,9 +237,9 @@ void CLActivationLayerKernel::configure(const CLCompileContext &compile_context,
_config_id = "activation_layer_";
_config_id += lower_string(string_from_data_type(dt));
_config_id += "_";
- _config_id += support::cpp11::to_string(input->info()->dimension(0));
+ _config_id += support::cpp11::to_string(input->dimension(0));
_config_id += "_";
- _config_id += support::cpp11::to_string(input->info()->dimension(1));
+ _config_id += support::cpp11::to_string(input->dimension(1));
}
Status CLActivationLayerKernel::validate(const ITensorInfo *input, const ITensorInfo *output, const ActivationLayerInfo &act_info)
@@ -260,21 +251,25 @@ Status CLActivationLayerKernel::validate(const ITensorInfo *input, const ITensor
return Status{};
}
-void CLActivationLayerKernel::run(const Window &window, cl::CommandQueue &queue)
+void CLActivationLayerKernel::run_op(const InputTensorMap &inputs, const OutputTensorMap &outputs, const Window &window, cl::CommandQueue &queue)
{
ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window);
+ const auto src = utils::cast::polymorphic_downcast<const ICLTensor *>(inputs.at(TensorType::ACL_SRC));
+ auto dst = utils::cast::polymorphic_downcast<ICLTensor *>(outputs.at(TensorType::ACL_DST));
+ ARM_COMPUTE_ERROR_ON(_run_in_place && src != dst);
+
Window collapsed = window.collapse_if_possible(ICLKernel::window(), Window::DimZ);
Window slice = collapsed.first_slice_window_3D();
do
{
unsigned int idx = 0;
- add_3D_tensor_argument(idx, _input, slice);
+ add_3D_tensor_argument(idx, src, slice);
if(!_run_in_place)
{
- add_3D_tensor_argument(idx, _output, slice);
+ add_3D_tensor_argument(idx, dst, slice);
}
enqueue(queue, *this, slice, lws_hint());
}