parameters: (op_type: str, attrs_list: Optional[List[str]] = None, mapping_to_xir=False)
return_statement: return decorate
docstring: The decorator is used to register the function as a custom operation.
    Args:
  	op_type(str): The operator type registered into quantizer. 
                  The type should not conflict with pytorch_nndct
                  
  	attrs_list(Optional[List[str]], optional): the name list of attributes that define operation flavor. 
                                                For example, Convolution operation has such attributes as padding, dilation, stride and groups. 
                                                The order of name in attrs_list should be consistent with that of the arguments list. 
                                                Default: None
docstring_summary: The decorator is used to register the function as a custom operation.
    Args:
  	op_type(str): The operator type registered into quantizer. 
                  The type should not conflict with pytorch_nndct
                  
  	attrs_list(Optional[List[str]], optional): the name list of attributes that define operation flavor. 
                                                For example, Convolution operation has such attributes as padding, dilation, stride and groups. 
                                                The order of name in attrs_list should be consistent with that of the arguments list. 
                                                Default: None
docstring_tokens: The decorator is used to register the function as a custom operation . Args : op_type ( str ) : The operator type registered into quantizer . The type should not conflict with pytorch_nndct attrs_list ( Optional [ List [ str ]] optional ) : the name list of attributes that define operation flavor . For example Convolution operation has such attributes as padding dilation stride and groups . The order of name in attrs_list should be consistent with that of the arguments list . Default : None
function: def register_custom_op(op_type: str, attrs_list: Optional[List[str]] = None, mapping_to_xir=False):
    """The decorator is used to register the function as a custom operation.
    Args:
  	op_type(str): The operator type registered into quantizer. 
                  The type should not conflict with pytorch_nndct
                  
  	attrs_list(Optional[List[str]], optional): the name list of attributes that define operation flavor. 
                                                For example, Convolution operation has such attributes as padding, dilation, stride and groups. 
                                                The order of name in attrs_list should be consistent with that of the arguments list. 
                                                Default: None
    
    """
    def decorate(func):    
      if op_type in NNDCT_OP.__dict__.values():
        NndctScreenLogger().error(f"'{op_type}' has been defined in pytorch_nndct, please use other type name.")     
        exit(1)                                                                                                                                                                                                                       
      if not inspect.isfunction(func):
        RuntimeError("This api only decorate a function object")
      
      custom_op_attr_map = GLOBAL_MAP.get_ele(NNDCT_KEYS.CUSTOM_OP_ATTRS_MAP)
      if custom_op_attr_map is None:
        custom_op_attr_map = {}
        GLOBAL_MAP.set_map(NNDCT_KEYS.CUSTOM_OP_ATTRS_MAP, custom_op_attr_map)
      if op_type in custom_op_attr_map:
        NndctScreenLogger().error(f"'{op_type}' can't be registered multiple times.")
      else:
        custom_op_attr_map[op_type] = attrs_list if attrs_list is not None else []
        
      if mapping_to_xir is True:
        custom2xir = GLOBAL_MAP.get_ele(NNDCT_KEYS.CUSTOM_TO_XIR_LIST)
        if custom2xir is None:
          custom2xir = []
          GLOBAL_MAP.set_map(NNDCT_KEYS.CUSTOM_TO_XIR_LIST, custom2xir)
        if op_type not in custom2xir:
          custom2xir.append(op_type) 
        else:
          raise RuntimeError(f"{op_type} has alrealy been mapped to XIR. Please use this op type instead of custom op.")
        
      @functools.wraps(func)
      def innner(*args, **kwargs):
        custom_op = types.new_class(op_type, (torch.autograd.Function,), {})
        custom_op.forward = staticmethod(func)
        return custom_op.apply(*args, **kwargs)
      return innner
    NndctScreenLogger().info(f'`{op_type}` has been registered as a custom op.')
    return decorate
function_tokens: def register_custom_op ( op_type : str , attrs_list : Optional [ List [ str ] ] = None , mapping_to_xir = False ) : def decorate ( func ) : if op_type in NNDCT_OP . __dict__ . values ( ) : NndctScreenLogger ( ) . error ( f"'{op_type}' has been defined in pytorch_nndct, please use other type name." ) exit ( 1 ) if not inspect . isfunction ( func ) : RuntimeError ( "This api only decorate a function object" ) custom_op_attr_map = GLOBAL_MAP . get_ele ( NNDCT_KEYS . CUSTOM_OP_ATTRS_MAP ) if custom_op_attr_map is None : custom_op_attr_map = { } GLOBAL_MAP . set_map ( NNDCT_KEYS . CUSTOM_OP_ATTRS_MAP , custom_op_attr_map ) if op_type in custom_op_attr_map : NndctScreenLogger ( ) . error ( f"'{op_type}' can't be registered multiple times." ) else : custom_op_attr_map [ op_type ] = attrs_list if attrs_list is not None else [ ] if mapping_to_xir is True : custom2xir = GLOBAL_MAP . get_ele ( NNDCT_KEYS . CUSTOM_TO_XIR_LIST ) if custom2xir is None : custom2xir = [ ] GLOBAL_MAP . set_map ( NNDCT_KEYS . CUSTOM_TO_XIR_LIST , custom2xir ) if op_type not in custom2xir : custom2xir . append ( op_type ) else : raise RuntimeError ( f"{op_type} has alrealy been mapped to XIR. Please use this op type instead of custom op." ) @ functools . wraps ( func ) def innner ( * args , * * kwargs ) : custom_op = types . new_class ( op_type , ( torch . autograd . Function , ) , { } ) custom_op . forward = staticmethod ( func ) return custom_op . apply ( * args , * * kwargs ) return innner NndctScreenLogger ( ) . info ( f'`{op_type}` has been registered as a custom op.' ) return decorate