arogozhnikov / einops

Flexible and powerful tensor operations for readable and reliable code (for pytorch, jax, TF and others)

Home Page:https://einops.rocks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] einops should support floating point bound variables

marksandler2 opened this issue · comments

Describe the bug
Using floating point bound variables variables should work when changing the shape.
E.g. this:

 einops.rearrange(jnp.zeros((10, 10)),'(i t) j -> i (t j)', t=0.5)

Should be equivalent to this:

 einops.rearrange(jnp.zeros((10, 10)),'i (t j) -> (i t) j', t=2)

Reproduction steps

import einops
import jax.numpy as np
einops.rearrange(jnp.zeros((10, 10)),'(i t) j -> i (t j)', t=0.5)

Expected behavior

Return tensor 20x5. Instead it raised an exception:

Your platform

Python 3.10, einops version: 0.6.0, jax

einops should support floating point bound variables

no, it should not.

It's 1) totally unreadable 2) breaks "shapes visible from pattern" 3) ties behavior to non-verbalized state (dtypes).