coreai_opt.inspection.ModuleInfo¶
- class coreai_opt.inspection.ModuleInfo(module_name, module_type, child_modules, ops, input_ops, output_ops)[source]¶
Bases:
objectA node in the
nn.Modulehierarchy with its directly-owned ops.Mirrors the
nn.Modulenesting structure: eachModuleInfoholds the ops that belong directly to that module and references its child modules as nestedModuleInfoinstances.- Parameters:
module_name (str)
module_type (str)
child_modules (dict[str, ModuleInfo])
ops (list[OpInfo])
input_ops (list[OpInfo])
output_ops (list[OpInfo])
- module_name¶
Fully-qualified module name (e.g.,
"encoder.conv1"). Empty string for the root module.- Type:
str
- module_type¶
Fully-qualified class name of the module (e.g.,
"torch.nn.modules.conv.Conv2d").- Type:
str
- child_modules¶
Child modules keyed by
module_name, in insertion order.- Type:
dict[str, ModuleInfo]
- __init__(module_name, module_type, child_modules, ops, input_ops, output_ops)¶
- Parameters:
module_name (str)
module_type (str)
child_modules (dict[str, ModuleInfo])
ops (list[OpInfo])
input_ops (list[OpInfo])
output_ops (list[OpInfo])
- Return type:
None
Methods
all_ops()Return all ops within this module and its submodules in graph order.
children()Yield direct child modules in insertion order.
get_submodule(module_name)Return a descendant module by its fully-qualified name.
modules()Yield this module and all descendant modules in depth-first order.
Yield
(module_name, ModuleInfo)for direct child modules.Yield
(module_name, ModuleInfo)for this module and all descendants.- all_ops()[source]¶
Return all ops within this module and its submodules in graph order.
- Return type:
list[OpInfo]
- children()[source]¶
Yield direct child modules in insertion order.
- Return type:
Iterator[ModuleInfo]
- get_submodule(module_name)[source]¶
Return a descendant module by its fully-qualified name.
- Parameters:
module_name (str) – Fully-qualified module name (e.g.,
"encoder.conv1").- Raises:
KeyError – If no module with the given name exists in this subtree.
- Return type:
- modules()[source]¶
Yield this module and all descendant modules in depth-first order.
- Return type:
Iterator[ModuleInfo]
- named_children()[source]¶
Yield
(module_name, ModuleInfo)for direct child modules.- Return type:
Iterator[tuple[str, ModuleInfo]]
- named_modules()[source]¶
Yield
(module_name, ModuleInfo)for this module and all descendants.- Return type:
Iterator[tuple[str, ModuleInfo]]
- child_modules: dict[str, ModuleInfo]¶
- module_name: str¶
- module_type: str¶