MCPcopy Create free account
hub / github.com/NVIDIA/FasterTransformer / safe_transpose

Function safe_transpose

examples/pytorch/utils.py:40–45  ·  view source on GitHub ↗
(tensor)

Source from the content-addressed store, hash-verified

38
39
40def safe_transpose(tensor):
41 if tensor.dim() <= 1:
42 return tensor
43 if tensor.dim() == 2:
44 return tensor.T
45 raise ValueError("Tensor has more than 2 dimensions, unable to safely transpose.")
46
47
48WEIGHT2DTYPE = {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected