ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Driver.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 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 "PModelsRunner.h"
18
19#include <luci/Log.h>
20
21#include <iostream>
22
23int entry(int argc, char **argv)
24{
25 LOGGER(l);
26
27 if (argc != 5)
28 {
29 std::cerr
30 << "Usage: " << argv[0]
31 << " <path/to/partition/config> <num_inputs> <path/to/input/prefix> <path/to/output/file>\n";
32 return EXIT_FAILURE;
33 }
34 // NOTE: about input/output data file name
35 // - I/O file name format is like filename.ext0, filename.ext1, ...
36 // NOTE: about output shape
37 // - file name with filename.ext0.shape, filename.ext1.shape, ...
38 // having one line text content of CSV format(like H,W or N,C,H,W)
39
40 const char *config_filename = argv[1];
41 const int32_t num_inputs = atoi(argv[2]);
42 const char *input_prefix = argv[3];
43 const char *output_file = argv[4];
44
46
47 INFO(l) << "Read config file: " << config_filename << std::endl;
48 if (not pmrunner.load_config(config_filename))
49 return EXIT_FAILURE;
50
51 INFO(l) << "Read input file: " << input_prefix << ", #inputs: " << num_inputs << std::endl;
52 pmrunner.load_inputs(input_prefix, num_inputs);
53
54 INFO(l) << "Run all partitioned models..." << std::endl;
55 if (!pmrunner.run())
56 return EXIT_FAILURE;
57
58 INFO(l) << "Save output file: " << output_file << std::endl;
59 pmrunner.save_outputs(output_file);
60
61 return EXIT_SUCCESS;
62}
#define LOGGER(name)
Definition Log.h:65
#define INFO(name)
Definition Log.h:68
PModelsRunner runs partitioned models from input data file and stores output data to a file.
void save_outputs(const std::string &output_file)
void load_inputs(const std::string &input_prefix, int32_t num_inputs)
bool load_config(const std::string &filename)
int entry(int argc, char **argv)
Definition Driver.cpp:29