parameters: (self)
docstring: Add input_names, attr_names, primitive_target to primitive's attr.
docstring_summary: Add input_names, attr_names, primitive_target to primitive's attr.
docstring_tokens: Add input_names attr_names primitive_target to primitive s attr .
function: def _update_attr(self):
          """Add input_names, attr_names, primitive_target to primitive's attr."""
          # add input_names, attr_names
          func_attr = {}
          if callable(self.func):
              func_attr = getattr(self.func, "func_attr", None)
          elif isinstance(self.func, str):
              func_attr = Custom.attr_dict.get(self.func)
          if isinstance(func_attr, dict):
              input_names = func_attr.get("input_names")
              attr_names = func_attr.get("attr_names")
              if input_names:
                  self.add_prim_attr("input_names", input_names)
              if attr_names:
                  self.add_prim_attr("attr_names", attr_names)
          # add primitive_target
          registered_targets = self._get_registered_targets()
          if self.func_type == "pyfunc":
              self.add_prim_attr("primitive_target", "CPU")
              if registered_targets and registered_targets != ["CPU"]:
                  logger.warning("CustomPyfunc only supports CPU platform, but gets registered target as {}."
                                 "We will run CustomPyfunc on CPU".format(registered_targets))
          elif self.func_type == "aot":
              if len(registered_targets) != 1:
                  logger.info("Target of CustomAOT will be set according to context.")
              elif registered_targets == ["GPU"]:
                  self.add_prim_attr("primitive_target", "GPU")
              elif registered_targets == ["CPU"]:
                  self.add_prim_attr("primitive_target", "CPU")
          if callable(self.func) and callable(self.out_shape):
              if hasattr(self.out_shape, "type") and getattr(self.out_shape, "type") == "autodiff":
                  self.add_prim_attr("autodiff", True)
          else:
              self.add_prim_attr("autodiff", False)
function_tokens: def _update_attr ( self ) : # add input_names, attr_names func_attr = { } if callable ( self . func ) : func_attr = getattr ( self . func , "func_attr" , None ) elif isinstance ( self . func , str ) : func_attr = Custom . attr_dict . get ( self . func ) if isinstance ( func_attr , dict ) : input_names = func_attr . get ( "input_names" ) attr_names = func_attr . get ( "attr_names" ) if input_names : self . add_prim_attr ( "input_names" , input_names ) if attr_names : self . add_prim_attr ( "attr_names" , attr_names ) # add primitive_target registered_targets = self . _get_registered_targets ( ) if self . func_type == "pyfunc" : self . add_prim_attr ( "primitive_target" , "CPU" ) if registered_targets and registered_targets != [ "CPU" ] : logger . warning ( "CustomPyfunc only supports CPU platform, but gets registered target as {}." "We will run CustomPyfunc on CPU" . format ( registered_targets ) ) elif self . func_type == "aot" : if len ( registered_targets ) != 1 : logger . info ( "Target of CustomAOT will be set according to context." ) elif registered_targets == [ "GPU" ] : self . add_prim_attr ( "primitive_target" , "GPU" ) elif registered_targets == [ "CPU" ] : self . add_prim_attr ( "primitive_target" , "CPU" ) if callable ( self . func ) and callable ( self . out_shape ) : if hasattr ( self . out_shape , "type" ) and getattr ( self . out_shape , "type" ) == "autodiff" : self . add_prim_attr ( "autodiff" , True ) else : self . add_prim_attr ( "autodiff" , False )