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

Function canonicalize_dtype

imperative/python/megengine/xla/dtype.py:63–73  ·  view source on GitHub ↗
(dtype, x64_enabled=False, allow_opaque_dtype=False)

Source from the content-addressed store, hash-verified

61# do not enable x64 because megengine only support x32
62@lru_cache(maxsize=None)
63def canonicalize_dtype(dtype, x64_enabled=False, allow_opaque_dtype=False):
64 assert allow_opaque_dtype == False and x64_enabled == False
65 try:
66 dtype_ = np.dtype(dtype)
67 except TypeError as e:
68 raise TypeError(f"dtype {dtype!r} not understood") from e
69
70 if x64_enabled:
71 return dtype_
72 else:
73 return _dtype_to_32bit_dtype.get(dtype_, dtype_)
74
75
76def _canonicalize_ndarray_dtype(x):

Calls 2

dtypeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected