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

Function _loadInputs

express/module/Module.cpp:320–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

318}
319
320static void _loadInputs(Module::Info* info, const std::vector<std::string>& inputs, const Net* net) {
321 auto type = net->sourceType();
322 if (type == NetSource_TENSORFLOW || type == NetSource_TFLITE) {
323 info->defaultFormat = NHWC;
324 } else {
325 info->defaultFormat = NCHW;
326 }
327 info->inputs.resize(inputs.size());
328 std::map<std::string, Variable::Info> allInputs;
329 for (int i=0; i<net->oplists()->size(); ++i) {
330 auto op = net->oplists()->GetAs<Op>(i);
331 if (op->type() == OpType_Input && op->main_as_Input() != nullptr) {
332 auto name = net->tensorName()->GetAsString(op->outputIndexes()->data()[0])->str();
333 auto inputInfo = op->main_as_Input();
334 std::vector<int> dims;
335 if (nullptr != inputInfo->dims()) {
336 dims.resize(inputInfo->dims()->size());
337 for (int v=0; v<dims.size(); ++v) {
338 dims[v] = inputInfo->dims()->data()[v];
339 }
340 }
341 auto dtype = Utils::revertDataType(inputInfo->dtype());
342 Variable::Info vinfo;
343 vinfo.dim = std::move(dims);
344 vinfo.order = Utils::revertFormat(inputInfo->dformat());
345 vinfo.type = dtype;
346 vinfo.syncSize();
347 allInputs.insert(std::make_pair(name, std::move(vinfo)));
348 }
349 }
350 for (int i=0; i<inputs.size(); ++i) {
351 auto iter = allInputs.find(inputs[i]);
352 if (iter != allInputs.end()) {
353 info->inputs[i] = iter->second;
354 }
355 }
356}
357
358Module* Module::load(const std::vector<std::string>& inputs, const std::vector<std::string>& outputs, const char* fileName, const std::shared_ptr<MNN::Express::Executor::RuntimeManager> _rtMgr, const Module::Config* config) {
359 AutoStorage<uint8_t> buffer;

Callers 1

loadInternalFunction · 0.85

Calls 12

GetAsStringMethod · 0.80
dtypeMethod · 0.80
syncSizeMethod · 0.80
resizeMethod · 0.45
sizeMethod · 0.45
typeMethod · 0.45
strMethod · 0.45
dataMethod · 0.45
dimsMethod · 0.45
insertMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected