ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Driver.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 <arser/arser.h>
18#include <foder/FileLoader.h>
19#include <tfldump/Dump.h>
20
21#include <iostream>
22
23int entry(int argc, char **argv)
24{
26 arser.add_argument("tflite").help("TFLite file to dump");
27
28 try
29 {
30 arser.parse(argc, argv);
31 }
32 catch (const std::runtime_error &err)
33 {
34 std::cout << err.what() << '\n';
35 std::cout << arser;
36 return 255;
37 }
38
39 std::string tflite_path = arser.get<std::string>("tflite");
40 // Load TF lite model from a tflite file
41 foder::FileLoader fileLoader{tflite_path};
42 std::vector<char> modelData = fileLoader.load();
43 const tflite::Model *tflmodel = tflite::GetModel(modelData.data());
44 if (tflmodel == nullptr)
45 {
46 std::cerr << "ERROR: Failed to load tflite '" << tflite_path << "'" << std::endl;
47 return 255;
48 }
49
50 std::cout << "Dump: " << tflite_path << std::endl << std::endl;
51
52 tfldump::ModelEx modelex;
53 modelex.model = tflmodel;
54 modelex.rawdata = &modelData;
55
56 std::cout << modelex << std::endl;
57
58 return 0;
59}
DataBuffer load(void) const
Definition FileLoader.h:39
int entry(int argc, char **argv)
Definition Driver.cpp:29
Definition arser.h:39
const std::vector< char > * rawdata
Definition Dump.h:30
const tflite::Model * model
Definition Dump.h:29