Skip to content

Commit 8b1e44d

Browse files
committed
docstrings
Signed-off-by: Gal Hubara Agam <96368689+galagam@users.noreply.github.com>
1 parent 74d11fc commit 8b1e44d

File tree

1 file changed

+32
-0
lines changed
  • tensorrt_llm/_torch/auto_deploy/utils

1 file changed

+32
-0
lines changed

tensorrt_llm/_torch/auto_deploy/utils/_graph.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,19 +404,51 @@ def get_lm_head_weights(model: nn.Module) -> torch.Tensor:
404404

405405

406406
def get_attr_by_name(obj, name):
407+
"""Get an attribute specified by a dot-separated path on an object.
408+
409+
Args:
410+
obj: The root object from which to resolve the attribute path.
411+
name (str): Dot-separated attribute path (e.g., "a.b.c").
412+
413+
Returns:
414+
The value of the resolved attribute.
415+
416+
Raises:
417+
AttributeError: If any component in the path does not exist.
418+
"""
407419
for part in name.split("."):
408420
obj = getattr(obj, part)
409421
return obj
410422

411423

412424
def set_attr_by_name(obj, name, value):
425+
"""Set an attribute specified by a dot-separated path on an object.
426+
427+
Args:
428+
obj: The root object on which to set the attribute.
429+
name (str): Dot-separated attribute path (e.g., "a.b.c").
430+
value: The value to assign to the target attribute.
431+
432+
Raises:
433+
AttributeError: If any intermediate component in the path does not exist.
434+
"""
413435
parts = name.split(".")
414436
for part in parts[:-1]:
415437
obj = getattr(obj, part)
416438
setattr(obj, parts[-1], value)
417439

418440

419441
def del_attr_by_name(obj, name):
442+
"""Delete an attribute specified by a dot-separated path from an object.
443+
444+
Args:
445+
obj: The root object from which to delete the attribute.
446+
name (str): Dot-separated attribute path (e.g., "a.b.c").
447+
448+
Raises:
449+
AttributeError: If any intermediate component in the path does not exist
450+
or if the final attribute does not exist.
451+
"""
420452
parts = name.split(".")
421453
for part in parts[:-1]:
422454
obj = getattr(obj, part)

0 commit comments

Comments
 (0)