TensorBoard DP/DDP graph fix (#3325)

This commit is contained in:
Glenn Jocher authored and GitHub committed 2021-05-25 11:45:24 +02:00
1 parent 407dc5008e
commit aad99b63d6
2 files changed
+9 -3

No files matched your search

+6
View File
@@ -134,9 +134,15 @@ def profile(x, ops, n=100, device=None):
def is_parallel(model):
# Returns True if model is of type DP or DDP
return type(model) in (nn.parallel.DataParallel, nn.parallel.DistributedDataParallel)
def de_parallel(model):
# De-parallelize a model: returns single-GPU model if model is of type DP or DDP
return model.module if is_parallel(model) else model
def intersect_dicts(da, db, exclude=()):
# Dictionary intersection of matching keys and shapes, omitting 'exclude' keys, using da values
return {k: v for k, v in da.items() if k in db and not any(x in k for x in exclude) and v.shape == db[k].shape}