SPAC-4B-ZeroGPU / spac /sparse /linear.py
Jack04810's picture
Build and validate native SPAC extensions for ZeroGPU Blackwell
c83d2d6 verified
Raw History Blame Contribute Delete
303 Bytes
"""Apply a linear layer to sparse feature rows."""
import torch.nn as nn
from . import SparseTensor
class SparseLinear(nn.Linear):
def forward(self, value: SparseTensor) -> SparseTensor:
features = value.feats.to(self.weight.dtype)
return value.replace(super().forward(features))