//Because of Unknow Error, so I have to use 6 XML files to save those matrixs void myPCA::saveModel() { FileStorage fs1("mean.xml", FileStorage::WRITE); FileStorage fs2("sample.xml", FileStorage::WRITE); FileStorage fs3("eigen.xml", FileStorage::WRITE); FileStorage fs4("proj.xml", FileStorage::WRITE); FileStorage fs5("ID.xml", FileStorage::WRITE); FileStorage fs6("sampleOri.xml", FileStorage::WRITE); fs1 << "MeanFace" << meanFace; fs2 << "SampleMatrix" << sampleMatrix ; fs3 << "EigenVectors" << eigenVectors; fs4 << "ProjFaces" << projFaces; fs5 << "TrainImageID" << trainImageID; fs6 << "SampleMatrixOri" << sampleMatrixOri ; }
void myPCA::loadModel() { FileStorage fs1("mean.xml", FileStorage::READ); FileStorage fs2("sample.xml", FileStorage::READ); FileStorage fs3("eigen.xml", FileStorage::READ); FileStorage fs4("proj.xml", FileStorage::READ); FileStorage fs5("ID.xml", FileStorage::READ); FileStorage fs6("sampleOri.xml", FileStorage::READ); fs1["MeanFace"] >> meanFace; fs2["SampleMatrix"] >> sampleMatrix ; fs3["EigenVectors"] >> eigenVectors; fs4["ProjFaces"] >> projFaces; fs5["TrainImageID"] >> trainImageID; fs6["SampleMatrixOri"] >> sampleMatrixOri ; }
nmethod* SICompiler::compile() { EventMarker em("SIC-compiling %#lx %#lx", L->selector(), NULL); ShowCompileInMonitor sc(L->selector(), "SIC", recompilee != NULL); // cannot recompile uncommon branches in DI nmethods & top nmethod yet FlagSetting fs2(SICDeferUncommonBranches, SICDeferUncommonBranches && diLink == NULL && L->adeps->length() == 0 && L->selector() != VMString[DO_IT]); // don't use uncommon traps when recompiling because of trap useUncommonTraps = SICDeferUncommonBranches && !currentProcess->isUncommon(); // don't inline into doIt FlagSetting fs3(Inline, Inline && L->selector() != VMString[DO_IT]); # if TARGET_ARCH != I386_ARCH // no FastMapTest possible on I386 // don't use fast map loads if this nmethod trapped a lot FlagSetting fs4(FastMapTest, FastMapTest && (recompilee == NULL || recompilee->flags.trapCount < MapLoadTrapLimit)); # endif FlagSetting fs5(PrintCompilation, PrintCompilation || PrintSICCompilation); timer t; FlagSetting fs6(verifyOften, SICDebug || CheckAssertions); if(PrintCompilation || PrintLongCompilation || PrintCompilationStatistics || VMSICLongProfiling) { t.start(); } if (PrintCompilation || PrintSICCode) { lprintf("*SIC-%s%scompiling %s%s: (SICCompilationCount=%d)", currentProcess->isUncommon() ? "uncommon-" : "", recompilee ? "re" : "", sprintName( (methodMap*) method()->map(), L->selector()), sprintValueMethod( L->receiver ), (void*)SICCompilationCount); } topScope->genCode(); buildBBs(); if (verifyOften) bbIterator->verify(false); bbIterator->eliminateUnreachableNodes(); // needed for removeUptoMerge to work // compute exposed blocks and up-level accessed vars bbIterator->computeExposedBlocks(); bbIterator->computeUplevelAccesses(); // make defs & uses and insert flush nodes for uplevel-accessed vars bbIterator->makeUses(); // added verify here cause want to catch unreachable merge preds // before elimination -- dmu if (verifyOften) bbIterator->verify(); if (SICLocalCopyPropagate) { bbIterator->localCopyPropagate(); if (verifyOften) bbIterator->verify(); } if (SICGlobalCopyPropagate) { bbIterator->globalCopyPropagate(); if (verifyOften) bbIterator->verify(); } if (SICEliminateUnneededNodes) { bbIterator->eliminateUnneededResults(); if (verifyOften) bbIterator->verify(); } // do after CP to explot common type test source regs if (SICOptimizeTypeTests) { bbIterator->computeDominators(); bbIterator->optimizeTypeTests(); if (verifyOften) bbIterator->verify(); } // allocate the temp (i.e. volatile) registers bbIterator->allocateTempRegisters(); // allocate the callee-saved (i.e. non-volatile) registers SICAllocator* a = theAllocator; a->allocate(bbIterator->globals, topScope->incoming); stackLocCount = a->stackTemps; // make sure frame size is aligned properly int32 frame_size_so_far = frameSize(); stackLocCount += roundTo(frame_size_so_far, frame_word_alignment) - frame_size_so_far; // compute the register masks for inline caches bbIterator->computeMasks(stackLocCount, nonRegisterArgCount()); topScope->computeMasks(regStringToMask(topScope->incoming), stackLocCount, nonRegisterArgCount()); if (PrintSICCode) { print_code(false); lprintf("\n\n"); } topScope->describe(); // must come before gen to set scopeInfo genHelper = new SICGenHelper; bbIterator->gen(); assert(theAssembler->verifyLabels(), "undefined labels"); rec->generate(); topScope->fixupBlocks(); // must be after rec->gen to know offsets if (vscopes) computeMarkers(); // ditto nmethod* nm = new_nmethod(this, false); if (theAssembler->lastBackpatch >= theAssembler->instsEnd) fatal("dangling branch"); em.event.args[1] = nm; fint ms = IntervalTimer::dont_use_any_timer ? 0 : t.millisecs(); if (PrintCompilation || PrintLongCompilation) { if (!PrintCompilation && PrintLongCompilation && ms >= MaxCompilePause) { lprintf("*SIC-%s%scompiling ", currentProcess->isUncommon() ? "uncommon-" : "", recompilee ? "re" : ""); methodMap* mm = method() ? (methodMap*) method()->map() : NULL; printName(mm, L->selector()); lprintf(": %#lx (%ld ms; level %ld)\n", nm, (void*)ms, (void*)nm->level()); } else if (PrintCompilation) { lprintf(": %#lx (%ld ms; level %ld v%d)\n", (void*)nm, (void*)ms, (void*)nm->level(), (void*)nm->version()); } } if (SICDebug && estimatedSize() > inlineLimit[NmInstrLimit]) { float rat = (float)estimatedSize() / (float)nm->instsLen(); lprintf("*est. size = %ld, true size = %ld, ratio = %4.2f\n", (void*)estimatedSize(), (void*)nm->instsLen(), *(void**)&rat); } if (PrintCompilationStatistics) { static fint counter = 0; lprintf("\n*SIC-time= |%ld| ms; to/co/sc/lo/de= |%ld|%ld|%ld|%ld|%ld| %ld|%ld|%ld| %ld |", (void*)ms, (void*) (nm->instsLen() + nm->scopes->length() + nm->locsLen() + nm->depsLen), (void*)nm->instsLen(), (void*)nm->scopes->length(), (void*)nm->locsLen(), (void*)nm->depsLen, (void*)BasicNode::currentID, (void*)bbIterator->bbCount, (void*)ncodes, (void*)counter++); } # if GENERATE_DEBUGGING_AIDS if (CheckAssertions) { // nm->verify(); } # endif return nm; }