Replies: 1 comment 4 replies
-
Not sure if you followed the recent changes in static shape types: https://aesara.readthedocs.io/en/latest/extending/type.html In general we are trying to make the output types more clever about static shapes, so the following should work like this: import aesara.tensor as at
x = at.tensor(dtype="float64", shape=(50,), name="x")
y = at.zeros_like(x)
y.type # TensorType(float64, (50,)) <- Not yet there This does not require any new functionality, only improving the output of Your suggestion goes one step further and gives names to these dimensions, but I feel part of it was related to being clever about the propagation of static type shape, which we are already working on. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I don't know if this was discussed before, but I think it could be really interesting and useful to store more information about dimensions in the TensorType.
We could for instance define objects for individual dimensions roughly like this:
We could then allow dimension information in the TensorType directly.
Which would give us a
TensorType(np.float64, shape=(None,), dims=(country,))
Many ops could then figure out the dimensions for output types.
at.zeros_like
for instance could tell us that the dimension of the output is the same as the dimension of the input, rather than just an unknown shape with the same rank as the input.Just for debugging alone I think this would be really helpful. If there are some shape mismatches the error message could tell us which dimensions are the problem.
It would also allow pymc to infer dims for eg deterministics.
We could add
at.dim_add(x, y)
or so that does broadcasting based on those dimensions instead based on the position of the dimensions, which I think can prevent a whole class of common bugs.I can also imaging that this could be useful for optimizations (especially reusing memory from old computations). If we have dimensions, we can tell that two variables have the same shape, whatever that shape might be.
Beta Was this translation helpful? Give feedback.
All reactions