utils¶
-
fn_args_to_dict(func, *args, **kwargs)[source]¶ Inspect function
funcand its arguments for running, and extract a dict mapping between argument names and keys.
-
class
InitTrackerMeta(name, bases, attrs)[source]¶ Bases:
pybind11_builtins.pybind11_typeThis metaclass wraps the
__init__method of a class to addinit_configattribute for instances of that class, andinit_configuse a dict to track the initial configuration. If the class has_wrap_initmethod, it would be hooked after__init__and called as_wrap_init(self, init_fn, init_args). Since InitTrackerMeta would be used as metaclass for pretrained model classes, which always are Layer andtype(Layer)is nottype, thus usetype(Layer)rather thantypeas base class for it to avoid inheritance metaclass conflicts.-
static
init_and_track_conf(init_func, help_func=None)[source]¶ wraps
init_funcwhich is__init__method of a class to addinit_configattribute for instances of that class. :param init_func: It should be the__init__method of a class. :type init_func: callable :param help_func: If provided, it would be hooked afterinit_funcand called as_wrap_init(self, init_func, *init_args, **init_args). Default None.- Returns
the wrapped function
- Return type
function
-
static