diff options
author | Gian Marco Iodice <gianmarco.iodice@arm.com> | 2023-07-07 11:25:57 +0100 |
---|---|---|
committer | Viet-Hoa Do <viet-hoa.do@arm.com> | 2023-07-20 08:48:15 +0000 |
commit | ebfdb5a1ea73c2269eec5af492970c2174ab7d0f (patch) | |
tree | 5c60d083100118f0a40e629dfa69b7a7373dd7fd /compute_kernel_writer/src/TensorUtils.cpp | |
parent | 29dc9fc1d3d6e90746ba1173e3318b774dcf7bed (diff) | |
download | ComputeLibrary-ebfdb5a1ea73c2269eec5af492970c2174ab7d0f.tar.gz |
Integrate CLTensorArgument
- Add CLTensorArgument to query the components and storages as OpenCL
variables (or by values when possible)
- Add caching mechanism in CLTensorArgument to keep track of the components and storages used
- Add unit tests
Resolves COMPMID-5787
Signed-off-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Signed-off-by: Viet-Hoa Do <viet-hoa.do@arm.com>
Change-Id: Ib39e1f77b097e5b907a296fe6b0d41bb4bcd4ffc
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9908
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Reviewed-by: Jakub Sujak <jakub.sujak@arm.com>
Diffstat (limited to 'compute_kernel_writer/src/TensorUtils.cpp')
-rw-r--r-- | compute_kernel_writer/src/TensorUtils.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/compute_kernel_writer/src/TensorUtils.cpp b/compute_kernel_writer/src/TensorUtils.cpp index 4970de75a6..24836092d4 100644 --- a/compute_kernel_writer/src/TensorUtils.cpp +++ b/compute_kernel_writer/src/TensorUtils.cpp @@ -22,14 +22,14 @@ * SOFTWARE. */ +#include "src/TensorUtils.h" #include "ckw/Error.h" #include "ckw/TensorInfo.h" - -#include "src/TensorUtils.h" +#include "ckw/types/TensorComponentType.h" namespace ckw { -TensorComponent get_tensor_dimension(TensorDataLayout layout, TensorDataLayoutComponent component) +TensorComponentType get_tensor_dimension(TensorDataLayout layout, TensorDataLayoutComponent component) { switch(layout) { @@ -37,41 +37,41 @@ TensorComponent get_tensor_dimension(TensorDataLayout layout, TensorDataLayoutCo switch(component) { case TensorDataLayoutComponent::C: - return TensorComponent::Dim0; + return TensorComponentType::Dim0; case TensorDataLayoutComponent::W: - return TensorComponent::Dim1; + return TensorComponentType::Dim1; case TensorDataLayoutComponent::H: - return TensorComponent::Dim2; + return TensorComponentType::Dim2; case TensorDataLayoutComponent::N: - return TensorComponent::Dim3; + return TensorComponentType::Dim3; default: COMPUTE_KERNEL_WRITER_ERROR_ON_MSG("Unsupported tensor component for NHWC"); - return TensorComponent::Unknown; + return TensorComponentType::Unknown; } case TensorDataLayout::Ndhwc: switch(component) { case TensorDataLayoutComponent::C: - return TensorComponent::Dim0; + return TensorComponentType::Dim0; case TensorDataLayoutComponent::W: - return TensorComponent::Dim1; + return TensorComponentType::Dim1; case TensorDataLayoutComponent::H: - return TensorComponent::Dim2; + return TensorComponentType::Dim2; case TensorDataLayoutComponent::D: - return TensorComponent::Dim3; + return TensorComponentType::Dim3; case TensorDataLayoutComponent::N: - return TensorComponent::Dim4; + return TensorComponentType::Dim4; default: COMPUTE_KERNEL_WRITER_ERROR_ON_MSG("Unsupported tensor component for NDHWC"); - return TensorComponent::Unknown; + return TensorComponentType::Unknown; } default: COMPUTE_KERNEL_WRITER_ERROR_ON_MSG("Unsupported tensor data layout"); - return TensorComponent::Unknown; + return TensorComponentType::Unknown; } } -TensorComponent get_tensor_stride(TensorDataLayout layout, TensorDataLayoutComponent component) +TensorComponentType get_tensor_stride(TensorDataLayout layout, TensorDataLayoutComponent component) { switch(layout) { @@ -79,37 +79,37 @@ TensorComponent get_tensor_stride(TensorDataLayout layout, TensorDataLayoutCompo switch(component) { case TensorDataLayoutComponent::C: - return TensorComponent::Stride0; + return TensorComponentType::Stride0; case TensorDataLayoutComponent::W: - return TensorComponent::Stride1; + return TensorComponentType::Stride1; case TensorDataLayoutComponent::H: - return TensorComponent::Stride2; + return TensorComponentType::Stride2; case TensorDataLayoutComponent::N: - return TensorComponent::Stride3; + return TensorComponentType::Stride3; default: COMPUTE_KERNEL_WRITER_ERROR_ON_MSG("Unsupported tensor component for NHWC"); - return TensorComponent::Unknown; + return TensorComponentType::Unknown; } case TensorDataLayout::Ndhwc: switch(component) { case TensorDataLayoutComponent::C: - return TensorComponent::Stride0; + return TensorComponentType::Stride0; case TensorDataLayoutComponent::W: - return TensorComponent::Stride1; + return TensorComponentType::Stride1; case TensorDataLayoutComponent::H: - return TensorComponent::Stride2; + return TensorComponentType::Stride2; case TensorDataLayoutComponent::D: - return TensorComponent::Stride3; + return TensorComponentType::Stride3; case TensorDataLayoutComponent::N: - return TensorComponent::Stride4; + return TensorComponentType::Stride4; default: COMPUTE_KERNEL_WRITER_ERROR_ON_MSG("Unsupported tensor component for NDHWC"); - return TensorComponent::Unknown; + return TensorComponentType::Unknown; } default: COMPUTE_KERNEL_WRITER_ERROR_ON_MSG("Unsupported tensor data layout"); - return TensorComponent::Unknown; + return TensorComponentType::Unknown; } } } // namespace ckw |