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

Method do_setup

examples/neon_permute.cpp:37–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35 NeonPermuteExample() = default;
36
37 bool do_setup(int, char **) override
38 {
39 // Initialise shapes
40 init_tensor(TensorShape(8U, 4U, 2U), tensor_nchw, DataType::U8, DataLayout::NCHW);
41 init_tensor(TensorShape(2U, 8U, 4U), tensor_nhwc, DataType::U8, DataLayout::NHWC);
42 init_tensor(TensorShape(8U, 4U, 2U), tensor_nchw_result, DataType::U8, DataLayout::NCHW);
43
44 // Create the permutation vector to turn a NCHW tensor to NHWC.
45 // The input tensor is NCHW, which means that the fastest changing coordinate is W=8U.
46 // For permutation vectors the fastest changing coordinate is the one on the left too.
47 // Each element in the permutation vector specifies a mapping from the source tensor to the destination one, thus if we
48 // use 2U in the permutation vector's first element we are telling the function to move the channels to the fastest
49 // changing coordinate in the destination tensor.
50
51 const PermutationVector vector_nchw_to_nhwc(2U, 0U, 1U);
52 permute_nhwc.configure(&tensor_nchw, &tensor_nhwc, vector_nchw_to_nhwc);
53
54 // Allocate and fill tensors
55 tensor_nhwc.allocator()->allocate();
56 tensor_nchw.allocator()->allocate();
57 fill_tensor(tensor_nchw);
58
59 // Demostrate autoconfigure for the output tensor
60 const PermutationVector vector_nhwc_to_nchw(1U, 2U, 0U);
61 permute_nchw.configure(&tensor_nhwc, &tensor_nchw_result, vector_nhwc_to_nchw);
62 tensor_nchw_result.allocator()->allocate();
63
64 return true;
65 }
66 void do_run() override
67 {
68 permute_nhwc.run();

Callers

nothing calls this directly

Calls 5

TensorShapeClass · 0.50
fill_tensorFunction · 0.50
configureMethod · 0.45
allocateMethod · 0.45
allocatorMethod · 0.45

Tested by

no test coverage detected