MCPcopy Index your code
hub / github.com/POSTECH-CVLab/PyTorch-StudioGAN / matrix

Function matrix

src/utils/ada_aug.py:42–50  ·  view source on GitHub ↗
(*rows, device=None)

Source from the content-addressed store, hash-verified

40# Helpers for constructing transformation matrices.
41
42def matrix(*rows, device=None):
43 assert all(len(row) == len(rows[0]) for row in rows)
44 elems = [x for row in rows for x in row]
45 ref = [x for x in elems if isinstance(x, torch.Tensor)]
46 if len(ref) == 0:
47 return misc.constant(np.asarray(rows), device=device)
48 assert device is None or device == ref[0].device
49 elems = [x if isinstance(x, torch.Tensor) else misc.constant(x, shape=ref[0].shape, device=ref[0].device) for x in elems]
50 return torch.stack(elems, dim=-1).reshape(ref[0].shape + (len(rows), -1))
51
52def translate2d(tx, ty, **kwargs):
53 return matrix(

Callers 7

translate2dFunction · 0.85
translate3dFunction · 0.85
scale2dFunction · 0.85
scale3dFunction · 0.85
rotate2dFunction · 0.85
rotate3dFunction · 0.85
forwardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected