提交 1b1cfcf3 authored 作者: Frederic Bastien's avatar Frederic Bastien

make the expected numpy code of round_half_away_from_zero output the good dtype…

make the expected numpy code of round_half_away_from_zero output the good dtype when dealing with float32.
上级 213288c7
...@@ -1295,7 +1295,14 @@ def round_half_away_from_zero_(a): ...@@ -1295,7 +1295,14 @@ def round_half_away_from_zero_(a):
return numpy.floor(a + 0.5) return numpy.floor(a + 0.5)
else: else:
return numpy.ceil(a - 0.5) return numpy.ceil(a - 0.5)
round_half_away_from_zero_vec = numpy.vectorize(round_half_away_from_zero_)
round_half_away_from_zero_vec64 = numpy.vectorize(round_half_away_from_zero_)
round_half_away_from_zero_vec32 = numpy.vectorize(round_half_away_from_zero_,otypes=['float32'])
def round_half_away_from_zero_vec(a):
if a.dtype == numpy.float32:
return round_half_away_from_zero_vec32(a)
return round_half_away_from_zero_vec64(a)
class RoundHalfAwayFromZero(UnaryScalarOp): class RoundHalfAwayFromZero(UnaryScalarOp):
""" """
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论