tensorflow/core/grappler/optimizers/data/fusion_utils.cc
// This function produces signature having names that do not conflict with
// `first_signature`.  The input of returns and nodes that will be fused are
// updated to use new names.
This function produces signature having names that do not conflict with
`first_signature`.  The input of returns and nodes that will be fused are
updated to use new names.
This function produces signature having names that do not conflict with ` first_signature ` . The input of returns and nodes that will be fused are updated to use new names .
OpDef GetUniqueSignature(const OpDef& first_signature,
                         const OpDef& second_signature,
                         protobuf::Map<string, string>* rets_to_fuse,
                         protobuf::RepeatedPtrField<NodeDef>* nodes_to_fuse) {
  const gtl::FlatMap<string, string> changed_input_names =
      GetUniqueNames(first_signature.input_arg(), second_signature.input_arg());
  OpDef signature;
  signature.set_name(second_signature.name());
  for (const auto& input_arg : second_signature.input_arg()) {
    auto& input = *signature.add_input_arg();
    input = input_arg;
    if (const string* new_name =
            gtl::FindOrNull(changed_input_names, input.name())) {
      input.set_name(*new_name);
    }
  }
  const gtl::FlatMap<string, string> changed_output_names = GetUniqueNames(
      first_signature.output_arg(), second_signature.output_arg());
  for (const auto& output_arg : second_signature.output_arg()) {
    auto& output = *signature.add_output_arg();
    output = output_arg;
    if (const string* new_name =
            gtl::FindOrNull(changed_output_names, output.name())) {
      output.set_name(*new_name);
    }
  }
  protobuf::Map<string, string> new_rets;
  for (const auto& ret : *rets_to_fuse) {
    const auto& key = changed_output_names.count(ret.first)
                          ? changed_output_names.at(ret.first)
                          : ret.first;
    const auto& input = ParseNodeConnection(ret.second);
    const auto& value =
        changed_input_names.count(input)
            ? changed_input_names.at(input) + ParseOutputNode(ret.second)
            : ret.second;
    new_rets[key] = value;
  }
  *rets_to_fuse = std::move(new_rets);
  for (NodeDef& function_node : *nodes_to_fuse) {
    for (auto& node_input : *function_node.mutable_input()) {
      const auto& input = ParseNodeConnection(node_input);
      if (const string* new_name =
              gtl::FindOrNull(changed_input_names, input)) {
        node_input = *new_name + ParseOutputNode(node_input);
      }
    }
  }
  return signature;
}
OpDef GetUniqueSignature ( const OpDef & first_signature , const OpDef & second_signature , protobuf :: Map < string , string > * rets_to_fuse , protobuf :: RepeatedPtrField < NodeDef > * nodes_to_fuse ) { const gtl :: FlatMap < string , string > changed_input_names = GetUniqueNames ( first_signature . input_arg ( ) , second_signature . input_arg ( ) ) ; OpDef signature ; signature . set_name ( second_signature . name ( ) ) ; for ( const auto & input_arg : second_signature . input_arg ( ) ) { auto & input = * signature . add_input_arg ( ) ; input = input_arg ; if ( const string * new_name = gtl :: FindOrNull ( changed_input_names , input . name ( ) ) ) { input . set_name ( * new_name ) ; } } const gtl :: FlatMap < string , string > changed_output_names = GetUniqueNames ( first_signature . output_arg ( ) , second_signature . output_arg ( ) ) ; for ( const auto & output_arg : second_signature . output_arg ( ) ) { auto & output = * signature . add_output_arg ( ) ; output = output_arg ; if ( const string * new_name = gtl :: FindOrNull ( changed_output_names , output . name ( ) ) ) { output . set_name ( * new_name ) ; } } protobuf :: Map < string , string > new_rets ; for ( const auto & ret : * rets_to_fuse ) { const auto & key = changed_output_names . count ( ret . first ) ? changed_output_names . at ( ret . first ) : ret . first ; const auto & input = ParseNodeConnection ( ret . second ) ; const auto & value = changed_input_names . count ( input ) ? changed_input_names . at ( input ) + ParseOutputNode ( ret . second ) : ret . second ; new_rets [ key ] = value ; } * rets_to_fuse = std :: move ( new_rets ) ; for ( NodeDef & function_node : * nodes_to_fuse ) { for ( auto & node_input : * function_node . mutable_input ( ) ) { const auto & input = ParseNodeConnection ( node_input ) ; if ( const string * new_name = gtl :: FindOrNull ( changed_input_names , input ) ) { node_input = * new_name + ParseOutputNode ( node_input ) ; } } } return signature ; }
This function produces signature having names that do not conflict with
`first_signature`.
This function produces signature having names that do not conflict with ` first_signature ` .