From 3b162e53267d13d18891baf3372f971f1d4213d3 Mon Sep 17 00:00:00 2001 From: David Svantesson Date: Tue, 28 Mar 2023 14:13:32 +0000 Subject: Reorder added Adds Reorder kernel exposing blocking reorders from arm_gemm Resolves ONCPUML-1232 Change-Id: I42bf4166311fe1771565134d3ed7039fc8e30230 Signed-off-by: David Svantesson Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9500 Comments-Addressed: Arm Jenkins Reviewed-by: SiCong Li Tested-by: Arm Jenkins Benchmark: Arm Jenkins --- tests/datasets/ReorderLayerDataset.h | 158 +++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 tests/datasets/ReorderLayerDataset.h (limited to 'tests/datasets') diff --git a/tests/datasets/ReorderLayerDataset.h b/tests/datasets/ReorderLayerDataset.h new file mode 100644 index 0000000000..8e1a8422b2 --- /dev/null +++ b/tests/datasets/ReorderLayerDataset.h @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2023 Arm Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ACL_TESTS_DATASETS_REORDERLAYERDATASET +#define ACL_TESTS_DATASETS_REORDERLAYERDATASET + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "utils/TypePrinter.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +/** [ReorderLayer datasets] **/ +class ReorderLayerDataset +{ +public: + using type = std::tuple; + + struct iterator + { + iterator(std::vector::const_iterator in_it, + std::vector::const_iterator out_it, + std::vector::const_iterator _wf_in_it, + std::vector::const_iterator _wf_out_it) + : _in_it{ std::move(in_it) }, + _out_it{ std::move(out_it) }, + _wf_in_it{ std::move(_wf_in_it) }, + _wf_out_it{ std::move(_wf_out_it) } + { + } + + std::string description() const + { + std::stringstream description; + description << "In=" << *_in_it << ":"; + description << "Out=" << *_out_it << ":"; + description << "Wf_In=" << *_wf_in_it << ":"; + description << "Wf_Out=" << *_wf_out_it; + return description.str(); + } + + ReorderLayerDataset::type operator*() const + { + return std::make_tuple(*_in_it, *_out_it, *_wf_in_it, *_wf_out_it); + } + + iterator &operator++() + { + ++_in_it; + ++_out_it; + ++_wf_in_it; + ++_wf_out_it; + + return *this; + } + + private: + std::vector::const_iterator _in_it; + std::vector::const_iterator _out_it; + std::vector::const_iterator _wf_in_it; + std::vector::const_iterator _wf_out_it; + }; + + iterator begin() const + { + return iterator(_in_shapes.begin(), _out_shapes.begin(), _in_wfs.begin(), _out_wfs.begin()); + } + + int size() const + { + return std::min(_in_shapes.size(), std::min(_out_shapes.size(), std::min(_in_wfs.size(), _out_wfs.size()))); + } + + void add_config(TensorShape in, TensorShape out, WeightFormat in_wf, WeightFormat out_wf) + { + _in_shapes.emplace_back(std::move(in)); + _out_shapes.emplace_back(std::move(out)); + _in_wfs.emplace_back(std::move(in_wf)); + _out_wfs.emplace_back(std::move(out_wf)); + } + + // protected: + ReorderLayerDataset() = default; + ReorderLayerDataset(ReorderLayerDataset &&) = default; + + private: + std::vector _in_shapes{}; + std::vector _out_shapes{}; + std::vector _in_wfs{}; + std::vector _out_wfs{}; +}; + +/** [ReorderLayer datasets] **/ + +class ReorderLayerDatasetBlock4 final : public ReorderLayerDataset +{ + public: + ReorderLayerDatasetBlock4() + { + add_config(TensorShape(10U, 9U), TensorShape(10U, 12U), WeightFormat::OHWI, WeightFormat::OHWIo4); + add_config(TensorShape(16U, 16U), TensorShape(16U, 16U), WeightFormat::OHWI, WeightFormat::OHWIo4); + add_config(TensorShape(10U, 511U), TensorShape(10U, 512U), WeightFormat::OHWI, WeightFormat::OHWIo4); + add_config(TensorShape(234U, 301U), TensorShape(234U, 304U), WeightFormat::OHWI, WeightFormat::OHWIo4); + add_config(TensorShape(1024U, 1024U), TensorShape(1024U, 1024U), WeightFormat::OHWI, WeightFormat::OHWIo4); + add_config(TensorShape(10U, 9U, 1U, 1U), TensorShape(10U, 12U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo4); + add_config(TensorShape(16U, 16U, 1U, 1U), TensorShape(16U, 16U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo4); + add_config(TensorShape(10U, 511U, 1U, 1U), TensorShape(10U, 512U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo4); + add_config(TensorShape(234U, 301U, 1U, 1U), TensorShape(234U, 304U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo4); + add_config(TensorShape(1024U, 1024U, 1U, 1U), TensorShape(1024U, 1024U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo4); + } +}; + +class ReorderLayerDatasetBlock8 final : public ReorderLayerDataset +{ + public: + ReorderLayerDatasetBlock8() + { + add_config(TensorShape(10U, 9U), TensorShape(10U, 16U), WeightFormat::OHWI, WeightFormat::OHWIo8); + add_config(TensorShape(16U, 16U), TensorShape(16U, 16U), WeightFormat::OHWI, WeightFormat::OHWIo8); + add_config(TensorShape(10U, 511U), TensorShape(10U, 512U), WeightFormat::OHWI, WeightFormat::OHWIo8); + add_config(TensorShape(234U, 301U), TensorShape(234U, 304U), WeightFormat::OHWI, WeightFormat::OHWIo8); + add_config(TensorShape(1024U, 1024U), TensorShape(1024U, 1024U), WeightFormat::OHWI, WeightFormat::OHWIo8); + add_config(TensorShape(10U, 9U, 1U, 1U), TensorShape(10U, 16U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo8); + add_config(TensorShape(16U, 16U, 1U, 1U), TensorShape(16U, 16U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo8); + add_config(TensorShape(10U, 511U, 1U, 1U), TensorShape(10U, 512U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo8); + add_config(TensorShape(234U, 301U, 1U, 1U), TensorShape(234U, 304U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo8); + add_config(TensorShape(1024U, 1024U, 1U, 1U), TensorShape(1024U, 1024U, 1U, 1U), WeightFormat::OHWI, WeightFormat::OHWIo8); + } +}; + +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ACL_TESTS_DATASETS_REORDERLAYERDATASET */ -- cgit v1.2.1