TrainingExtensions/torch/src/python/aimet_torch/meta/connectedgraph.py
def _generate_module_tensor_shapes_lookup_table(model: torch.nn.Module,
                                                    model_input: Union[torch.Tensor, Tuple]) -> \
            ModuleTensorShapeMapType:
        """
        Generates a look up dictionary for getting module input and output shapes from the module.
        :param model: Pytorch model
        :param model_input: Input to run through forward pass
        :return: Map of modules and input and output tensor shapes obtained from a forward pass
        """
        module_tensor_shapes_map = {}

        def forward_hook(curr_module: torch.nn.Module,
                         inputs: Union[torch.Tensor, List, Dict, None],
                         outputs: Union[torch.Tensor, List, Dict, None]):
            """
            Custom forward hook function to add every module to module-to-tensor shapes dict.
            :param curr_module: Current module being traversed during forward pass.
            :param inputs: tuple of input tensors to the current module
            :param outputs: tuple of output tensors of the current module
            """
            input_shapes = _get_module_tensor_shapes_entry(inputs)
            output_shapes = _get_module_tensor_shapes_entry(outputs)
            if not isinstance(input_shapes, List):
                input_shapes = [input_shapes]
            if not isinstance(output_shapes, List):
                output_shapes = [output_shapes]
            module_tensor_shapes_map[curr_module] = (input_shapes, output_shapes)

        run_hook_for_layers_with_given_input(model, model_input, forward_hook, leaf_node_only=False)

        return module_tensor_shapes_map

        Generates a look up dictionary for getting module input and output shapes from the module.
        :param model: Pytorch model
        :param model_input: Input to run through forward pass
        :return: Map of modules and input and output tensor shapes obtained from a forward pass
        
Generates a look up dictionary for getting module input and output shapes from the module.
Generates a look up dictionary for getting module input and output shapes from the module .
def _generate_module_tensor_shapes_lookup_table(model: torch.nn.Module,
                                                    model_input: Union[torch.Tensor, Tuple]) -> \
            ModuleTensorShapeMapType:
        module_tensor_shapes_map = {}
        def forward_hook(curr_module: torch.nn.Module,
                         inputs: Union[torch.Tensor, List, Dict, None],
                         outputs: Union[torch.Tensor, List, Dict, None]):
            input_shapes = _get_module_tensor_shapes_entry(inputs)
            output_shapes = _get_module_tensor_shapes_entry(outputs)
            if not isinstance(input_shapes, List):
                input_shapes = [input_shapes]
            if not isinstance(output_shapes, List):
                output_shapes = [output_shapes]
            module_tensor_shapes_map[curr_module] = (input_shapes, output_shapes)
        run_hook_for_layers_with_given_input(model, model_input, forward_hook, leaf_node_only=False)
        return module_tensor_shapes_map
def _generate_module_tensor_shapes_lookup_table ( model : torch . nn . Module , model_input : Union [ torch . Tensor , Tuple ] ) -> ModuleTensorShapeMapType : module_tensor_shapes_map = { } def forward_hook ( curr_module : torch . nn . Module , inputs : Union [ torch . Tensor , List , Dict , None ] , outputs : Union [ torch . Tensor , List , Dict , None ] ) : """
            Custom forward hook function to add every module to module-to-tensor shapes dict.
            :param curr_module: Current module being traversed during forward pass.
            :param inputs: tuple of input tensors to the current module
            :param outputs: tuple of output tensors of the current module
            """ input_shapes = _get_module_tensor_shapes_entry ( inputs ) output_shapes = _get_module_tensor_shapes_entry ( outputs ) if not isinstance ( input_shapes , List ) : input_shapes = [ input_shapes ] if not isinstance ( output_shapes , List ) : output_shapes = [ output_shapes ] module_tensor_shapes_map [ curr_module ] = ( input_shapes , output_shapes ) run_hook_for_layers_with_given_input ( model , model_input , forward_hook , leaf_node_only = False ) return module_tensor_shapes_map
Generates a look up dictionary for getting module input and output shapes from the module.
Generates a look up dictionary for getting module input and output shapes from the module .
"""
        Generates a look up dictionary for getting module input and output shapes from the module.
        :param model: Pytorch model
        :param model_input: Input to run through forward pass
        :return: Map of modules and input and output tensor shapes obtained from a forward pass
        """ """
            Custom forward hook function to add every module to module-to-tensor shapes dict.
            :param curr_module: Current module being traversed during forward pass.
            :param inputs: tuple of input tensors to the current module
            :param outputs: tuple of output tensors of the current module
            """
Map of modules and input and output tensor shapes obtained from a forward pass
Map of modules and input and output tensor shapes obtained from a forward pass
model
torch.nn.Module
None
model_input
Union[torch.Tensor, Tuple]
Input to run through forward pass
Input to run through forward pass