tensorflow/lite/tools/optimize/calibration/calibrator.cc
// Creates a mapping between the static model graph and the runtime TfLiteNode*
// nodes in the graph for the given context.
// This is done by querying the TfLiteContext for node and registrations using
// the |NodeInfoDelegateObserver|.
Creates a mapping between the static model graph and the runtime TfLiteNode
nodes in the graph for the given context.
This is done by querying the TfLiteContext for node and registrations using
the |NodeInfoDelegateObserver|.
Creates a mapping between the static model graph and the runtime TfLiteNode nodes in the graph for the given context . This is done by querying the TfLiteContext for node and registrations using the |NodeInfoDelegateObserver| .
TfLiteStatus GetNodeOpInfoMapAndContext(
    const absl::flat_hash_map<std::tuple<int, int>, OperatorInfo>&
        node_to_opinfo,
    tflite::Interpreter* const interpreter,
    std::unordered_map<const TfLiteNode*, OperatorInfo>* node_ptr_opinfo_map,
    TfLiteContext** context) {
  *context = interpreter->primary_subgraph().context();
  TF_LITE_ENSURE(*context,
                 interpreter->execution_plan().size() <= node_to_opinfo.size());
  for (const auto& entry : node_to_opinfo) {
    auto op_info = entry.second;
    int subgraph_index, op_index;
    std::tie(subgraph_index, op_index) = entry.first;
    const auto* node_and_reg =
        interpreter->node_and_registration(subgraph_index, op_index);
    op_info.registration = &node_and_reg->second;
    node_ptr_opinfo_map->insert({&node_and_reg->first, op_info});
  }
  return kTfLiteOk;
}
TfLiteStatus GetNodeOpInfoMapAndContext ( const absl :: flat_hash_map < std :: tuple < int , int > , OperatorInfo > & node_to_opinfo , tflite :: Interpreter * const interpreter , std :: unordered_map < const TfLiteNode * , OperatorInfo > * node_ptr_opinfo_map , TfLiteContext * * context ) { * context = interpreter -> primary_subgraph ( ) . context ( ) ; TF_LITE_ENSURE ( * context , interpreter -> execution_plan ( ) . size ( ) <= node_to_opinfo . size ( ) ) ; for ( const auto & entry : node_to_opinfo ) { auto op_info = entry . second ; int subgraph_index , op_index ; std :: tie ( subgraph_index , op_index ) = entry . first ; const auto * node_and_reg = interpreter -> node_and_registration ( subgraph_index , op_index ) ; op_info . registration = & node_and_reg -> second ; node_ptr_opinfo_map -> insert ( { & node_and_reg -> first , op_info } ) ; } return kTfLiteOk ; }
Creates a mapping between the static model graph and the runtime TfLiteNode
nodes in the graph for the given context.
Creates a mapping between the static model graph and the runtime TfLiteNode nodes in the graph for the given context .
// Since we only consider the primary subgraph while populating // node_to_opinfo, do the same here. // Because Flex delegate can merge multiple op nodes into one Delegate node if // they are located in a row, the size of the execution plan can be lesser // than the size of the graph's op nodes.