optimum/graphcore/modeling_utils.py
def outline_attribute(module: nn.Module, value: str):
    """Adds an attribute to a module. This attribute will be used
    when comparing operation equivalence in outlining. For example:

    layer1 = nn.Linear(...)
    layer2 = nn.Linear(...)
    layer3 = nn.Linear(...)
    layer4 = nn.Linear(...)
    outline_attribute(layer1, "A")
    outline_attribute(layer2, "A")
    outline_attribute(layer3, "B")

    The code for layer1 can be reused for layer2.
    But it can't be used for layer3 or layer4.
    """
    context = poptorch.Attribute(__outline={"layer": value})

    def enable(*args):
        context.__enter__()

    def disable(*args):
        context.__exit__(None, None, None)

    handles = []
    handles.append(module.register_forward_pre_hook(enable))
    handles.append(module.register_forward_hook(disable))
    return handles
Adds an attribute to a module. This attribute will be used
    when comparing operation equivalence in outlining. For example:

    layer1 = nn.Linear(...)
    layer2 = nn.Linear(...)
    layer3 = nn.Linear(...)
    layer4 = nn.Linear(...)
    outline_attribute(layer1, "A")
    outline_attribute(layer2, "A")
    outline_attribute(layer3, "B")

    The code for layer1 can be reused for layer2.
    But it can't be used for layer3 or layer4.
    
Adds an attribute to a module. This attribute will be used
when comparing operation equivalence in outlining. For example.



The code for layer1 can be reused for layer2.
But it can't be used for layer3 or layer4.
Adds an attribute to a module . This attribute will be used when comparing operation equivalence in outlining . For example . The code for layer1 can be reused for layer2 . But it can ' t be used for layer3 or layer4 .
def outline_attribute(module: nn.Module, value: str):
    context = poptorch.Attribute(__outline={"layer": value})
    def enable(*args):
        context.__enter__()
    def disable(*args):
        context.__exit__(None, None, None)
    handles = []
    handles.append(module.register_forward_pre_hook(enable))
    handles.append(module.register_forward_hook(disable))
    return handles
def outline_attribute ( module : nn . Module , value : str ) : context = poptorch . Attribute ( __outline = { "layer" : value } ) def enable ( * args ) : context . __enter__ ( ) def disable ( * args ) : context . __exit__ ( None , None , None ) handles = [ ] handles . append ( module . register_forward_pre_hook ( enable ) ) handles . append ( module . register_forward_hook ( disable ) ) return handles
Adds an attribute to a module.
Adds an attribute to a module .
"""Adds an attribute to a module. This attribute will be used
    when comparing operation equivalence in outlining. For example:

    layer1 = nn.Linear(...)
    layer2 = nn.Linear(...)
    layer3 = nn.Linear(...)
    layer4 = nn.Linear(...)
    outline_attribute(layer1, "A")
    outline_attribute(layer2, "A")
    outline_attribute(layer3, "B")

    The code for layer1 can be reused for layer2.
    But it can't be used for layer3 or layer4.
    """
module
nn.Module
value
str