Skip to content

ENH: Join looses static shape information #163

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
michaelosthege opened this issue Jan 3, 2023 · 1 comment · Fixed by #164
Closed

ENH: Join looses static shape information #163

michaelosthege opened this issue Jan 3, 2023 · 1 comment · Fixed by #164
Labels
enhancement New feature or request shape inference

Comments

@michaelosthege
Copy link
Member

Describe the issue:

A simple pt.concatenate of tensors with known static shapes could easily result in a static shape.

Currently it does not.

Reproducable code example:

def test_concatenate_static_shapes():
    a = pt.ones((2, 3))
    b = pt.ones((2, 5))
    c = pt.concatenate([a, b], axis=1)
    assert c.eval().shape == (2, 8)
    assert c.type.shape == (2, 8)
    pass

Error message:

>       assert c.type.shape == (2, 8)
E       assert (None, None) == (2, 8)
E         At index 0 diff: None != 2
E         Full diff:
E         - (2, 8)
E         + (None, None)

tests\test_setsubtensor.py:103: AssertionError

PyTensor version information:

main

Context for the issue:

No response

@michaelosthege michaelosthege added the bug Something isn't working label Jan 3, 2023
@ricardoV94
Copy link
Member

ricardoV94 commented Jan 3, 2023

That's not a bug. It's fine for an Op to lose shape information (as long as it's still correct). We can improve it of course.

Other parts of the library do assume shape is not lost (e.g., some asserts in rewrites). Those are bugs.

@ricardoV94 ricardoV94 changed the title BUG: Join looses static shape information ENH: Join looses static shape information Jan 3, 2023
@ricardoV94 ricardoV94 added enhancement New feature or request shape inference and removed bug Something isn't working labels Jan 3, 2023
michaelosthege added a commit to michaelosthege/pytensor that referenced this issue Jan 3, 2023
michaelosthege added a commit to michaelosthege/pytensor that referenced this issue Jan 3, 2023
michaelosthege added a commit to michaelosthege/pytensor that referenced this issue Jan 3, 2023
twiecki pushed a commit that referenced this issue Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request shape inference
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants