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

Function validate_arguments

src/cpu/kernels/CpuAddMulAddKernel.cpp:59–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57};
58
59Status validate_arguments(const ITensorInfo *input1,
60 const ITensorInfo *input2,
61 const ITensorInfo *bn_mul,
62 const ITensorInfo *bn_add,
63 const ITensorInfo *add_output,
64 const ITensorInfo *final_output,
65 ConvertPolicy policy,
66 const ActivationLayerInfo &act_info)
67{
68 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input1, input2, bn_mul, bn_add, final_output);
69 ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(input1, input2, bn_mul, bn_add);
70
71 ARM_COMPUTE_RETURN_ERROR_ON_MSG(policy != ConvertPolicy::SATURATE, "Only Saturate Policy is supported");
72
73 using ActFunction = ActivationLayerInfo::ActivationFunction;
74 const ActFunction act_func = act_info.activation();
75 ARM_COMPUTE_RETURN_ERROR_ON_MSG((act_func != ActFunction::BOUNDED_RELU && act_func != ActFunction::RELU &&
76 act_func != ActFunction::LU_BOUNDED_RELU && act_func != ActFunction::IDENTITY),
77 "Only RELU Family activations, or no activation, is supported");
78
79 ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(input1);
80 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input1, 1, DataType::QASYMM8, DataType::QASYMM8_SIGNED,
81 DataType::F16, DataType::F32);
82 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input1, input2);
83
84 if (is_data_type_quantized(input1->data_type()))
85 {
86 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(bn_mul, 1, DataType::F32);
87 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(bn_add, 1, DataType::F32);
88 }
89 else
90 {
91 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input1, bn_mul);
92 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input1, bn_add);
93 }
94
95 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(input1, input2); // No broadcasting
96 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(bn_mul, bn_add);
97 ARM_COMPUTE_RETURN_ERROR_ON_MSG(bn_mul->num_dimensions() != 1, "BatchNorm coefficients should be 1D array");
98 ARM_COMPUTE_RETURN_ERROR_ON_MSG(bn_mul->tensor_shape()[0] != input1->tensor_shape()[0],
99 "First dimensions of inputs and batchNorm coefs should match");
100
101 // Validate in case we have add layer's output (intermediate) initialized
102 if (add_output != nullptr && add_output->total_size() > 0)
103 {
104 ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(add_output);
105 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input1, add_output);
106 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(input1, add_output);
107 }
108 else
109 {
110 // No configured output. Since `add_output` is expected to match `input1`,
111 // there's nothing extra to check in this case.
112 }
113
114 // Validate in case final output has been initialized
115 if (final_output->total_size() > 0)
116 {

Callers 2

configureMethod · 0.70
validateMethod · 0.70

Calls 6

is_data_type_quantizedFunction · 0.85
activationMethod · 0.80
get_isaMethod · 0.80
data_typeMethod · 0.45
num_dimensionsMethod · 0.45
total_sizeMethod · 0.45

Tested by

no test coverage detected