CoolFace
Apppublic

softwareweaver/MusicGen

sourceHugging Facecc-by-nc-4.0updated 11mo agoView on Hugging Face
0likes
test_activations.py30 linesDownload Raw Back to modules
1# Copyright (c) Meta Platforms, Inc. and affiliates.2# All rights reserved.3#4# This source code is licensed under the license found in the5# LICENSE file in the root directory of this source tree.6 7import torch8from torch import nn9 10from audiocraft.modules.activations import CustomGLU11 12 13class TestActivations:14    def test_custom_glu_calculation(self):15 16        activation = CustomGLU(nn.Identity())17 18        initial_shape = (4, 8, 8)19 20        part_a = torch.ones(initial_shape) * 221        part_b = torch.ones(initial_shape) * -122        input = torch.cat((part_a, part_b), dim=-1)23 24        output = activation(input)25 26        # ensure all dimensions match initial shape27        assert output.shape == initial_shape28        # ensure the gating was calculated correctly a * f(b)29        assert torch.all(output == -2).item()30