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

Method do_setup

examples/neon_copy_objects.cpp:39–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37{
38public:
39 bool do_setup(int argc, char **argv) override
40 {
41 ARM_COMPUTE_UNUSED(argc);
42 ARM_COMPUTE_UNUSED(argv);
43
44 /** [Copy objects example] */
45 constexpr unsigned int width = 4;
46 constexpr unsigned int height = 3;
47 constexpr unsigned int batch = 2;
48
49 src_data = new float[width * height * batch];
50 dst_data = new float[width * height * batch];
51
52 // Fill src_data with pseudo(meaningless) values:
53 for (unsigned int b = 0; b < batch; b++)
54 {
55 for (unsigned int h = 0; h < height; h++)
56 {
57 for (unsigned int w = 0; w < width; w++)
58 {
59 src_data[b * (width * height) + h * width + w] = static_cast<float>(100 * b + 10 * h + w);
60 }
61 }
62 }
63
64 // Initialize the tensors dimensions and type:
65 const TensorShape shape(width, height, batch);
66 input.allocator()->init(TensorInfo(shape, 1, DataType::F32));
67 output.allocator()->init(TensorInfo(shape, 1, DataType::F32));
68
69 // Configure softmax:
70 softmax.configure(&input, &output);
71
72 // Allocate the input / output tensors:
73 input.allocator()->allocate();
74 output.allocator()->allocate();
75
76 // Fill the input tensor:
77 // Simplest way: create an iterator to iterate through each element of the input tensor:
78 Window input_window;
79 input_window.use_tensor_dimensions(input.info()->tensor_shape());
80 std::cout << " Dimensions of the input's iterator:\n";
81 std::cout << " X = [start=" << input_window.x().start() << ", end=" << input_window.x().end()
82 << ", step=" << input_window.x().step() << "]\n";
83 std::cout << " Y = [start=" << input_window.y().start() << ", end=" << input_window.y().end()
84 << ", step=" << input_window.y().step() << "]\n";
85 std::cout << " Z = [start=" << input_window.z().start() << ", end=" << input_window.z().end()
86 << ", step=" << input_window.z().step() << "]\n";
87
88 // Create an iterator:
89 Iterator input_it(&input, input_window);
90
91 // Iterate through the elements of src_data and copy them one by one to the input tensor:
92 // This is equivalent to:
93 // for( unsigned int z = 0; z < batch; ++z)
94 // {
95 // for( unsigned int y = 0; y < height; ++y)
96 // {

Callers

nothing calls this directly

Calls 13

stepMethod · 0.80
TensorInfoClass · 0.50
initMethod · 0.45
allocatorMethod · 0.45
configureMethod · 0.45
allocateMethod · 0.45
infoMethod · 0.45
startMethod · 0.45
xMethod · 0.45
endMethod · 0.45
yMethod · 0.45
zMethod · 0.45

Tested by

no test coverage detected