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/gpu/cl/operators/ClActivation.cpp | |
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/gpu/cl/operators/ClActivation.cpp')
-rw-r--r-- | src/runtime/gpu/cl/operators/ClActivation.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/runtime/gpu/cl/operators/ClActivation.cpp b/src/runtime/gpu/cl/operators/ClActivation.cpp index 71aa57bdbd..bef42d7fae 100644 --- a/src/runtime/gpu/cl/operators/ClActivation.cpp +++ b/src/runtime/gpu/cl/operators/ClActivation.cpp @@ -26,6 +26,10 @@ #include "src/core/gpu/cl/ClCompileContext.h" #include "src/core/gpu/cl/kernels/ClActivationKernel.h" +#include "src/common/IOperator.h" +#include "src/common/utils/LegacySupport.h" +#include "src/gpu/cl/ClContext.h" + namespace arm_compute { namespace opencl @@ -42,4 +46,35 @@ Status ClActivation::validate(const ITensorInfo *src, const ITensorInfo *dst, co return kernels::ClActivationKernel::validate(src, dst, act_info); } } // namespace opencl + +namespace gpu +{ +namespace opencl +{ +std::tuple<IOperator *, StatusCode> ClContext::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(arm_compute::opencl::ClActivation::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<arm_compute::opencl::ClActivation>(); + act_op->configure(CLKernelLibrary::get().get_compile_context(), &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 opencl +} // namespace gpu } // namespace arm_compute |