tensorflow/core/debug/debug_io_utils.cc
// Publishes encoded GraphDef through a gRPC debugger stream, in chunks,
// conforming to the gRPC message size limit.
Publishes encoded GraphDef through a gRPC debugger stream, in chunks,
conforming to the gRPC message size limit.
Publishes encoded GraphDef through a gRPC debugger stream in chunks conforming to the gRPC message size limit .
Status PublishEncodedGraphDefInChunks(const string& encoded_graph_def,
                                      const string& device_name,
                                      const int64_t wall_time,
                                      const string& debug_url) {
  const uint64 hash = ::tensorflow::Hash64(encoded_graph_def);
  const size_t total_length = encoded_graph_def.size();
  const size_t num_chunks =
      static_cast<size_t>(std::ceil(static_cast<float>(total_length) /
                                    DebugGrpcIO::kGrpcMessageSizeLimitBytes));
  for (size_t i = 0; i < num_chunks; ++i) {
    const size_t pos = i * DebugGrpcIO::kGrpcMessageSizeLimitBytes;
    const size_t len = (i == num_chunks - 1)
                           ? (total_length - pos)
                           : DebugGrpcIO::kGrpcMessageSizeLimitBytes;
    Event event;
    event.set_wall_time(static_cast<double>(wall_time));
    event.set_graph_def(strings::StrCat(hash, ",", device_name, ",", wall_time,
                                        "|", i, "|", num_chunks, "|",
                                        encoded_graph_def.substr(pos, len)));
    const Status s = DebugGrpcIO::SendEventProtoThroughGrpcStream(
        event, debug_url, num_chunks - 1 == i);
    if (!s.ok()) {
      return errors::FailedPrecondition(
          "Failed to send chunk ", i, " of ", num_chunks,
          " of encoded GraphDef of size ", encoded_graph_def.size(), " bytes, ",
          "due to: ", s.error_message());
    }
  }
  return Status::OK();
}
Status PublishEncodedGraphDefInChunks ( const string & encoded_graph_def , const string & device_name , const int64_t wall_time , const string & debug_url ) { const uint64 hash = :: tensorflow :: Hash64 ( encoded_graph_def ) ; const size_t total_length = encoded_graph_def . size ( ) ; const size_t num_chunks = static_cast < size_t > ( std :: ceil ( static_cast < float > ( total_length ) / DebugGrpcIO :: kGrpcMessageSizeLimitBytes ) ) ; for ( size_t i = 0 ; i < num_chunks ; ++ i ) { const size_t pos = i * DebugGrpcIO :: kGrpcMessageSizeLimitBytes ; const size_t len = ( i == num_chunks - 1 ) ? ( total_length - pos ) : DebugGrpcIO :: kGrpcMessageSizeLimitBytes ; Event event ; event . set_wall_time ( static_cast < double > ( wall_time ) ) ; event . set_graph_def ( strings :: StrCat ( hash , " " , device_name , " " , wall_time , " " , i , " " , num_chunks , " " , encoded_graph_def . substr ( pos , len ) ) ) ; const Status s = DebugGrpcIO :: SendEventProtoThroughGrpcStream ( event , debug_url , num_chunks - 1 == i ) ; if ( ! s . ok ( ) ) { return errors :: FailedPrecondition ( " " , i , " " , num_chunks , " " , encoded_graph_def . size ( ) , " " , " " , s . error_message ( ) ) ; } } return Status :: OK ( ) ; }
Publishes encoded GraphDef through a gRPC debugger stream, in chunks,
conforming to the gRPC message size limit.
Publishes encoded GraphDef through a gRPC debugger stream in chunks conforming to the gRPC message size limit .
// Prefix the chunk with //   <hash64>,<device_name>,<wall_time>|<index>|<num_chunks>|. // TODO(cais): Use DebuggerEventMetadata to store device_name, num_chunks // and chunk_index, instead.