ONE - On-device Neural Engine
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 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
17#include <iostream>
18#include <vector>
19
20#include "support/CommandLine.h"
21#include "pass/PassException.h"
22#include "Driver.h"
23
24using namespace nnc;
25
26/*
27 * Prints the explanatory string of an exception. If the exception is nested, recurses to print
28 * the explanatory string of the exception it holds.
29 */
30static void printException(const std::exception &e, int indent = 0)
31{
32 std::cerr << std::string(indent, ' ') << e.what() << std::endl;
33 try
34 {
35 std::rethrow_if_nested(e);
36 }
37 catch (const std::exception &e)
38 {
39 printException(e, indent + 2);
40 }
41}
42
43int main(int argc, const char *argv[])
44{
45 int exit_code = EXIT_FAILURE;
46
47 try
48 {
49 // Parse command line
51
52 //
53 // run compiler pipeline:
54 //
55 // for_each(all_passes):
56 // run pass
57 //
58 Driver driver;
59 driver.runDriver();
60
61 // errors didn't happen
62 exit_code = EXIT_SUCCESS;
63 }
64 catch (const DriverException &e)
65 {
66 printException(e);
67 std::cerr << "use --help for more information" << std::endl;
68 }
69 catch (const PassException &e)
70 {
71 printException(e);
72 }
73
74 return exit_code;
75}
int main(void)
exceptions description class for compiler driver
Definition Driver.h:32
Compiler Driver manages the whole pipeline compilation process.
Definition Driver.h:48
objects of this class are to be thrown from Passes if errors are occurred
static CommandLine * getParser()
singleton method
void parseCommandLine(int argc, const char **argv, bool check_nonoptional=true)
parse command line option