MCPcopy Create free account
hub / github.com/evilsocket/cake / causal_pad

Method causal_pad

cake-core/src/models/vibevoice/vae_decoder.rs:372–378  ·  view source on GitHub ↗

Apply causal left-padding to a tensor: zero-pad `amount` on the left of dim 2.

(x: &Tensor, amount: usize)

Source from the content-addressed store, hash-verified

370
371 /// Apply causal left-padding to a tensor: zero-pad `amount` on the left of dim 2.
372 fn causal_pad(x: &Tensor, amount: usize) -> Result<Tensor> {
373 if amount == 0 {
374 return Ok(x.clone());
375 }
376 let pad = Tensor::zeros((x.dim(0)?, x.dim(1)?, amount), x.dtype(), x.device())?;
377 Tensor::cat(&[&pad, x], 2)
378 }
379
380 /// Trim causal ConvTranspose1d output to remove extra samples.
381 /// ConvTranspose1d with kernel=2*stride, stride=S, padding=0 produces:

Callers

nothing calls this directly

Calls 3

dtypeMethod · 0.80
cloneMethod · 0.45
deviceMethod · 0.45

Tested by

no test coverage detected