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)
| 1294 | |
| 1295 | |
| 1296 | def 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 | |
| 1320 | if hasattr(paddle.static, "register_op"): |
no outgoing calls
no test coverage detected