ATLAS Offline Software
Loading...
Searching...
No Matches
extract-onnx-metadata.cxx File Reference
#include <ONNXUtils/ONNXWrapper.h>
#include <iostream>
Include dependency graph for extract-onnx-metadata.cxx:

Go to the source code of this file.

Functions

int main (int narg, char *argv[])

Function Documentation

◆ main()

int main ( int narg,
char * argv[] )

Definition at line 4 of file extract-onnx-metadata.cxx.

4 {
5 std::cout<<narg;
6 if (narg != 3 && narg != 2) {
7 std::cout << "usage: " << argv[0] << " <onnx_file> [key]" << std::endl;
8 return 1;
9 }
10
11 ONNXWrapper* model = new ONNXWrapper(argv[1]);
12
13
14 // no key provided, print out all
15 if (narg == 2) { // should be extend to more that 2 inputs and outputs
16 // print input/output shape and names
17 for ( const auto &p : model->GetModelInputs() )
18 {
19 std::string separator;
20 std::cout << "Input: " << p.first << ", shape: (";
21 for (auto x : p.second) {
22 std::cout << separator << x;
23 separator = ",";
24 }
25 std::cout << ")" << std::endl;
26 }
27 for ( const auto &p : model->GetModelOutputs() )
28 {
29 std::string separator;
30 std::cout << "Outputs: " << p.first << ", shape: (";
31 for (auto x : p.second) {
32 std::cout << separator << x;
33 separator = ",";
34 }
35 std::cout << ")" << std::endl;
36 }
37 for ( const auto &p : model->GetMETAData() )
38 {
39 std::cout <<"META data: "<< p.first << '\t' << p.second.at(0) << std::endl;
40 }
41 // print meta data
42 delete model;
43 return 2;
44 }
45
46 // key provided, print out key
47 std::cout << model->GetMETADataByKey(argv[2]) << std::endl;
48 delete model;
49
50 return 0;
51}
#define x