parameters: (net_dict, model, file_name, is_encrypt, **kwargs)
docstring: Save graph and parameter together.
docstring_summary: Save graph and parameter together.
docstring_tokens: Save graph and parameter together .
function: def _save_mindir_together(net_dict, model, file_name, is_encrypt, **kwargs):
      """Save graph and parameter together."""
      for param_proto in model.graph.parameter:
          param_name = param_proto.name[param_proto.name.find(":") + 1:]
          if param_name in net_dict.keys():
              param_data = net_dict[param_name].data.asnumpy().tobytes()
              param_proto.raw_data = param_data
          else:
              logger.critical("The parameter %s in the graph should also be defined in the network.", param_name)
              raise ValueError("The parameter {} in the graph should also be defined in the "
                               "network.".format(param_name))
      if not file_name.endswith('.mindir'):
          file_name += ".mindir"
      current_path = os.path.abspath(file_name)
      dirname = os.path.dirname(current_path)
      os.makedirs(dirname, exist_ok=True)
      if os.path.exists(file_name):
          os.chmod(file_name, stat.S_IWUSR)
      with open(file_name, 'wb') as f:
          os.chmod(file_name, stat.S_IRUSR | stat.S_IWUSR)
          model_string = model.SerializeToString()
          if is_encrypt():
              model_string = _encrypt(model_string, len(model_string), kwargs['enc_key'], len(kwargs['enc_key']),
                                      kwargs['enc_mode'])
          f.write(model_string)
          os.chmod(file_name, stat.S_IRUSR)
function_tokens: def _save_mindir_together ( net_dict , model , file_name , is_encrypt , * * kwargs ) : for param_proto in model . graph . parameter : param_name = param_proto . name [ param_proto . name . find ( ":" ) + 1 : ] if param_name in net_dict . keys ( ) : param_data = net_dict [ param_name ] . data . asnumpy ( ) . tobytes ( ) param_proto . raw_data = param_data else : logger . critical ( "The parameter %s in the graph should also be defined in the network." , param_name ) raise ValueError ( "The parameter {} in the graph should also be defined in the " "network." . format ( param_name ) ) if not file_name . endswith ( '.mindir' ) : file_name += ".mindir" current_path = os . path . abspath ( file_name ) dirname = os . path . dirname ( current_path ) os . makedirs ( dirname , exist_ok = True ) if os . path . exists ( file_name ) : os . chmod ( file_name , stat . S_IWUSR ) with open ( file_name , 'wb' ) as f : os . chmod ( file_name , stat . S_IRUSR | stat . S_IWUSR ) model_string = model . SerializeToString ( ) if is_encrypt ( ) : model_string = _encrypt ( model_string , len ( model_string ) , kwargs [ 'enc_key' ] , len ( kwargs [ 'enc_key' ] ) , kwargs [ 'enc_mode' ] ) f . write ( model_string ) os . chmod ( file_name , stat . S_IRUSR )