Skip to content
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

Also infer dynamic axes for every model input and output #529

Merged
merged 8 commits into from
Jul 23, 2024

Conversation

NeoLegends
Copy link
Contributor

@NeoLegends NeoLegends added the bug Something isn't working label Jul 22, 2024
@NeoLegends NeoLegends self-assigned this Jul 22, 2024
Copy link
Member

@albertz albertz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should not hardcode ...:size1 here. You can just check the entry in extern_data/model_outputs, it will tell you what dynamic dims are there.

@NeoLegends
Copy link
Contributor Author

How so? This is not within RETURNN (where this info might be available), and there are cases where there's simply extern_data = {"data": {"dim": 60}} and no more info.

@albertz
Copy link
Member

albertz commented Jul 22, 2024

there are cases where there's simply extern_data = {"data": {"dim": 60}}

It applies extern_data_template_from_config_opts. This will call Tensor(**opts). I.e. for your example, Tensor(dim=60). It follows the defaults from Tensor. The shape by default is (None, dim). shape is without the batch dim, for historical reasons. But there is by default always a batch dim, with default batch_dim_axis=0. The None in shape refers to a dynamic dim. As it comes after the batch dim, you get the axis 1 here.

You could replicate the defaults from Tensor here. But to really cover all cases, I think the easiest would be to just from returnn.tensor import Tensor and then Tensor(name=name, **opts).

@NeoLegends NeoLegends requested a review from albertz July 23, 2024 10:51
returnn/compile.py Outdated Show resolved Hide resolved
returnn/compile.py Outdated Show resolved Hide resolved
@NeoLegends NeoLegends requested a review from albertz July 23, 2024 12:07
returnn/compile.py Outdated Show resolved Hide resolved
@NeoLegends NeoLegends merged commit 7eca8a3 into main Jul 23, 2024
4 checks passed
@albertz albertz deleted the moritz-fix-dynamic-axes-inference branch July 23, 2024 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants