xref: /aosp_15_r20/external/tensorflow/tensorflow/python/tpu/tensor_tracer.proto (revision b6fb3261f9314811a0f4371741dbb8839866f948)
1syntax = "proto3";
2
3package tensorflow;
4
5import "tensorflow/core/framework/graph.proto";
6
7// Tensor Tracer Report proto gives information about the trace including:
8// - TensorTracerConfig: version, device, num replicas, trace mode.
9// - Graphdef, e.g., list of operations, tensors
10// - TracedTensorDef:
11//    * Name of the tensor
12//    * Tracepoint name if provided.
13//    * Index of the tensor in the compact cache if traced.
14//    * Explanation for why the tensor is traced or not.
15message TensorTracerReport {
16  TensorTracerConfig config = 1;
17
18  // Tensorflow graph.
19  tensorflow.GraphDef graphdef = 2;
20
21  // A map from tensor name to its TracedTensorDef.
22  map<string, TracedTensorDef> tensordef = 3;
23
24  // The fingerprint of the TensorTracerReport (fingerprint calculation excludes
25  // this field and graphdef).
26  string fingerprint = 4;
27
28  // The function_name passed to the function_callback
29  // that produced this TensorTracerReport
30  string concrete_function_name = 5;
31
32  // The index of the last stack frame where the stack traces for all output
33  // operations in the graph have the same value.
34  int32 last_common_frame_no = 6;
35
36  // List of names of output tensors of the function being traced.
37  repeated string outputs = 7;
38
39  // Information about the number of tensors traced and skipped.
40  TracingStats tracing_stats = 8;
41
42  message TensorTracerConfig {
43    // Tensor tracer version, e.g. hostcall, outside compilation.
44    string version = 1;
45    // Traced device, CPU, TPU...
46    string device = 2;
47
48    // Trace mode, norm, summary, full-trace.
49    string trace_mode = 3;
50
51    // Number of cores, e.g. TPU cores, in the system.
52    int32 num_cores = 4;
53
54    // Number of hosts, e.g. compute nodes in the system.
55    int32 num_hosts = 5;
56
57    // Keep submode as string for backward compatibility.
58    string submode = 6;
59
60    // Keep num cores per host for backward compatibility.
61    int32 num_cores_per_host = 7;
62
63    // Id of the included cores, if a subset of cores are traced.
64    repeated int32 included_cores = 8;
65
66    // The names of the signatures corresponding to the cache indices.
67    repeated string signatures = 9;
68  }
69
70  message TracingStats {
71    // The total number of tensors in the function.
72    int32 total_tensors = 1;
73    // The number of traced tensors in the function.
74    int32 traced_tensors = 2;
75    // Counts of traced tensors by op type.
76    map<string, int32> traced_tensor_types = 3;
77    // The number of tensors added by Tensor Tracer.
78    int32 added_tensors = 4;
79  }
80
81  message TracedTensorDef {
82    // Name of the tensor as appears in tf graph.
83    string name = 1;
84    // Cache index of the tensor. This may be different than topological index.
85    int32 cache_index = 2;
86    // If trace points are provided, corresponding tracepoint name of the
87    // tensor. Trace points are placed on the edges (tensors) in the tensorflow
88    // graph, and they force tensor tracer to trace the corresponding tensor.
89    // Tracepoints can be added using the programatic interface
90    // tensor_tracer.tensor_tracepoint(tensor, trace_point_name) function.
91    // This will add a trace point with the given trace_point_name for the given
92    // tensor. If a trace_point is provided for the tensor,
93    // trace_point name will be used for the rest of the analysis instead of
94    // tensor names. One can use trace_point_name's to compare two models with
95    // arbitrary tensor names by providing the same trace point name for the
96    // tensors that are comparable.
97    string trace_point_name = 3;
98    // Whether the tensor is traced or not.
99    bool is_traced = 4;
100    // Detailed explanation why the tensor is traced or not.
101    string explanation = 5;
102    // Detailed stack of operation
103    Stack op_stack_info = 6;
104
105    message Stack {
106      // Function names from stack
107      repeated string stack_fn_names = 1;
108      // Line in stack
109      repeated string stack_lines = 2;
110      // Filenames from stack
111      repeated string stack_filenames = 3;
112      // Line number in file from stack
113      repeated int32 stack_linenos = 4;
114    }
115  }
116}
117