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

Function TEST_CASE

tests/validation/NEON/Im2Col.cpp:276–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274
275TEST_SUITE(SpecialCases)
276TEST_CASE(PaddedChannelNHWC, framework::DatasetMode::PRECOMMIT)
277{
278 // Const data
279 const TensorShape src_shape = TensorShape(7U, 27U, 13U);
280 const DataType data_type = DataType::F32;
281 const DataLayout data_layout = DataLayout::NHWC;
282 const bool has_bias = false;
283 const unsigned int num_groups = 1;
284 const Size2D spatial_kernel(3, 3);
285 const QuantizationInfo qinfo{};
286 const PadStrideInfo conv_info(1U, 1U, 0U, 0U);
287
288 // Calculate destination shape
289 TensorInfo src_info(src_shape, 1, data_type);
290 src_info.set_data_layout(data_layout);
291 const TensorShape dst_shape =
292 compute_im2col_conv_shape(&src_info, spatial_kernel, conv_info, has_bias, Size2D(1U, 1U), false, num_groups);
293
294 // Compute target
295 Tensor src_target = create_tensor<Tensor>(src_shape, data_type, 1, qinfo, data_layout);
296 Tensor dst_target = create_tensor<Tensor>(dst_shape, data_type, 1, qinfo);
297
298 // Configure target function
299 CpuIm2Col im2col_func;
300 im2col_func.configure(src_target.info(), dst_target.info(), spatial_kernel, conv_info, has_bias);
301
302 // Extend padding
303 src_target.info()->extend_padding(PaddingSize(3, 5, 9, 1));
304 dst_target.info()->extend_padding(PaddingSize(8, 1, 1, 3));
305
306 // Validate and allocate tensors
307 ARM_COMPUTE_EXPECT(src_target.info()->is_resizable(), framework::LogLevel::ERRORS);
308 ARM_COMPUTE_EXPECT(dst_target.info()->is_resizable(), framework::LogLevel::ERRORS);
309
310 src_target.allocator()->allocate();
311 dst_target.allocator()->allocate();
312
313 ARM_COMPUTE_EXPECT(!src_target.info()->is_resizable(), framework::LogLevel::ERRORS);
314 ARM_COMPUTE_EXPECT(!dst_target.info()->is_resizable(), framework::LogLevel::ERRORS);
315
316 // Fill target source
317 library->fill_tensor_uniform(Accessor(src_target), 0);
318
319 ITensorPack pack = {{TensorType::ACL_SRC, &src_target}, {TensorType::ACL_DST, &dst_target}};
320 // Run target function
321 im2col_func.run(pack);
322
323 // Calculate Reference
324 SimpleTensor<float> src_ref{src_shape, data_type, 1, qinfo, data_layout};
325 SimpleTensor<float> dst_ref{dst_shape, data_type, 1, qinfo, DataLayout::NCHW};
326
327 // Fill reference source
328 library->fill_tensor_uniform(src_ref, 0);
329
330#ifndef DOXYGEN_SKIP_THIS
331 // Run reference function
332 reference::im2col(src_ref, dst_ref, spatial_kernel, conv_info, has_bias, num_groups, 0);
333#endif // DOXYGEN_SKIP_THIS

Callers

nothing calls this directly

Calls 14

Size2DClass · 0.85
AccessorClass · 0.85
im2colFunction · 0.85
fill_tensor_uniformMethod · 0.80
TensorShapeClass · 0.50
validateFunction · 0.50
configureMethod · 0.45
infoMethod · 0.45
extend_paddingMethod · 0.45
is_resizableMethod · 0.45
allocateMethod · 0.45

Tested by

no test coverage detected