TrainingExtensions/torch/src/python/aimet_torch/meta/connectedgraph.py
def _create_product_from_connection(product_name: str, connection: torch._C.TensorType,
                                    output_map: Dict[torch._C.TensorType, torch._C.TensorType]) -> Product:
    """
    Create connected graph product given a connection.
    :param product_name: Name of product to create
    :param connection: Connection to extract shape information from
    :param output_map: Mapping between higher level connections with corresponding lower level recursive connections.
        Only the base level connections carry shape information.
    :return: Product that was created
    """
    # Create product if it doesn't already exist. There is a limitation here, where two ops with multiple
    # unique connections linking the two will only result in one product being created. (For example, LSTM
    # with output, h, and c feeding into a second LSTM would show 3 unique connections). This behavior
    # matches the existing connected graph behavior, but is an item of possible rework in the future.

    # Get product shape
    shape = None
    if isinstance(connection.type(), torch._C.TensorType):
        shape = connection.type().sizes()
        if shape is None and connection in output_map:
            # Shape may be none if this is an output connection that was replaced from the output of a lower level
            # module. Look up the corresponding lowest level connection in output_map.
            if isinstance(output_map[connection].type(), torch._C.TensorType):
                shape = output_map[connection].type().sizes()

    product = Product(product_name, shape)
    return product

    Create connected graph product given a connection.
    :param product_name: Name of product to create
    :param connection: Connection to extract shape information from
    :param output_map: Mapping between higher level connections with corresponding lower level recursive connections.
        Only the base level connections carry shape information.
    :return: Product that was created
    
Create connected graph product given a connection.
Create connected graph product given a connection .
def _create_product_from_connection(product_name: str, connection: torch._C.TensorType,
                                    output_map: Dict[torch._C.TensorType, torch._C.TensorType]) -> Product:
    shape = None
    if isinstance(connection.type(), torch._C.TensorType):
        shape = connection.type().sizes()
        if shape is None and connection in output_map:
            if isinstance(output_map[connection].type(), torch._C.TensorType):
                shape = output_map[connection].type().sizes()
    product = Product(product_name, shape)
    return product
def _create_product_from_connection ( product_name : str , connection : torch . _C . TensorType , output_map : Dict [ torch . _C . TensorType , torch . _C . TensorType ] ) -> Product : shape = None if isinstance ( connection . type ( ) , torch . _C . TensorType ) : shape = connection . type ( ) . sizes ( ) if shape is None and connection in output_map : if isinstance ( output_map [ connection ] . type ( ) , torch . _C . TensorType ) : shape = output_map [ connection ] . type ( ) . sizes ( ) product = Product ( product_name , shape ) return product
Create connected graph product given a connection.
Create connected graph product given a connection .
"""
    Create connected graph product given a connection.
    :param product_name: Name of product to create
    :param connection: Connection to extract shape information from
    :param output_map: Mapping between higher level connections with corresponding lower level recursive connections.
        Only the base level connections carry shape information.
    :return: Product that was created
    """ # Create product if it doesn't already exist. There is a limitation here, where two ops with multiple # unique connections linking the two will only result in one product being created. (For example, LSTM # with output, h, and c feeding into a second LSTM would show 3 unique connections). This behavior # matches the existing connected graph behavior, but is an item of possible rework in the future. # Get product shape # Shape may be none if this is an output connection that was replaced from the output of a lower level # module. Look up the corresponding lowest level connection in output_map.
Product that was created
Product that was created
product_name
str
Name of product to create
Name of product to create
connection
torch._C.TensorType
Connection to extract shape information from
Connection to extract shape information from
output_map
Dict[torch._C.TensorType, torch._C.TensorType]
Mapping between higher level connections with corresponding lower level recursive connections.
Only the base level connections carry shape information.
Mapping between higher level connections with corresponding lower level recursive connections . Only the base level connections carry shape information .