MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / update_cache

Method update_cache

imperative/python/src/backtrace.cpp:142–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142void FrameInfoCache::update_cache(
143 int key,
144 const SmallVector<std::pair<PyFrameObject*, FrameInfoPtr>, 100>& frames) {
145 stack_cache.resize(key + frames.size() + 1);
146 auto it = frames.rbegin();
147 auto cur_key = key + 1;
148 for (; it != frames.rend(); it++, cur_key++) {
149 auto&& [frame, finfo] = *it;
150 stack_cache[cur_key] = finfo;
151 if (auto* key_ptr = TraceKeyWrapper::try_cast(frame->f_trace)) {
152 key_ptr->key = cur_key;
153 } else {
154 auto* py_key = TraceKeyWrapper::make(cur_key, frame->f_trace);
155 frame->f_trace = py_key;
156 }
157 }
158}
159
160int FrameInfoCache::get_frame_key(PyFrameObject* frame) {
161 auto* key = TraceKeyWrapper::try_cast(frame->f_trace);

Callers 1

Calls 6

try_castFunction · 0.85
resizeMethod · 0.80
rbeginMethod · 0.80
rendMethod · 0.80
makeFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected