提交 bc10e2b9 authored 作者: Brandon T. Willard's avatar Brandon T. Willard 提交者: Brandon T. Willard

Remove unnecessary constant cloning from aesara.scan.opt rewrites

上级 b990275e
...@@ -123,7 +123,7 @@ def remove_constants_and_unused_inputs_scan(fgraph, node): ...@@ -123,7 +123,7 @@ def remove_constants_and_unused_inputs_scan(fgraph, node):
try: try:
# This works if input is a constant that has all entries # This works if input is a constant that has all entries
# equal # equal
givens[op_ins[idx]] = node_inp.clone()[0] givens[op_ins[idx]] = node_inp[0]
except TypeError: except TypeError:
pass pass
elif op_ins[idx] in all_ins: elif op_ins[idx] in all_ins:
...@@ -148,7 +148,7 @@ def remove_constants_and_unused_inputs_scan(fgraph, node): ...@@ -148,7 +148,7 @@ def remove_constants_and_unused_inputs_scan(fgraph, node):
nw_outer_nonseq = [] nw_outer_nonseq = []
for idx, (nw_in, nw_out) in enumerate(zip(non_seqs, outer_non_seqs)): for idx, (nw_in, nw_out) in enumerate(zip(non_seqs, outer_non_seqs)):
if isinstance(nw_out, Constant): if isinstance(nw_out, Constant):
givens[nw_in] = nw_out.clone() givens[nw_in] = nw_out
elif nw_in in all_ins: elif nw_in in all_ins:
# Indices of elements of nw_outer_nonseq that are equivalent # Indices of elements of nw_outer_nonseq that are equivalent
# to nw_out. # to nw_out.
...@@ -697,7 +697,7 @@ def push_out_inner_vars( ...@@ -697,7 +697,7 @@ def push_out_inner_vars(
new_outer_var = old_scan_args.outer_in_non_seqs[idx_non_seq] new_outer_var = old_scan_args.outer_in_non_seqs[idx_non_seq]
elif isinstance(var, Constant): elif isinstance(var, Constant):
new_outer_var = var.clone() new_outer_var = var
elif var in old_scan_args.inner_out_nit_sot: elif var in old_scan_args.inner_out_nit_sot:
idx_nitsot = old_scan_args.inner_out_nit_sot.index(var) idx_nitsot = old_scan_args.inner_out_nit_sot.index(var)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论