Skip to content
Open
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
4 changes: 4 additions & 0 deletions pytensor/tensor/rewriting/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ def local_blockwise_dot_to_mul(fgraph, node):
new_b = b
else:
return None

# new condition to handle (1,1) @ (1,1)
if a.ndim == 2 and b.ndim == 2 and a.shape == (1, 1) and b.shape == (1, 1):
return [a * b] # Direct elementwise multiplication
Comment on lines +299 to +301
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already handled, the issue that was not handled was for the care dot (not the blockwised versions) that this rewrite tracks.

Also a.ndim is redundant if you are checking the shape explicitly. More important you have to use static shape a.type.shape not the symbolic shape a.shape, as is done in the rest of this function

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will look into that again!


new_a = copy_stack_trace(a, new_a)
new_b = copy_stack_trace(b, new_b)
Expand Down