MCPcopy Index your code
hub / github.com/NVIDIA/TensorRT-LLM / gelu

Function gelu

tensorrt_llm/functional.py:3350–3362  ·  view source on GitHub ↗

Add a GELU operation. Parameters: input : Tensor The input tensor on which the activation function is applied. Returns: The tensor produced by the activation layer.

(x: Tensor)

Source from the content-addressed store, hash-verified

3348
3349
3350def gelu(x: Tensor) -> Tensor:
3351 '''
3352 Add a GELU operation.
3353
3354 Parameters:
3355 input : Tensor
3356 The input tensor on which the activation function is applied.
3357
3358 Returns:
3359 The tensor produced by the activation layer.
3360 '''
3361 return 0.5 * x * (
3362 tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * pow(x, 3.0))) + 1.0)
3363
3364
3365def geglu(x: Tensor) -> Tensor:

Callers 3

forwardMethod · 0.90
test_mlp_smooth_quantMethod · 0.85
gegluFunction · 0.85

Calls 1

sqrtMethod · 0.80

Tested by 1

test_mlp_smooth_quantMethod · 0.68