ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Driver.cpp File Reference
#include "FMEqualizer.h"
#include "EqualizePatternRead.h"
#include <arser/arser.h>
#include <foder/FileLoader.h>
#include <luci/CircleExporter.h>
#include <luci/CircleFileExpContract.h>
#include <luci/ImporterEx.h>
#include <luci/Service/Validate.h>
#include <iostream>
#include <string>

Go to the source code of this file.

Functions

int entry (int argc, char **argv)
 Dump IR for given arguments.
 

Function Documentation

◆ entry()

int entry ( int  argc,
char **  argv 
)

Dump IR for given arguments.

Call example: $ ./build/compiler/encodump/encodump \ –frontend build/compiler/enco/frontend/caffe/libenco_caffe_frontend.so \ –frontend-arg build/compiler/enco/test/caffe/Convolution_003.prototxt \ –frontend-arg build/compiler/enco/test/caffe/Convolution_003.caffemodel

HDF5 layout is like below

GROUP "/" ㄴGROUP "name" ㄴATTRIBUTE "0" ㄴDATA (0): "input_01:0" ㄴATTRIBUTE "1" ㄴDATA (0): "input_02:0" ㄴGROUP "value" ㄴDATASET "0" ㄴDATA ... ㄴDATASET "1" ㄴDATA ...

Definition at line 32 of file Driver.cpp.

33{
34 arser::Arser arser("fm-apply applies channel-wise scale/shift for FM equalization");
35
37
38 arser.add_argument("--input").required().help("Input circle model");
39
40 arser.add_argument("--fme_patterns")
41 .required()
42 .help("Json file that describes feture map equalization info");
43
44 arser.add_argument("--output").required().help("Output circle model");
45
46 try
47 {
48 arser.parse(argc, argv);
49 }
50 catch (const std::runtime_error &err)
51 {
52 std::cerr << err.what() << std::endl;
53 std::cout << arser;
54 return EXIT_FAILURE;
55 }
56
57 if (arser.get<bool>("--verbose"))
58 {
59 // The third parameter of setenv means REPLACE.
60 // If REPLACE is zero, it does not overwrite an existing value.
61 setenv("LUCI_LOG", "100", 0);
62 }
63
64 const std::string input_path = arser.get<std::string>("--input");
65 const std::string fme_patterns_path = arser.get<std::string>("--fme_patterns");
66 const std::string output_path = arser.get<std::string>("--output");
67
68 luci::ImporterEx importerex;
69 auto module = importerex.importVerifyModule(input_path);
70 assert(module != nullptr); // FIX_ME_UNLESS
71
72 auto patterns = fme_apply::read(fme_patterns_path);
73
74 for (size_t idx = 0; idx < module->size(); ++idx)
75 {
76 auto graph = module->graph(idx);
77
78 FMEqualizer equalizer;
79 equalizer.equalize(graph, patterns);
80
81 if (!luci::validate(graph))
82 {
83 std::cerr << "ERROR: Equalized graph is invalid" << std::endl;
84 return EXIT_FAILURE;
85 }
86 }
87
88 // Export to output Circle file
89 luci::CircleExporter exporter;
90
91 luci::CircleFileExpContract contract(module.get(), output_path);
92
93 if (!exporter.invoke(&contract))
94 {
95 std::cerr << "ERROR: Failed to export '" << output_path << "'" << std::endl;
96 return EXIT_FAILURE;
97 }
98
99 return EXIT_SUCCESS;
100}
static void add_verbose(Arser &arser)
Definition arser.h:765
void equalize(loco::Graph *g, std::vector< EqualizePattern > &p)
bool invoke(Contract *) const
Definition arser.h:39
std::vector< EqualizePattern > read(const std::string &filename)
bool validate(luci::PartitionTable &partition)

References arser::Helper::add_verbose(), fme_apply::FMEqualizer::equalize(), luci::CircleExporter::invoke(), fme_apply::read(), and luci::validate().