syntax = "proto2";

package caffe2;

// A few notes about the Caffe2's protobuffer convention:
// (1) Most objects are registered by their types, such as operators and nets.
//     For these, we have a string-type field "type" for registration purposes.
// (2) We do not use extension because that used to create quite some conflicts
//     in Caffe's protobuf design.
// (3) We have not used any proto3 specific features, such as Any or Map. This
//     is mainly for backward compatibility purposes but we may consider using
//     those in the future.

// A two number summary for a value. It also has count for restoring.
message TwoNumberStatsProto {
  optional float mean = 1;
  optional float stddev = 2;
  optional int64 count = 3;
}

// Blob profiling information. Profile for a blob is created every time
// a node outputs to the blob.
message BlobProfile {
  // Name of the blob (corresponds to OperatorDef.output).
  optional string name = 1;  // required

  // Profiling statistics.
  optional TwoNumberStatsProto bytes_used = 3;
}

// Protobuf format to serialize profiler data.
message ProfDAGProto {
  // The name for the operator
  required string name = 1;
  // The mean execution time
  required float mean = 2;
  // The standard deviation
  required float stddev = 3;

  // New field to represent the numbers above, and with count.
  optional TwoNumberStatsProto execution_time = 4;

  // Blob profiles that this node outputs.
  repeated BlobProfile output_profile = 5;

  // The extra_info from the operator device option.
  repeated string extra_info = 7;

}

// Operator profiling information.
//
// Note: The indices for elements of 'stats' and the indices of
// 'output_profile' inside each 'stats' are assumed to match the
// indices of 'op' elements of a corresponding NetDef and the 'output'
// indices within each 'op'.
message ProfDAGProtos {
  repeated ProfDAGProto stats = 1;
  optional string net_name = 2;
  repeated OpProfile ops_stats = 3;
}

// Represents specification of an operation cost.
message OpProfile {
  optional string idx = 1;
  optional string net_name = 2;
  optional string type = 3;
  optional float exec_time_secs = 4;
}
