MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / fill_paddle_tensor

Function fill_paddle_tensor

fastdeploy/utils.py:1296–1317  ·  view source on GitHub ↗

Fill a paddle tensor with the given value. Args: shared_inputs_object: Either an object with attributes or a dictionary key: The key/attribute name to access value: The value to fill the tensor with

(shared_inputs_object, key, value)

Source from the content-addressed store, hash-verified

1294
1295
1296def fill_paddle_tensor(shared_inputs_object, key, value):
1297 """
1298 Fill a paddle tensor with the given value.
1299
1300 Args:
1301 shared_inputs_object: Either an object with attributes or a dictionary
1302 key: The key/attribute name to access
1303 value: The value to fill the tensor with
1304 """
1305 try:
1306 # Handle both dictionary-style and object-style access
1307 if hasattr(shared_inputs_object, key):
1308 attr = getattr(shared_inputs_object, key)
1309 elif hasattr(shared_inputs_object, "__getitem__") and key in shared_inputs_object:
1310 attr = shared_inputs_object[key]
1311 else:
1312 return
1313
1314 if isinstance(attr, paddle.Tensor):
1315 attr.fill_(value)
1316 except Exception as e:
1317 llm_logger.warning(f"Failed to fill key {key} with value {value}: {e}")
1318
1319
1320if hasattr(paddle.static, "register_op"):

Callers 2

reset_share_inputsMethod · 0.90
reset_model_inputsMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected