diff options
author | Viet-Hoa Do <viet-hoa.do@arm.com> | 2023-07-20 17:31:47 +0100 |
---|---|---|
committer | Viet-Hoa Do <viet-hoa.do@arm.com> | 2023-07-21 13:33:12 +0000 |
commit | 25d26f4d86042e0ca52ac1bef4039b187f77b5b3 (patch) | |
tree | 9a4ee7d5173883a2c67a68689d591efd746f2b5f /compute_kernel_writer/include | |
parent | 8dfb8820d5fe0f72a923eccc3bb73ee0b87d5511 (diff) | |
download | ComputeLibrary-25d26f4d86042e0ca52ac1bef4039b187f77b5b3.tar.gz |
Change TileOperand to a view of a tile object
* TileOperand instead of being the tile object now is only a view
of a tile object.
- declare_tile now returns a TileOperand object, not a reference
to a TileOperand object.
- This is to prepare for the posibility that the users need
to perform operations on part of a tile (e.g. a scalar value,
a vector, a sub-tile).
Partially resolves: COMPMID-6391
Signed-off-by: Viet-Hoa Do <viet-hoa.do@arm.com>
Change-Id: I35c08b22a384a756d99dcd04cbe66fc57bd548d2
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9958
Reviewed-by: Gunes Bayir <gunes.bayir@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/include')
-rw-r--r-- | compute_kernel_writer/include/ckw/KernelWriter.h | 24 | ||||
-rw-r--r-- | compute_kernel_writer/include/ckw/TileOperand.h | 24 |
2 files changed, 33 insertions, 15 deletions
diff --git a/compute_kernel_writer/include/ckw/KernelWriter.h b/compute_kernel_writer/include/ckw/KernelWriter.h index 85ae47f686..cfd24d35a3 100644 --- a/compute_kernel_writer/include/ckw/KernelWriter.h +++ b/compute_kernel_writer/include/ckw/KernelWriter.h @@ -28,7 +28,6 @@ #include "ckw/TileOperand.h" #include <memory> -#include <set> #include <string> namespace ckw @@ -103,23 +102,30 @@ public: * * @returns The created tile operand */ - virtual TileOperand &declare_tile(const std::string &name, const TileInfo &tile_info) = 0; + virtual TileOperand declare_tile(const std::string &name, const TileInfo &tile_info) = 0; protected: int32_t id_space() const; - /** Pure virtual function to be overridden by language specific subclasses to add a tile operand to the kernel */ - virtual TileOperand &add_operand(const std::string &name, const TileInfo &tile_info) = 0; - - /** Add a tile operand to the operand list */ - TileOperand &add_operand(std::unique_ptr<TileOperand> &operand_ptr); - /** Generate full variable name by prefixing it with id space */ std::string generate_full_name(const std::string &name) const; + /** Create a new tile operand referring to the specified tile object. + * + * This class has friendship relationship with @ref TileOperand which allows it + * to access the private constructor. + */ + static TileOperand create_tile_operand(ITile &tile); + + /** Get the reference to tile object from the tile operand. + * + * This class has friendship relationship with @ref TileOperand which allows it + * to access the private reference to the private tile field. + */ + static ITile &get_tile(const TileOperand &operand); + private: int32_t _id_space{ 0 }; - std::set<std::unique_ptr<TileOperand>> _operands {}; }; } // namespace ckw diff --git a/compute_kernel_writer/include/ckw/TileOperand.h b/compute_kernel_writer/include/ckw/TileOperand.h index abd3e0ac97..fe44b73e82 100644 --- a/compute_kernel_writer/include/ckw/TileOperand.h +++ b/compute_kernel_writer/include/ckw/TileOperand.h @@ -22,20 +22,32 @@ * SOFTWARE. */ -#ifndef CKW_INCLUDE_CKW_TILEOPERAND -#define CKW_INCLUDE_CKW_TILEOPERAND +#ifndef CKW_INCLUDE_CKW_TILEOPERAND_H +#define CKW_INCLUDE_CKW_TILEOPERAND_H namespace ckw { -/** Tile operand which can be either scalar, vector or 2D tile. */ +class KernelWriter; +class ITile; + +/** A tile operand refers to a tile object that can be used for kernel writing. */ class TileOperand { public: - /* Destructor */ - virtual ~TileOperand(); + // The constructor and _tile field is completely hidden from the public API to avoid any misuse. + // Only kernel writer class interacts with tile operand hence we allow it to access this field. + friend class KernelWriter; + +private: + // These are hidden from the public API to avoid any misuse. + + /** Initialize a new instance of @ref TileOperand class for the given tile. */ + TileOperand(ITile &tile); + + ITile &_tile; }; } // namespace ckw -#endif /* COMPUTE_KERNEL_WRITER_INCLUDE_CKW_TILEOPERAND */ +#endif // CKW_INCLUDE_CKW_TILEOPERAND_H |