MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / validate

Method validate

arm_compute/runtime/CPP/functions/CPPSplit.h:58–125  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 9

compute_split_shapeFunction · 0.85
validateFunction · 0.50
num_dimensionsMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
total_sizeMethod · 0.45
setMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected