tensorflow/lite/toco/tensorflow_graph_matching/resolve_svdf.cc
// Receives a vector of cluster nodes and returns only those which are array
// partitions (of type 'Const' and have the pattern 'part_<.*>' in their name.
// Since these nodes are connected to a Concatenate node, it makes sure the
// axis value input of the Concatenate operator is 0.
Receives a vector of cluster nodes and returns only those which are array
partitions (of type 'Const' and have the pattern 'part_<.*>' in their name.
Since these nodes are connected to a Concatenate node, it makes sure the
axis value input of the Concatenate operator is 0.
Receives a vector of cluster nodes and returns only those which are array partitions ( of type ' Const ' and have the pattern ' part_< . * > ' in their name . Since these nodes are connected to a Concatenate node it makes sure the axis value input of the Concatenate operator is 0 .
void FilterPartitionedConstNodes(
    const std::string& const_pattern,
    const std::vector<const NodeDef*>& cluster_nodes,
    std::vector<const NodeDef*>* const_node_parts) {
  for (const NodeDef* node : cluster_nodes) {
    std::string node_name_to_upper = node->name();
    std::transform(node_name_to_upper.begin(), node_name_to_upper.end(),
                   node_name_to_upper.begin(), ::toupper);
    if (StrContains(node->name(), const_pattern) && node->op() == "Const") {
      if (StrContains(node_name_to_upper, "/PART_")) {
        const_node_parts->push_back(node);
      } else if (StrContains(node->name(), "AXIS") &&
                 StrContains(node->name(), "CONCAT")) {
        const auto& value_attr = node->attr().at("value");
        const tensorflow::TensorProto& tensor = value_attr.tensor();
        CHECK_EQ(tensor.int_val(0), 0);
      }
    }
  }
  std::sort(const_node_parts->begin(), const_node_parts->end(),
            [](const NodeDef* a, const NodeDef* b) {
              return (a->name().compare(b->name()) < 0 &&
                      (a->name().size() < b->name().size()));
            });
}
void FilterPartitionedConstNodes ( const std :: string & const_pattern , const std :: vector < const NodeDef * > & cluster_nodes , std :: vector < const NodeDef * > * const_node_parts ) { for ( const NodeDef * node : cluster_nodes ) { std :: string node_name_to_upper = node -> name ( ) ; std :: transform ( node_name_to_upper . begin ( ) , node_name_to_upper . end ( ) , node_name_to_upper . begin ( ) , :: toupper ) ; if ( StrContains ( node -> name ( ) , const_pattern ) && node -> op ( ) == " " ) { if ( StrContains ( node_name_to_upper , " " ) ) { const_node_parts -> push_back ( node ) ; } else if ( StrContains ( node -> name ( ) , " " ) && StrContains ( node -> name ( ) , " " ) ) { const auto & value_attr = node -> attr ( ) . at ( " " ) ; const tensorflow :: TensorProto & tensor = value_attr . tensor ( ) ; CHECK_EQ ( tensor . int_val ( 0 ) , 0 ) ; } } } std :: sort ( const_node_parts -> begin ( ) , const_node_parts -> end ( ) , [ ] ( const NodeDef * a , const NodeDef * b ) { return ( a -> name ( ) . compare ( b -> name ( ) ) < 0 && ( a -> name ( ) . size ( ) < b -> name ( ) . size ( ) ) ) ; } ) ; }
Receives a vector of cluster nodes and returns only those which are array
partitions (of type 'Const' and have the pattern 'part_<.
Receives a vector of cluster nodes and returns only those which are array partitions ( of type ' Const ' and have the pattern ' part_< .
// For now only supporting Concatenate on Axix 0