MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / PrepareScope

Method PrepareScope

paddle/fluid/inference/api/analysis_predictor.cc:822–846  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

820}
821
822bool AnalysisPredictor::PrepareScope(
823 const std::shared_ptr<framework::Scope> &parent_scope) {
824#ifdef PADDLE_WITH_XPU
825 // Set "XPU_PADDLE_L3_SIZE" to "0" to avoid malloc l3 cache when xpu_context
826 // init.
827 setenv("XPU_PADDLE_L3_SIZE", "0", 0);
828#endif
829 if (parent_scope) {
830 PADDLE_ENFORCE_NOT_NULL(
831 parent_scope,
832 common::errors::PreconditionNotMet(
833 "Both program and parent_scope should be set in Clone mode."));
834 scope_ = parent_scope;
835 status_is_cloned_ = true;
836 } else {
837 paddle::framework::InitMemoryMethod();
838 paddle::framework::InitDevices();
839 paddle::framework::InitDefaultKernelSignatureMap();
840 // TODO(wilber): we need to release memory occupied by weights.
841 scope_ = std::make_unique<paddle::framework::Scope>();
842 status_is_cloned_ = false;
843 }
844 sub_scope_ = &scope_->NewScope();
845 return true;
846}
847
848void AnalysisPredictor::OptimizeInferencePirProgram() {
849 auto ir_printing_conditions = [this](::pir::Pass *pass,

Callers

nothing calls this directly

Calls 3

InitMemoryMethodFunction · 0.85
InitDevicesFunction · 0.50

Tested by

no test coverage detected