Skip to content

RandomVariables have unnecessary SpecifyShape when size is casted #691

@ricardoV94

Description

@ricardoV94

The following happens on Windows because constant integer lists default to int32 instead of int64 as on Linux.

import aesara.tensor as at

print(at.random.normal(size=1).owner.inputs[1])  # TensorConstant{(1,) of 1}
print(at.random.normal(size=(1,)).owner.inputs[1])  # SpecifyShape.0
print(at.random.normal(size=(1, 2)).owner.inputs[1])  # SpecifyShape.0

To replicate on Linux, one would need to:

print(at.random.normal(size=at.constant((1,), dtype='int32')).owner.inputs[1])  # SpecifyShape.0
print(at.random.normal(size=at.constant((1, 2), dtype='int32')).owner.inputs[1])  # SpecifyShape.0

This is not terrible in itself, but led to bigger issues in pymc-devs/pymc#5140 because of #692

Edit: Updated to mention this only happens when casting is involved, which is the case on Windows due to constants of integer lists defaulting to int32. The bigger problem comes for #692, because some Ops like Alloc return a different output type when a shape is wrapped in a SpecifyShape.

As it stands the above is more of a nuisance than a bug. We might still not want to not apply SpecifyShape to casts of constants, specially since this will be the default on Windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    WindowsrefactorThis issue involves refactoring

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions