MCPcopy
hub / github.com/NVIDIA/TensorRT-LLM / clip

Function clip

tensorrt_llm/functional.py:798–819  ·  view source on GitHub ↗

Add a CLIP operation that sets the range to [alpha, beta]. Parameters: input : Tensor The input tensor on which the activation function is applied. alpha : float The lower bound of the CLIP function. beta : float The upper bound

(input: Tensor, alpha: float, beta: float)

Source from the content-addressed store, hash-verified

796
797
798def clip(input: Tensor, alpha: float, beta: float) -> Tensor:
799 '''
800 Add a CLIP operation that sets the range to [alpha, beta].
801
802 Parameters:
803 input : Tensor
804 The input tensor on which the activation function is applied.
805
806 alpha : float
807 The lower bound of the CLIP function.
808
809 beta : float
810 The upper bound of the CLIP function.
811
812 Returns:
813 The tensor produced by the activation layer.
814 '''
815 layer = default_trtnet().add_activation(input.trt_tensor,
816 trt.ActivationType.CLIP)
817 layer.alpha = alpha
818 layer.beta = beta
819 return _create_tensor(layer.get_output(0), layer)
820
821
822relu = partial(activation, act_type=trt.ActivationType.RELU)

Callers 5

gegeluFunction · 0.70
quantize_per_tokenFunction · 0.50
quantize_fp8_per_tokenFunction · 0.50
quantize_tensorFunction · 0.50
forwardMethod · 0.50

Calls 3

default_trtnetFunction · 0.85
_create_tensorFunction · 0.85
get_outputMethod · 0.45

Tested by

no test coverage detected