Add the softplus activation base on PyTorch definition. See https://pytorch.org/docs/stable/generated/torch.nn.functional.softplus.html#torch-nn-functional-softplus for a description of that function. Parameters: input : Tensor Input TensorRT LLM Tensor.
(input: Tensor, beta: float, threshold: float)
| 3461 | |
| 3462 | |
| 3463 | def softplus(input: Tensor, beta: float, threshold: float) -> Tensor: |
| 3464 | ''' |
| 3465 | Add the softplus activation base on PyTorch definition. |
| 3466 | |
| 3467 | See https://pytorch.org/docs/stable/generated/torch.nn.functional.softplus.html#torch-nn-functional-softplus for a |
| 3468 | description of that function. |
| 3469 | |
| 3470 | Parameters: |
| 3471 | input : Tensor |
| 3472 | Input TensorRT LLM Tensor. |
| 3473 | beta : float |
| 3474 | The parameter for softplus computation. |
| 3475 | threshold : float |
| 3476 | The threshold for reverting to the linear function when input * beta > threshold |
| 3477 | |
| 3478 | Returns: |
| 3479 | The output tensor created by that layer. |
| 3480 | ''' |
| 3481 | sf_layer = default_trtnet().add_activation(input.trt_tensor, |
| 3482 | trt.ActivationType.SOFTPLUS) |
| 3483 | sf_layer.alpha = 1 / beta |
| 3484 | sf_layer.beta = beta |
| 3485 | |
| 3486 | prod_tensor = input * beta |
| 3487 | result = prod_tensor > threshold |
| 3488 | |
| 3489 | return where(result, input, _create_tensor(sf_layer.get_output(0), |
| 3490 | sf_layer)) |
| 3491 | |
| 3492 | |
| 3493 | def outer(input: Tensor, vec2: Tensor) -> Tensor: |
nothing calls this directly
no test coverage detected