diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2021-08-03 08:24:00 +0100 |
---|---|---|
committer | Sheri Zhang <sheri.zhang@arm.com> | 2021-08-04 08:56:33 +0000 |
commit | 4164814a099773c0a512889473c980bc148e590f (patch) | |
tree | 7ee27bbd40724635f5bf22bc9ec28b3a1a4d1ac9 /src/runtime/cpu/operators | |
parent | 6e90c12e3067c482524a08bf322f42de6d9d27b9 (diff) | |
download | ComputeLibrary-4164814a099773c0a512889473c980bc148e590f.tar.gz |
Implement Operator API
Resolves: COMPMID-4512
Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com>
Change-Id: Id12130365fa3fe2261160931dcc7affb6b467186
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6031
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/runtime/cpu/operators')
-rw-r--r-- | src/runtime/cpu/operators/CpuActivation.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/runtime/cpu/operators/CpuActivation.cpp b/src/runtime/cpu/operators/CpuActivation.cpp index 7753c9601f..80667becff 100644 --- a/src/runtime/cpu/operators/CpuActivation.cpp +++ b/src/runtime/cpu/operators/CpuActivation.cpp @@ -23,7 +23,10 @@ */ #include "src/runtime/cpu/operators/CpuActivation.h" +#include "src/common/IOperator.h" +#include "src/common/utils/LegacySupport.h" #include "src/core/cpu/kernels/CpuActivationKernel.h" +#include "src/cpu/CpuContext.h" namespace arm_compute { @@ -40,5 +43,30 @@ Status CpuActivation::validate(const ITensorInfo *input, const ITensorInfo *outp { return kernels::CpuActivationKernel::validate(input, output, activation_info); } + +std::tuple<IOperator *, StatusCode> CpuContext::create_activation(const AclTensorDescriptor &src, const AclTensorDescriptor &dst, const AclActivationDescriptor &act, bool is_validate) +{ + TensorInfo src_info = detail::convert_to_legacy_tensor_info(src); + TensorInfo dst_info = detail::convert_to_legacy_tensor_info(dst); + auto info = detail::convert_to_activation_info(act); + + if(is_validate && !bool(CpuActivation::validate(&src_info.set_is_resizable(false), &dst_info.set_is_resizable(false), info))) + { + return std::make_tuple(nullptr, StatusCode::UnsupportedConfig); + } + + auto act_op = std::make_unique<cpu::CpuActivation>(); + act_op->configure(&src_info, &dst_info, info); + + auto op = new arm_compute::IOperator(static_cast<IContext *>(this)); + if(op == nullptr) + { + ARM_COMPUTE_LOG_ERROR_ACL("Couldn't allocate internal resources"); + return { nullptr, StatusCode::OutOfMemory }; + } + op->set_internal_operator(std::move(act_op)); + + return std::make_tuple(op, StatusCode::Success); +} } // namespace cpu } // namespace arm_compute |