diff options
author | SiCong Li <sicong.li@arm.com> | 2023-03-21 12:00:15 +0000 |
---|---|---|
committer | SiCong Li <sicong.li@arm.com> | 2023-03-27 12:56:26 +0000 |
commit | 5a7d1571a2de24eefc6f1d8d22deeef9f47521ee (patch) | |
tree | 1a9610a60f468619aa54acd4454ace59d83b5b88 /tests/validation/reference | |
parent | b531b7549abdd5c10b14b00107ea647591baa430 (diff) | |
download | ComputeLibrary-5a7d1571a2de24eefc6f1d8d22deeef9f47521ee.tar.gz |
Fix BatchToSpaceFixture
* Use a vector to represent the (static) block shape instead of an N-D
Tensor. The previous use of ND Tensor as block shape was wrong, not
adhering to the specification, and non-functional (only first dim was
used anyway).
* The fixture now accepts a static block shape, because the dynamic
case is not properly implemented and will be deprecated for now.
* Fix an assertion error in reference implementation.
Partially resolves COMPMID-5918
Change-Id: I5221e52ccc05e7c1249dec3a42426f954a73729a
Signed-off-by: SiCong Li <sicong.li@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9357
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Pablo Marquez Tello <pablo.tello@arm.com>
Reviewed-by: Omar Al Khatib <omar.alkhatib@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/validation/reference')
-rw-r--r-- | tests/validation/reference/BatchToSpaceLayer.cpp | 18 | ||||
-rw-r--r-- | tests/validation/reference/BatchToSpaceLayer.h | 2 |
2 files changed, 12 insertions, 8 deletions
diff --git a/tests/validation/reference/BatchToSpaceLayer.cpp b/tests/validation/reference/BatchToSpaceLayer.cpp index aeda733bb6..63d121f59b 100644 --- a/tests/validation/reference/BatchToSpaceLayer.cpp +++ b/tests/validation/reference/BatchToSpaceLayer.cpp @@ -23,8 +23,10 @@ */ #include "BatchToSpaceLayer.h" +#include "arm_compute/core/Validate.h" #include "tests/validation/Helpers.h" +#include "arm_compute/core/utils/misc/ShapeCalculator.h" namespace arm_compute { namespace test @@ -35,18 +37,20 @@ namespace reference { // Batch to Space template <typename T> -SimpleTensor<T> batch_to_space(const SimpleTensor<T> &src, const SimpleTensor<int32_t> &block_shape, const TensorShape &dst_shape, const CropInfo &crop_info) +SimpleTensor<T> batch_to_space(const SimpleTensor<T> &src, const std::vector<int32_t> &block_shape, const CropInfo &crop_info, const TensorShape &dst_shape) { - ARM_COMPUTE_ERROR_ON(block_shape[0] <= 0); - ARM_COMPUTE_ERROR_ON(block_shape[1] <= 0); + ARM_COMPUTE_ERROR_ON(block_shape[0] < 1); + ARM_COMPUTE_ERROR_ON(block_shape[1] < 1); + const auto expected_dst_shape = misc::shape_calculator::compute_batch_to_space_shape(DataLayout::NCHW, src.shape(), block_shape[0], block_shape[1], crop_info); + ARM_COMPUTE_ERROR_ON(arm_compute::detail::have_different_dimensions(expected_dst_shape, dst_shape, 0)); + ARM_COMPUTE_UNUSED(expected_dst_shape); + SimpleTensor<T> result(dst_shape, src.data_type()); int out_pos = 0; const auto width_out = static_cast<int>(dst_shape[0]); const auto height_out = static_cast<int>(dst_shape[1]); const auto z_out = static_cast<int>(dst_shape[2]); const auto batch_out = static_cast<int>(dst_shape[3]); - ARM_COMPUTE_ERROR_ON(width_out <= static_cast<int>(crop_info.left + crop_info.right)); - ARM_COMPUTE_ERROR_ON(height_out <= static_cast<int>(crop_info.top + crop_info.bottom)); for(int batch = 0; batch < batch_out; ++batch) { @@ -71,8 +75,8 @@ SimpleTensor<T> batch_to_space(const SimpleTensor<T> &src, const SimpleTensor<in return result; } -template SimpleTensor<float> batch_to_space(const SimpleTensor<float> &src, const SimpleTensor<int32_t> &block_shape, const TensorShape &dst_shape, const CropInfo &crop_info = CropInfo{}); -template SimpleTensor<half> batch_to_space(const SimpleTensor<half> &src, const SimpleTensor<int32_t> &block_shape, const TensorShape &dst_shape, const CropInfo &crop_info = CropInfo{}); +template SimpleTensor<float> batch_to_space(const SimpleTensor<float> &src, const std::vector<int32_t> &block_shape, const CropInfo &crop_info, const TensorShape &dst_shape); +template SimpleTensor<half> batch_to_space(const SimpleTensor<half> &src, const std::vector<int32_t> &block_shape, const CropInfo &crop_info, const TensorShape &dst_shape); } // namespace reference } // namespace validation } // namespace test diff --git a/tests/validation/reference/BatchToSpaceLayer.h b/tests/validation/reference/BatchToSpaceLayer.h index 18010f1885..a37bfc3373 100644 --- a/tests/validation/reference/BatchToSpaceLayer.h +++ b/tests/validation/reference/BatchToSpaceLayer.h @@ -37,7 +37,7 @@ namespace validation namespace reference { template <typename T> -SimpleTensor<T> batch_to_space(const SimpleTensor<T> &src, const SimpleTensor<int32_t> &block_shape, const TensorShape &dst_shape, const CropInfo &crop_info = CropInfo{}); +SimpleTensor<T> batch_to_space(const SimpleTensor<T> &src, const std::vector<int32_t> &block_shape, const CropInfo &crop_info, const TensorShape &dst_shape); } // namespace reference } // namespace validation } // namespace test |