| 242 | } |
| 243 | |
| 244 | bool IsInplaceAllowed( |
| 245 | TaskNode* task_node, const std::vector<std::string>& bns, |
| 246 | const std::function<const TaskNode*(const std::string&)>& TaskNode4SoleOpName) { |
| 247 | if (task_node->exec_gph().node_num() != 1) { return false; } |
| 248 | const auto& exec_node = *task_node->exec_gph().SoleNode(); |
| 249 | for (const auto& bn : bns) { |
| 250 | // TaskNode for bn is not nullptr if it's on the same device with `task_node` |
| 251 | if (TaskNode4SoleOpName(exec_node.op()->BnInOp2Lbi(bn).op_name()) == nullptr) { return false; } |
| 252 | const RegstDesc& regst_desc = *exec_node.RegstDesc4BnInOp(bn); |
| 253 | if (regst_desc.NumOfLbi() != 1) { return false; } |
| 254 | } |
| 255 | const BlobDesc* first_blob = nullptr; |
| 256 | for (const auto& bn : bns) { |
| 257 | const BlobDesc* blob_desc = exec_node.RegstDesc4BnInOp(bn)->SoleBlobDesc(); |
| 258 | if (first_blob == nullptr) { |
| 259 | first_blob = blob_desc; |
| 260 | } else { |
| 261 | if (!(first_blob->shape().elem_cnt() == blob_desc->shape().elem_cnt() |
| 262 | && first_blob->data_type() == blob_desc->data_type())) { |
| 263 | return false; |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | return true; |
| 268 | } |
| 269 | |
| 270 | std::unique_ptr<BoxingLogger> CreateBoxingLogger() { |
| 271 | if (Singleton<ResourceDesc, ForSession>::Get()->enable_debug_mode()) { |
no test coverage detected