syntax = "proto3";

option go_package = "github.com/wandb/wandb/core/internal/tensorboard/tbproto";

import "core/internal/tensorboard/tbproto/histogram.proto";
import "core/internal/tensorboard/tbproto/tensor.proto";

// An Event proto written by TensorBoard into a tfevents file.
//
// https://github.com/tensorflow/tensorboard/blob/master/tensorboard/compat/proto/event.proto
//
// We only include fields that are relevant to us.
message TFEvent {
  // Timestamp of the event.
  double wall_time = 1;

  // An event-specific "step" number, often used as the X axis in charts.
  //
  // The linked source documents this as "Global step of the event."
  //
  // The meaning of this seems to depend on the event itself. For example,
  // a summary event with a single value tagged "epoch_learning_rate"
  // may use the step as an epoch number, but a summary event for
  // "evaluation_loss_vs_iterations" may use as an iteration number.
  // Because of this, consecutive events in a tfevents file may have
  // unrelated step numbers.
  int64 step = 2;

  oneof what {
    // A summary was generated.
    Summary summary = 5;
  }
}

// A TensorBoard "summary" event.
//
// https://github.com/tensorflow/tensorboard/blob/master/tensorboard/compat/proto/summary.proto
//
// We only include fields that are relevant to us.
message Summary {
  message Image {
    int32 height = 1;
    int32 width = 2;

    // Encoded image data.
    //
    // The most common type is PNG, but the TB images plugin seems to also
    // support BMP, GIF, JPEG, and SVG.
    //
    // https://github.com/tensorflow/tensorboard/blob/b56c65521cbccf3097414cbd7e30e55902e08cab/tensorboard/plugins/image/images_plugin.py#L31-L37
    bytes encoded_image_string = 4;
  }

  message Value {
    // Tag name for the data.
    string tag = 1;

    // Which plugins may use this data.
    //
    // See the note in the original source file: the metadata is only present
    // on the first summary value of each tag.
    SummaryMetadata metadata = 9;

    // Value associated with the tag.
    oneof value {
      float simple_value = 2;
      Image image = 4;
      HistogramProto histo = 5;
      TensorProto tensor = 8;
    }
  }

  // Set of values for the summary.
  repeated Value value = 1;
}

// Information about which plugins are able to make use of a certain
// summary value.
message SummaryMetadata {
  message PluginData {
    // The name of the plugin this data pertains to.
    string plugin_name = 1;
  }

  // Data that associates a summary with a certain plugin.
  PluginData plugin_data = 1;
}
