Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3c3ca0b
Benchmark another FusionOptimizer graph
ricardoV94 Sep 4, 2025
7119770
Short-circuit `as_scalar` common cases faster
ricardoV94 Sep 20, 2025
b944c9f
Speedup supports c_code
ricardoV94 Sep 18, 2025
0e5c760
Speedup FusionOptimizer.elemwise_to_scalar
ricardoV94 Sep 5, 2025
62de419
Avoid double cloning of Composite Ops created by FusionOptimizer
ricardoV94 Sep 20, 2025
0337dce
Do not recompute toposort in every iteration of FusionOptimizer
ricardoV94 Sep 12, 2025
42de0ea
Cleanup FusionOptimizer code
ricardoV94 Sep 12, 2025
ca607bf
Copy on write in FusionOptimizer
ricardoV94 Sep 12, 2025
4364bee
Use bitset to check ancestors more efficiently
ricardoV94 Sep 12, 2025
6f5a3fa
Avoid backtracking in FusionOptimizer
ricardoV94 Sep 18, 2025
6a99dca
Benchmark function compilation
ricardoV94 Sep 3, 2025
538a5e7
Avoid FunctionGraph overhead when compiling single Ops to C
ricardoV94 Sep 3, 2025
cd213d1
Use single tracks in WalkingGraphRewriter
ricardoV94 Sep 3, 2025
1db1f92
Exit from DestroyHandler orderings faster
ricardoV94 Sep 3, 2025
54c3f02
Make DimShuffle a regular COp
ricardoV94 Sep 5, 2025
5e2ceb7
Speedup _gemm_canonicalize
ricardoV94 Sep 5, 2025
1719169
Simpler Elemwise.infer_shape
ricardoV94 Sep 5, 2025
e4da2d7
Use non recursive algorithm in `rebuild_collect_shared`
ricardoV94 Sep 5, 2025
b4cc77e
.avoid cast in hot loop
ricardoV94 Sep 5, 2025
fdf12fd
.faster tensortype creation
ricardoV94 Sep 5, 2025
0308384
upcast not needed all the time
ricardoV94 Sep 5, 2025
a3bcf0c
cache _upcast_impl
ricardoV94 Sep 5, 2025
4753a08
Gemm optimizer spends too much time creating constants of the wrong t…
ricardoV94 Sep 5, 2025
4f09fb7
Fail fast scan memory inplace
ricardoV94 Sep 5, 2025
272816e
Fast Scan equality for same identity
ricardoV94 Sep 7, 2025
90ab712
.speedup composite rewrites
ricardoV94 Sep 5, 2025
330a1e0
Revert "Use non recursive algorithm in `rebuild_collect_shared`"
ricardoV94 Sep 20, 2025
9ffd97f
Speedup gradient
ricardoV94 Sep 23, 2025
2349641
.speedup stuff
ricardoV94 Oct 2, 2025
2c6bff5
.speedup stuff
ricardoV94 Oct 2, 2025
ed5cec2
Reapply "Use non recursive algorithm in `rebuild_collect_shared`"
ricardoV94 Oct 4, 2025
2ea91fd
.speedup stuff
ricardoV94 Oct 4, 2025
9ba0923
.speedup stuff
ricardoV94 Oct 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 50 additions & 40 deletions pytensor/compile/function/pfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,47 +179,57 @@ def clone_v_get_shared_updates(v, copy_inputs_over):

"""
# this co-recurses with clone_a
assert v is not None
if v in clone_d:
return clone_d[v]
if v.owner:
owner = v.owner
if owner not in clone_d:
for i in owner.inputs:
clone_v_get_shared_updates(i, copy_inputs_over)
clone_node_and_cache(
owner,
clone_d,
strict=rebuild_strict,
clone_inner_graphs=clone_inner_graphs,
)
return clone_d.setdefault(v, v)
elif isinstance(v, SharedVariable):
if v not in shared_inputs:
shared_inputs.append(v)
if v.default_update is not None:
# Check that v should not be excluded from the default
# updates list
if no_default_updates is False or (
isinstance(no_default_updates, list) and v not in no_default_updates
):
# Do not use default_update if a "real" update was
# provided
if v not in update_d:
v_update = v.type.filter_variable(
v.default_update, allow_convert=False
stack = [v]
try:
while True:
v = stack[-1]
if v in clone_d:
stack.pop()
continue
if (apply := v.owner) is not None:
if all(i in clone_d for i in apply.inputs):
# all inputs have been cloned, we can clone this node
stack.pop()
clone_node_and_cache(
apply,
clone_d,
strict=rebuild_strict,
clone_inner_graphs=clone_inner_graphs,
)
if not v.type.is_super(v_update.type):
raise TypeError(
"An update must have a type compatible with "
"the original shared variable"
)
update_d[v] = v_update
update_expr.append((v, v_update))
if not copy_inputs_over:
return clone_d.setdefault(v, v.clone())
else:
return clone_d.setdefault(v, v)
else:
# expand on the inputs
stack.extend(apply.inputs)
else:
stack.pop()
clone_d[v] = v if copy_inputs_over else v.clone()

# Special handling of SharedVariables
if isinstance(v, SharedVariable):
if v not in shared_inputs:
shared_inputs.append(v)
if v.default_update is not None:
# Check that v should not be excluded from the default
# updates list
if no_default_updates is False or (
isinstance(no_default_updates, list)
and v not in no_default_updates
):
# Do not use default_update if a "real" update was
# provided
if v not in update_d:
v_update = v.type.filter_variable(
v.default_update, allow_convert=False
)
if not v.type.is_super(v_update.type):
raise TypeError(
"An update must have a type compatible with "
"the original shared variable"
)
update_d[v] = v_update
update_expr.append((v, v_update))
except IndexError:
pass # stack is empty
return clone_d[v]

# initialize the clone_d mapping with the replace dictionary
if replace is None:
Expand Down
Loading