| 50 | GraphVDSRExample &operator=(const GraphVDSRExample &) = delete; |
| 51 | ~GraphVDSRExample() override = default; |
| 52 | bool do_setup(int argc, char **argv) override |
| 53 | { |
| 54 | // Parse arguments |
| 55 | cmd_parser.parse(argc, argv); |
| 56 | cmd_parser.validate(); |
| 57 | |
| 58 | // Consume common parameters |
| 59 | common_params = consume_common_graph_parameters(common_opts); |
| 60 | |
| 61 | // Return when help menu is requested |
| 62 | if (common_params.help) |
| 63 | { |
| 64 | cmd_parser.print_help(argv[0]); |
| 65 | return false; |
| 66 | } |
| 67 | |
| 68 | // Get input image width and height |
| 69 | const unsigned int image_width = model_input_width->value(); |
| 70 | const unsigned int image_height = model_input_height->value(); |
| 71 | |
| 72 | // Print parameter values |
| 73 | std::cout << common_params << std::endl; |
| 74 | std::cout << "Image width: " << image_width << std::endl; |
| 75 | std::cout << "Image height: " << image_height << std::endl; |
| 76 | |
| 77 | // Get trainable parameters data path |
| 78 | const std::string data_path = common_params.data_path; |
| 79 | const std::string model_path = "/cnn_data/vdsr_model/"; |
| 80 | |
| 81 | // Create a preprocessor object |
| 82 | std::unique_ptr<IPreprocessor> preprocessor = std::make_unique<TFPreproccessor>(); |
| 83 | |
| 84 | // Create input descriptor |
| 85 | const TensorShape tensor_shape = |
| 86 | permute_shape(TensorShape(image_width, image_height, 1U, common_params.batches), DataLayout::NCHW, |
| 87 | common_params.data_layout); |
| 88 | TensorDescriptor input_descriptor = |
| 89 | TensorDescriptor(tensor_shape, common_params.data_type).set_layout(common_params.data_layout); |
| 90 | |
| 91 | // Set weights trained layout |
| 92 | const DataLayout weights_layout = DataLayout::NCHW; |
| 93 | |
| 94 | // Note: Quantization info are random and used only for benchmarking purposes |
| 95 | graph << common_params.target << common_params.fast_math_hint |
| 96 | << InputLayer(input_descriptor.set_quantization_info(QuantizationInfo(0.0078125f, 128)), |
| 97 | get_input_accessor(common_params, std::move(preprocessor), false)); |
| 98 | |
| 99 | SubStream left(graph); |
| 100 | SubStream right(graph); |
| 101 | |
| 102 | // Layer 1 |
| 103 | right << ConvolutionLayer(3U, 3U, 64U, get_weights_accessor(data_path, "conv0_w.npy", weights_layout), |
| 104 | get_weights_accessor(data_path, "conv0_b.npy"), PadStrideInfo(1, 1, 1, 1), 1, |
| 105 | QuantizationInfo(0.031778190285f, 156), QuantizationInfo(0.0784313753247f, 128)) |
| 106 | .set_name("conv0") |
| 107 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 108 | .set_name("conv0/Relu"); |
| 109 |
nothing calls this directly
no test coverage detected