ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Driver.cpp File Reference
#include "EqualizePatternFinder.h"
#include "EqualizePatternWrite.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("fme-detect detects patterns to apply FM equalization in "
35 "the circle model");
36
38
39 arser.add_argument("--input").required().help("Input circle model");
40
41 arser.add_argument("--output")
42 .required()
43 .help("Output json file that describes equalization patterns");
44
45 arser.add_argument("--allow_dup_op")
46 .nargs(0)
47 .default_value(false)
48 .help("Allow to create duplicate operations when a feature map matches "
49 "with multiple equalization patterns. This can increase the size of "
50 "the model. Default is false.");
51
52 try
53 {
54 arser.parse(argc, argv);
55 }
56 catch (const std::runtime_error &err)
57 {
58 std::cerr << err.what() << std::endl;
59 std::cout << arser;
60 return EXIT_FAILURE;
61 }
62
63 if (arser.get<bool>("--verbose"))
64 {
65 // The third parameter of setenv means REPLACE.
66 // If REPLACE is zero, it does not overwrite an existing value.
67 setenv("LUCI_LOG", "100", 0);
68 }
69
70 const std::string input_path = arser.get<std::string>("--input");
71 const std::string output_path = arser.get<std::string>("--output");
72 const bool allow_dup_op = arser.get<bool>("--allow_dup_op");
73
75 {
76 ctx._allow_dup_op = allow_dup_op;
77 }
78 EqualizePatternFinder finder(ctx);
79
80 luci::ImporterEx importerex;
81 auto module = importerex.importVerifyModule(input_path);
82 assert(module != nullptr); // FIX_ME_UNLESS
83
84 std::vector<EqualizePattern> patterns;
85 for (size_t idx = 0; idx < module->size(); ++idx)
86 {
87 auto graph = module->graph(idx);
88
89 auto matched = finder.find(graph);
90 patterns.insert(patterns.end(), matched.begin(), matched.end());
91 }
92
93 fme_detect::write(patterns, output_path);
94
95 return EXIT_SUCCESS;
96}
static void add_verbose(Arser &arser)
Definition arser.h:765
Definition arser.h:39
void write(const std::vector< EqualizePattern > &patterns, const std::string &filename)

References fme_detect::EqualizePatternFinder::Context::_allow_dup_op, arser::Helper::add_verbose(), fme_detect::EqualizePatternFinder::find(), and fme_detect::write().