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

Method _make_non_contiguous

test/test_modules.py:336–346  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

334 requires_grad=True, training=training)
335
336 def _make_non_contiguous(obj):
337 def inner_make_non_contiguous(obj):
338 # Scalar tensors can not be made non-contiguous
339 if not isinstance(obj, torch.Tensor) or obj.dim() == 0:
340 return obj
341
342 out = torch.repeat_interleave(obj, 2, dim=-1)
343 out = out[..., ::2].detach()
344 out.requires_grad = obj.requires_grad
345 return out
346 return self._traverse_obj(obj, inner_make_non_contiguous)
347
348 def _can_be_noncontiguous(obj):
349 if isinstance(obj, (tuple, list)):

Callers

nothing calls this directly

Calls 1

_traverse_objMethod · 0.95

Tested by

no test coverage detected