[MO] Avoid maskedconstant to array conversion (#10233)

* Avoid maskedconstant to array conversion

* remove redundant input

* Add link to github issue
This commit is contained in:
Anton Chetverikov
2022-02-10 16:24:05 +03:00
committed by GitHub
parent bc21e52912
commit 9af8d9339c

View File

@@ -36,6 +36,10 @@ def reduce_helper(func: callable, x: np.array, axis: tuple, keepdims: bool):
:return: the result tensor
"""
result = func(x, axis=axis, keepdims=keepdims)
# we need to handle this case specially to avoid problems with deepcopy method with MaskedConstant converted to
# masked_array - see issue https://github.com/numpy/numpy/issues/21022
if isinstance(result, np.ma.core.MaskedConstant):
return np.ma.masked_array(data=-1, mask=True, dtype=result.dtype)
if is_fully_defined(x):
return result
else: