syntax = "proto3";

package tensorflow.profiler;

// All possible execution modes of a tf-function.
enum TfFunctionExecutionMode {
  // Yet to be set.
  INVALID_MODE = 0;
  // Eager execution.
  EAGER_MODE = 1;
  // Graph execution with tracing.
  TRACED_MODE = 2;
  // Graph execution without tracing.
  NOT_TRACED_MODE = 3;
  // Concrete function.
  CONCRETE_MODE = 4;
}

// All possible compilers that can be used to compile a tf-function in the graph
// mode.
enum TfFunctionCompiler {
  // Yet to be set.
  INVALID_COMPILER = 0;
  // Any other compiler.
  OTHER_COMPILER = 1;
  // If some instance of the function is compiled with XLA and some is compiled
  // with Non-XLA, use "MIXED_COMPILER".
  MIXED_COMPILER = 2;
  // XLA compiler.
  XLA_COMPILER = 3;
  // MLIR compiler.
  MLIR_COMPILER = 4;
}

// Metrics associated with a particular execution mode of a tf-function.
message TfFunctionMetrics {
  // Number of invocations to the function in that execution mode.
  uint64 count = 1;
  // The sum of "self-execution" time of this function over those invocations.
  uint64 self_time_ps = 2;
}

// Statistics for a tf-function.
message TfFunction {
  // A map from each execution mode to its corresponding metrics.
  map<int32, TfFunctionMetrics> metrics = 1;
  // Total tracing count from the program's beginning (i.e. beyond the profiling
  // period) of this tf-function.
  int64 total_tracing_count = 2;
  // Compiler used to compile this function.
  TfFunctionCompiler compiler = 3;
  // Percentage of time spent in the expensive calls to this function in the
  // profiled period.
  double expensive_call_percent = 4;
}

// Statistics for all tf-functions.
message TfFunctionDb {
  // A map from function name to the statistics of that function.
  map<string, TfFunction> tf_functions = 1;
}
