(self, inp: Tensor)
| 490 | return clip(table, 0, 255) |
| 491 | |
| 492 | def forward(self, inp: Tensor) -> Tensor: |
| 493 | if inp.dtype.name == "uint8": |
| 494 | if self.per_channel is True: |
| 495 | flatten_inp = reshape( |
| 496 | inp, (inp.shape[0] * inp.shape[1], inp.shape[2] * inp.shape[3]) |
| 497 | ).astype("int32") |
| 498 | else: |
| 499 | flatten_inp = flatten(inp, 1).astype("int32") |
| 500 | table = self._get_table(flatten_inp.shape[0]) |
| 501 | result = gather(table, 1, flatten_inp) |
| 502 | result = reshape(result, inp.shape).astype("uint8") |
| 503 | return result |
| 504 | else: |
| 505 | input_dtype = inp.dtype |
| 506 | _, center_value, _ = _get_value_range_of_dtype(input_dtype) |
| 507 | if self.per_channel is True: |
| 508 | size = (inp.shape[0], inp.shape[1], 1, 1) |
| 509 | else: |
| 510 | size = (inp.shape[0], 1, 1, 1) |
| 511 | alpha = self._get_parameter(self.alpha, size) |
| 512 | if input_dtype.kind in ["u", "i"]: |
| 513 | center_value = int(center_value) |
| 514 | result = center_value + mul(inp.astype("float32") - center_value, alpha) |
| 515 | result = result.astype(input_dtype) |
| 516 | return result |
| 517 | |
| 518 | |
| 519 | class Mixup(Module): |
nothing calls this directly
no test coverage detected