提交 980b74a7 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Merge pull request #3075 from carriepl/remove_floordiv_ref

Make tensor.floor_div a reference to tensor.int_div
...@@ -3067,16 +3067,13 @@ def true_div(a, b): ...@@ -3067,16 +3067,13 @@ def true_div(a, b):
@_scal_elemwise_with_nfunc('floor_divide', 2, 1) @_scal_elemwise_with_nfunc('floor_divide', 2, 1)
def floor_div(a, b): def int_div(a, b):
"""elementwise [floor] division (inverse of multiplication)""" """elementwise [floor] division (inverse of multiplication)"""
# see decorator for function body # see decorator for function body
# not a c/p error, floor_div and int_div are the same thing # floor_div and int_div are the same thing
@_scal_elemwise_with_nfunc('floor_divide', 2, 1) floor_div = int_div
def int_div(a, b):
"""elementwise integer-division"""
# see decorator for function body
def ceil_intdiv(a, b): def ceil_intdiv(a, b):
......
...@@ -3133,7 +3133,7 @@ def local_mul_switch_sink(node): ...@@ -3133,7 +3133,7 @@ def local_mul_switch_sink(node):
@register_canonicalize @register_canonicalize
@gof.local_optimizer([T.true_div, T.int_div, T.floor_div]) @gof.local_optimizer([T.true_div, T.int_div])
def local_div_switch_sink(node): def local_div_switch_sink(node):
""" """
This optimization makes the folowing changes in the graph: This optimization makes the folowing changes in the graph:
...@@ -3145,8 +3145,7 @@ def local_div_switch_sink(node): ...@@ -3145,8 +3145,7 @@ def local_div_switch_sink(node):
NaN or inf values for cases where the switch returns 0. NaN or inf values for cases where the switch returns 0.
See local_mul_switch_sink for more details. See local_mul_switch_sink for more details.
""" """
if (node.op != T.true_div and node.op != T.int_div if (node.op != T.true_div and node.op != T.int_div):
and node.op != T.floor_div):
return False return False
op = node.op op = node.op
if node.inputs[0].owner and node.inputs[0].owner.op == T.switch: if node.inputs[0].owner and node.inputs[0].owner.op == T.switch:
...@@ -4399,7 +4398,7 @@ def local_mul_to_sqr(node): ...@@ -4399,7 +4398,7 @@ def local_mul_to_sqr(node):
@register_canonicalize @register_canonicalize
@gof.local_optimizer([T.int_div, T.floor_div]) @gof.local_optimizer([T.int_div])
def local_intdiv_by_one(node): def local_intdiv_by_one(node):
"""x // 1 -> x """x // 1 -> x
""" """
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论