You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Useless integer casts in Alloc/Reshape shape arguments are not canonicalized away #2135
Integer-to-integer casts on shape arguments of Alloc (and other shape-consuming ops like Reshape) are not removed during canonicalization, even though these ops accept any integer dtype for shape inputs.
For example, Alloc(val, int32_var.astype("int64")) keeps the Cast{int64} node in the optimized graph, despite Alloc working correctly with int32 shape inputs directly.
The same issue applies to all integer-to-integer casts on shape arguments: int16, int32, uint8, uint16, uint32 to int64. These casts are functionally unnecessary since Alloc accepts any integer dtype for shape inputs.
A canonicalization rewrite should strip integer casts from shape arguments of shape-consuming ops (Alloc, Reshape, etc.), since the cast has no semantic effect.
This is a minor inefficiency but can clutter graphs and interfere with pattern matching in other rewrites that expect clean shape inputs.
Activity