(self, input, i_type)
| 197 | nn.init.uniform_(b, -bound, bound) |
| 198 | |
| 199 | def forward(self, input, i_type): |
| 200 | assert input.dtype == torch.float32 and i_type.dtype == torch.int64 |
| 201 | out = torch.empty(input.shape[0], self.out_features).fill_(np.nan).to(input) |
| 202 | for t, w in enumerate(self.weight): |
| 203 | idxs_this_type = (i_type == t).nonzero()[:, 0] |
| 204 | in_this_type = input[idxs_this_type] |
| 205 | out_this_type = in_this_type.matmul(w.t()) |
| 206 | if self.bias is not None: |
| 207 | out_this_type += self.bias[t] |
| 208 | out[idxs_this_type] = out_this_type |
| 209 | |
| 210 | return out |
| 211 | |
| 212 | # This is a correct but memory-intensive version of forward() |
| 213 | # def forward(self, input, i_type): |
nothing calls this directly
no outgoing calls
no test coverage detected