aboutsummaryrefslogtreecommitdiff
path: root/examples/graph_edsr.cpp
diff options
context:
space:
mode:
authorSang-Hoon Park <sang-hoon.park@arm.com>2020-03-06 16:32:01 +0000
committerGeorgios Pinitas <georgios.pinitas@arm.com>2020-03-11 18:34:03 +0000
commit6800117df3be825f0ec5c6cc71c4377322f51b99 (patch)
tree0e579a271f2676dc2d6aa947df29a5cf0ab8bd1c /examples/graph_edsr.cpp
parent9204646e091ffc25eda61768537357916a4f7df4 (diff)
downloadComputeLibrary-6800117df3be825f0ec5c6cc71c4377322f51b99.tar.gz
COMPMID-3221: (DATA_UPDATE) add graph example for EDSR
Change-Id: Id74190e2af444da8dab4813fd65016104f3882a9 Signed-off-by: Sang-Hoon Park <sang-hoon.park@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/2862 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'examples/graph_edsr.cpp')
-rw-r--r--examples/graph_edsr.cpp108
1 files changed, 108 insertions, 0 deletions
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<SimpleOption<std::string>>("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<std::string> *expected_output_filename{ nullptr };
+
+ GraphEdsr model{};
+};
+
+int main(int argc, char **argv)
+{
+ return run_example<GraphEdsrExample>(argc, argv);
+}