Skip to main content

ClikaRT::ops::snake

function

snake()

Tensor snake(
    Tensor x,
    OptionalTensor alpha = {},
    OptionalTensor beta = {},
    double eps = 1e-9
)

Periodic "snake" activation (neural vocoders), per channels-last channel.

snake(x)c=x+sin2(αcx)βc+ε\mathrm{snake}(x)_{\ldots c} = x + \frac{\sin^2(\alpha_c \, x)}{\beta_c + \varepsilon}

alpha (frequency) and beta (magnitude) are rank-1 [C] tensors over x's last dim, in the REAL domain. Apply exp once at setup for a log-scale checkpoint parameterization. beta absent selects the plain form (beta = alpha). One fused pass; the composed spelling costs five elementwise calls over the whole stream.

Parameters

  • x: the input tensor, channels-last [..., C].
  • alpha: the [C] frequency tensor. Absent uses the alpha held by the bound primitive (module usage).
  • beta: the [C] magnitude tensor. Absent selects the plain form.
  • eps: the no-division-by-zero guard added to beta.

Throws

  • ClikaRT::Error: when a param's length does not match x's last dim, when alpha is absent with none bound, or when the dtype is not served (code_name() carries the reason).

Returns: a new tensor, same shape and dtype as x.

auto y = ClikaRT::ops::snake(x, freq, magnitude); // freq/magnitude: [C]

Declared in ClikaRT/compute/ops.h, line 1032