MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / IsInplaceAllowed

Function IsInplaceAllowed

oneflow/core/graph/task_graph.cpp:244–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242}
243
244bool 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
270std::unique_ptr<BoxingLogger> CreateBoxingLogger() {
271 if (Singleton<ResourceDesc, ForSession>::Get()->enable_debug_mode()) {

Callers 1

Calls 9

node_numMethod · 0.80
SoleNodeMethod · 0.80
RegstDesc4BnInOpMethod · 0.80
NumOfLbiMethod · 0.80
SoleBlobDescMethod · 0.80
opMethod · 0.45
elem_cntMethod · 0.45
shapeMethod · 0.45
data_typeMethod · 0.45

Tested by

no test coverage detected