11/*
2- * Copyright (c) 2018-2021, 2023 Arm Limited.
2+ * Copyright (c) 2018-2021, 2023, 2026 Arm Limited.
33 *
44 * SPDX-License-Identifier: MIT
55 *
3030#include " arm_compute/core/utils/StringUtils.h"
3131
3232#include " src/core/CL/CLValidate.h"
33+ #include " src/core/CPP/Validate.h"
3334#include " src/core/helpers/AutoConfiguration.h"
3435#include " src/core/helpers/WindowHelpers.h"
3536#include " support/StringSupport.h"
@@ -42,16 +43,23 @@ namespace
4243Status validate_arguments (const ITensorInfo *input, const ITensorInfo *block_info, const ITensorInfo *output)
4344{
4445 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR (input, block_info, output);
45- ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN (block_info, 1 , DataType::S32);
46+ ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED (input, block_info);
47+ const size_t one_channel = 1u ;
48+ ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN (block_info, one_channel, DataType::S32);
4649 ARM_COMPUTE_RETURN_ERROR_ON (input->num_dimensions () > 4 );
4750 ARM_COMPUTE_RETURN_ERROR_ON (input->data_type () == DataType::UNKNOWN);
4851
4952 // Validate output if initialized
5053 if (output->total_size () != 0 )
5154 {
55+ ARM_COMPUTE_ERROR_ON_SIZE_UNSUPPORTED (output);
5256 ARM_COMPUTE_RETURN_ERROR_ON (output->num_dimensions () > 4 );
5357 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES (input, output);
5458 }
59+ else
60+ {
61+ // Ignored; dynamic block is deprecated.
62+ }
5563
5664 return Status{};
5765}
@@ -62,6 +70,9 @@ Status validate_arguments_static(const ITensorInfo *input,
6270 const CropInfo &crop_info)
6371{
6472 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR (input, output);
73+ ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED (input);
74+ const size_t one_channel = 1u ;
75+ ARM_COMPUTE_RETURN_ERROR_ON (input->num_channels () != one_channel);
6576 ARM_COMPUTE_RETURN_ERROR_ON (input->num_dimensions () > 4 );
6677 ARM_COMPUTE_RETURN_ERROR_ON (block_shape_x <= 0 );
6778 ARM_COMPUTE_RETURN_ERROR_ON (block_shape_y <= 0 );
@@ -70,16 +81,23 @@ Status validate_arguments_static(const ITensorInfo *input,
7081 const int idx_batch = get_data_layout_dimension_index (data_layout, DataLayoutDimension::BATCHES);
7182 ARM_COMPUTE_RETURN_ERROR_ON (input->tensor_shape ()[idx_batch] % (block_shape_x * block_shape_y) != 0 );
7283
84+ const TensorShape expected_output_shape = compute_batch_to_space_shape (input->data_layout (), input->tensor_shape (),
85+ block_shape_x, block_shape_y, crop_info);
86+
7387 // Validate output if initialized
7488 if (output->total_size () != 0 )
7589 {
76- const TensorShape expected_output_shape = compute_batch_to_space_shape (
77- input->data_layout (), input->tensor_shape (), block_shape_x, block_shape_y, crop_info);
90+ ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED (output);
7891 const TensorInfo expected_output = output->clone ()->set_tensor_shape (expected_output_shape);
7992 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES (output, &expected_output);
8093 ARM_COMPUTE_RETURN_ERROR_ON (output->num_dimensions () > 4 );
8194 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES (input, output);
8295 }
96+ else
97+ {
98+ const auto output_info = TensorInfo (expected_output_shape, one_channel, input->data_type ());
99+ ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED (&output_info);
100+ }
83101
84102 return Status{};
85103}
0 commit comments