tensorflow/compiler/mlir/tensorflow/utils/export_utils.cc
// Converts a location to the debug information for the node def.
Converts a location to the debug information for the node def.
Converts a location to the debug information for the node def .
Status ConvertLocation(mlir::Location inst_loc, llvm::StringRef node_name,
                       NodeDef::ExperimentalDebugInfo* debug_info) {
  mlir::Location unwrapped_inst_loc = GetLocationWithoutOpType(inst_loc);
  if (auto call_site = unwrapped_inst_loc.dyn_cast<mlir::CallSiteLoc>()) {
    if (auto name_loc = GetLocationWithoutOpType(call_site.getCallee())
                            .dyn_cast<mlir::NameLoc>()) {
      llvm::StringRef original_node_name, original_func_name;
      std::tie(original_node_name, original_func_name) =
          name_loc.getName().strref().split('@');
      if (node_name == original_node_name && original_func_name.empty()) {
        return Status::OK();
      }
      debug_info->add_original_node_names(original_node_name.str());
      if (!original_func_name.empty()) {
        debug_info->add_original_func_names(original_func_name.str());
      }
    }
  } else if (auto fused = unwrapped_inst_loc.dyn_cast<mlir::FusedLoc>()) {
    auto locations = fused.getLocations();
    if (locations.size() <= 1)
      return errors::InvalidArgument("expected experimental debuf info.");
    for (int i = 0, end = locations.size() - 1; i < end; ++i) {
      TF_RETURN_IF_ERROR(ConvertLocation(locations[i], node_name, debug_info));
    }
  }
  return Status::OK();
}
Status ConvertLocation ( mlir :: Location inst_loc , llvm :: StringRef node_name , NodeDef :: ExperimentalDebugInfo * debug_info ) { mlir :: Location unwrapped_inst_loc = GetLocationWithoutOpType ( inst_loc ) ; if ( auto call_site = unwrapped_inst_loc . dyn_cast < mlir :: CallSiteLoc > ( ) ) { if ( auto name_loc = GetLocationWithoutOpType ( call_site . getCallee ( ) ) . dyn_cast < mlir :: NameLoc > ( ) ) { llvm :: StringRef original_node_name , original_func_name ; std :: tie ( original_node_name , original_func_name ) = name_loc . getName ( ) . strref ( ) . split ( ' ' ) ; if ( node_name == original_node_name && original_func_name . empty ( ) ) { return Status :: OK ( ) ; } debug_info -> add_original_node_names ( original_node_name . str ( ) ) ; if ( ! original_func_name . empty ( ) ) { debug_info -> add_original_func_names ( original_func_name . str ( ) ) ; } } } else if ( auto fused = unwrapped_inst_loc . dyn_cast < mlir :: FusedLoc > ( ) ) { auto locations = fused . getLocations ( ) ; if ( locations . size ( ) <= 1 ) return errors :: InvalidArgument ( " " ) ; for ( int i = 0 , end = locations . size ( ) - 1 ; i < end ; ++ i ) { TF_RETURN_IF_ERROR ( ConvertLocation ( locations [ i ] , node_name , debug_info ) ) ; } } return Status :: OK ( ) ; }
Converts a location to the debug information for the node def.
Converts a location to the debug information for the node def .
// The location points to the current node def. // skip the first one, which is the name of the node_def.