MCPcopy Create free account
hub / github.com/alibaba/MNN / writeFb

Function writeFb

tools/converter/source/common/writeFb.cpp:177–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175 return 0;
176}
177int writeFb(std::unique_ptr<MNN::NetT>& netT, const modelConfig& config, std::unique_ptr<MNN::OpT>&& metaOp) {
178 postTreat(netT, config);
179 // Merge Meta to metaOp
180 auto oplist = std::move(netT->oplists);
181 for (auto& op : oplist) {
182 if (op->type == OpType_Extra) {
183 auto dstExtra = metaOp->main.AsExtra();
184 auto extra = op->main.AsExtra();
185 if (extra->type == "Meta" && extra->engine == "MNN") {
186 for (auto& attr : extra->attr) {
187 dstExtra->attr.emplace_back(std::move(attr));
188 }
189 // Remove meta op
190 continue;
191 }
192 }
193 netT->oplists.emplace_back(std::move(op));
194 }
195 std::set<std::string> notSupportOps;
196
197 // Detect unsupport op
198 auto CheckIfNotSupported = [&] (const std::unique_ptr<MNN::OpT>& op) {
199 if (op->type == MNN::OpType_Extra) {
200 if (op->main.AsExtra()->engine != "MNN") {
201 notSupportOps.insert(op->main.AsExtra()->engine + "::" + op->main.AsExtra()->type);
202 }
203 }
204 };
205 for (auto& op : netT->oplists) {
206 CheckIfNotSupported(op);
207 }
208 for (auto& subgraph : netT->subgraphs) {
209 for (auto& op : subgraph->nodes) {
210 CheckIfNotSupported(op);
211 }
212 }
213
214 std::ostringstream notSupportInfo;
215 if (!notSupportOps.empty() && !config.allowCustomOp) {
216 for (auto name : notSupportOps) {
217 notSupportInfo << name << " | ";
218 }
219 auto opNames = notSupportInfo.str();
220 LOG(FATAL) << "These Op Not Support: " << opNames.substr(0, opNames.size() - 2);
221 return 1;
222 }
223
224 // dump input and output tensor name
225 {
226 std::set<int> inputIdx, outputIdx, realOutput;
227 std::vector<int> realInput;
228 for (const auto& op : netT->oplists) {
229 for (auto i : op->inputIndexes) {
230 inputIdx.insert(i);
231 }
232 for (auto o : op->outputIndexes) {
233 outputIdx.insert(o);
234 if (op->type == OpType_Input) {

Callers 1

convertModelMethod · 0.85

Calls 15

postTreatFunction · 0.85
splitNamesFunction · 0.85
splitDimsFunction · 0.85
converToStaticModelFunction · 0.85
AsExtraMethod · 0.80
substrMethod · 0.80
to_stringFunction · 0.50
insertMethod · 0.45
emptyMethod · 0.45
strMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected