(ctx, input)
| 78 | class STE_binary(torch.autograd.Function): |
| 79 | @staticmethod |
| 80 | def forward(ctx, input): |
| 81 | ctx.save_for_backward(input) |
| 82 | input = torch.clamp(input, min=-1, max=1) |
| 83 | # out = torch.sign(input) |
| 84 | p = (input >= 0) * (+1.0) |
| 85 | n = (input < 0) * (-1.0) |
| 86 | out = p + n |
| 87 | return out |
| 88 | @staticmethod |
| 89 | def backward(ctx, grad_output): |
| 90 | # mask: to ensure x belongs to (-1, 1) |
nothing calls this directly
no outgoing calls
no test coverage detected