diff options
author | Gian Marco Iodice <gianmarco.iodice@arm.com> | 2023-08-14 16:25:48 +0100 |
---|---|---|
committer | Gian Marco Iodice <gianmarco.iodice@arm.com> | 2023-08-15 08:30:02 +0000 |
commit | e32acd6e357631ef08f7f9df74efebbeb066c271 (patch) | |
tree | b9ded35e554dd09bbac5a906b7b7f73c0f2ef8be /compute_kernel_writer/src/Tensor3dMapper.h | |
parent | 338ef4699735db16d346e52f05b822f8fd5e3263 (diff) | |
download | ComputeLibrary-e32acd6e357631ef08f7f9df74efebbeb066c271.tar.gz |
Refactor the Tensor3dMapper object
- Return TileVariable instead of std::string
- Accept TensorSamplerFormat instead of TensorSamples in the list of
constructor input arguments
Resolves COMPMID-6496
Signed-off-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Change-Id: Idb555cbed45d741b049dfbbc1d4bbddf139deae4
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10131
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'compute_kernel_writer/src/Tensor3dMapper.h')
-rw-r--r-- | compute_kernel_writer/src/Tensor3dMapper.h | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/compute_kernel_writer/src/Tensor3dMapper.h b/compute_kernel_writer/src/Tensor3dMapper.h index 1c3856addd..fa68ac2d15 100644 --- a/compute_kernel_writer/src/Tensor3dMapper.h +++ b/compute_kernel_writer/src/Tensor3dMapper.h @@ -25,56 +25,57 @@ #ifndef CKW_SRC_TENSOR3DMAPPER_H #define CKW_SRC_TENSOR3DMAPPER_H -#include "ckw/TensorSampler.h" - #include <string> + namespace ckw { - +// Forward declarations class ITensor; -class TensorSampler; +enum class TensorSamplerFormat; +struct TileVariable; -/** This internal-only class is responsible to map an Nd tensor to a 3d tensor with the - * help of TensorSampler object. The aim of the dimensionality reduction is to reduce +/** This internal-only class is responsible to map an Nd tensor spatial dimensions to a 3d tensor spatial dimensions with the + * help of TensorSamplerFormat. + * Attention: The batch is not considered as a spatial dimension and it is treated as an offset + * + * The aim of the dimensionality reduction is primarily to reduce * the address calculation to: - * x + y * stride_y + z * stride_z + offset, where offset is determined by the batch. + * x + y * stride_y + z * stride_z + offset, where offset is determined by the batch (for example, b * stride_batch). + * */ class Tensor3dMapper { public: /** Constructor */ - Tensor3dMapper(ITensor *tensor, TensorSampler sampler); + Tensor3dMapper(ITensor *tensor, TensorSamplerFormat format); /** Get dimension x as string */ - std::string tensor_component_x() const; + TileVariable dim_x() const; /** Get dimension y as string */ - std::string tensor_component_y() const; + TileVariable dim_y() const; /** Get dimension z as string */ - std::string tensor_component_z() const; + TileVariable dim_z() const; + + /** Get batch dimension as string */ + TileVariable dim_batch() const; /** Get stride for dimension x as string */ - std::string tensor_component_stride_x() const; + TileVariable stride_x() const; /** Get stride for dimension y as string */ - std::string tensor_component_stride_y() const; + TileVariable stride_y() const; /** Get stride for dimension z as string */ - std::string tensor_component_stride_z() const; + TileVariable stride_z() const; /** Get stride for batch dimension as string */ - std::string tensor_component_stride_batch() const; - - /** Get the tensor sampler */ - TensorSampler sampler() const; - - /** Get the associated tensor */ - ITensor *tensor() const; + TileVariable stride_batch() const; private: - ITensor *_tensor; - TensorSampler _sampler; + ITensor *_tensor; + TensorSamplerFormat _format; }; } // namespace ckw |