Implementation:Facebookresearch Audiocraft NormConv
| Knowledge Sources | |
|---|---|
| Domains | Neural_Networks, Audio_Processing |
| Last Updated | 2026-02-14 01:00 GMT |
Overview
Concrete tool for normalized and streaming-aware convolution wrappers with weight normalization, spectral normalization, and causal padding support.
Description
This module provides NormConv1d, NormConv2d, NormConvTranspose1d, and NormConvTranspose2d wrappers that add configurable normalization (none, weight_norm, spectral_norm, time_group_norm) and causal padding to standard PyTorch convolutions. The pad1d and unpad1d helpers handle asymmetric padding for causal convolutions. These are the building blocks for SEANet encoder/decoder architectures.
Usage
Import these wrappers when building convolutional audio processing modules that need normalization and causal padding support.
Code Reference
Source Location
- Repository: Facebookresearch_Audiocraft
- File: audiocraft/modules/conv.py
- Lines: 1-243
Signature
class NormConv1d(nn.Module):
def __init__(self, *args, causal: bool = False, norm: str = 'none',
norm_kwargs: tp.Dict = {}, **kwargs): ...
class NormConvTranspose1d(nn.Module):
def __init__(self, *args, causal: bool = False, norm: str = 'none',
norm_kwargs: tp.Dict = {}, **kwargs): ...
def pad1d(x: torch.Tensor, paddings: tp.Tuple[int, int],
mode: str = 'zero', value: float = 0.) -> torch.Tensor: ...
def unpad1d(x: torch.Tensor, paddings: tp.Tuple[int, int]) -> torch.Tensor: ...
Import
from audiocraft.modules.conv import NormConv1d, NormConvTranspose1d, pad1d, unpad1d
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| x | torch.Tensor | Yes | Input tensor (1D or 2D depending on conv type) |
| causal | bool | No | Enable causal (left) padding |
| norm | str | No | Normalization type: 'none', 'weight_norm', 'spectral_norm', 'time_group_norm' |
Outputs
| Name | Type | Description |
|---|---|---|
| output | torch.Tensor | Convolved and normalized output |