aboutsummaryrefslogtreecommitdiff
path: root/compute_kernel_writer/src/ITile.h
diff options
context:
space:
mode:
authorGian Marco Iodice <gianmarco.iodice@arm.com>2023-01-19 17:14:26 +0000
committerGian Marco Iodice <gianmarco.iodice@arm.com>2023-05-24 08:30:23 +0000
commit6c113ed1a95a08d17c2d556bd7b03c901512a34f (patch)
treec616a085e1eb3b4b9ac01a1f261182d4d10c481a /compute_kernel_writer/src/ITile.h
parent1355ec4797cd77060af51c8b27d99ea1d25c08da (diff)
downloadComputeLibrary-6c113ed1a95a08d17c2d556bd7b03c901512a34f.tar.gz
Prepare the basic types for the compute kernel writer (CKW)
- Add TensorInfo - Add TileInfo - Add CLTile - Add basic utility methods to get tensor components - Add unit tests Resolves COMPMID-5782, COMPMID-5785 Signed-off-by: Gian Marco Iodice <gianmarco.iodice@arm.com> Change-Id: I5e590bddd240d2f1fc876cac7129947558d7d53b Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/c/VisualCompute/ComputeLibrary/+/486221 Tested-by: bsgcomp <bsgcomp@arm.com> Reviewed-by: Jakub Sujak <jakub.sujak@arm.com> Reviewed-by: Pablo Tello <pablo.tello@arm.com> Comments-Addressed: bsgcomp <bsgcomp@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9687 Reviewed-by: Viet-Hoa Do <viet-hoa.do@arm.com> Reviewed-by: Pablo Marquez Tello <pablo.tello@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'compute_kernel_writer/src/ITile.h')
-rw-r--r--compute_kernel_writer/src/ITile.h134
1 files changed, 134 insertions, 0 deletions
diff --git a/compute_kernel_writer/src/ITile.h b/compute_kernel_writer/src/ITile.h
new file mode 100644
index 0000000000..283e6fa236
--- /dev/null
+++ b/compute_kernel_writer/src/ITile.h
@@ -0,0 +1,134 @@
+/*
+ * 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 COMPUTE_KERNEL_WRITER_SRC_ITILE_H
+#define COMPUTE_KERNEL_WRITER_SRC_ITILE_H
+
+#include "ckw/TileInfo.h"
+
+#include <string>
+#include <vector>
+
+namespace ckw
+{
+/** Tile descriptor which reports the underlying datatype and vector length */
+struct TileVariableDescriptor
+{
+ DataType dt { DataType::Unknown }; /** Data type */
+ int32_t len { 1 }; /** Number of elements in a single variable. For example, 1 for scalar */
+};
+
+/** Tile variable */
+struct TileVariable
+{
+ std::string str {""}; /** Tile variable as a string */
+ TileVariableDescriptor desc {}; /** Tile value descriptor which reports the datatype and vector length */
+};
+
+/** Tile base class.
+ * A Tile is a collection of variables (either program variables or constants) used to express a 2D data.
+ */
+class ITile
+{
+public:
+ virtual ~ITile() = default;
+ /** Method to get all TileVariable objects
+ *
+ * @return a vector containing all @ref TileVariable objects
+ */
+ virtual std::vector<TileVariable> all() const = 0;
+ /** Method to get the name of the tile.
+ *
+ * @return the name of the tile
+ */
+ std::string name() const
+ {
+ return _basename;
+ }
+ /** Method to get the tile info
+ *
+ * @return the @ref TileInfo
+ */
+ TileInfo info() const
+ {
+ return _info;
+ }
+ /** Method to know whether the tile is assignable or not.
+ * For example, a constant tile is not assignable.
+ *
+ * @return true if the tile is assignable
+ */
+ virtual bool is_assignable() const = 0;
+
+protected:
+ TileInfo _info { DataType::Unknown }; // Tile info
+ std::string _basename { "" }; // Tile name
+};
+
+/** Tile base class to store scalar variables.
+ */
+class IScalarTile : public ITile
+{
+public:
+ virtual ~IScalarTile() = default;
+ /** Method to get the scalar variable from a tile as a string
+ * @param[in] col Tile column. If out-of-bound, the column is clamped to the nearest valid edge
+ * @param[in] row Tile row. If out-of-bound, the row is clamped to the nearest valid edge
+ *
+ * @return the @ref TileVariable
+ */
+ virtual TileVariable scalar(int32_t col, int32_t row) const = 0;
+};
+
+/** Tile base class to store vector variables. It derives from IScalarTile since we can still access the scalar variable
+ */
+class IVectorTile : public IScalarTile
+{
+public:
+ virtual ~IVectorTile() = default;
+ /** Method to get the vector variable from a tile.
+ * The user can query the list of supported vector lengths through the supported_vector_lengths() method.
+ *
+ * @param[in] row Tile row. If out-of-bound, the row is clamped to the nearest valid edge
+ *
+ * @return the vector variable as a @ref TileVariable
+ */
+ virtual TileVariable vector(int32_t row) const = 0;
+ /** Method to get a sub-vector variable. The length of the sub-vector must be supported by the derived IVectorTile class
+ *
+ * @param[in] col_start Tile starting column to get the sub-vector. If out-of-bound, the derived IVectorTile class may throw an assert.
+ * @param[in] width The width of the sub-vector. The width must be supported by the derived IVectorTile class and the last element must be in-bound.
+ * @param[in] row Tile row. If out-of-bound, the row is clamped to the nearest valid edge
+ *
+ * @return the vector variable as a @ref TileVariable
+ */
+ virtual TileVariable vector(int32_t col_start, int32_t width, int32_t row) const = 0;
+ /** Method to get the supported vector length.
+ *
+ * @return a vector containing the supported vector lengths
+ */
+ virtual std::vector<int32_t> supported_vector_lengths() const = 0;
+};
+} // namespace ckw
+
+#endif /* COMPUTE_KERNEL_WRITER_SRC_ITILE_H */