提交 98eb9b65 authored 作者: Razvan Pascanu's avatar Razvan Pascanu

Corrected the canonical form of a slice following Pascal suggestions.

上级 f8e22d5e
......@@ -2664,19 +2664,25 @@ def get_canonical_form_slice(theslice, length):
stop = switch(ge(stop,length), length,stop)
nw_stop = switch(lt(step,0), start+1, stop )
nw_start = switch(lt(step,0), stop +1, start)
slice_len = ( start -stop - 1)//abs(step) + 1
slice_len = switch(lt(slice_len,0), 0, slice_len)
neg_start = nw_stop - (slice_len-1)*abs(step)-1
neg_start = switch(lt(neg_start,0), nw_stop-1, neg_start)
nw_start = switch(lt(step,0), neg_start, start)
nw_start = switch(lt(nw_start,0), 0, nw_start)
nw_stop = switch(lt(nw_stop,0) , 0, nw_stop )
nw_step = abs(step)
if step != 1:
reverse = sgn(step)
return slice(nw_start, nw_stop, nw_step), reverse
else:
return slice(nw_start, nw_stop, nw_step), None
return slice(nw_start, nw_stop, nw_step), 1
else:
value = extract_constant(theslice)
value = switch(lt(value,0), value+length, value)
return value, None
return value, 1
def transpose(x, **kwargs):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论