MCPcopy Create free account
hub / github.com/NVIDIA/DALI / _get_absdiff

Function _get_absdiff

dali/test/python/test_utils.py:167–182  ·  view source on GitHub ↗
(left, right)

Source from the content-addressed store, hash-verified

165
166
167def _get_absdiff(left, right):
168 def make_unsigned(dtype):
169 if not np.issubdtype(dtype, np.signedinteger):
170 return dtype
171 return {
172 np.dtype(np.int8): np.uint8,
173 np.dtype(np.int16): np.uint16,
174 np.dtype(np.int32): np.uint32,
175 np.dtype(np.int64): np.uint64,
176 }[dtype]
177
178 # np.abs of diff doesn't handle overflow for unsigned types
179 absdiff = np.maximum(left, right) - np.minimum(left, right)
180 # max - min can overflow for signed types, wrap them up
181 absdiff = absdiff.astype(make_unsigned(absdiff.dtype))
182 return absdiff
183
184
185def _check_absdiff():

Callers 2

_check_absdiffFunction · 0.85
get_absdiffFunction · 0.85

Calls 1

make_unsignedFunction · 0.85

Tested by

no test coverage detected