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

Function gather_nd

tensorrt_llm/functional.py:2313–2333  ·  view source on GitHub ↗

Adds a layer that performs a gather with some element-wise dimensions. See: https://onnx.ai/onnx/operators/onnx__GatherND.html The gather is performed on dim=batch_dims. Parameters: input: Tensor The tensor on which the gather operation is performed. ind

(input: Tensor, indices: Tensor, batch_dims: int = 1)

Source from the content-addressed store, hash-verified

2311
2312
2313def gather_nd(input: Tensor, indices: Tensor, batch_dims: int = 1) -> Tensor:
2314 '''
2315 Adds a layer that performs a gather with some element-wise dimensions.
2316 See: https://onnx.ai/onnx/operators/onnx__GatherND.html
2317 The gather is performed on dim=batch_dims.
2318
2319 Parameters:
2320 input: Tensor
2321 The tensor on which the gather operation is performed.
2322 indices: Tensor
2323 The tensor that indicates which entries to be gathered.
2324 batch_dims: int
2325 The number of first dimensions that should be skipped before gather starts.
2326 Returns:
2327 A tensor created by the gather layer with GatherMode.ND.
2328 '''
2329 gather_layer = default_trtnet().add_gather_v2(input.trt_tensor,
2330 indices.trt_tensor,
2331 mode=trt.GatherMode.ND)
2332 gather_layer.num_elementwise_dims = batch_dims
2333 return _create_tensor(gather_layer.get_output(0), gather_layer)
2334
2335
2336def nonzero(input: Tensor) -> Tensor:

Callers 5

_unpack_beamsFunction · 0.90
_get_draft_token_arrayFunction · 0.90
_gather_beamsFunction · 0.90
_process_gen_logitsFunction · 0.90
forward_expertsMethod · 0.85

Calls 3

default_trtnetFunction · 0.85
_create_tensorFunction · 0.85
get_outputMethod · 0.45

Tested by

no test coverage detected