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

Method validate

src/cpu/operators/CpuDirectConv2d.cpp:142–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142Status CpuDirectConv2d::validate(const ITensorInfo *src,
143 const ITensorInfo *weights,
144 const ITensorInfo *bias,
145 const ITensorInfo *dst,
146 const PadStrideInfo &conv_info,
147 const ActivationLayerInfo &act_info)
148{
149 ARM_COMPUTE_TRACE_EVENT(ARM_COMPUTE_PROF_CAT_CPU, ARM_COMPUTE_PROF_LVL_CPU, "CpuDirectConv2d::validate");
150 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src, weights, dst);
151 TensorInfo acc_to_use{};
152 if (src->data_layout() == DataLayout::NCHW)
153 {
154 TensorShape permuted_input_shape = src->tensor_shape();
155 TensorShape permuted_weights_shape = weights->tensor_shape();
156 TensorShape permuted_output_shape = dst->tensor_shape();
157 permute(permuted_input_shape, PermutationVector(2U, 0U, 1U));
158 permute(permuted_weights_shape, PermutationVector(2U, 0U, 1U));
159 permute(permuted_output_shape, PermutationVector(2U, 0U, 1U));
160
161 const TensorInfo permuted_input = TensorInfo(src->clone()
162 ->set_is_resizable(true)
163 .reset_padding()
164 .set_tensor_shape(permuted_input_shape)
165 .set_data_layout(DataLayout::NHWC));
166 const TensorInfo permuted_weights = TensorInfo(weights->clone()
167 ->set_is_resizable(true)
168 .reset_padding()
169 .set_tensor_shape(permuted_weights_shape)
170 .set_data_layout(DataLayout::NHWC));
171 const TensorInfo permuted_output = TensorInfo(dst->clone()
172 ->set_is_resizable(true)
173 .reset_padding()
174 .set_tensor_shape(permuted_output_shape)
175 .set_data_layout(DataLayout::NHWC));
176
177 ARM_COMPUTE_RETURN_ON_ERROR(CpuPermute::validate(src, &permuted_input, PermutationVector(2U, 0U, 1U)));
178 ARM_COMPUTE_RETURN_ON_ERROR(CpuPermute::validate(weights, &permuted_weights, PermutationVector(2U, 0U, 1U)));
179 ARM_COMPUTE_RETURN_ON_ERROR(CpuPermute::validate(&permuted_output, dst, PermutationVector(1U, 2U, 0U)));
180
181 // output might not be initialized since it can be an intermediate tensor of another layer
182 const DataType data_type = src->data_type();
183 const TensorInfo accumulator(
184 permuted_output.clone()->set_is_resizable(true).reset_padding().set_data_type(data_type));
185 acc_to_use = accumulator;
186 ARM_COMPUTE_RETURN_ON_ERROR(
187 kernels::CpuDirectConv2dKernel::validate(&permuted_input, &permuted_weights, &accumulator, conv_info));
188 }
189 else
190 {
191 // output might not be initialized since it can be an intermediate tensor of another layer
192 const DataType data_type = src->data_type();
193 const TensorInfo accumulator(dst->clone()->set_is_resizable(true).reset_padding().set_data_type(data_type));
194 acc_to_use = accumulator;
195 // Validate Convolution kernel
196 ARM_COMPUTE_RETURN_ON_ERROR(kernels::CpuDirectConv2dKernel::validate(src, weights, &accumulator, conv_info));
197 }
198
199 if (bias != nullptr)

Callers

nothing calls this directly

Calls 9

enabledMethod · 0.80
permuteFunction · 0.50
TensorInfoClass · 0.50
validateFunction · 0.50
data_layoutMethod · 0.45
cloneMethod · 0.45
data_typeMethod · 0.45
dimensionMethod · 0.45
num_dimensionsMethod · 0.45

Tested by

no test coverage detected