ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Driver.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
18
19#include <arser/arser.h>
20#include <vconone/vconone.h>
21
22#include <stdlib.h>
23
24using namespace minmax_embedder;
25
26void print_version(void)
27{
28 std::cout << "minmax-embedder version " << vconone::get_string() << std::endl;
29 std::cout << vconone::get_copyright() << std::endl;
30}
31
32int entry(const int argc, char **argv)
33{
34 arser::Arser arser("minmax-embedder embeds given minmax into circle");
36 // named args
37 arser.add_argument("--min_percentile")
38 .type(arser::DataType::FLOAT)
39 .default_value(1.f)
40 .help("Set min percentile (default: 1)");
41 arser.add_argument("--max_percentile")
42 .type(arser::DataType::FLOAT)
43 .default_value(99.f)
44 .help("Set max percentile (default: 99)");
45 arser.add_argument("-o").default_value("out.circle").help("Path to output circle model");
46 // positional args: minmax(h5), input(circle)
47 arser.add_argument("circle").help("Path to input circle model");
48 arser.add_argument("minmax").help("Path to minmax data in hdf5");
49 try
50 {
51 arser.parse(argc, argv);
52 }
53 catch (const std::runtime_error &err)
54 {
55 std::cout << err.what() << std::endl;
56 std::cout << arser;
57 return EXIT_FAILURE;
58 }
59
60 std::string minmax_path = arser.get<std::string>("minmax");
61 std::string circle_path = arser.get<std::string>("circle");
62 std::string output_path = arser.get<std::string>("-o");
63 float min_percentile = arser.get<float>("--min_percentile");
64 float max_percentile = arser.get<float>("--max_percentile");
65
66 EmbedderOptions opt{min_percentile, max_percentile};
67 try
68 {
69 Embedder().embed(output_path, circle_path, minmax_path, opt);
70 }
71 catch (const std::runtime_error &err)
72 {
73 std::cout << err.what() << std::endl;
74 return EXIT_FAILURE;
75 }
76
77 return EXIT_SUCCESS;
78}
static void add_version(Arser &arser, const std::function< void(void)> &func)
Definition arser.h:755
void embed(const std::string &output_path, const std::string &input_path, const std::string &minmax_path, const EmbedderOptions &)
Definition Embedder.cpp:77
void print_version(void)
Definition Driver.cpp:26
int entry(const int argc, char **argv)
Dump IR for given arguments.
Definition Driver.cpp:32
Definition arser.h:39
std::string get_copyright(void)
get_copyright will return copyright string
Definition version.cpp:54
std::string get_string(void)
get_string will return string of major.minor.patch (without build)
Definition version.cpp:44