提交 77205b27 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

more update after more code review

上级 d543d5d2
...@@ -4830,7 +4830,9 @@ class Reshape(Op): ...@@ -4830,7 +4830,9 @@ class Reshape(Op):
if crit == 1 and len(requ_part) > 0: if crit == 1 and len(requ_part) > 0:
# If there are both 0 and -1 in requ_size, it is impossible # If there are both 0 and -1 in requ_size, it is impossible
# to determine a right output, but we can at least prevent # to determine a right output, but we can at least prevent
# a division by 0. # a division by 0. We do not want to keep a negative
# size here as it could lead to further weird errors
# after other optimizations.
requ_size = mul(*requ_part) requ_size = mul(*requ_part)
missing = input_size // (1 if requ_size == 0 else requ_size) missing = input_size // (1 if requ_size == 0 else requ_size)
for i, ele in enumerate(requ): for i, ele in enumerate(requ):
...@@ -4853,11 +4855,10 @@ class Reshape(Op): ...@@ -4853,11 +4855,10 @@ class Reshape(Op):
requ_size = -mul(*requ) requ_size = -mul(*requ)
# If there are both 0 and -1 in requ_size, it is impossible # If there are both 0 and -1 in requ_size, it is impossible
# to determine a right output, but we can at least prevent # to determine a right output, but we can at least prevent
# a division by 0. # a division by 0. We do not want to keep a negative
rest_size = (input_size // # size here as it could lead to further weird errors
switch(eq(requ_size, 0), # after other optimizations.
1, rest_size = input_size // maximum(requ_size, 1)
requ_size))
return [tuple([switch(eq(requ[i], -1), return [tuple([switch(eq(requ[i], -1),
rest_size, rest_size,
requ[i]) requ[i])
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论