From 0499dff9293a86d3d53f72fed0a38b2823563674 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Fri, 31 Jul 2020 22:21:38 +0100 Subject: COMPMID-3392: Collapse TensorMaps into a single TensorPack Collapse InputTensorMap and OutputTensorMap to a single TensorPack mechanism. Signed-off-by: Georgios Pinitas Change-Id: Ie2fdfc6b07d84ad589169ec99ca64fcf45a00bec Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/c/VisualCompute/ComputeLibrary/+/253783 Tested-by: bsgcomp Reviewed-by: Michalis Spyrou Signed-off-by: Michalis Spyrou Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3641 Tested-by: Arm Jenkins Comments-Addressed: Arm Jenkins Reviewed-by: SiCong Li Reviewed-by: Sheri Zhang --- src/runtime/NEON/INEOperator.cpp | 10 ++-- src/runtime/NEON/functions/NEActivationLayer.cpp | 8 ++-- .../NEON/functions/NEArithmeticAddition.cpp | 8 ++-- .../NEON/functions/NEArithmeticSubtraction.cpp | 8 ++-- src/runtime/NEON/functions/NEConcatenateLayer.cpp | 22 ++++----- .../NEON/functions/NEElementwiseOperators.cpp | 56 ++++++++++++++-------- src/runtime/NEON/functions/NEPReluLayer.cpp | 8 ++-- .../NEON/functions/NEPixelWiseMultiplication.cpp | 16 ++++--- src/runtime/NEON/functions/NEReshapeLayer.cpp | 8 ++-- src/runtime/NEON/functions/NESlice.cpp | 7 +-- src/runtime/NEON/functions/NEStridedSlice.cpp | 7 +-- 11 files changed, 91 insertions(+), 67 deletions(-) (limited to 'src/runtime/NEON') diff --git a/src/runtime/NEON/INEOperator.cpp b/src/runtime/NEON/INEOperator.cpp index 1d819977c8..75068b15c9 100644 --- a/src/runtime/NEON/INEOperator.cpp +++ b/src/runtime/NEON/INEOperator.cpp @@ -33,19 +33,17 @@ INEOperator::INEOperator(IRuntimeContext *ctx) { } -void INEOperator::run(InputTensorMap inputs, OutputTensorMap outputs, OperatorTensorMap workspace) +void INEOperator::run(ITensorPack &tensors) { - ARM_COMPUTE_UNUSED(workspace); - - if(inputs.empty() || outputs.empty()) + if(tensors.empty()) { ARM_COMPUTE_ERROR("No inputs provided"); } - NEScheduler::get().schedule_op(_kernel.get(), Window::DimY, inputs, outputs); + NEScheduler::get().schedule_op(_kernel.get(), Window::DimY, tensors); } -void INEOperator::prepare(OperatorTensorMap constants) +void INEOperator::prepare(ITensorPack &constants) { ARM_COMPUTE_UNUSED(constants); } diff --git a/src/runtime/NEON/functions/NEActivationLayer.cpp b/src/runtime/NEON/functions/NEActivationLayer.cpp index 0e75e58b3b..7f55edbf70 100644 --- a/src/runtime/NEON/functions/NEActivationLayer.cpp +++ b/src/runtime/NEON/functions/NEActivationLayer.cpp @@ -85,9 +85,9 @@ Status NEActivationLayer::validate(const ITensorInfo *input, const ITensorInfo * void NEActivationLayer::run() { - const InputTensorMap src{ { TensorType::ACL_SRC, _impl->src } }; - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; - - _impl->op->run(src, dst, {}); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC, _impl->src); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } } // namespace arm_compute diff --git a/src/runtime/NEON/functions/NEArithmeticAddition.cpp b/src/runtime/NEON/functions/NEArithmeticAddition.cpp index b18309ef1d..4453a015e8 100644 --- a/src/runtime/NEON/functions/NEArithmeticAddition.cpp +++ b/src/runtime/NEON/functions/NEArithmeticAddition.cpp @@ -79,8 +79,10 @@ void NEArithmeticAddition::configure(const ITensor *input1, const ITensor *input void NEArithmeticAddition::run() { - const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; - _impl->op->run(src, dst, {}); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); + pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } } // namespace arm_compute diff --git a/src/runtime/NEON/functions/NEArithmeticSubtraction.cpp b/src/runtime/NEON/functions/NEArithmeticSubtraction.cpp index c7f492bcbc..1c95bbfae8 100644 --- a/src/runtime/NEON/functions/NEArithmeticSubtraction.cpp +++ b/src/runtime/NEON/functions/NEArithmeticSubtraction.cpp @@ -80,8 +80,10 @@ void NEArithmeticSubtraction::configure(const ITensor *input1, const ITensor *in void NEArithmeticSubtraction::run() { - const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; - _impl->op->run(src, dst, {}); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); + pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } } // namespace arm_compute diff --git a/src/runtime/NEON/functions/NEConcatenateLayer.cpp b/src/runtime/NEON/functions/NEConcatenateLayer.cpp index 9f8a2a1b8e..8df4f4cb62 100644 --- a/src/runtime/NEON/functions/NEConcatenateLayer.cpp +++ b/src/runtime/NEON/functions/NEConcatenateLayer.cpp @@ -146,16 +146,14 @@ Status NEConcatenation::validate(const std::vector &inputs_ return Status{}; } -void NEConcatenation::run(InputTensorMap inputs, OutputTensorMap outputs, OperatorTensorMap workspace) +void NEConcatenation::run(ITensorPack &tensors) { - ARM_COMPUTE_UNUSED(workspace); - - if(inputs.empty() || outputs.empty()) + if(tensors.empty()) { ARM_COMPUTE_ERROR("No inputs provided"); } - if(inputs.size() != _num_inputs) + if(static_cast(tensors.size() - 1) != static_cast(_num_inputs)) { ARM_COMPUTE_ERROR("Configured with different number of inputs"); } @@ -163,8 +161,10 @@ void NEConcatenation::run(InputTensorMap inputs, OutputTensorMap outputs, Operat int i = 0; for(auto &k : _concat_kernels) { - const InputTensorMap input = { { TensorType::ACL_SRC, inputs.at(ACL_SRC_VEC + i) } }; - NEScheduler::get().schedule_op(k.get(), Window::DimY, input, outputs); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC, tensors.get_const_tensor(ACL_SRC_VEC + i)); + pack.add_tensor(TensorType::ACL_DST, tensors.get_tensor(ACL_DST)); + NEScheduler::get().schedule_op(k.get(), Window::DimY, pack); ++i; } } @@ -216,13 +216,13 @@ Status NEConcatenateLayer::validate(const std::vector &inpu void NEConcatenateLayer::run() { - InputTensorMap srcs; + ITensorPack pack; for(unsigned i = 0; i < _impl->num_inputs; ++i) { - srcs.insert(std::make_pair(TensorType::ACL_SRC_VEC + i, _impl->srcs.at(i))); + pack.add_tensor(TensorType::ACL_SRC_VEC + i, _impl->srcs.at(i)); } - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; + pack.add_tensor(TensorType::ACL_DST, _impl->dst); - _impl->op->run(srcs, dst, {}); + _impl->op->run(pack); } } // namespace arm_compute diff --git a/src/runtime/NEON/functions/NEElementwiseOperators.cpp b/src/runtime/NEON/functions/NEElementwiseOperators.cpp index 9340cc09d4..d1f60c71e1 100644 --- a/src/runtime/NEON/functions/NEElementwiseOperators.cpp +++ b/src/runtime/NEON/functions/NEElementwiseOperators.cpp @@ -163,9 +163,11 @@ Status NEElementwiseMax::validate(const ITensorInfo *input1, const ITensorInfo * void NEElementwiseMax::run() { - const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; - _impl->op->run(src, dst, {}); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); + pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } struct NEElementwiseMin::Impl @@ -202,9 +204,11 @@ Status NEElementwiseMin::validate(const ITensorInfo *input1, const ITensorInfo * void NEElementwiseMin::run() { - const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; - _impl->op->run(src, dst, {}); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); + pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } struct NEElementwiseSquaredDiff::Impl @@ -241,9 +245,11 @@ Status NEElementwiseSquaredDiff::validate(const ITensorInfo *input1, const ITens void NEElementwiseSquaredDiff::run() { - const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; - _impl->op->run(src, dst, {}); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); + pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } struct NEElementwiseDivision::Impl @@ -280,9 +286,11 @@ Status NEElementwiseDivision::validate(const ITensorInfo *input1, const ITensorI void NEElementwiseDivision::run() { - const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; - _impl->op->run(src, dst, {}); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); + pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } struct NEElementwisePower::Impl @@ -319,9 +327,11 @@ Status NEElementwisePower::validate(const ITensorInfo *input1, const ITensorInfo void NEElementwisePower::run() { - const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; - _impl->op->run(src, dst, {}); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); + pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } template @@ -364,9 +374,11 @@ Status NEElementwiseComparisonStatic::validate(const ITensorInfo *input1, c template void NEElementwiseComparisonStatic::run() { - const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; - _impl->op->run(src, dst, {}); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); + pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } struct NEElementwiseComparison::Impl @@ -401,9 +413,11 @@ Status NEElementwiseComparison::validate(const ITensorInfo *input1, const ITenso void NEElementwiseComparison::run() { - const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; - _impl->op->run(src, dst, {}); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); + pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } // Supported Specializations diff --git a/src/runtime/NEON/functions/NEPReluLayer.cpp b/src/runtime/NEON/functions/NEPReluLayer.cpp index 15d9fd9959..f9393a4d92 100644 --- a/src/runtime/NEON/functions/NEPReluLayer.cpp +++ b/src/runtime/NEON/functions/NEPReluLayer.cpp @@ -71,9 +71,11 @@ void NEPReluLayer::configure(const ITensor *input, const ITensor *alpha, ITensor void NEPReluLayer::run() { - const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; - _impl->op->run(src, dst, {}); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); + pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } Status NEPReluLayer::validate(const ITensorInfo *input, const ITensorInfo *alpha, const ITensorInfo *output) diff --git a/src/runtime/NEON/functions/NEPixelWiseMultiplication.cpp b/src/runtime/NEON/functions/NEPixelWiseMultiplication.cpp index ba5dd7cdee..4208878b75 100644 --- a/src/runtime/NEON/functions/NEPixelWiseMultiplication.cpp +++ b/src/runtime/NEON/functions/NEPixelWiseMultiplication.cpp @@ -97,9 +97,11 @@ void NEPixelWiseMultiplication::configure(const ITensor *input1, const ITensor * void NEPixelWiseMultiplication::run() { - const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; - _impl->op->run(src, dst, {}); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); + pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } struct NEComplexPixelWiseMultiplication::Impl @@ -134,8 +136,10 @@ void NEComplexPixelWiseMultiplication::configure(ITensor *input1, ITensor *input void NEComplexPixelWiseMultiplication::run() { - const InputTensorMap src{ { TensorType::ACL_SRC_0, _impl->src_0 }, { TensorType::ACL_SRC_1, _impl->src_1 } }; - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; - _impl->op->run(src, dst, {}); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC_0, _impl->src_0); + pack.add_tensor(TensorType::ACL_SRC_1, _impl->src_1); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } } // namespace arm_compute diff --git a/src/runtime/NEON/functions/NEReshapeLayer.cpp b/src/runtime/NEON/functions/NEReshapeLayer.cpp index 47d5519274..c1c88c1c7a 100644 --- a/src/runtime/NEON/functions/NEReshapeLayer.cpp +++ b/src/runtime/NEON/functions/NEReshapeLayer.cpp @@ -84,9 +84,9 @@ Status NEReshapeLayer::validate(const ITensorInfo *input, const ITensorInfo *out void NEReshapeLayer::run() { - const InputTensorMap src{ { TensorType::ACL_SRC, _impl->src } }; - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; - - _impl->op->run(src, dst, {}); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC, _impl->src); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } } // namespace arm_compute diff --git a/src/runtime/NEON/functions/NESlice.cpp b/src/runtime/NEON/functions/NESlice.cpp index 7c3252178b..2bacf2ee2a 100644 --- a/src/runtime/NEON/functions/NESlice.cpp +++ b/src/runtime/NEON/functions/NESlice.cpp @@ -94,9 +94,10 @@ void NESlice::configure(const ITensor *input, ITensor *output, const Coordinates void NESlice::run() { - const InputTensorMap src{ { TensorType::ACL_SRC, _impl->src } }; - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; - _impl->op->run(src, dst, {}); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC, _impl->src); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } } // namespace arm_compute diff --git a/src/runtime/NEON/functions/NEStridedSlice.cpp b/src/runtime/NEON/functions/NEStridedSlice.cpp index 37e3590446..8bf81e8270 100644 --- a/src/runtime/NEON/functions/NEStridedSlice.cpp +++ b/src/runtime/NEON/functions/NEStridedSlice.cpp @@ -76,9 +76,10 @@ void NEStridedSlice::configure(const ITensor *input, ITensor *output, void NEStridedSlice::run() { - const InputTensorMap src{ { TensorType::ACL_SRC, _impl->src } }; - const OutputTensorMap dst{ { TensorType::ACL_DST, _impl->dst } }; - _impl->op->run(src, dst, {}); + ITensorPack pack; + pack.add_tensor(TensorType::ACL_SRC, _impl->src); + pack.add_tensor(TensorType::ACL_DST, _impl->dst); + _impl->op->run(pack); } Status NEStridedSlice::validate(const ITensorInfo *input, const ITensorInfo *output, -- cgit v1.2.1