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

Function isinstance_namedtuple

deepspeed/runtime/zero/utils.py:145–156  ·  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

143
144
145def isinstance_namedtuple(obj: object) -> bool:
146 """
147 Is this an instance of namedtuple/NamedTuple?
148 From: https://stackoverflow.com/a/62692640
149
150 Args:
151 obj (object): An object.
152
153 Returns:
154 bool: True if namedtuple/NamedTuple else False.
155 """
156 return isinstance(obj, tuple) and hasattr(obj, '_asdict') and hasattr(obj, '_fields')
157
158
159def is_zero_param(parameter):

Callers 1

apply_to_tensors_onlyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected