Skip to content

Check what happens if we remove view_ops #1345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 16 additions & 14 deletions pytensor/compile/function/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import pytensor
import pytensor.compile.profiling
from pytensor.compile.io import In, SymbolicInput, SymbolicOutput
from pytensor.compile.ops import deep_copy_op, view_op
from pytensor.compile.ops import deep_copy_op
from pytensor.compile.profiling import ProfileStats
from pytensor.configdefaults import config
from pytensor.graph.basic import (
Expand Down Expand Up @@ -1260,9 +1260,11 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
# and not(wrapped_outputs[i].borrow and wrapped_outputs[j].borrow):
if fgraph.outputs[j] in views_of_output_i:
if wrapped_outputs[i].borrow and wrapped_outputs[j].borrow:
fgraph.change_node_input(
*output_client, view_op(original_out), reason=reason
)
pass

# fgraph.change_node_input(
# *output_client, view_op(original_out), reason=reason
# )
else:
fgraph.change_node_input(
*output_client, deep_copy_op(original_out), reason=reason
Expand All @@ -1287,11 +1289,11 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
if input_j in fgraph.inputs:
j = fgraph.inputs.index(input_j)
if wrapped_outputs[i].borrow and wrapped_inputs[j].borrow:
fgraph.change_node_input(
*output_client,
view_op(original_out),
reason=reason,
)
# fgraph.change_node_input(
# *output_client,
# view_op(original_out),
# reason=reason,
# )
break
else:
fgraph.change_node_input(
Expand All @@ -1301,11 +1303,11 @@ def insert_deepcopy(fgraph, wrapped_inputs, wrapped_outputs):
)
break
elif wrapped_outputs[i].borrow:
fgraph.change_node_input(
*output_client,
view_op(original_out),
reason=reason,
)
# fgraph.change_node_input(
# *output_client,
# view_op(original_out),
# reason=reason,
# )
break
else:
fgraph.change_node_input(
Expand Down
4 changes: 4 additions & 0 deletions pytensor/tensor/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2203,12 +2203,16 @@ def c_code(self, node, name, input_names, output_names, sub):
}}
}}
}}
if ({output_name}==NULL){{
printf("Have to allocate new AdvancedSubtensor1 output\n");
}}
{output_name} = (PyArrayObject*)PyArray_TakeFrom(
{a_name}, (PyObject*){i_name}, 0, {output_name}, NPY_RAISE);
if ({output_name} == NULL) {fail};
"""

def c_code_cache_version(self):
return None
return (4,)


Expand Down
Loading