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

Method clone

express/module/Module.cpp:278–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276 return outputs;
277 }
278 virtual Module* clone(CloneContext* ctx) const override {
279 auto mModule = mChildren[0];
280 if (nullptr == ctx->pRuntimeManager) {
281 auto origin = mInfo->runTimeManager->getInside();
282 ScheduleConfig config;
283 config.type = origin->mRuntime.first.begin()->first;
284 config.numThread = origin->mContent->mNumberThread;
285 std::shared_ptr<Executor::RuntimeManager> newRt (Executor::RuntimeManager::createRuntimeManager(config));
286 const_cast<RuntimeAttr*>(newRt->getInside())->mContent = origin->mContent;
287 // Inherit pMeta so cloned modules don't push a stale nullptr at forward time.
288 const_cast<RuntimeAttr*>(newRt->getInside())->mMeta = origin->mMeta;
289 ctx->pRuntimeManager = newRt;
290 }
291 std::shared_ptr<Module::Info> newInfo(new Module::Info);
292 *newInfo = *mInfo;
293 newInfo->runTimeManager = ctx->pRuntimeManager;
294 std::shared_ptr<Module> submodule(mModule->clone(ctx));
295 NetModule* module(new NetModule(submodule, newInfo, nullptr, 0, 0.0f));
296#ifdef MNN_INTERNAL_ENABLED
297 module->mLogInfo = mLogInfo;
298#endif
299 return this->cloneBaseTo(ctx, module);
300 }
301 const Module::Info* info() const {
302 return mInfo.get();
303 }

Callers

nothing calls this directly

Calls 4

cloneBaseToMethod · 0.80
moduleFunction · 0.50
beginMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected