| 222 | return qx |
| 223 | |
| 224 | def round_n2f3(self, q_pos, q_neg, dev): |
| 225 | q_pos = torch.where(q_pos >= 0.8114928305149078, torch.tensor(1.0).to(dev), q_pos) |
| 226 | q_pos = torch.where((q_pos < 0.8114928305149078) & (q_pos >= 0.5024898052215576), torch.tensor(0.6229856610298157).to(dev), q_pos) |
| 227 | q_pos = torch.where((q_pos < 0.5024898052215576) & (q_pos >= 0.2826657369732857), torch.tensor(0.3819939494132996).to(dev), q_pos) |
| 228 | q_pos = torch.where((q_pos < 0.2826657369732857) & (q_pos >= 0.0916687622666359), torch.tensor(0.1833375245332718).to(dev), q_pos) |
| 229 | q_pos = torch.where(q_pos < 0.0916687622666359, torch.tensor(0).to(dev), q_pos) |
| 230 | |
| 231 | q_neg = torch.where(q_neg >= -0.1234657019376755, torch.tensor(0).to(dev), q_neg) |
| 232 | q_neg = torch.where((q_neg < -0.1234657019376755) & (q_neg >= -0.39097706973552704), torch.tensor(-0.2469314038753510).to(dev), q_neg) |
| 233 | q_neg = torch.where((q_neg < -0.39097706973552704) & (q_neg >= -0.7675113677978516), torch.tensor(-0.5350227355957031).to(dev), q_neg) |
| 234 | q_neg = torch.where(q_neg < -0.7675113677978516, torch.tensor(-1.0).to(dev), q_neg) |
| 235 | |
| 236 | return q_pos, q_neg |
| 237 | |
| 238 | def round_pass(self, q_pos, q_neg, dev): |
| 239 | y_grad_pos, y_grad_neg = q_pos, q_neg |