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

Function geglu

tensorrt_llm/functional.py:3365–3381  ·  view source on GitHub ↗

Add a Gated-GELU operation. That function takes a tensor, splits it into two halves along the last dimension, applies GELU to the second half and multiply the results. The behavior is undefined if the last dimension is not even. Parameters: input : Tensor T

(x: Tensor)

Source from the content-addressed store, hash-verified

3363
3364
3365def geglu(x: Tensor) -> Tensor:
3366 '''
3367 Add a Gated-GELU operation.
3368
3369 That function takes a tensor, splits it into two halves along the last
3370 dimension, applies GELU to the second half and multiply the results. The
3371 behavior is undefined if the last dimension is not even.
3372
3373 Parameters:
3374 input : Tensor
3375 The input tensor on which the activation function is applied.
3376
3377 Returns:
3378 The tensor produced by the activation layer.
3379 '''
3380 a, b = chunk(x, 2, dim=-1)
3381 return a * gelu(b)
3382
3383
3384def quick_gelu(x: Tensor) -> Tensor:

Callers 1

forwardMethod · 0.50

Calls 2

chunkFunction · 0.85
geluFunction · 0.85

Tested by

no test coverage detected