Static function to check if given info will lead to a valid configuration of @ref CPPSplit * * @param[in] input The input tensor info. Data types supported: All. * @param[in] outputs A vector containing the output tensors' info. Data types supported: same as @p input. * The output tensors should match the input tensor dimensions for all shape dimensions apa
| 56 | * @return a status |
| 57 | */ |
| 58 | static Status validate(const ITensorInfo *input, const std::vector<ITensorInfo *> &outputs, unsigned int axis) |
| 59 | { |
| 60 | ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input); |
| 61 | ARM_COMPUTE_RETURN_ERROR_ON(axis >= input->num_dimensions()); |
| 62 | ARM_COMPUTE_RETURN_ERROR_ON(outputs.size() < 2); |
| 63 | |
| 64 | // Get output shape |
| 65 | TensorShape output_shape{}; |
| 66 | unsigned int total_output_shape_size = 0; |
| 67 | |
| 68 | // Sum the output sizes and fall back to evenly-sized splits if any are zero |
| 69 | const bool using_split_shapes = std::none_of(outputs.begin(), outputs.end(), |
| 70 | [&total_output_shape_size](ITensorInfo *info) |
| 71 | { |
| 72 | unsigned int output_shape_size = |
| 73 | info->tensor_shape().total_size(); |
| 74 | total_output_shape_size += output_shape_size; |
| 75 | return output_shape_size == 0; |
| 76 | }); |
| 77 | |
| 78 | if (using_split_shapes) |
| 79 | { |
| 80 | ARM_COMPUTE_RETURN_ERROR_ON(input->tensor_shape().total_size() != total_output_shape_size); |
| 81 | } |
| 82 | else |
| 83 | { |
| 84 | output_shape = arm_compute::misc::shape_calculator::compute_split_shape(input, axis, outputs.size()); |
| 85 | ARM_COMPUTE_RETURN_ERROR_ON(output_shape.total_size() == 0); |
| 86 | } |
| 87 | |
| 88 | // Validate output tensors |
| 89 | unsigned int axis_offset = 0; |
| 90 | for (const auto &output : outputs) |
| 91 | { |
| 92 | ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(output); |
| 93 | if (using_split_shapes) |
| 94 | { |
| 95 | output_shape = output->tensor_shape(); |
| 96 | ARM_COMPUTE_RETURN_ERROR_ON(output_shape.total_size() == 0); |
| 97 | } |
| 98 | |
| 99 | const size_t axis_split_step = output_shape[axis]; |
| 100 | |
| 101 | // Start/End coordinates |
| 102 | Coordinates start_coords; |
| 103 | Coordinates end_coords; |
| 104 | for (unsigned int d = 0; d < output_shape.num_dimensions(); ++d) |
| 105 | { |
| 106 | end_coords.set(d, -1); |
| 107 | } |
| 108 | |
| 109 | // Output auto inizialitation if not yet initialized |
| 110 | TensorInfo tmp_output_info = *output->clone(); |
| 111 | if (tmp_output_info.tensor_shape().total_size() == 0) |
| 112 | { |
| 113 | tmp_output_info = input->clone()->set_is_resizable(true).set_tensor_shape(output_shape); |
| 114 | } |
| 115 |
nothing calls this directly
no test coverage detected