提交 288b1e75 编写于 作者: Q Qinghe JING 提交者: Dong Daxiang

Fix segmentation fault bug in reduce ops (#22079)

* fix dim=[] bug in reduce ops
上级 385ed8a5
......@@ -3882,9 +3882,9 @@ def reduce_sum(input, dim=None, keep_dim=False, name=None):
if dim is not None and not isinstance(dim, list):
dim = [dim]
attrs = {
'dim': dim if dim != None else [0],
'dim': dim if dim != None and dim != [] else [0],
'keep_dim': keep_dim,
'reduce_all': True if dim == None else False
'reduce_all': True if dim == None or dim == [] else False
}
if in_dygraph_mode():
......@@ -3957,9 +3957,9 @@ def reduce_mean(input, dim=None, keep_dim=False, name=None):
if dim is not None and not isinstance(dim, list):
dim = [dim]
attrs = {
'dim': dim if dim != None else [0],
'dim': dim if dim != None and dim != [] else [0],
'keep_dim': keep_dim,
'reduce_all': True if dim == None else False
'reduce_all': True if dim == None or dim == [] else False
}
if in_dygraph_mode():
......@@ -4034,9 +4034,9 @@ def reduce_max(input, dim=None, keep_dim=False, name=None):
inputs={'X': input},
outputs={'Out': out},
attrs={
'dim': dim if dim != None else [0],
'dim': dim if dim != None and dim != [] else [0],
'keep_dim': keep_dim,
'reduce_all': True if dim == None else False
'reduce_all': True if dim == None or dim == [] else False
})
return out
......@@ -4095,9 +4095,9 @@ def reduce_min(input, dim=None, keep_dim=False, name=None):
inputs={'X': input},
outputs={'Out': out},
attrs={
'dim': dim if dim != None else [0],
'dim': dim if dim != None and dim != [] else [0],
'keep_dim': keep_dim,
'reduce_all': True if dim == None else False
'reduce_all': True if dim == None or dim == [] else False
})
return out
......@@ -4157,9 +4157,9 @@ def reduce_prod(input, dim=None, keep_dim=False, name=None):
inputs={'X': input},
outputs={'Out': out},
attrs={
'dim': dim if dim != None else [0],
'dim': dim if dim != None and dim != [] else [0],
'keep_dim': keep_dim,
'reduce_all': True if dim == None else False
'reduce_all': True if dim == None or dim == [] else False
})
return out
......@@ -4215,9 +4215,9 @@ def reduce_all(input, dim=None, keep_dim=False, name=None):
inputs={'X': input},
outputs={'Out': out},
attrs={
'dim': dim if dim != None else [0],
'dim': dim if dim != None and dim != [] else [0],
'keep_dim': keep_dim,
'reduce_all': True if dim == None else False
'reduce_all': True if dim == None or dim == [] else False
})
return out
......@@ -4273,9 +4273,9 @@ def reduce_any(input, dim=None, keep_dim=False, name=None):
inputs={'X': input},
outputs={'Out': out},
attrs={
'dim': dim if dim != None else [0],
'dim': dim if dim != None and dim != [] else [0],
'keep_dim': keep_dim,
'reduce_all': True if dim == None else False
'reduce_all': True if dim == None or dim == [] else False
})
return out
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册