rwth-i6 / i6_core

Sisyphus recipies for ASR
Mozilla Public License 2.0
16 stars 23 forks source link

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

Closed NeoLegends closed 3 months ago

NeoLegends commented 3 months ago

I think this could be a fix for https://github.com/rwth-i6/i6_core/pull/510#issuecomment-2242807757 and https://bitbucket.org/omnifluent/apptek_asr/pull-requests/1173/overview.

NeoLegends commented 3 months ago

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 commented 3 months ago

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).