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

Class InterpreterCoreInfoCache

paddle/fluid/framework/executor_cache.h:142–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140};
141
142class InterpreterCoreInfoCache {
143 public:
144 static InterpreterCoreInfoCache& Instance();
145 bool Has(const InterpreterCoreInfoCacheKey& key) const {
146 int64_t hash_key = key.hash();
147 return info_map_.find(hash_key) != info_map_.end() &&
148 info_map_.at(hash_key).IsAvailable(key.is_grad());
149 }
150
151 InterpreterCoreInfo::CacheValue& GetMutable(
152 const InterpreterCoreInfoCacheKey& key) {
153 int64_t hash_key = key.hash();
154 return info_map_[hash_key].GetMutable(key.is_grad());
155 }
156
157 void UpdateSkipEagerDeleteVars(const InterpreterCoreInfoCacheKey& key,
158 const std::set<std::string>& skip_vars) {
159 auto& cached_value = GetMutable(key);
160 cached_value.skip_eager_delete_vars_ = std::move(skip_vars);
161 }
162
163 std::set<std::string>& GetSkipEagerDeleteVars(
164 const InterpreterCoreInfoCacheKey& key) {
165 auto& cached_value = GetMutable(key);
166 return cached_value.skip_eager_delete_vars_;
167 }
168
169 size_t Size() const { return info_map_.size(); }
170
171 void Finalize() {
172 // NOTE(Aurelius84): DO NOT perform finalize in destructor
173 // to avoid problems caused by destructor order of static
174 // object.
175 info_map_.clear();
176 }
177
178 private:
179 std::unordered_map<int64_t, InterpreterCoreInfo> info_map_;
180};
181
182std::shared_ptr<InterpreterCore> CreateProgramInterpreterCoreInfoToCache(
183 const ProgramDesc& program_desc,

Callers

nothing calls this directly

Calls 4

GetMutableFunction · 0.85
hashMethod · 0.45
GetMutableMethod · 0.45
is_gradMethod · 0.45

Tested by

no test coverage detected