MCPcopy Create free account
hub / github.com/ai-techsystems/deepC / writeUsageFunction

Method writeUsageFunction

src/codegen/cppCodeGen.cpp:130–159  ·  view source on GitHub ↗

Use Model: _bundleDir : dirname("generated exe, i.e. a.out"); parameter file(s) : in _bundleDir input file(s) : with a path relative to current dir. output file(s) : in current dir

Source from the content-addressed store, hash-verified

128// input file(s) : with a path relative to current dir.
129// output file(s) : in current dir
130std::string dnnc::cppCodeGen::writeUsageFunction() {
131
132 std::string code = "void usage(char** args) {\n";
133 code += _tab + "std::cout << \"\\nUsage: \" << args[0] <<\n";
134 std::vector<dnnc::ioNode *> modelIns = modelInputs();
135 for (ioNode *term : modelIns)
136 if (paramFile(term->name()).empty())
137 code += _tab + _tab + "\" <datafile for input \\\"" + term->name() +
138 "\\\">\" <<";
139 code += "\n" + _tab + _tab + "\"\\n\\n\";\n\n";
140
141 code += _tab + "std::cout << \"This model has \" << " +
142 std::to_string(modelIns.size()) + " << \" input(s):\\n\";\n";
143 size_t inIndex = 1;
144 for (ioNode *term : modelIns)
145 if (paramFile(term->name()).empty())
146 code += _tab + "std::cout << \"\\t " + std::to_string(inIndex++) +
147 ". \\\"" + term->name() + "\\\" (shape " +
148 shapeStr(term->shape()) + "):\\n\";\n\n";
149
150 code += _tab + "std::cout << \"Output(s) will be written in file(s):\\n\";\n";
151 size_t outIndex = 1;
152 for (ioNode *term : _graph.outputs())
153 code += _tab + "std::cout << \"\\t " + std::to_string(outIndex++) +
154 ". \\\"" + term->name() + ".out\\\" (shape " +
155 shapeStr(term->shape()) + "):\\n\";\n";
156
157 code += "}\n";
158 return code;
159}
160
161std::string dnnc::cppCodeGen::writeMainFunction(std::string body) {
162

Callers

nothing calls this directly

Calls 5

emptyMethod · 0.45
nameMethod · 0.45
sizeMethod · 0.45
shapeMethod · 0.45
outputsMethod · 0.45

Tested by

no test coverage detected