MCPcopy Create free account
hub / github.com/pytorch/pytorch / _to_mem_format

Method _to_mem_format

test/test_modules.py:637–645  ·  view source on GitHub ↗
(mem_format, obj)

Source from the content-addressed store, hash-verified

635
636 # Called after _check_dims, when we know that >= 1 tensor can be converted to mem_format
637 def _to_mem_format(mem_format, obj):
638 def inner_to_mem_format(obj):
639 d = obj.dim()
640 if ((mem_format == torch.channels_last and d != 4)
641 or (mem_format == torch.channels_last_3d and d != 5)):
642 return obj.clone().detach().requires_grad_(obj.requires_grad)
643 return obj.clone().to(memory_format=mem_format).detach().requires_grad_(obj.requires_grad)
644
645 return self._traverse_obj(obj, inner_to_mem_format)
646
647 def _check_out_mem_format(output, input_mem_format, module_mem_format):
648 def inner_check_out_mem_format(output):

Callers

nothing calls this directly

Calls 1

_traverse_objMethod · 0.95

Tested by

no test coverage detected