diff options
author | Michalis Spyrou <michalis.spyrou@arm.com> | 2020-07-16 17:46:51 +0100 |
---|---|---|
committer | Michalis Spyrou <michalis.spyrou@arm.com> | 2020-07-21 16:22:21 +0000 |
commit | f20d6d6ae5a0da2c856294e93341cdc065db58f9 (patch) | |
tree | 0e11a924371691fb9d345cd9362cd8cc06662432 /src/runtime/CL/functions/CLStridedSlice.cpp | |
parent | c6eaec3610fa27651582f6c1acad35afffe360f6 (diff) | |
download | ComputeLibrary-f20d6d6ae5a0da2c856294e93341cdc065db58f9.tar.gz |
COMPMID-3390: Async support to CLStridedSliceLayerKernel kernels/functions
Signed-off-by: Michalis Spyrou <michalis.spyrou@arm.com>
Change-Id: I9ff7e8d2fb4d36c4b7c44e885abf34ff6d4c577c
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3587
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/CL/functions/CLStridedSlice.cpp')
-rw-r--r-- | src/runtime/CL/functions/CLStridedSlice.cpp | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/src/runtime/CL/functions/CLStridedSlice.cpp b/src/runtime/CL/functions/CLStridedSlice.cpp index fc011ceaf7..d1b16700ff 100644 --- a/src/runtime/CL/functions/CLStridedSlice.cpp +++ b/src/runtime/CL/functions/CLStridedSlice.cpp @@ -23,12 +23,55 @@ */ #include "arm_compute/runtime/CL/functions/CLStridedSlice.h" +#include "arm_compute/core/CL/ICLTensor.h" #include "arm_compute/core/CL/kernels/CLStridedSliceKernel.h" #include "arm_compute/core/Types.h" #include "support/MemorySupport.h" namespace arm_compute { +namespace experimental +{ +void CLStridedSlice::configure(const CLCompileContext &compile_context, const ITensorInfo *input, ITensorInfo *output, + const Coordinates &starts, const Coordinates &ends, const BiStrides &strides, + int32_t begin_mask, int32_t end_mask, int32_t shrink_axis_mask) +{ + auto k = arm_compute::support::cpp14::make_unique<CLStridedSliceKernel>(); + k->configure(compile_context, input, output, starts, ends, strides, begin_mask, end_mask, shrink_axis_mask); + _kernel = std::move(k); +} + +Status CLStridedSlice::validate(const ITensorInfo *input, const ITensorInfo *output, + const Coordinates &starts, const Coordinates &ends, const BiStrides &strides, + int32_t begin_mask, int32_t end_mask, int32_t shrink_axis_mask) +{ + return CLStridedSliceKernel::validate(input, output, starts, ends, strides, begin_mask, end_mask, shrink_axis_mask); +} + +MemoryRequirements CLStridedSlice::workspace() const +{ + return MemoryRequirements{}; +} +} // namespace experimental + +struct CLStridedSlice::Impl +{ + const ICLTensor *src{ nullptr }; + ICLTensor *dst{ nullptr }; + CLRuntimeContext *ctx{ nullptr }; + std::unique_ptr<experimental::CLStridedSlice> op{ nullptr }; +}; + +CLStridedSlice::CLStridedSlice(CLRuntimeContext *ctx) + : _impl(support::cpp14::make_unique<Impl>()) +{ + _impl->ctx = ctx; +} + +CLStridedSlice::CLStridedSlice(CLStridedSlice &&) = default; +CLStridedSlice &CLStridedSlice::operator=(CLStridedSlice &&) = default; +CLStridedSlice::~CLStridedSlice() = default; + void CLStridedSlice::configure(const ICLTensor *input, ICLTensor *output, const Coordinates &starts, const Coordinates &ends, const BiStrides &strides, int32_t begin_mask, int32_t end_mask, int32_t shrink_axis_mask) @@ -40,15 +83,27 @@ void CLStridedSlice::configure(const CLCompileContext &compile_context, const IC const Coordinates &starts, const Coordinates &ends, const BiStrides &strides, int32_t begin_mask, int32_t end_mask, int32_t shrink_axis_mask) { - auto k = arm_compute::support::cpp14::make_unique<CLStridedSliceKernel>(); - k->configure(compile_context, input, output, starts, ends, strides, begin_mask, end_mask, shrink_axis_mask); - _kernel = std::move(k); + ARM_COMPUTE_ERROR_ON_NULLPTR(input); + + _impl->src = input; + _impl->dst = output; + + _impl->op = arm_compute::support::cpp14::make_unique<experimental::CLStridedSlice>(); + _impl->op->configure(compile_context, _impl->src->info(), _impl->dst->info(), starts, ends, strides, begin_mask, end_mask, shrink_axis_mask); } Status CLStridedSlice::validate(const ITensorInfo *input, const ITensorInfo *output, const Coordinates &starts, const Coordinates &ends, const BiStrides &strides, int32_t begin_mask, int32_t end_mask, int32_t shrink_axis_mask) { - return CLStridedSliceKernel::validate(input, output, starts, ends, strides, begin_mask, end_mask, shrink_axis_mask); + return experimental::CLStridedSlice::validate(input, output, starts, ends, strides, begin_mask, end_mask, shrink_axis_mask); +} + +void CLStridedSlice::run() +{ + const InputTensorMap src{ { TensorType::ACL_SRC, _impl->src } }; + const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; + + _impl->op->run(src, dst, {}); } } // namespace arm_compute |