-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Milestone
Description
nn.constant and nn.random_uniform and related functions, nn.reduce require the shape argument to be ordered (list, tuple). (Same for nn.Parameter, but we keep that now as a separate special case.)
This is inconsistent to almost everywhere else where shape is unordered (set), on purpose because the order should never matter and up to RETURNN.
Inconsistency is not the only problem though.
Often you have given some tensor x, and then you maybe want to create a constant of the same shape, like nn.zeros_like. The canonical code nn.constant(..., shape=x.shape) does not work currently because nn.constant requires shape to be ordered, while x.shape is a set.
What are the options:
nn.zeros_likecurrently usesx.data.dim_tags, which is ordered. But I'm not sure this is a good solution. First, I'm not sure it is even a good idea that we exposex.datadirectly. We might want to be able to change this maybe. Also, it might not be reliable or deterministic. This order is determined when the returnn-common model construction code runs (maybe on CPU) but later (maybe on GPU) it would have been different.- Introduce a generic
nn.as_ordered_dims(...)function or so, which introduces some ordering, by some heuristics.nn.constantetc would accept an unordered set of dims but then internally it usesnn.as_ordered_dims(...)to make it ordered. - Already implement this on RETURNN side.
Metadata
Metadata
Assignees
Labels
No labels