diff options
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 |