From 6800117df3be825f0ec5c6cc71c4377322f51b99 Mon Sep 17 00:00:00 2001 From: Sang-Hoon Park Date: Fri, 6 Mar 2020 16:32:01 +0000 Subject: COMPMID-3221: (DATA_UPDATE) add graph example for EDSR Change-Id: Id74190e2af444da8dab4813fd65016104f3882a9 Signed-off-by: Sang-Hoon Park Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/2862 Tested-by: Arm Jenkins Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins --- examples/graph_edsr.cpp | 108 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 examples/graph_edsr.cpp (limited to 'examples/graph_edsr.cpp') diff --git a/examples/graph_edsr.cpp b/examples/graph_edsr.cpp new file mode 100644 index 0000000000..405c355bf6 --- /dev/null +++ b/examples/graph_edsr.cpp @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2020 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "arm_compute/graph/Utils.h" + +#include "support/ToolchainSupport.h" +#include "utils/CommonGraphOptions.h" +#include "utils/Utils.h" + +#include "graph_edsr.h" + +using namespace arm_compute::graph; +using namespace arm_compute::utils; + +class GraphEdsrExample : public Example +{ +public: + GraphEdsrExample() + : cmd_parser(), common_opts(cmd_parser), common_params() + { + expected_output_filename = cmd_parser.add_option>("expected-output-filename", ""); + expected_output_filename->set_help("Name of npy file containing the expected output to validate the graph output."); + } + + GraphEdsrExample(const GraphEdsrExample &) = delete; + GraphEdsrExample &operator=(const GraphEdsrExample &) = delete; + GraphEdsrExample(GraphEdsrExample &&) = default; + GraphEdsrExample &operator=(GraphEdsrExample &&) = default; + ~GraphEdsrExample() override = default; + + bool do_setup(int argc, char **argv) override + { + // Parse arguments + cmd_parser.parse(argc, argv); + cmd_parser.validate(); + + // Consume common parameters + common_params = consume_common_graph_parameters(common_opts); + + // Return when help menu is requested + if(common_params.help) + { + cmd_parser.print_help(argv[0]); + return false; + } + + // Print parameter values + std::cout << common_params << std::endl; + + model.setup(common_params, *expected_output_filename); + + GraphConfig config; + config.num_threads = common_params.threads; + config.use_tuner = common_params.enable_tuner; + config.tuner_mode = common_params.tuner_mode; + config.tuner_file = common_params.tuner_file; + + context.set_config(config); + + auto pass_manager = create_default_pass_manager(common_params.target, config); + manager.finalize_graph(model.graph(), context, pass_manager, common_params.target); + + return true; + } + + void do_run() override + { + manager.execute_graph(model.graph()); + } + +private: + CommandLineParser cmd_parser; + CommonGraphOptions common_opts; + CommonGraphParams common_params; + + GraphContext context{}; + GraphManager manager{}; + + SimpleOption *expected_output_filename{ nullptr }; + + GraphEdsr model{}; +}; + +int main(int argc, char **argv) +{ + return run_example(argc, argv); +} -- cgit v1.2.1