Skip to content

Conversation

@thkkk
Copy link

@thkkk thkkk commented Oct 9, 2025

Added view(-1, 1) before expanding 1D tensors:

        # time embeddings
        if t.dim() == 1:
            t = t.expand(t.size(0), seq_len)

The original code attempted to directly expand 1D tensors to 2D, which could cause runtime errors since expand() only works on dimensions of size 1 (or just keep the size of dimensions). The fix ensures we first reshape 1D tensors to have a size-1 dimension before expansion.

        if t.dim() == 1:
            # Note: expand only works for dimensions of size 1; view(-1, 1) must be called first.
            t = t.view(-1, 1).expand(t.size(0), seq_len)
        elif t.dim() == 2 and t.size(1) == 1:
            t = t.expand(t.size(0), seq_len)
image

Moreover:

  • Verified the fix handles various tensor shapes correctly
  • The code correctness was validated via comprehensive i2v training experiments

expand()only works on dimensions of size 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant