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

Method replace_all_uses_with

tensorrt_llm/functional.py:556–573  ·  view source on GitHub ↗

Replace all uses of this tensor as an input to consumer layers

(self, new_tensor)

Source from the content-addressed store, hash-verified

554 return self.network.get_tensor_users(self)
555
556 def replace_all_uses_with(self, new_tensor):
557 '''
558 Replace all uses of this tensor as an input to consumer layers
559 '''
560
561 self.network.is_graph_altered = True
562 users = self.get_users()
563 for user in users:
564 inputs_changed = 0
565 for i in range(user.num_inputs):
566 if user.get_inputs(i)[0].trt_tensor is self.trt_tensor:
567 inputs_changed += 1
568 user.set_input(i, new_tensor.trt_tensor)
569 assert inputs_changed >= 1, "Tensor not found in layer inputs"
570
571 # update the FLayerMetadata as well
572 flayer = gw.FLayerInfoMemo.instance().get(user.name)
573 flayer and flayer.replace_input_with(self, new_tensor)
574
575 def is_trt_wrapper(self):
576 '''

Callers 15

rewriteMethod · 0.45
recover_passFunction · 0.45
remove_output_quantizersFunction · 0.45
_process_moe_nodeFunction · 0.45
_applyMethod · 0.45
_applyMethod · 0.45
_stack_fp8_moe_weightsFunction · 0.45
_stack_nvfp4_moe_weightsFunction · 0.45
_applyMethod · 0.45

Calls 5

get_usersMethod · 0.95
replace_input_withMethod · 0.80
get_inputsMethod · 0.45
getMethod · 0.45
instanceMethod · 0.45

Tested by 2

rewriteMethod · 0.36