ONE - On-device Neural Engine
Loading...
Searching...
No Matches
tfkit::ConvertCommand Struct Referencefinal

#include <ConvertCommand.hpp>

Collaboration diagram for tfkit::ConvertCommand:

Public Member Functions

int run (int argc, const char *const *argv) const override
 
- Public Member Functions inherited from cli::Command
virtual ~Command ()=default
 

Detailed Description

Definition at line 25 of file ConvertCommand.hpp.

Member Function Documentation

◆ run()

int tfkit::ConvertCommand::run ( int  argc,
const char *const *  argv 
) const
overridevirtual

Implements cli::Command.

Definition at line 99 of file ConvertCommand.cpp.

100{
101 tensorflow::GraphDef graph_def;
102
103 // NOTE The current implementation accepts only command-line for the following form:
104 //
105 // tfkit convert --input-format (pb or pbtxt) --output-format json ...
106 //
107 // TODO Support more options
108 assert(argc >= 4);
109 assert(std::string(argv[0]) == "--input-format");
110 const std::string input_format{argv[1]};
111 assert(std::string(argv[2]) == "--output-format");
112 const std::string output_format{argv[3]};
113
114 std::map<std::string, std::unique_ptr<Importer>> importers;
115
116 importers["pb"] = std::make_unique<ImporterImpl<DataFormat::PBBIN>>();
117 importers["pbtxt"] = std::make_unique<ImporterImpl<DataFormat::PBTXT>>();
118
119 std::map<std::string, std::unique_ptr<Exporter>> exporters;
120
121 exporters["json"] = std::make_unique<ExporterImpl<DataFormat::JSON>>();
122
123 auto importer = importers.at(input_format).get();
124 auto exporter = exporters.at(output_format).get();
125
126 CmdArguments cmdargs(argc - 4, argv + 4);
127
128 auto ioconfig = make_ioconfig(cmdargs);
129
130 if (!importer->run(ioconfig->in(), graph_def))
131 {
132 std::cerr << "ERROR: Failed to import" << std::endl;
133 return 255;
134 }
135
136 if (!exporter->run(graph_def, ioconfig->out()))
137 {
138 std::cerr << "ERROR: Failed to export" << std::endl;
139 return 255;
140 }
141
142 return 0;
143}
std::unique_ptr< IOConfiguration > make_ioconfig(const CmdArguments &cmdargs)
Definition Support.cpp:111

References tfkit::make_ioconfig().

Referenced by package.infer.session::inference().


The documentation for this struct was generated from the following files: