MCPcopy Create free account
hub / github.com/tdrussell/diffusion-pipe / forward

Method forward

models/cosmos_predict2_modeling.py:772–786  ·  view source on GitHub ↗

Apply the Fourier feature transformation to the input tensor. Args: x (torch.Tensor): The input tensor. gain (float, optional): An additional gain factor applied during the forward pass. Defaults to 1. Returns: torch.Tensor: The transfor

(self, x: torch.Tensor, gain: float = 1.0)

Source from the content-addressed store, hash-verified

770 self.phases = 2 * np.pi * torch.rand(self.num_channels, generator=generator).to(self.freqs.device)
771
772 def forward(self, x: torch.Tensor, gain: float = 1.0) -> torch.Tensor:
773 """
774 Apply the Fourier feature transformation to the input tensor.
775
776 Args:
777 x (torch.Tensor): The input tensor.
778 gain (float, optional): An additional gain factor applied during the forward pass. Defaults to 1.
779
780 Returns:
781 torch.Tensor: The transformed tensor, with Fourier features applied.
782 """
783 in_dtype = x.dtype
784 x = x.to(torch.float32).ger(self.freqs.to(torch.float32)).add(self.phases.to(torch.float32))
785 x = x.cos().mul(self.gain * gain).to(in_dtype)
786 return x
787
788
789class PatchEmbed(nn.Module):

Callers

nothing calls this directly

Calls 2

addMethod · 0.80
toMethod · 0.45

Tested by

no test coverage detected