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

Method check_version

src/core/impl/graph/eager_eval.cpp:138–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138int EagerEvalManager::check_version(OperatorNodeBase* opr) {
139 auto&& trait = m_opr2version[opr];
140 if (!trait) {
141 trait = m_version_trait_pool.alloc();
142 using F = VersionTrait::Flag;
143 if (is_opr_mutable(opr)) {
144 if (opr->input().size()) {
145 for (auto&& i : opr->input()) {
146 auto&& trait_i = m_opr2version.at(i->owner_opr());
147 trait_i->readers.push_back(trait);
148 if (trait_i->flag & F::MUTABLE_SOURCE) {
149 trait->flag = F::MUTABLE;
150 }
151 }
152 } else {
153 trait->flag = static_cast<F>(F::MUTABLE | F::MUTABLE_SOURCE);
154 }
155 } else {
156 trait->flag = F::CONST;
157 }
158 trait->need_reeval = true;
159 return -1;
160 }
161 if (!trait->need_reeval) {
162 // need following check since user could invalidate output
163 // tensors explicitly (e.g. calling clear_device_memory())
164 for (auto&& i : opr->output()) {
165 if (!i->dev_tensor_valid()) {
166 trait->need_reeval = true;
167 break;
168 }
169 }
170 }
171 return trait->need_reeval;
172}
173
174void EagerEvalManager::prepare_for_exec(OperatorNodeBase* opr) {
175 // validate inputs

Callers

nothing calls this directly

Calls 9

is_opr_mutableFunction · 0.85
dev_tensor_validMethod · 0.80
allocMethod · 0.45
sizeMethod · 0.45
inputMethod · 0.45
atMethod · 0.45
owner_oprMethod · 0.45
push_backMethod · 0.45
outputMethod · 0.45

Tested by

no test coverage detected