MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / convert

Function convert

imperative/python/megengine/core/tensor/utils.py:102–109  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

100 ndim: int, axis: Union[int, Iterable], reverse=False
101) -> Union[int, list]:
102 def convert(x):
103 x_org = x
104 if x < 0:
105 x = ndim + x
106 assert (
107 x >= 0 and x < ndim
108 ), "axis {} is out of bounds for tensor of dimension {}".format(x_org, ndim)
109 return x
110
111 if isinstance(axis, int):
112 return convert(axis)

Callers 2

_normalize_axisFunction · 0.70
_convert_inputs_cppFunction · 0.50

Calls 1

formatMethod · 0.45

Tested by

no test coverage detected