| 136 | } |
| 137 | |
| 138 | int 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 | |
| 174 | void EagerEvalManager::prepare_for_exec(OperatorNodeBase* opr) { |
| 175 | // validate inputs |
nothing calls this directly
no test coverage detected