MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT-LLM / replace_input_with

Method replace_input_with

tensorrt_llm/graph_rewriting.py:373–392  ·  view source on GitHub ↗

Replace the input `src` with the input `dst` in the raw_inputs. src: Tensor dst: Tensor

(self, src, dst)

Source from the content-addressed store, hash-verified

371 return copy(self.raw_inputs)
372
373 def replace_input_with(self, src, dst):
374 """Replace the input `src` with the input `dst` in the raw_inputs.
375
376 src: Tensor
377 dst: Tensor
378 """
379 from .functional import Tensor
380
381 def replace(arg: Any):
382 if isinstance(arg, Tensor):
383 if arg.trt_tensor is src.trt_tensor:
384 return dst
385 return arg
386 elif isinstance(arg, (list, tuple)):
387 return [replace(x) for x in arg]
388 elif isinstance(arg, dict):
389 return {k: replace(v) for k, v in arg.items()}
390 return arg
391
392 replace(self.raw_inputs)
393
394 def replace_outputs_uses_with(self, net: Network, new_outs: List[Any]):
395 """Replace the output users with the new outputs.

Callers 7

replace_all_uses_withMethod · 0.80
_applyMethod · 0.80
applyMethod · 0.80
_shard_parameter_nodeFunction · 0.80
_insert_sharded_moeFunction · 0.80
_applyMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected