Jeremy Johnson | c833081 | 2024-01-18 16:57:28 +0000 | [diff] [blame] | 1 | // Copyright (c) 2023-2024, ARM Limited. |
Jeremy Johnson | b20b0c9 | 2023-10-04 14:17:55 +0100 | [diff] [blame] | 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #ifndef GENERATE_DOT_PRODUCT_H_ |
| 16 | #define GENERATE_DOT_PRODUCT_H_ |
| 17 | |
| 18 | #include "generate_utils.h" |
| 19 | |
| 20 | #include <memory> |
| 21 | |
| 22 | namespace TosaReference |
| 23 | { |
| 24 | |
| 25 | /// \brief Generic dot-product generator interface |
| 26 | class IDotProductGenerator |
| 27 | { |
| 28 | public: |
| 29 | virtual float operator()(uint32_t k) = 0; |
Jeremy Johnson | 65ba809 | 2023-10-09 16:31:13 +0100 | [diff] [blame] | 30 | virtual ~IDotProductGenerator() = default; |
Jeremy Johnson | c833081 | 2024-01-18 16:57:28 +0000 | [diff] [blame] | 31 | virtual uint32_t nextIndex() = 0; |
Jeremy Johnson | b20b0c9 | 2023-10-04 14:17:55 +0100 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | /// \brief Dot-product stage generator selector |
| 35 | std::unique_ptr<IDotProductGenerator> pickDotProductGenerator(const GenerateConfig& cfg); |
| 36 | |
| 37 | /// \brief Perform dot-product based generation |
| 38 | /// |
| 39 | /// \param cfg Generator related meta-data |
| 40 | /// \param data Buffer to generate the data to |
Jeremy Johnson | d41feb7 | 2023-10-12 16:03:15 +0100 | [diff] [blame] | 41 | /// \param size Size of the buffer |
Jeremy Johnson | b20b0c9 | 2023-10-04 14:17:55 +0100 | [diff] [blame] | 42 | /// |
| 43 | /// \return True on successful generation |
| 44 | bool generateDotProduct(const GenerateConfig& cfg, void* data, size_t size); |
| 45 | |
| 46 | }; // namespace TosaReference |
| 47 | |
| 48 | #endif // GENERATE_DOT_PRODUCT_H_ |