| 34 | { |
| 35 | public: |
| 36 | bool do_setup(int argc, char **argv) override |
| 37 | { |
| 38 | TensorShape input_shape{32, 256, 256}; |
| 39 | TensorShape weights_shape{32, 4, 4, 4}; |
| 40 | TensorShape output_shape{4, 127, 127}; |
| 41 | TensorInfo input_info{input_shape, 1, DataType::F16, DataLayout::NHWC}; |
| 42 | TensorInfo weights_info{weights_shape, 1, DataType::F16, DataLayout::NHWC}; |
| 43 | TensorInfo output_info{output_shape, 1, DataType::F16, DataLayout::NHWC}; |
| 44 | PadStrideInfo ps_info{1, 1, 0, 0, DimensionRoundingType::FLOOR}; |
| 45 | |
| 46 | if (argc == 11) |
| 47 | { |
| 48 | try |
| 49 | { |
| 50 | const size_t input_x = std::stoul(argv[1]); |
| 51 | const size_t input_y = std::stoul(argv[2]); |
| 52 | const size_t input_z = std::stoul(argv[3]); |
| 53 | const size_t kernel_size_x = std::stoul(argv[4]); |
| 54 | const size_t kernel_size_y = std::stoul(argv[5]); |
| 55 | const size_t output_channels = std::stoul(argv[6]); |
| 56 | const uint32_t stride_x = static_cast<uint32_t>(std::stoul(argv[7])); |
| 57 | const uint32_t stride_y = static_cast<uint32_t>(std::stoul(argv[8])); |
| 58 | const uint32_t pad_x = static_cast<uint32_t>(std::stoul(argv[9])); |
| 59 | const uint32_t pad_y = static_cast<uint32_t>(std::stoul(argv[10])); |
| 60 | |
| 61 | input_shape = TensorShape{input_z, input_x, input_y}; |
| 62 | input_info = TensorInfo{input_shape, 1, DataType::F16, DataLayout::NHWC}; |
| 63 | weights_shape = TensorShape{input_z, kernel_size_x, kernel_size_y, output_channels}; |
| 64 | weights_info = TensorInfo{weights_shape, 1, DataType::F16, DataLayout::NHWC}; |
| 65 | ps_info = PadStrideInfo{stride_x, stride_y, pad_x, pad_y, DimensionRoundingType::FLOOR}; |
| 66 | output_shape = arm_compute::misc::shape_calculator::compute_deep_convolution_shape( |
| 67 | input_info, weights_info, ps_info); |
| 68 | output_info = TensorInfo{output_shape, 1, DataType::F16, DataLayout::NHWC}; |
| 69 | } |
| 70 | catch (const std::exception &e) |
| 71 | { |
| 72 | ARM_COMPUTE_ERROR(e.what()); |
| 73 | return false; |
| 74 | } |
| 75 | } |
| 76 | else if (argc != 1) |
| 77 | { |
| 78 | ARM_COMPUTE_ERROR( |
| 79 | "Invalid number of arguments. Usage:\n" |
| 80 | "<input_width> <input_height> <input_channels> <kernel_size_x> <kernel_size_y> <output_channels> " |
| 81 | "<stride_x> <stride_y> <pad_x> <pad_y>\n"); |
| 82 | return false; |
| 83 | } |
| 84 | |
| 85 | input.allocator()->init(input_info); |
| 86 | weights.allocator()->init(weights_info); |
| 87 | output.allocator()->init(output_info); |
| 88 | |
| 89 | auto status = NEConvolutionLayer::validate(input.info(), weights.info(), nullptr, output.info(), ps_info); |
| 90 | if (status.error_code() != ErrorCode::OK) |
| 91 | { |
| 92 | ARM_COMPUTE_ERROR(status.error_description().c_str()); |
| 93 | return false; |
nothing calls this directly
no test coverage detected