Attribute Utils

parallelformers.utils.attr_utils.igetattr(obj, attr, *args)[source]

Indexed getattr function

Examples

>>> model = Model()
>>> igetattr(model, "weight[2]")
parallelformers.utils.attr_utils.isetattr(obj, attr, val)[source]

Indexed setattr function

Examples

>>> model = Model()
>>> isetattr(model, "weight[2]", new_weight)
parallelformers.utils.attr_utils.rgetattr(obj, attr, default=None)[source]

Recursive getattr function based on igetattr

Examples

>>> model = Model()
>>> rgetattr(model, "layer[2].attention.weight[3].data")
parallelformers.utils.attr_utils.rsetattr(obj, attr, val)[source]

Recursive setattr function based on isetattr

Examples

>>> model = Model()
>>> rgetattr(model, "layer[2].attention.weight[3].data", new_data)
parallelformers.utils.attr_utils.rhasattr(obj, attr)[source]

Recursive hasattr function based on igetattr

Examples

>>> model = Model()
>>> rhasattr(model, "layer[2].attention.weight[3].data")
True