Spaces:
Sleeping

File size: 303 Bytes
c83d2d6
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
"""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))