Skip to content

Replace dot of 1 and x -> x #810

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Dhruvanshu-Joshi
Copy link
Member

Description

So here, I aim to replace the output of a graph of x.[1] or x@[1] with x.
I am not quite sure if this is the correct way to do so. When x = pt.col('x') this works fine.
However for x = fmatrix("x") or x = vector("x") or x = pt.tensor("x", shape=(1, 3, 2), dtype="float64") I kept running into the error:

TypeError: The type of the replacement (Matrix(float64, shape=(3, 2))) must be compatible with the type of the original Variable (Matrix(float64, shape=(3, 1))).

To solve this, I introduced:

if not old_out.type.is_super(new_out.type):
    new_out = alloc_like(new_out, old_out, fgraph)

However, x = pt.tensor("x", shape=(1, 3, 2), dtype="float64") still complained with:

raise ValueError(
ValueError: Alloc static input type and target shape are incompatible: Matrix(float64, shape=(3, 2)) vs (3, 1)

Finally,

if not old_out.type.is_super(new_out.type):
    new_out = new_out.reshape(old_out.shape)

works fine but introduces a Reshape op in the graph.

Related Issue

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplify dots with 1
1 participant