| 37 | { |
| 38 | public: |
| 39 | bool do_setup(int argc, char **argv) override |
| 40 | { |
| 41 | ARM_COMPUTE_UNUSED(argc); |
| 42 | ARM_COMPUTE_UNUSED(argv); |
| 43 | |
| 44 | // Create memory manager components |
| 45 | // We need 2 memory managers: 1 for handling the tensors within the functions (mm_layers) and 1 for handling the input and output tensors of the functions (mm_transitions)) |
| 46 | auto lifetime_mgr0 = std::make_shared<BlobLifetimeManager>(); // Create lifetime manager |
| 47 | auto lifetime_mgr1 = std::make_shared<BlobLifetimeManager>(); // Create lifetime manager |
| 48 | auto pool_mgr0 = std::make_shared<PoolManager>(); // Create pool manager |
| 49 | auto pool_mgr1 = std::make_shared<PoolManager>(); // Create pool manager |
| 50 | auto mm_layers = std::make_shared<MemoryManagerOnDemand>(lifetime_mgr0, pool_mgr0); // Create the memory manager |
| 51 | auto mm_transitions = |
| 52 | std::make_shared<MemoryManagerOnDemand>(lifetime_mgr1, pool_mgr1); // Create the memory manager |
| 53 | |
| 54 | // The weights and biases tensors should be initialized with the values inferred with the training |
| 55 | |
| 56 | // Set memory manager where allowed to manage internal memory requirements |
| 57 | conv0 = std::make_unique<NEConvolutionLayer>(mm_layers); |
| 58 | conv1 = std::make_unique<NEConvolutionLayer>(mm_layers); |
| 59 | fc0 = std::make_unique<NEFullyConnectedLayer>(mm_layers); |
| 60 | softmax = std::make_unique<NESoftmaxLayer>(mm_layers); |
| 61 | |
| 62 | /* [Initialize tensors] */ |
| 63 | |
| 64 | // Initialize src tensor |
| 65 | constexpr unsigned int width_src_image = 32; |
| 66 | constexpr unsigned int height_src_image = 32; |
| 67 | constexpr unsigned int ifm_src_img = 1; |
| 68 | |
| 69 | const TensorShape src_shape(width_src_image, height_src_image, ifm_src_img); |
| 70 | src.allocator()->init(TensorInfo(src_shape, 1, DataType::F32)); |
| 71 | |
| 72 | // Initialize tensors of conv0 |
| 73 | constexpr unsigned int kernel_x_conv0 = 5; |
| 74 | constexpr unsigned int kernel_y_conv0 = 5; |
| 75 | constexpr unsigned int ofm_conv0 = 8; |
| 76 | |
| 77 | const TensorShape weights_shape_conv0(kernel_x_conv0, kernel_y_conv0, src_shape.z(), ofm_conv0); |
| 78 | const TensorShape biases_shape_conv0(weights_shape_conv0[3]); |
| 79 | const TensorShape out_shape_conv0(src_shape.x(), src_shape.y(), weights_shape_conv0[3]); |
| 80 | |
| 81 | weights0.allocator()->init(TensorInfo(weights_shape_conv0, 1, DataType::F32)); |
| 82 | biases0.allocator()->init(TensorInfo(biases_shape_conv0, 1, DataType::F32)); |
| 83 | out_conv0.allocator()->init(TensorInfo(out_shape_conv0, 1, DataType::F32)); |
| 84 | |
| 85 | // Initialize tensor of act0 |
| 86 | out_act0.allocator()->init(TensorInfo(out_shape_conv0, 1, DataType::F32)); |
| 87 | |
| 88 | // Initialize tensor of pool0 |
| 89 | TensorShape out_shape_pool0 = out_shape_conv0; |
| 90 | out_shape_pool0.set(0, out_shape_pool0.x() / 2); |
| 91 | out_shape_pool0.set(1, out_shape_pool0.y() / 2); |
| 92 | out_pool0.allocator()->init(TensorInfo(out_shape_pool0, 1, DataType::F32)); |
| 93 | |
| 94 | // Initialize tensors of conv1 |
| 95 | constexpr unsigned int kernel_x_conv1 = 3; |
| 96 | constexpr unsigned int kernel_y_conv1 = 3; |
nothing calls this directly
no test coverage detected