Download code/models/tt_dit/utils/mochi.py from sunandbean/diffrhythm-1.2-p100a: direct link, hf CLI and curl.
- Browser
- Download file 596 Bytes
-
https://huggingface.co/sunandbean/diffrhythm-1.2-p100a/resolve/main/code/models/tt_dit/utils/mochi.py
- Command line
-
hf download hf://sunandbean/diffrhythm-1.2-p100a/code/models/tt_dit/utils/mochi.py
-
curl -L -o mochi.py https://huggingface.co/sunandbean/diffrhythm-1.2-p100a/resolve/main/code/models/tt_dit/utils/mochi.py
596 Bytes
| # SPDX-FileCopyrightText: © 2025 Tenstorrent USA, Inc. | |
| # SPDX-License-Identifier: Apache-2.0 | |
| import torch | |
| def stack_cos_sin(cos, sin): | |
| cos = torch.stack([cos, cos], dim=-1).flatten(-2) | |
| sin = torch.stack([sin, sin], dim=-1).flatten(-2) | |
| return cos, sin | |
| def get_rot_transformation_mat(): | |
| # ROPE op uses a single tile | |
| dhead = 32 | |
| rot_emb_matrix = torch.zeros(1, 1, dhead, dhead) | |
| rot_emb_matrix[..., torch.arange(0, dhead, 2), torch.arange(1, dhead, 2)] = 1 | |
| rot_emb_matrix[..., torch.arange(1, dhead, 2), torch.arange(0, dhead, 2)] = -1 | |
| return rot_emb_matrix | |