MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / isinstance_namedtuple

Function isinstance_namedtuple

deepspeed/runtime/zero/utils.py:136–147  ·  view source on GitHub ↗

Is this an instance of namedtuple/NamedTuple? From: https://stackoverflow.com/a/62692640 Args: obj (object): An object. Returns: bool: True if namedtuple/NamedTuple else False.

(obj: object)

Source from the content-addressed store, hash-verified

134
135
136def isinstance_namedtuple(obj: object) -> bool:
137 """
138 Is this an instance of namedtuple/NamedTuple?
139 From: https://stackoverflow.com/a/62692640
140
141 Args:
142 obj (object): An object.
143
144 Returns:
145 bool: True if namedtuple/NamedTuple else False.
146 """
147 return isinstance(obj, tuple) and hasattr(obj, '_asdict') and hasattr(obj, '_fields')
148
149
150def is_zero_param(parameter):

Callers 1

apply_to_tensors_onlyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected